Summary: | Win32: Toolbar drop down arrow always black | ||
---|---|---|---|
Product: | [Eclipse Project] Platform | Reporter: | Conrad Groth <info> |
Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> |
Status: | NEW --- | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | aaron, alexandr.miloslavskiy, gayanper, Lars.Vogel, laurent.caron, lshanmug, mariomarinato, niraj.modi, prace.de+eclipse |
Version: | 4.8 | Keywords: | helpwanted |
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows All | ||
Whiteboard: | |||
Bug Depends on: | 508033 | ||
Bug Blocks: |
Description
Conrad Groth
2017-12-11 06:19:06 EST
Guys, has anybody found a solution to this issue yet? Any suggestion on how to create a custom drawer for the Arrow in ToolItems? I just addressed this issue in DevStyle by adding a PaintListener to the ToolBar, directly at the end of the contructor and then paint the dopdown arrow for each item like this: public ToolBar (Composite parent, int style) { … addPaintListener(new ToolBarPainter()); } //DropDown icon drawer class private final class ToolBarPainter implements PaintListener { @Override public void paintControl(PaintEvent e) { if (items == null || items.length == 0) { return; } if (!isDarkTheme) { //Need to check if it’s an eclipse dark theme return; } for (ToolItem item : items) { if (item != null && item.isEnabled()) { if ((item.getStyle() & SWT.DROP_DOWN) == 0) { continue; } Rectangle itemBounds = item.getBounds(); //Now some maths magic Point tbSize = ToolBar.this.getSize(); int centerY = tbSize.y / 2; e.gc.setBackground(e.widget.getDisplay() .getSystemColor(SWT.COLOR_WIDGET_FOREGROUND)); e.gc.setForeground(e.widget.getDisplay() .getSystemColor(SWT.COLOR_WIDGET_FOREGROUND)); int[] points = new int[6]; points[0] = itemBounds.x + itemBounds.width - 14; points[1] = centerY - 2; points[2] = itemBounds.x + itemBounds.width - 5; points[3] = centerY - 2; points[4] = itemBounds.x + itemBounds.width - 10; points[5] = centerY + 3; e.gc.fillPolygon(points); } } } } This fix works well on Windows. Aaron, I like the idea. Please convert that idea into a Gerrit for a custom CSS handler so that it can be applied. See http://www.vogella.com/tutorials/Eclipse4CSS/article.html#exercise-define-a-custom-css-selector-and-css-property for an example for a custom CSS handler. I had to move the painting some pixels to the right. Under Windows 10 the black arrow which came from the OS was visible for 1 pixel at the right. So my version is: final int[] points = new int[6]; points[0] = itemBounds.x + itemBounds.width - 13; points[1] = centerY - 2; points[2] = itemBounds.x + itemBounds.width - 3; points[3] = centerY - 2; points[4] = itemBounds.x + itemBounds.width - 9; points[5] = centerY + 3; e.gc.fillPolygon(points); We had the same issue on our RCP-based application. We noticed that on other platform (MacOS, I did not tried on Linux) the color of the arrow is the foreground color of the toolbar. So in the proposed PaintListener (Comment #2) we should use e.gc.setBackground(e.widget.getDisplay() .getSystemColor(item.getParent().getForeground()); @Lars : in this case, the "color" property of the CSS entry should change the color of the arrow. What do you think ? Alexandr, can you check? I think this one is fixed with your recent changes. Our application doesn't use Toolbar, therefore I won't be able to spend time on this issue. However, I did a quick analysis and found that most likely, on Win10 this code will help when placed in 'createHandle()' : if (OS.IsAppThemed ()) OS.SetWindowTheme (handle, "DarkMode\0".toCharArray(), null); (In reply to Alexandr Miloslavskiy from comment #7) > Our application doesn't use Toolbar, therefore I won't be able to spend time > on this issue. > > However, I did a quick analysis and found that most likely, on Win10 this > code will help when placed in 'createHandle()' : > > if (OS.IsAppThemed ()) > OS.SetWindowTheme (handle, "DarkMode\0".toCharArray(), null); Thanks, Alexander for this tip. Anyone interested in converting this to a Gerrit? Resetting target, please re-target as required. Mass move out to 4.18 Resetting target. |