Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 480586

Summary: [HiDPI][Win32] Tree expansion triangle issues
Product: [Eclipse Project] Platform Reporter: Thomas Singer <eclipse>
Component: SWTAssignee: Conrad Groth <info>
Status: RESOLVED FIXED QA Contact: Niraj Modi <niraj.modi>
Severity: normal    
Priority: P3 CC: gautier.desaintmartinlacaze, info, Lars.Vogel, lshanmug, nikita, niraj.modi, peter
Version: 4.5   
Target Milestone: 4.8 M7   
Hardware: PC   
OS: Windows NT   
See Also: https://git.eclipse.org/r/116664
https://git.eclipse.org/r/122007
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=3b871dbaca01b0bfa4dade0a4713684d07f25402
Whiteboard:
Bug Depends on: 155817    
Bug Blocks: 517055    
Attachments:
Description Flags
tree expansion icons of Windows File Explorer and SmartGit (using SWT 4.5)
none
Screenshot on Windows 10 - File Explore vs. SmartGit with SWT
none
Windows 10 - File Explorer vs. Eclipse 4.7.2
none
Windows 10 - File Explorer vs. Eclipse 4.8M5 none

Description Thomas Singer CLA 2015-10-25 05:35:13 EDT
Created attachment 257495 [details]
tree expansion icons of Windows File Explorer and SmartGit (using SWT 4.5)

I'm using Windows 8.1 with a quad-HD resolution (200% zoom level). I've noticed two issues with trees:

- the expansion triangles are not scaled

