Bug 568194 - [JFace] add a SymbolImageDescriptor
Summary: [JFace] add a SymbolImageDescriptor
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.14   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Christoph Laeubrich CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks: 568887
  Show dependency tree
 
Reported: 2020-10-24 06:23 EDT by Christoph Laeubrich CLA
Modified: 2021-09-16 05:00 EDT (History)
5 users (show)

See Also:


Attachments
Example Project (3.42 KB, application/zip)
2020-10-24 06:41 EDT, Christoph Laeubrich CLA
no flags Details
Example Screenshot with different states (74.27 KB, image/png)
2020-10-24 06:42 EDT, Christoph Laeubrich CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Laeubrich CLA 2020-10-24 06:23:46 EDT
As suggested in Bug 567898 it would be nice to support "Font-Icon", that means that a symbol from a given font can be used as icon images in buttons/toolbars/menus and so on.

The advantage is that these kind of images can scale to whatever size is requested when true-type fonts are used.
Comment 1 Christoph Laeubrich CLA 2020-10-24 06:24:33 EDT
I'll provide a Gerrit for this as a first simple starting point.
Comment 2 Eclipse Genie CLA 2020-10-24 06:29:00 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/171215
Comment 3 Christoph Laeubrich CLA 2020-10-24 06:41:39 EDT
Created attachment 284557 [details]
Example Project

Example Project to demonstrate usage
Comment 4 Christoph Laeubrich CLA 2020-10-24 06:42:55 EDT
Created attachment 284558 [details]
Example Screenshot with different states

