mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-13 09:29:10 +02:00
cocoa: manual drawing of highlight color for (vibrant)dark theme in 10.13. #34600
git-svn-id: trunk@61137 -
This commit is contained in:
parent
1a44035345
commit
93f5a590b4
@ -30,7 +30,7 @@ uses
|
|||||||
CGGeometry,
|
CGGeometry,
|
||||||
// Libs
|
// Libs
|
||||||
MacOSAll, CocoaAll, CocoaUtils, CocoaGDIObjects,
|
MacOSAll, CocoaAll, CocoaUtils, CocoaGDIObjects,
|
||||||
cocoa_extra, CocoaPrivate,
|
cocoa_extra, CocoaPrivate, CocoaThemes,
|
||||||
// LCL
|
// LCL
|
||||||
LCLType;
|
LCLType;
|
||||||
|
|
||||||
@ -196,6 +196,11 @@ type
|
|||||||
procedure lclInsDelRow(Arow: Integer; inserted: Boolean); override;
|
procedure lclInsDelRow(Arow: Integer; inserted: Boolean); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TCellCocoaTableListView1013 = objcclass(TCellCocoaTableListView, NSTableViewDelegateProtocol, NSTableViewDataSourceProtocol)
|
||||||
|
// overriding the highlight color for dark theme
|
||||||
|
procedure highlightSelectionInClipRect(clipRect: NSRect); override;
|
||||||
|
end;
|
||||||
|
|
||||||
// View based NSTableView
|
// View based NSTableView
|
||||||
|
|
||||||
TCocoaTableListItem = objcclass(NSView)
|
TCocoaTableListItem = objcclass(NSView)
|
||||||
@ -304,6 +309,13 @@ begin
|
|||||||
else
|
else
|
||||||
Result := TCellCocoaTableListView.alloc;
|
Result := TCellCocoaTableListView.alloc;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
|
|
||||||
|
// this is required for "dark theme" support on 10.13
|
||||||
|
if (NSAppkitVersionNumber >= NSAppKitVersionNumber10_13)
|
||||||
|
and (NSAppkitVersionNumber < NSAppKitVersionNumber10_14)
|
||||||
|
then
|
||||||
|
Result := TCellCocoaTableListView1013.alloc
|
||||||
|
else
|
||||||
Result := TCellCocoaTableListView.alloc;
|
Result := TCellCocoaTableListView.alloc;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
@ -1186,5 +1198,41 @@ begin
|
|||||||
removeRowsAtIndexes_withAnimation(rows, 0);
|
removeRowsAtIndexes_withAnimation(rows, 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TCellCocoaTableListView1013 }
|
||||||
|
|
||||||
|
procedure TCellCocoaTableListView1013.highlightSelectionInClipRect(clipRect: NSRect
|
||||||
|
);
|
||||||
|
var
|
||||||
|
r : NSInteger;
|
||||||
|
rows : NSRange;
|
||||||
|
cnt : integer;
|
||||||
|
focused: Boolean;
|
||||||
|
hicolor: NSColor;
|
||||||
|
begin
|
||||||
|
if not IsPaintDark then begin
|
||||||
|
inherited highlightSelectionInClipRect(clipRect);
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
focused := Assigned(window) and (window.firstResponder = Self);
|
||||||
|
if focused then
|
||||||
|
hicolor := NSColor.alternateSelectedControlColor
|
||||||
|
else
|
||||||
|
// the default color is NSColor.secondarySelectedControlColor;
|
||||||
|
hicolor := NSColor.darkGrayColor;
|
||||||
|
|
||||||
|
rows := rowsInRect(clipRect);
|
||||||
|
cnt := rows.length;
|
||||||
|
r := rows.location;
|
||||||
|
hicolor.setFill;
|
||||||
|
while cnt>0 do
|
||||||
|
begin
|
||||||
|
if isRowSelected(r) then NSRectFill(rectOfRow(r));
|
||||||
|
inc(r);
|
||||||
|
dec(cnt);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user