9
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
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
11
#define SSYHINTARROW_BORDER_COLOR [NSColor whiteColor ]
12
- #define SSYHINTARROW_SCALE_FACTOR [[NSScreen mainScreen ] userSpaceScaleFactor ]
13
12
14
13
static SSYHintArrow* static_helpArrow = nil ;
15
14
16
15
@implementation SSYHintArrow
17
16
18
17
# pragma mark * Heavy Lifters
19
18
19
+ - (CGFloat )scaleFactor {
20
+ // Was using deprecated [NSScreen mainScreen] userSpaceScaleFactor]
21
+ CGFloat factor = [[self contentView ] backingScaleFactor ] ;
22
+ return factor ;
23
+ }
24
+
20
25
- (void )updateGeometry {
21
26
[m_view setFrame: NSMakeRect (0.0 , 0.0 , m_size.width, m_size.height)] ;
22
27
23
28
NSRect contentRect = NSZeroRect ;
24
29
contentRect.size = [m_view frame ].size ;
25
30
26
31
// Account for viewMargin.
27
- m_viewFrame = NSMakeRect (m_viewMargin * SSYHINTARROW_SCALE_FACTOR ,
28
- m_viewMargin * SSYHINTARROW_SCALE_FACTOR ,
32
+ m_viewFrame = NSMakeRect (m_viewMargin * [ self scaleFactor ] ,
33
+ m_viewMargin * [ self scaleFactor ] ,
29
34
[m_view frame ].size .width , [m_view frame ].size .height ) ;
30
35
contentRect = NSInsetRect (contentRect,
31
- -m_viewMargin * SSYHINTARROW_SCALE_FACTOR ,
32
- -m_viewMargin * SSYHINTARROW_SCALE_FACTOR ) ;
36
+ -m_viewMargin * [ self scaleFactor ] ,
37
+ -m_viewMargin * [ self scaleFactor ] ) ;
33
38
34
- CGFloat scaledArrowHeight = m_arrowHeight * SSYHINTARROW_SCALE_FACTOR ;
39
+ CGFloat scaledArrowHeight = m_arrowHeight * [ self scaleFactor ] ;
35
40
m_viewFrame.origin .x += scaledArrowHeight ;
36
41
contentRect.size .width += scaledArrowHeight ;
37
42
@@ -56,7 +61,7 @@ - (void)updateGeometry {
56
61
57
62
58
63
- (NSBezierPath *)backgroundPath {
59
- CGFloat scaleFactor = SSYHINTARROW_SCALE_FACTOR ;
64
+ CGFloat scaleFactor = [ self scaleFactor ] ;
60
65
CGFloat scaledRadius = m_cornerRadius * scaleFactor ;
61
66
NSRect contentArea = NSInsetRect (m_viewFrame,
62
67
-m_viewMargin * scaleFactor,
@@ -122,7 +127,7 @@ - (NSColor *)backgroundColorPatternImage {
122
127
// Draw border if appropriate.
123
128
if (m_borderWidth > 0 ) {
124
129
// Double the borderWidth since we're drawing inside the path.
125
- [bgPath setLineWidth: (m_borderWidth * 2.0 ) * SSYHINTARROW_SCALE_FACTOR ] ;
130
+ [bgPath setLineWidth: (m_borderWidth * 2.0 ) * [ self scaleFactor ] ] ;
126
131
[m_borderColor set ] ;
127
132
[bgPath stroke ] ;
128
133
}
0 commit comments