- in the Windows File Explorer the triangles automatically if the tree loses the focus
Comment 1 Thomas Singer CLA 2016-12-13 03:59:53 EST
Bug 509126 is a similar issue. Maybe both can be resolved together.
Comment 2 Niraj Modi CLA 2018-01-31 07:15:43 EST
(In reply to Thomas Singer from comment #0)
> Created attachment 257495 [details]
> tree expansion icons of Windows File Explorer and SmartGit (using SWT 4.5)
> 
> I'm using Windows 8.1 with a quad-HD resolution (200% zoom level). I've
> noticed two issues with trees:
> 
> - the expansion triangles are not scaled
Tested with latest Eclipse release, I don't see this problem on Win10/Win7.


> - in the Windows File Explorer the triangles automatically if the tree loses
> the focus
Please share more details on above point, it's not clear to me.
Comment 3 Thomas Singer CLA 2018-02-01 02:13:13 EST
Created attachment 272483 [details]
Screenshot on Windows 10 - File Explore vs. SmartGit with SWT
Comment 4 Thomas Singer CLA 2018-02-01 02:22:22 EST
> - in the Windows File Explorer the triangles automatically if the tree loses the
> focus

Sorry, the word "hide" is missing. It should read:

- in the Windows File Explorer the triangles automatically hide if the tree loses the focus or the mouse cursor moves away

Attached are screenshots of SmartGit 18.1 preview as well as from Eclipse 4.7.2 and 4.8M5 showing the problem if too small triangles in SWT.
Comment 5 Thomas Singer CLA 2018-02-01 02:22:55 EST
Created attachment 272484 [details]
Windows 10 - File Explorer vs. Eclipse 4.7.2
Comment 6 Thomas Singer CLA 2018-02-01 02:23:14 EST
Created attachment 272485 [details]
Windows 10 - File Explorer vs. Eclipse 4.8M5
Comment 7 Niraj Modi CLA 2018-02-01 06:32:12 EST
(In reply to Thomas Singer from comment #6)
> Created attachment 272485 [details]
> Windows 10 - File Explorer vs. Eclipse 4.8M5

What's the OS zoom level here ?
Comment 8 Thomas Singer CLA 2018-02-01 11:22:08 EST
I'm using 200% zoom.
Comment 9 Conrad Groth CLA 2018-02-03 07:04:08 EST
(In reply to Thomas Singer from comment #0)
> ...
> - in the Windows File Explorer the triangles automatically if the tree loses
> the focus

This can be enabled by the VM argument "-Dorg.eclipse.swt.internal.win32.enableFadeInOutExpandos".
Comment 10 Conrad Groth CLA 2018-02-03 13:30:18 EST
The issue only occurs without images. The reason can be found here: https://developercommunity.visualstudio.com/content/problem/46919/explorer-themed-cmfc-ctreectrl-not-high-dpi-aware.html
Comment 11 Thomas Singer CLA 2018-02-03 13:45:38 EST
(In reply to Conrad Groth from comment #9)
> (In reply to Thomas Singer from comment #0)
> > ...
> > - in the Windows File Explorer the triangles automatically if the tree loses
> > the focus
> 
> This can be enabled by the VM argument
> "-Dorg.eclipse.swt.internal.win32.enableFadeInOutExpandos".

I've tried this with Snippet15 (http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet15.java), but don't see any difference on Windows 10.
Comment 12 Eclipse Genie CLA 2018-02-03 14:45:53 EST
New Gerrit change created: https://git.eclipse.org/r/116664
Comment 13 Conrad Groth CLA 2018-02-03 14:55:19 EST
(In reply to Thomas Singer from comment #11)
> (In reply to Conrad Groth from comment #9)
> > (In reply to Thomas Singer from comment #0)
> > > ...
> > > - in the Windows File Explorer the triangles automatically if the tree loses
> > > the focus
> > 
> > This can be enabled by the VM argument
> > "-Dorg.eclipse.swt.internal.win32.enableFadeInOutExpandos".
> 
> I've tried this with Snippet15
> (http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/
> org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet15.java), but
> don't see any difference on Windows 10.

That's strange. For me the fading also doesn't work with Snippet15, but with the ControlExample.
Comment 14 Conrad Groth CLA 2018-02-03 15:02:22 EST
The tree has to be able to lose the focus to fade out the triangles and because it's the only Control in Snippet15, the tree cannot lose the focus. As soon as you add another control, e.g. a Button, to the snippet and click on the button, the fading of the tree triangles work.

I think, that's no problem for real life applications, as they most likely have more than one control ;)
Comment 15 Thomas Singer CLA 2018-02-04 01:44:19 EST
The fading seems not to work for owner-drawn trees, right? When using it in SmartGit, it does not work for the Repositories and Branches view, but for the tree in the preferences dialog.
Comment 16 Conrad Groth CLA 2018-02-04 16:21:22 EST
(In reply to Thomas Singer from comment #15)
> The fading seems not to work for owner-drawn trees, right? When using it in
> SmartGit, it does not work for the Repositories and Branches view, but for
> the tree in the preferences dialog.

I looked into the code and indeed the fading is disabled if any background color is set, even if it's the system default. I don't know why that was implemented. The comment says:
Feature in Windows. When TVM_SETBKCOLOR is used to set the background color of a tree, the plus/minus animation draws badly.  The fix is to clear the effect.
Comment 17 Niraj Modi CLA 2018-02-09 03:59:11 EST
(In reply to Conrad Groth from comment #16)
> I looked into the code and indeed the fading is disabled if any background
> color is set, even if it's the system default. I don't know why that was
> implemented. The comment says:
> Feature in Windows. When TVM_SETBKCOLOR is used to set the background color
> of a tree, the plus/minus animation draws badly.  The fix is to clear the
> effect.

Searched for the possible reason for this implementation.
Below bug seems related and which may have introduced a fix to the bad drawing with expand(plus/minus) in Tree class (possibly for WinXP only):
https://bugs.eclipse.org/bugs/show_bug.cgi?id=155817

Going by the code comments also, Tree's plus/minus is more of WinXP specific UI element. And if this assumption is correct and since WinXP is no longer relevant:
We can try to introduce this fading animation effect back for Win7 and onward OS version.
Comment 18 Niraj Modi CLA 2018-02-21 11:34:42 EST
Hi Conrad,
If required we can split this bug for the two issues mentioned in comment 0
Also note, next week is last week of development for M6.
Comment 19 Conrad Groth CLA 2018-03-04 07:06:27 EST
(In reply to Niraj Modi from comment #18)
> Hi Conrad,
> If required we can split this bug for the two issues mentioned in comment 0
> Also note, next week is last week of development for M6.

Created follow up bug 531971 for the fading issue.

I also updated the patch and it now uses the native device zoom to scale up the needed indent! The device zoom (configured via the property swt.autoScale) doesn't make sense, as the triangle size only depends on the native device zoom.

@Thomas: Which method did you use to scale SmartGit, the native device zoom (via system settings -> resolution) or the device zoom (configurable by the property swt.autoScale) ?
Comment 20 Thomas Singer CLA 2018-03-04 10:37:17 EST
For non-Mac systems we are investigating org.eclipse.swt.internal.deviceZoom and calculate from display.getDPI().x / 96.
Comment 21 Niraj Modi CLA 2018-04-03 06:59:58 EDT
(In reply to Conrad Groth from comment #19)
> (In reply to Niraj Modi from comment #18)
> > Hi Conrad,
> > If required we can split this bug for the two issues mentioned in comment 0
> > Also note, next week is last week of development for M6.
> 
> Created follow up bug 531971 for the fading issue.
> 
> I also updated the patch and it now uses the native device zoom to scale up
> the needed indent! The device zoom (configured via the property
> swt.autoScale) doesn't make sense, as the triangle size only depends on the
> native device zoom.
Hi Conrad,
Few outstanding comments needs to be addressed before we commit, please refer gerrit. Thanks!
Comment 22 Eclipse Genie CLA 2018-05-02 06:11:16 EDT
New Gerrit change created: https://git.eclipse.org/r/122007
Comment 23 Nikita Nemkin CLA 2018-05-02 06:20:40 EDT
I've created a simplified version of Conrad's patch. It fixes scaling for trees without images.

Trees with images will fix themselves when swt.autoScale=exact and swt.autoScale.method=smooth.
Comment 25 Lars Vogel CLA 2018-05-03 08:12:33 EDT
Thanks Conrad and Nikita for the fix.