diff options
author | Lakshmi Priya Shanmugam | 2019-04-23 11:08:00 +0000 |
---|---|---|
committer | Lakshmi Priya Shanmugam | 2019-04-24 07:14:14 +0000 |
commit | a72bc4bdb1b35e53fd153195ddca0156074ce5ac (patch) | |
tree | 7a2200e4bf681945c0cc037e1b29b801491b89e8 | |
parent | 743a669fa009e450db474aa61830821c2d048973 (diff) | |
download | eclipse.platform.swt-a72bc4bdb1b35e53fd153195ddca0156074ce5ac.tar.gz eclipse.platform.swt-a72bc4bdb1b35e53fd153195ddca0156074ce5ac.tar.xz eclipse.platform.swt-a72bc4bdb1b35e53fd153195ddca0156074ce5ac.zip |
Bug 540357 - [10.14] Make SWT adapt to switching to dark mode (and back)
Set correct foreground color for TabFolder and Tree and Table headers.
Redraw header view after setting header fg & bg colors.
Table header bg/fg color should use the default color when no color is
set, similar to Tree.
Change-Id: Ief188ba5fd1fda8efe563fa492a74b4fc01df77d
5 files changed, 12 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabItem.java index a31be56d73..eec9f4a077 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabItem.java @@ -464,8 +464,12 @@ void updateText (boolean selected) { attriStr.release(); } double /*float*/ [] foreground = parent.foreground; - if (foreground == null && selected && OS.VERSION >= 0x1070) { - foreground = display.getNSColorRGB(NSColor.alternateSelectedControlTextColor()); + if (foreground == null) { + if (selected && OS.VERSION >= 0x1070) { + foreground = display.getNSColorRGB(NSColor.alternateSelectedControlTextColor()); + } else { + foreground = parent.defaultForeground().handle; + } } attriStr = parent.createString(text, null, foreground, 0, false, true, true); //force parent to resize diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java index 40dfa25432..f46680e0b8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java @@ -1481,7 +1481,7 @@ public Color getHeaderBackground () { } private Color getHeaderBackgroundColor () { - return headerBackground != null ? Color.cocoa_new (display, headerBackground) : getBackgroundColor (); + return headerBackground != null ? Color.cocoa_new (display, headerBackground) : defaultBackground (); } /** @@ -1501,7 +1501,7 @@ public Color getHeaderForeground () { } Color getHeaderForegroundColor () { - return headerForeground != null ? Color.cocoa_new (display, headerForeground) : getForegroundColor (); + return headerForeground != null ? Color.cocoa_new (display, headerForeground) : defaultForeground (); } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TableColumn.java index 6d706f4de5..1cc6fc3e49 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TableColumn.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TableColumn.java @@ -252,7 +252,7 @@ void drawInteriorWithFrame_inView (long /*int*/ id, long /*int*/ sel, NSRect cel NSTableHeaderCell headerCell = nsColumn.headerCell (); if (displayText != null) { Font font = Font.cocoa_new(display, headerCell.font ()); - attrString = parent.createString(displayText, font, parent.headerForeground, SWT.LEFT, false, (parent.state & DISABLED) == 0, false); + attrString = parent.createString(displayText, font, parent.getHeaderForegroundColor().handle, SWT.LEFT, false, (parent.state & DISABLED) == 0, false); stringSize = attrString.size (); contentWidth += Math.ceil (stringSize.width); if (image != null) contentWidth += MARGIN; /* space between image and text */ diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java index 522fa6c67e..6fcb41098f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java @@ -2942,7 +2942,7 @@ public void setHeaderBackground (Color color) { if (equals (headerBackground, this.headerBackground)) return; this.headerBackground = headerBackground; if (getHeaderVisible()) { - redrawWidget (view, false); + redrawWidget (headerView, false); } } @@ -2974,7 +2974,7 @@ public void setHeaderForeground (Color color) { if (equals (headerForeground, this.headerForeground)) return; this.headerForeground = headerForeground; if (getHeaderVisible()) { - redrawWidget (view, false); + redrawWidget (headerView, false); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeColumn.java index ed8bacd892..9996ae638f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeColumn.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeColumn.java @@ -254,7 +254,7 @@ void drawInteriorWithFrame_inView (long /*int*/ id, long /*int*/ sel, NSRect cel NSTableHeaderCell headerCell = nsColumn.headerCell (); if (displayText != null) { Font font = Font.cocoa_new(display, headerCell.font ()); - attrString = parent.createString(displayText, font, parent.headerForeground, SWT.LEFT, false, (parent.state & DISABLED) == 0, false); + attrString = parent.createString(displayText, font, parent.getHeaderForegroundColor().handle, SWT.LEFT, false, (parent.state & DISABLED) == 0, false); stringSize = attrString.size (); contentWidth += Math.ceil (stringSize.width); if (image != null) contentWidth += MARGIN; /* space between image and text */ |