Find a Screenshot attached that shows a toolbar using symbol icons.
Comment 5 Lars Vogel CLA 2020-10-28 02:58:44 EDT
(In reply to Christoph Laeubrich from comment #4)
> Created attachment 284558 [details]
> Example Screenshot with different states
> 
> Find a Screenshot attached that shows a toolbar using symbol icons.

Do you plan to support this also in e4 application contributions via the icon uri in the model?
Comment 6 Christoph Laeubrich CLA 2020-10-28 03:43:54 EDT
(In reply to Lars Vogel from comment #5)
> Do you plan to support this also in e4 application contributions via the
> icon uri in the model?

this is not E4 specific, next step (if basic support is there) would be to add an URI handler to jface that support URLs of the following format:

symbol-icon://😁@16px/<an optional font name>#FF0000

if that is done, maybe someone with E4-Editor skills can enhance the e4-model editor to even support this with a specialized dialog.
Comment 7 Lars Vogel CLA 2020-10-30 03:59:35 EDT
(In reply to Christoph Laeubrich from comment #6)
> (In reply to Lars Vogel from comment #5)
> > Do you plan to support this also in e4 application contributions via the
> > icon uri in the model?
> 
> this is not E4 specific, next step (if basic support is there) would be to
> add an URI handler to jface that support URLs of the following format:
> 
> symbol-icon://😁@16px/<an optional font name>#FF0000

That would be great. Please open a bug report for this, depending on this bug.

> symbol-icon://😁@16px/

16px is for the default font size? I would assume the font will adjust to the HDPI setting, correct?


> if that is done, maybe someone with E4-Editor skills can enhance the
> e4-model editor to even support this with a specialized dialog.

This would be nice but low priority. Supporting font icons in toolbar would already be a big archivement even without a dialog to select it.
Comment 8 Christoph Laeubrich CLA 2020-10-30 04:05:00 EDT
(In reply to Lars Vogel from comment #7)
> > symbol-icon://😁@16px/
> 
> 16px is for the default font size? I would assume the font will adjust to
> the HDPI setting, correct?

Its the initial image size (font sizes are smaller but are dynamical calculated according to requested image size). The descriptor will adjust to any zoom factor requested. of course the 16px is not fixed as shown in attached screenshot that shows a toolbar with much larger image size.
Comment 9 Wim Jongman CLA 2020-11-09 09:11:35 EST
@Lars, Add me to the cc if you want me to notice it. 

This looks nice. FYI, Nebula has FontAwesome support [1].


[1] https://wiki.eclipse.org/Nebula_FontAwesome
Comment 10 Mickael Istria CLA 2020-11-12 08:53:55 EST
Before we go into increasing the amount of code in Platform for that, do we already have a real use-case in Platform for that?
I think we need to avoid Platform to grow as a collection of unused APIs that make maintenance harder, and we should first have agreement on a use-case to consume the API inside Platform before providing it.
Comment 11 Wim Jongman CLA 2020-11-13 06:55:01 EST
(In reply to Mickael Istria from comment #10)
> Before we go into increasing the amount of code in Platform for that, do we
> already have a real use-case in Platform for that?
> I think we need to avoid Platform to grow as a collection of unused APIs


This is chicken-egg. How can platform use it if it is not available?

Let's meet midway an put it in internal so that we can at least start using it.

> that make maintenance harder, and we should first have agreement on a
> use-case to consume the API inside Platform before providing it.

The use case is the move to native SVG support and eventually get rid of all that icon@2x complexity.
Comment 12 Christoph Laeubrich CLA 2020-11-13 07:14:31 EST
The class itself is already package private and only available through static factory methods (like for URLs and files).

I don't know if there is an official "definition" or something like this for what platform is, but if I just take what generally is assumed to be a platform (something other people can build up and share common concepts) it makes sense to provide things that seems useful for a greater audience and even if (not yet) the platform code itself uses it it makes sense to offer it if there is larger interest, there's always a world outside Eclipse :-)

Font-Based icons are just a de-factor standard in modern (web) UIs and JFace/SWT is in my opinion really lacking some basic features to create UIs that don't look like your stuck in the 90's... but maybe RCP was meant to mean Retro-Client-Platform anyways?! :-)

This will become even more useful if we can convince SWT to provide some platform independent fonts, see Bug 568520 and yes SVG support is also on the list but this has become more complicated than I initially thought an thus will take some time, but this is independent from the SVG story IMO.
Comment 13 Lars Vogel CLA 2020-11-13 07:19:24 EST
The change should at least at some unit tests.
Comment 14 Mickael Istria CLA 2020-11-13 07:39:39 EST
(In reply to Wim Jongman from comment #11)
> Let's meet midway an put it in internal so that we can at least start using
> it.

I disagree here. Let's just add it when it's necessary. Platform won't be healthier if it's just a library of untested code.
As long as there is no consumer for it in Platform, it's better to remain on Gerrit, then consumers can already start building on top of the Gerrit patch; and we get everything merged at once when a user-story is better covered by this addition.

(In reply to Christoph Laeubrich from comment #12)
> I don't know if there is an official "definition" or something like this for
> what platform is, but if I just take what generally is assumed to be a
> platform (something other people can build up and share common concepts) it
> makes sense to provide things that seems useful for a greater audience and
> even if (not yet) the platform code itself uses it it makes sense to offer
> it if there is larger interest, there's always a world outside Eclipse :-)

Sure, but Platform as a project can difficulty cope with the trouble of all its extenders. The general rule is that Platform only hosts code it does consume ("dogfooding"), it's not supposed to be a library of random utility code that we don't have in the IDE any use-case for.
 
> Font-Based icons are just a de-factor standard in modern (web) UIs and
> JFace/SWT is in my opinion really lacking some basic features to create UIs
> that don't look like your stuck in the 90's... but maybe RCP was meant to
> mean Retro-Client-Platform anyways?! :-)

I'm all for font-based icons; but here my concerns are not really the question of *what* can be API or not; but more of *how*. Something that is not used inside Platform (or JDT or PDE) is usually a sign that it's immature to become part of Platform.
Now. whenever Platorm/JDT/PDE gets improved thanks to a new API, we can consider adding the API and the consume in a row.
Comment 15 Wim Jongman CLA 2020-11-13 08:39:44 EST
(In reply to Mickael Istria from comment #14)


> Now. whenever Platorm/JDT/PDE gets improved thanks to a new API, we can
> consider adding the API and the consume in a row.

I agree with your arguments, but can you explain how we can improve without providing the code first?
Comment 16 Mickael Istria CLA 2020-11-13 08:42:37 EST
(In reply to Wim Jongman from comment #15)
> I agree with your arguments, but can you explain how we can improve without
> providing the code first?

Concretely, please submit with this same Gerrit or as a new Gerrit some code consuming this new code to improve something Platform or JDT or PDE. If we get agreement on the value, then we can more easily consider adding the utility that enables it.
Comment 17 Lars Vogel CLA 2020-11-13 09:06:20 EST
(In reply to Mickael Istria from comment #16)
> (In reply to Wim Jongman from comment #15)
> > I agree with your arguments, but can you explain how we can improve without
> > providing the code first?
> 
> Concretely, please submit with this same Gerrit or as a new Gerrit some code
> consuming this new code to improve something Platform or JDT or PDE. If we
> get agreement on the value, then we can more easily consider adding the
> utility that enables it.

Unit test and JFace snippet should be ok to submit it. I believe once we have that we can start writing more code to use it, e.g. in plugin.xml to define icons or in the e4 model
Comment 18 Mickael Istria CLA 2020-11-13 09:11:19 EST
(In reply to Lars Vogel from comment #17)
> Unit test and JFace snippet should be ok to submit it. I believe once we
> have that we can start writing more code to use it, e.g. in plugin.xml to
> define icons or in the e4 model

FWIW, I disagree with that. If we start allowing any piece of code to get as API without having use-case for it in the Eclipse project, then we basically end up maintaining a collection of software pieces that we don't even know whether anyone use them. It's just going to grow the maintenance cost without demonstrating value. A consumer inside Eclipse project seems necessary to me if we want thing to keep healthy on long run. Most committers here can barely afford maintaining what we know is used, growing the list by adding APIs which may not be used would basically slow down the project development tremendously on mid-term.
Comment 19 Christoph Laeubrich CLA 2020-11-13 09:20:18 EST
(In reply to Lars Vogel from comment #17)
> Unit test 

While I always try to add a unit-test whenever possible, its extremely hard to write one here as comparing an image of varying fonts is neither stable nor good to understand/debug and the SWT Image Interface is a real pain to test against as it uses native calls to retrieve pixel information that even vary on the same platform.
But if anyone has an idea how to test this in an automated way I'll be happy to add a test of course.
Comment 20 Alexander Kurtakov CLA 2020-11-13 10:25:17 EST
I also agree that before accepting smth as API we should have gerrit with at least one (preferably few) usages so they can be seen in action . This is critical to solidify the API.
E.g. for the unittest view (https://git.eclipse.org/r/c/platform/eclipse.platform.debug/+/171116) there is junit counterpart showing it in action (https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/171126) and a cdt one (https://github.com/vrubezhny/org.eclipse.unittest/tree/master/org.eclipse.unittest.cdt) and even a rust one (https://github.com/vrubezhny/corrosion/tree/rebased-unit-tesst-view). By doing that we have some confidence that we have taken wider usage criteria in account which still doesn't mean good API but it's at least a prereq.
So what Mickael is asking here is showing such usages so we do not publish API that will have to be deprecated shortly after it's announced due to finding deficiencies when we start using it in real world.
Comment 21 Lars Vogel CLA 2020-11-17 07:14:19 EST
I created Bug 568194 for the support of SymbolImageDescriptor in plugin.xml and the e4 model.
Comment 22 Wim Jongman CLA 2020-11-17 07:22:52 EST
(In reply to Lars Vogel from comment #21)
> I created xxxxxx for the support of SymbolImageDescriptor in plugin.xml
> and the e4 model.

That would be bug 568887
Comment 23 Mickael Istria CLA 2021-06-24 05:28:05 EDT
@Christoph: before we move on with this and have some consumers in Eclipse Platform and then can merge API; would you be interested in submitting this code as an example in org.eclipse.jface.snippets; so this code is in Platform and not "lost" on Gerrit and may be easier to retrieve later if we need it as API?
Comment 24 Christoph Laeubrich CLA 2021-09-16 05:00:17 EDT
It seems there is not much interest in this.