Skip to content

Commit f8aa2b5

Browse files
committed
Modernized appearance of SSYHintArrow.
1 parent 5d04166 commit f8aa2b5

File tree

2 files changed

+33
-30
lines changed

2 files changed

+33
-30
lines changed

SSYHintArrow.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ extern NSString* const SSYHintArrowDidCloseNotification ;
6363
http://www.mugginsoft.com
6464
*/
6565
@interface SSYHintArrow : NSWindow {
66+
NSColor* m_innerColor;
6667
NSColor* m_borderColor ;
6768
CGFloat m_borderWidth ;
6869
CGFloat m_viewMargin ;
@@ -71,7 +72,6 @@ extern NSString* const SSYHintArrowDidCloseNotification ;
7172
NSSize m_size ;
7273

7374
@private
74-
NSGradient* m_gradient ;
7575
NSView* m_view ;
7676
NSWindow* m_window ;
7777
NSPoint m_point ;

SSYHintArrow.m

+32-29
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66

77
NSString* const SSYHintArrowEventKey = @"SSYHintArrowEventKey" ;
88

9-
#define SSYHINTARROW_TOP_COLOR [NSColor colorWithCalibratedRed:(80.0/256.0) green:(111.0/256.0) blue:(246.0/256.0) alpha:1.0]
10-
#define SSYHINTARROW_BOTTOM_COLOR [NSColor colorWithCalibratedRed:(27.0/256.0) green:(68.0/256.0) blue:(243.0/256.0) alpha:1.0]
11-
#define SSYHINTARROW_BORDER_COLOR [NSColor whiteColor]
12-
139
static SSYHintArrow* static_helpArrow = nil ;
1410

1511
@implementation SSYHintArrow
@@ -115,26 +111,27 @@ - (NSColor *)backgroundColorPatternImage {
115111
NSImage* bg = [NSImage imageWithSize:[self frame].size
116112
flipped:NO
117113
drawingHandler:^(NSRect dstRect) {
118-
NSBezierPath* bgPath = [self backgroundPath] ;
119-
[NSGraphicsContext saveGraphicsState] ;
120-
[bgPath addClip] ;
121-
122-
// Draw background gradient.
123-
[m_gradient drawInBezierPath:bgPath
124-
angle:270.0] ;
114+
NSBezierPath* bgPath = [self backgroundPath] ;
115+
[NSGraphicsContext saveGraphicsState] ;
116+
[bgPath addClip] ;
117+
118+
// Draw background gradient.
119+
120+
[m_innerColor set];
121+
[bgPath fill];
125122

126-
// Draw border if appropriate.
127-
if (m_borderWidth > 0) {
128-
// Double the borderWidth since we're drawing inside the path.
129-
[bgPath setLineWidth:(m_borderWidth * 2.0) * [self scaleFactor]] ;
130-
[m_borderColor set] ;
131-
[bgPath stroke] ;
132-
}
133-
[NSGraphicsContext restoreGraphicsState] ;
134-
135-
return YES ;
136-
}] ;
137-
123+
// Draw border if appropriate.
124+
if (m_borderWidth > 0) {
125+
// Double the borderWidth since we're drawing inside the path.
126+
[bgPath setLineWidth:(m_borderWidth * 2.0) * [self scaleFactor]] ;
127+
[m_borderColor set] ;
128+
[bgPath stroke] ;
129+
}
130+
[NSGraphicsContext restoreGraphicsState] ;
131+
132+
return YES ;
133+
}] ;
134+
138135
return [NSColor colorWithPatternImage:bg] ;
139136
}
140137

@@ -178,10 +175,16 @@ - (SSYHintArrow *)initAttachedToPoint:(NSPoint)point
178175
backing:NSBackingStoreBuffered
179176
defer:NO])) {
180177
// Parameters for displaying the fat blue arrow.
181-
m_gradient = [[NSGradient alloc] initWithStartingColor:SSYHINTARROW_TOP_COLOR
182-
endingColor:SSYHINTARROW_BOTTOM_COLOR] ;
183-
m_size = NSMakeSize(74.0, 28.0) ;
184-
m_borderColor = [SSYHINTARROW_BORDER_COLOR copy] ;
178+
NSColor* color;
179+
if (@available(macOS 10.14, *)) {
180+
color = [NSColor controlAccentColor];
181+
} else {
182+
color = [NSColor colorWithCalibratedRed:(54.0/256.0) green:(90.0/256.0) blue:(245.0/256.0) alpha:0.0];
183+
}
184+
m_innerColor = [[color colorWithAlphaComponent:0.5] retain];
185+
186+
m_size = NSMakeSize(74.0, 28.0) ;
187+
m_borderColor = [[NSColor whiteColor] retain];
185188
m_borderWidth = 3.0 ;
186189
m_viewMargin = 3.0 ;
187190
m_cornerRadius = 10.0 ;
@@ -223,7 +226,7 @@ - (SSYHintArrow *)initAttachedToPoint:(NSPoint)point
223226

224227
- (void)dealloc {
225228
[m_borderColor release] ;
226-
[m_gradient release] ;
229+
[m_innerColor release] ;
227230

228231
[super dealloc] ;
229232
}
@@ -288,7 +291,7 @@ + (CAKeyframeAnimation *)shakeAnimation:(NSRect)frame {
288291
NSInteger i ;
289292
for (i = 0; i < 3; ++i) {
290293
CGPathAddLineToPoint(shakePath, NULL, NSMinX(frame), NSMinY(frame)) ;
291-
CGPathAddLineToPoint(shakePath, NULL, NSMinX(frame) + 15.0, NSMinY(frame)) ;
294+
CGPathAddLineToPoint(shakePath, NULL, NSMinX(frame) + 25.0, NSMinY(frame)) ;
292295
}
293296
CGPathCloseSubpath(shakePath) ;
294297
shakeAnimation.path = shakePath ;

0 commit comments

Comments
 (0)