Skip to content

Commit 1e12839

Browse files
committed
Merge branch 'master' of https://github.com/sneakyness/SCXcodeMiniMap into sneakyness-master
Conflicts: SCXcodeMinimap.xcodeproj/project.pbxproj SCXcodeMinimap/SCXcodeMinimap.m
2 parents 74c626b + ad326a3 commit 1e12839

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

SCXcodeMinimap/SCSelectionView.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@
1010

1111
@interface SCSelectionView : NSView
1212

13+
@property (nonatomic, assign) BOOL shouldInverseColors;
14+
1315
@end

SCXcodeMinimap/SCSelectionView.m

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,68 @@
88

99
#import "SCSelectionView.h"
1010

11+
@interface SCSelectionView ()
12+
13+
@property (nonatomic, retain) NSColor *selectionColor;
14+
15+
@end
16+
1117
@implementation SCSelectionView
1218

19+
- (void)dealloc
20+
{
21+
[self.selectionColor release];
22+
[super dealloc];
23+
}
24+
1325
- (void)drawRect:(NSRect)dirtyRect
1426
{
15-
[[NSColor colorWithDeviceRed:0.0f green:0.0f blue:0.0f alpha:0.3f] setFill];
27+
[[self selectionColor] setFill];
1628
NSRectFill(dirtyRect);
1729
}
1830

31+
- (NSColor *)selectionColor
32+
{
33+
if(_selectionColor == nil) {
34+
35+
_selectionColor = [NSColor colorWithDeviceRed:0.0f green:0.0f blue:0.0f alpha:0.3f];
36+
37+
Class DVTFontAndColorThemeClass = NSClassFromString(@"DVTFontAndColorTheme");
38+
39+
if([DVTFontAndColorThemeClass respondsToSelector:@selector(currentTheme)]) {
40+
NSObject *theme = [DVTFontAndColorThemeClass performSelector:@selector(currentTheme)];
41+
42+
if([theme respondsToSelector:@selector(sourceTextBackgroundColor)]) {
43+
NSColor *backgroundColor = [[theme performSelector:@selector(sourceTextBackgroundColor)] colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]];
44+
45+
if(self.shouldInverseColors) {
46+
47+
_selectionColor = [NSColor colorWithCalibratedRed:(1.0f - [backgroundColor redComponent])
48+
green:(1.0f - [backgroundColor greenComponent])
49+
blue:(1.0f - [backgroundColor blueComponent])
50+
alpha:0.3f];
51+
} else {
52+
53+
_selectionColor = [NSColor colorWithCalibratedHue:0.0f
54+
saturation:0.0f
55+
brightness:(1.0f - [backgroundColor brightnessComponent])
56+
alpha:0.3f];
57+
}
58+
}
59+
}
60+
}
61+
62+
return _selectionColor;
63+
}
64+
65+
- (void)setShouldInverseColors:(BOOL)shouldInverseColors
66+
{
67+
if(_shouldInverseColors == shouldInverseColors) {
68+
return;
69+
}
70+
71+
_shouldInverseColors = shouldInverseColors;
72+
_selectionColor = nil;
73+
}
1974

2075
@end

SCXcodeMinimap/SCXcodeMinimap.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ - (void)onDidFinishSetup:(NSNotification*)sender
206206
NSRect miniMapSelectionViewFrame = NSMakeRect(0, 0, miniMapScrollView.bounds.size.width, editorScrollView.visibleRect.size.height * kDefaultZoomLevel);
207207
SCSelectionView *miniMapSelectionView = [[SCSelectionView alloc] initWithFrame:miniMapSelectionViewFrame];
208208
[miniMapSelectionView setAutoresizingMask: NSViewMinXMargin | NSViewMaxXMargin | NSViewWidthSizable | NSViewHeightSizable | NSViewMinYMargin | NSViewMaxYMargin];
209+
//[miniMapSelectionView setShouldInverseColors:YES];
209210
[miniMapScrollView.contentView addSubview:miniMapSelectionView];
210211
[miniMapSelectionView release];
211212

0 commit comments

Comments
 (0)