Skip to content

Commit a514809

Browse files
committed
• SSYMultiFieldTextCell now inverts image when in Dark Mode. Requires CategoriesObjC commit f48b3e1.
• SSYVectorImages are now produced with a .name property, handy for debugging • Added warnings for some stuff that may require modification to support Dark Mode.
1 parent 1009471 commit a514809

5 files changed

+101
-25
lines changed

SSYAlert.m

+3
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ - (void)stealObjectsFromAppleAlerts {
823823
[image lockFocus] ;
824824
[[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh];
825825
CGFloat borderWength = 8.0 ;
826+
#warning Check this in Dark Mode
826827
[rawIcon drawInRect:NSMakeRect(
827828
borderWength,
828829
borderWength,
@@ -851,6 +852,7 @@ - (void)stealObjectsFromAppleAlerts {
851852
inset:12.0] ;
852853
[image lockFocus] ;
853854
[[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh];
855+
#warning Check this in Dark Mode
854856
[badge drawInRect:NSMakeRect(
855857
[image size].width / 2,
856858
0,
@@ -877,6 +879,7 @@ - (void)stealObjectsFromAppleAlerts {
877879
inset:12.0] ;
878880
[image lockFocus] ;
879881
[[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh];
882+
#warning Check this in Dark Mode
880883
[badge drawInRect:NSMakeRect(
881884
[image size].width / 2,
882885
0,

SSYMenuAddButton.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ - (void)drawRect:(NSRect)dirtyRect {
1010
// Draw the "+"
1111
// The y-axis seems to be flipped in here.
1212
NSImage* image = [NSImage imageNamed:@"NSAddTemplate"] ;
13+
#warning Check this in Dark Mode
1314
[image drawInRect:NSMakeRect(3,
1415
6,
1516
14,
@@ -28,4 +29,4 @@ - (void)drawRect:(NSRect)dirtyRect {
2829
[path fill] ;
2930
}
3031

31-
@end
32+
@end

SSYMenuGearButton.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ - (void)drawRect:(NSRect)dirtyRect {
88

99
// Draw the Gear
1010
NSImage* image = [NSImage imageNamed:@"NSActionTemplate"] ;
11+
#warning Check this in Dark Mode
1112
[image drawInRect:NSMakeRect(3,
1213
3,
1314
14,
@@ -25,4 +26,4 @@ - (void)drawRect:(NSRect)dirtyRect {
2526
[path fill] ;
2627
}
2728

28-
@end
29+
@end

SSYMultiTextFieldCell.m

+6-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#import "SSYMultiTextFieldCell.h"
2+
#import "NSImage+SSYDarkMode.h"
23

34

45
@implementation SSYMultiTextFieldCell
@@ -56,7 +57,6 @@ - (NSRect)drawAtLeftImage:(NSImage*)image
5657
NSSize imageSize ;
5758
imageSize.height = imageDimension ;
5859
imageSize.width = imageDimension ;
59-
[image setSize:imageSize];
6060

6161
NSRect imageFrame ;
6262
NSDivideRect(cellFrame, &imageFrame, &cellFrame, imageSize.width, NSMinXEdge) ;
@@ -66,25 +66,10 @@ - (NSRect)drawAtLeftImage:(NSImage*)image
6666
NSRectFill(imageFrame);
6767
}
6868

69-
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
70-
[image drawInRect:imageFrame
71-
fromRect:NSZeroRect
72-
operation:NSCompositePlusDarker
73-
fraction:1.0
74-
respectFlipped:YES
75-
hints:nil] ;
76-
#else
77-
if ([controlView isFlipped]) {
78-
imageFrame.origin.y += (cellFrame.size.height + imageDimension) / 2 ;
79-
}
80-
else {
81-
imageFrame.origin.y += (cellFrame.size.height - imageDimension) / 2 ;
82-
}
83-
#warning 10.5!!!!!!!!!!!!!!
84-
[image compositeToPoint:imageFrame.origin
85-
operation:NSCompositePlusDarker] ;
86-
#endif
87-
// I use plusDarker so I don't need an alpha channel - use white background and it "just works"
69+
[image drawInvertedIfDarkModeInRect:imageFrame
70+
operation:NSCompositingOperationPlusDarker
71+
fraction:1.0
72+
appearanceView:controlView];
8873
}
8974

9075
return cellFrame ;
@@ -154,4 +139,4 @@ - (void)drawWithFrame:(NSRect)cellFrame
154139
// //Create a menu here ...say your menu object is aenu
155140
// [NSMenu popUpContextMenu:aMenu withEvent:theEvent
156141
// forView:controlView];
157-
//}
142+
//}

SSYVectorImages.m

+88-2
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,7 @@ + (void)drawStyle:(SSYVectorImageStyle)style
486486

487487
/* Punch a round hole near the top of the bookmark
488488
This is done by with a separate bezier path which we first
489-
*reverse* and then *append* to the bookmark bezier path.
490-
(Prior to BookMacster 1.20.1, this was a solid white cirle.) */
489+
*reverse* and then *append* to the bookmark bezier path. */
491490
NSBezierPath* holePath = [NSBezierPath bezierPath] ;
492491
[holePath setLineWidth:5.0] ;
493492
#define HOLE_RADIUS 12
@@ -722,6 +721,93 @@ + (NSImage*)imageStyle:(SSYVectorImageStyle)style
722721
if (color == nil) {
723722
[rotatedImage setTemplate:YES] ;
724723
}
724+
725+
NSString* name;
726+
switch (style) {
727+
728+
case SSYVectorImageStylePlus:
729+
name = @"Plus";
730+
break;
731+
case SSYVectorImageStyleMinus:
732+
name = @"Minus";
733+
break;
734+
case SSYVectorImageStyleDash:
735+
name = @"Dash";
736+
break;
737+
case SSYVectorImageStyleDot:
738+
name = @"Dot";
739+
break;
740+
case SSYVectorImageStyleTarget:
741+
name = @"Target";
742+
break;
743+
case SSYVectorImageStyleChasingArrows:
744+
name = @"ChasingArrows";
745+
break;
746+
case SSYVectorImageStyleWindowWithSidebar:
747+
name = @"WindowWithSidebarr";
748+
break;
749+
case SSYVectorImageStyleTriangle90:
750+
name = @"Triangle90";
751+
break;
752+
case SSYVectorImageStyleTriangle53:
753+
name = @"Triangle53";
754+
break;
755+
case SSYVectorImageStyleInfoOff:
756+
name = @"InfoOff";
757+
break;
758+
case SSYVectorImageStyleInfoOn:
759+
name = @"InfoOn";
760+
break;
761+
case SSYVectorImageStyleHelp:
762+
name = @"Help";
763+
break;
764+
case SSYVectorImageStyleExclamation:
765+
name = @"Exclamation";
766+
break;
767+
case SSYVectorImageStyleStar:
768+
name = @"Star";
769+
break;
770+
case SSYVectorImageStyleRemoveX:
771+
name = @"RemoveX";
772+
break;
773+
case SSYVectorImageStyleBookmark:
774+
name = @"Bookmark";
775+
break;
776+
case SSYVectorImageStyleHierarchy:
777+
name = @"Bookmark";
778+
break;
779+
case SSYVectorImageStyleFlat:
780+
name = @"Flat";
781+
break;
782+
case SSYVectorImageStyleLineage:
783+
name = @"Lineage";
784+
break;
785+
case SSYVectorImageStyleTag:
786+
name = @"Tag";
787+
break;
788+
case SSYVectorImageStyleCheck1:
789+
name = @"Check1";
790+
break;
791+
case SSYVectorImageStyleCheck2:
792+
name = @"Check2";
793+
break;
794+
case SSYVectorImageStyleBookmarksInFolder:
795+
name = @"Folder";
796+
break;
797+
case SSYVectorImageStyleSettings:
798+
name = @"Settings";
799+
break;
800+
case SSYVectorImageStyleReports:
801+
name = @"Reports";
802+
break;
803+
case SSYVectorImageStyleRoundRadioKnob:
804+
name = @"RoundRadioKnow";
805+
break;
806+
case SSYVectorImageStyleHexagon:
807+
name = @"Hexagon";
808+
break;
809+
}
810+
rotatedImage.name = name;
725811

726812
return rotatedImage ;
727813
}

0 commit comments

Comments
 (0)