Modernize layout of Fonts & Colors preference page for better alignment and usability#3968
Modernize layout of Fonts & Colors preference page for better alignment and usability#3968deepika-u wants to merge 2 commits intoeclipse-platform:masterfrom
Conversation
|
@vogella - Can you take a look at this when you get some time please? |
|
@deepika-u I have the problem that the expand buttons are IMHO the ugliest buttons we have in Eclipse. Everytime I see these ugly button gradients I feel the desire to remove them. So I think I 'm not the right person to review this |
merks
left a comment
There was a problem hiding this comment.
Overall it looks good, but I've only looked at the changes here, not actually running in the IDE.
The setFont changes concern me a bit because I don't know the impact and you've not shown pictures of the impact.
| * | ||
| * @since 4.5 | ||
| */ |
There was a problem hiding this comment.
It's not API so no need for @since.
There was a problem hiding this comment.
oh ok removed them, thank you.
| appliedDialogFont.dispose(); | ||
| } | ||
| // Dispose custom images | ||
| if (expandImage != null && !expandImage.isDisposed()) { |
There was a problem hiding this comment.
I believe that you don't need an isDisposed guard just as there isn't one on the appliedDialogFont.
There was a problem hiding this comment.
updated as per appliedDialogFont.
| Composite mainColumn = new Composite(advancedComposite, SWT.NONE); | ||
| GridLayout layout = new GridLayout(); | ||
| layout.numColumns = 2; | ||
| GridLayout layout = new GridLayout(2, false); |
There was a problem hiding this comment.
You're inlining, which is fine, but as a reviewer it's not easy to see that this is identical. I trust that it is.
There was a problem hiding this comment.
Thanks for calling that out. Yes, this is functionally identical - new GridLayout(2, false) is equivalent to setting numColumns = 2 with the default makeColumnsEqualWidth = false.
I agree that the previous form may be easier to compare in a diff. I can revert to the expanded version if you prefer for readability.
There was a problem hiding this comment.
Actually it's more an observation. I like it simpler the way you wrote it! I trust that you are properly testing all the layout and appearance that the simpler expression produces good behavior.
| GridLayout layout = new GridLayout(2, false); | ||
| layout.marginWidth = 0; | ||
| layout.marginHeight = 0; | ||
| mainColumn.setFont(parent.getFont()); |
There was a problem hiding this comment.
Why this change? This might have an impact that I don't notice.
There was a problem hiding this comment.
Good point — thanks for calling that out.
This line was removed during layout refactoring, but it’s not strictly required since SWT controls inherit the parent font by default.
That said, I agree that keeping it makes the intent explicit and avoids any platform-specific inconsistencies. Shall i restore it to be safe and keep behavior identical to the original implementation.
There was a problem hiding this comment.
Yes, better safe than sorry I think.
| // LOAD IMAGES ONCE | ||
| ImageDescriptor expandDesc = ResourceLocator | ||
| .imageDescriptorFromBundle("org.eclipse.ui", "icons/full/elcl16/expandall.svg") //$NON-NLS-1$ //$NON-NLS-2$ | ||
| .orElse(null); |
There was a problem hiding this comment.
If this were to fail, the button will be useless (horribly ugly) won't it?
There was a problem hiding this comment.
ImageDescriptor collapseDesc = ResourceLocator
.imageDescriptorFromBundle("org.eclipse.ui", "icons/full/elcl16/collapseall.svg") //$NON-NLS-1$ //$NON-NLS-2$
.orElse(null);
collapseAllItem = new ToolItem(treeToolbar, SWT.PUSH);
if (collapseDesc != null) {
collapseImage = collapseDesc.createImage();
collapseAllItem.setImage(collapseImage);
} else {
// Fallback to shared image
collapseAllItem.setImage(
PlatformUI.getWorkbench().getSharedImages()
.getImage(org.eclipse.ui.ISharedImages.IMG_ELCL_COLLAPSEALL));
}
collapseAllItem.setToolTipText("Collapse All"); //$NON-NLS-1$
Thought of this way. But in the similar lines, icon for Expand All is not readily available in org.eclipse.ui.ISharedImages, how should this be handled in your opinion? can i use org.eclipse.ui.ISharedImages.IMG_ELCL_COLLAPSEALL or IMG_ELCL_REMOVE?
There was a problem hiding this comment.
I think in the past the tendency was to ensure that the icon was available locally in the bundle rather than to use fragile programmatic access.
Let's ask @HeikoKlare @BeckerWdf how one can best do something here that's not fragile.
There was a problem hiding this comment.
you could simply copy the PNG files into the bundle.
Alternatively add "Expand All" as org.eclipse.ui.ISharedImages as API and use it.
There was a problem hiding this comment.
Sorry, let me correct my update and put it across again in some time.
There was a problem hiding this comment.
Thanks for the insights @BeckerWdf and @merks
I tried exploring that way too but was unsure how to achieve it correct and complete.
My findings are : icons/images are already existing in below paths.
- ..\git\eclipse.platform.ui\bundles\org.eclipse.ui.ide\icons\full\elcl16 but here expandall.svg/png are not available.
- ..\git\eclipse.platform.ui\bundles\org.eclipse.ui.editors\icons\full\elcl16 has both.
- ..\git\eclipse.platform.ui\bundles\org.eclipse.ui\icons\full\elcl16 has both.
- ..\git\eclipse.platform.ui\bundles\org.eclipse.ui.navigator\icons\full\elcl16 but here expandall.svg/ png are not available.
So for this pr the respective java file is at "..\git\eclipse.platform.ui\bundles\org.eclipse.ui.workbench\eclipseui\org\eclipse\ui\internal\themes\ColorsAndFontsPreferencePage.java"
Option 1 - Add respective expandall, collapseall icons svg/png at freshly created path for this plugin "..\git\eclipse.platform.ui\bundles\org.eclipse.ui.workbench\icons\full\elcl16" and use like below
ImageDescriptor expandDesc = AbstractUIPlugin.imageDescriptorFromPlugin(
"org.eclipse.ui.workbench",
"icons/full/elcl16/expandall.svg"
);
expandImage = expandDesc.createImage();
expandAllItem.setImage(expandImage);
Option 2 - For API way, if i add "icons/full/elcl16/expandall.svg" corresponding entries(inline with collapseall.svg which is already accessible) in ISharedImages.java and WorkbenchImages.java. Are these the only 2 steps i need to perform or do i have to add anything else which i might have missed.
Another observation as well.
I also see entries in plugin.xml at "..\git\eclipse.platform.ui\bundles\org.eclipse.ui" as below
<image
commandId="org.eclipse.ui.navigate.collapseAll"
icon="$nl$/icons/full/elcl16/collapseall.svg">
</image>
<image
commandId="org.eclipse.ui.navigate.expandAll"
icon="$nl$/icons/full/elcl16/expandall.svg">
</image>
So anything in similar lines needs to be done? But I do understand these are used by the command framework and are not directly applicable for ToolItem usage but better to do, so that it is available as a generic solution if anywhere else - it can also be used(since collapseall is already available but not expandall)
Please let me know if my understanding is correct. Thanks in advance.
| @@ -974,7 +1001,8 @@ private String getText(Object element) { | |||
|
|
|||
| tree = new FilteredTree(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, filter, true); | |||
There was a problem hiding this comment.
It might be nice to fix this given so many other changes here.
There was a problem hiding this comment.
Updated it to tree = new FilteredTree(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, filter, true, true);
I’ve updated the deprecated constructor to the newer variant using the additional parameter for fast lookup. This keeps the behavior consistent while removing the warning.
@vogella In this change, the goal wasn’t to introduce any new visual design, but to improve layout consistency and usability (alignment of the filter, tree, and action controls). The icons used are existing Eclipse resources, so this mainly repositions current actions and adds the complementary expand/collapse functionality that was missing. |
Indeed. We are all aware that other folks are busily creating a new dual tone icon pack so one might imagine a pretty icon instead so as better to focus on the design and functionality. |
|
@deepika-u all good, just wanted to explain why I don't review this one |
Got it, thanks for clarifying. |
fe7a8c8 to
ad475cd
Compare
Refactored the layout of the Fonts & Colors preference page to improve alignment and usability.
Before this pr ->

Now with the pr ->

on clicking the
collapse allicon, all the sections which are shown expanded gets collapsed.To maintain consistency across other preference pages like ->
