-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Follow-Up Feature: Icon-Enablement with Rasterization of SVGs #1647
Draft
Michael5601
wants to merge
11
commits into
eclipse-platform:master
Choose a base branch
from
Michael5601:IconScalingWithDisabledLogic
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Follow-Up Feature: Icon-Enablement with Rasterization of SVGs #1647
Michael5601
wants to merge
11
commits into
eclipse-platform:master
from
Michael5601:IconScalingWithDisabledLogic
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature Proposal: Rasterization of SVGs at Runtime for Eclipse Icons Fixes eclipse-platform#1438 Eclipse currently loads icons exclusively as raster graphics (e.g., `.png`), without support for vector formats like `.svg`. A major drawback of raster graphics is their inability to scale without degrading image quality. Additionally, generating icons of different sizes requires manually rasterizing SVGs outside Eclipse, leading to unnecessary effort and many icon files. This PR introduces support for vector graphics in Eclipse, enabling SVGs to be used for icons. Existing PNG icons will continue to be loaded alongside SVGs, allowing the use of the new functionality without the need to replace all PNG files at once. --- - **How It Works**: - To use SVG icons, simply place the SVG file in the bundle and reference it in the `plugin.xml` and other necessary locations, as is done for PNGs. No additional configuration is required. - At runtime, Eclipse uses the library JSVG to rasterize the SVG into a raster image of the desired size, eliminating the need for scaling. My analysis shows that JSVG is the most suitable Java library for this purpose. - You need to write the flag `-Dswt.autoScale=quarter` into your `eclipse.ini` file or into the run arguments of a new configuration.
The caller needs to make sure the method is called with an SVG file. The check now only checks the first byte.
This was referenced Dec 11, 2024
This is a good thing for me. :) We could utilize the new behaviour from this draft, which means the pre-created PNGs can be removed and we have a little improvement in the look of the icons without changing their appearance (gray tone) too much. |
Michael5601
force-pushed
the
IconScalingWithDisabledLogic
branch
4 times, most recently
from
December 12, 2024 13:16
e9fb30d
to
bdba485
Compare
Michael5601
force-pushed
the
IconScalingWithDisabledLogic
branch
3 times, most recently
from
December 12, 2024 14:02
4aa622d
to
9104049
Compare
and add the other swt-fragments containing the native code explicitly to the build-path of swt.svg. Because the classloader of the host is shared by all fragments, the plain Java ServiceLoader can now be used to get an implementation of SVGRasterizer.
Michael5601
force-pushed
the
IconScalingWithDisabledLogic
branch
from
December 18, 2024 11:21
9104049
to
e0a66ba
Compare
Michael5601
force-pushed
the
IconScalingWithDisabledLogic
branch
from
December 18, 2024 11:38
e0a66ba
to
67d7433
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This draft outlines the follow-up functionality for the PR (Feature Proposal: Rasterization of SVGs at Runtime for Eclipse Icons).
The commit 4e6abc7 contains the new functionality that extends the base functionality of the mentioned PR. All future changes to the PR will be performed to this draft.
The new functionality extends the current automatic customization of icons in the
Image(Device device, Image srcImage, int flag)
constructor. While all of the core functionality is implemented within SWT, some changes are required in Platform UI, which can be found in the following Draft.When the
Image
constructor is invoked, the new functionality attempts to create a graphically customized icon by passing a specific flag (e.g.,SWT.IMAGE_DISABLE
) to the rasterization functionality introduced in the base PR. This functionality is enhanced by a preprocessing step that automatically adds a filter to the SVG before rasterization. These filters are designed to ensure that the resulting icons resemble the current pre-created disabled/gray icons loaded at runtime.It is important to note that the automatic icon customization differs between GTK and Cocoa/Win32. As such, the icons generated with the new functionality may not align perfectly with the automatically customized GTK icons. However, this discrepancy is also present with the current pre-created icons, so the impact is minimal. Additionally, most icons are pre-created and not automatically customized at runtime.
Below is a comparison between the current pre-created icons and the icons customized automatically at runtime using the new functionality. The color/saturation/brightness can be changed by adjusting the filter:
Pre-created and scaled down to 125% device zoom:
Automatically customized at runtime with the new functionality:
The following tasks need to be completed for this draft:
plugin.xml
files to ensure the automatic customization is triggered.Fixes #1438.