Revision: 10188
          http://sourceforge.net/p/skim-app/code/10188
Author:   hofman
Date:     2018-12-28 13:30:25 +0000 (Fri, 28 Dec 2018)
Log Message:
-----------
draw resize indicator using template image and image cell

Modified Paths:
--------------
    trunk/SKNoteOutlineView.h
    trunk/SKNoteOutlineView.m

Modified: trunk/SKNoteOutlineView.h
===================================================================
--- trunk/SKNoteOutlineView.h   2018-12-27 23:35:43 UTC (rev 10187)
+++ trunk/SKNoteOutlineView.h   2018-12-28 13:30:25 UTC (rev 10188)
@@ -41,7 +41,9 @@
 
 @protocol SKNoteOutlineViewDelegate;
 
-@interface SKNoteOutlineView : SKOutlineView
+@interface SKNoteOutlineView : SKOutlineView {
+    NSImageCell *resizeIndicatorCell;
+}
 
 - (void)toggleTableColumn:(id)sender;
 

Modified: trunk/SKNoteOutlineView.m
===================================================================
--- trunk/SKNoteOutlineView.m   2018-12-27 23:35:43 UTC (rev 10187)
+++ trunk/SKNoteOutlineView.m   2018-12-28 13:30:25 UTC (rev 10188)
@@ -98,6 +98,11 @@
     return self;
 }
 
+- (void)dealloc {
+    SKDESTROY(resizeIndicatorCell);
+    [super dealloc];
+}
+
 - (void)mouseDown:(NSEvent *)theEvent {
     if ([theEvent clickCount] == 1 && [[self delegate] 
respondsToSelector:@selector(outlineView:canResizeRowByItem:)] && [[self 
delegate] respondsToSelector:@selector(outlineView:setHeight:ofRowByItem:)]) {
         NSPoint mouseLoc = [theEvent locationInView:self];
@@ -146,23 +151,29 @@
     if ([[self delegate] 
respondsToSelector:@selector(outlineView:canResizeRowByItem:)] &&
         [[self delegate] outlineView:self canResizeRowByItem:[self 
itemAtRow:row]]) {
         
+        if (resizeIndicatorCell == nil) {
+            NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize(6.0, 
3.0)];
+            [image lockFocus];
+            [[NSColor colorWithCalibratedWhite:0.0 alpha:0.7] setStroke];
+            [NSBezierPath strokeLineFromPoint:NSMakePoint(0.0, 2.5) 
toPoint:NSMakePoint(6.0, 2.5)];
+            [NSBezierPath strokeLineFromPoint:NSMakePoint(2.0, 0.5) 
toPoint:NSMakePoint(4.0, 0.5)];
+            [image unlockFocus];
+            [image setTemplate:YES];
+            
+            resizeIndicatorCell = [[NSImageCell alloc] initImageCell:image];
+            [image release];
+        }
+        
         NSRect rect = [self rectOfRow:row];
-        CGFloat x = ceil(NSMidX(rect));
-        CGFloat y = NSMaxY(rect) - 1.5;
-        BOOL isHighlighted = [[self window] isKeyWindow] && [[self window] 
firstResponder] == self && [self isRowSelected:row];
-        BOOL isDark = SKHasDarkAppearance(nil);
-        
-        // @@ Dark mode
-
-        [NSGraphicsContext saveGraphicsState];
-        [NSBezierPath setDefaultLineWidth:1.0];
-        
-        [[NSColor colorWithCalibratedWhite:isDark || isHighlighted ? 1.0 : 0.0 
alpha:isHighlighted ? 0.7 : 0.5] setStroke];
-        [NSBezierPath strokeLineFromPoint:NSMakePoint(x - 1.0, y) 
toPoint:NSMakePoint(x + 1.0, y)];
-        y -= 2.0;
-        [NSBezierPath strokeLineFromPoint:NSMakePoint(x - 3.0, y) 
toPoint:NSMakePoint(x + 3.0, y)];
-        
-        [NSGraphicsContext restoreGraphicsState];
+        rect.origin.x = ceil(NSMidX(rect)) - 3.0;
+        rect.origin.y = NSMaxY(rect) - 4.0;
+        rect.size.width = 6.0;
+        rect.size.height = 3.0;
+        if ([[self window] isKeyWindow] && [[self window] firstResponder] == 
self && [self isRowSelected:row])
+            [resizeIndicatorCell setBackgroundStyle:NSBackgroundStyleDark];
+        else
+            [resizeIndicatorCell setBackgroundStyle:NSBackgroundStyleLight];
+        [resizeIndicatorCell drawWithFrame:rect inView:self];
     }
 }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to