|
6 | 6 |
|
7 | 7 | NSString* const SSYHintArrowEventKey = @"SSYHintArrowEventKey" ;
|
8 | 8 |
|
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 |
| - |
13 | 9 | static SSYHintArrow* static_helpArrow = nil ;
|
14 | 10 |
|
15 | 11 | @implementation SSYHintArrow
|
@@ -115,26 +111,27 @@ - (NSColor *)backgroundColorPatternImage {
|
115 | 111 | NSImage* bg = [NSImage imageWithSize:[self frame].size
|
116 | 112 | flipped:NO
|
117 | 113 | 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]; |
125 | 122 |
|
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 | + |
138 | 135 | return [NSColor colorWithPatternImage:bg] ;
|
139 | 136 | }
|
140 | 137 |
|
@@ -178,10 +175,16 @@ - (SSYHintArrow *)initAttachedToPoint:(NSPoint)point
|
178 | 175 | backing:NSBackingStoreBuffered
|
179 | 176 | defer:NO])) {
|
180 | 177 | // 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]; |
185 | 188 | m_borderWidth = 3.0 ;
|
186 | 189 | m_viewMargin = 3.0 ;
|
187 | 190 | m_cornerRadius = 10.0 ;
|
@@ -223,7 +226,7 @@ - (SSYHintArrow *)initAttachedToPoint:(NSPoint)point
|
223 | 226 |
|
224 | 227 | - (void)dealloc {
|
225 | 228 | [m_borderColor release] ;
|
226 |
| - [m_gradient release] ; |
| 229 | + [m_innerColor release] ; |
227 | 230 |
|
228 | 231 | [super dealloc] ;
|
229 | 232 | }
|
@@ -288,7 +291,7 @@ + (CAKeyframeAnimation *)shakeAnimation:(NSRect)frame {
|
288 | 291 | NSInteger i ;
|
289 | 292 | for (i = 0; i < 3; ++i) {
|
290 | 293 | 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)) ; |
292 | 295 | }
|
293 | 296 | CGPathCloseSubpath(shakePath) ;
|
294 | 297 | shakeAnimation.path = shakePath ;
|
|
0 commit comments