diff options
author | marc_culler <marc.culler@gmail.com> | 2020-09-12 21:33:08 (GMT) |
---|---|---|
committer | marc_culler <marc.culler@gmail.com> | 2020-09-12 21:33:08 (GMT) |
commit | 32b93e910cb8f5ef44e3561331a6dc9fda9b6aca (patch) | |
tree | cc92c02e99bae81e266e2f331ce86015d5b6d754 /macosx/ttkMacOSXTheme.c | |
parent | 4a8b7efd011cd0b919533728fcb8d6697bafd271 (diff) | |
parent | cd9987e74b4772140be98620c89fde03aac58ea2 (diff) | |
download | tk-32b93e910cb8f5ef44e3561331a6dc9fda9b6aca.zip tk-32b93e910cb8f5ef44e3561331a6dc9fda9b6aca.tar.gz tk-32b93e910cb8f5ef44e3561331a6dc9fda9b6aca.tar.bz2 |
Merge 8.6
Diffstat (limited to 'macosx/ttkMacOSXTheme.c')
-rw-r--r-- | macosx/ttkMacOSXTheme.c | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index 65c889c..fa4bca1 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -303,9 +303,10 @@ static void GetBackgroundColor( /*---------------------------------------------------------------------- - * +++ Single Arrow Buttons -- + * +++ Single Arrow Images -- * - * Used in ListHeaders and Comboboxes. + * Used in ListHeaders and Comboboxes as well as disclosure triangles in + * macOS 11. */ static void DrawDownArrow( @@ -352,6 +353,48 @@ static void DrawUpArrow( CGContextStrokePath(context); } +static void DrawClosedDisclosure( + CGContextRef context, + CGRect bounds, + CGFloat inset, + CGFloat size, + CGFloat *rgba) +{ + CGFloat x, y; + + CGContextSetRGBStrokeColor(context, rgba[0], rgba[1], rgba[2], rgba[3]); + CGContextSetLineWidth(context, 1.5); + x = bounds.origin.x + inset; + y = bounds.origin.y + trunc(bounds.size.height / 2); + CGContextBeginPath(context); + CGPoint arrow[3] = { + {x, y - size / 4 - 1}, {x + size / 2, y}, {x, y + size / 4 + 1} + }; + CGContextAddLines(context, arrow, 3); + CGContextStrokePath(context); +} + +static void DrawOpenDisclosure( + CGContextRef context, + CGRect bounds, + CGFloat inset, + CGFloat size, + CGFloat *rgba) +{ + CGFloat x, y; + + CGContextSetRGBStrokeColor(context, rgba[0], rgba[1], rgba[2], rgba[3]); + CGContextSetLineWidth(context, 1.5); + x = bounds.origin.x + inset; + y = bounds.origin.y + trunc(bounds.size.height / 2); + CGContextBeginPath(context); + CGPoint arrow[3] = { + {x, y - size / 4}, {x + size / 2, y + size / 2}, {x + size, y - size / 4} + }; + CGContextAddLines(context, arrow, 3); + CGContextStrokePath(context); +} + /*---------------------------------------------------------------------- * +++ Double Arrow Buttons -- * @@ -3002,8 +3045,21 @@ static void DisclosureElementDraw( }; BEGIN_DRAWING(d) - ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, + if ([NSApp macOSVersion] >= 110000) { + CGFloat rgba[4]; + NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace]; + NSColor *stroke = [[NSColor textColor] + colorUsingColorSpace: deviceRGB]; + [stroke getComponents: rgba]; + if (state & TTK_TREEVIEW_STATE_OPEN) { + DrawOpenDisclosure(dc.context, bounds, 2, 8, rgba); + } else { + DrawClosedDisclosure(dc.context, bounds, 2, 12, rgba); + } + } else { + ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL); + } END_DRAWING } } |