forked from eclipse-platform/eclipse.platform.ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Svg css color support #8
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
Open
vogella
wants to merge
19
commits into
master
Choose a base branch
from
svg-css-color-support
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.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
dd7a449
Reduce log level after an orphan perspective got fixed.
Mailaender 5c89bb8
Migrate org.eclipse.ui.workbench.texteditor.tests to JUnit 5
vogella 730daf6
Migrate org.eclipse.jface.tests to JUnit 5
vogella ea1b693
Migrate org.eclipse.ltk.core.refactoring.tests to JUnit 5
vogella de0e232
Version bump(s) for 4.39 stream
eclipse-platform-bot 676351a
Migrate org.eclipse.jface.tests to JUnit 5
vogella b53775d
Replace GIF icons with SVGs in example.navigator project
vogella 8aef950
Replace GIF icons with SVGs in org.eclipse.ui.examples.job
vogella 54a333a
Replace GIF icons with SVGs in org.eclipse.e4.ui.examples.job
vogella c0d5e68
Replace GIF icons with SVGs in org.eclipse.ui.examples.contributions
vogella f6d7f42
Replace GIF icons with SVGs in org.eclipse.ui.examples.undo
vogella db6812d
Replace GIF icons with SVGs in org.eclipse.ui.examples.views.properti…
vogella 69a3fd3
Replace some GIF icons with SVGs in org.eclipse.ui.forms.examples
vogella 5f45a66
Replace GIF icons with SVGs in org.eclipse.ui.examples.javaeditor
vogella 8d56753
Replace GIF icon with SVG in org.eclipse.ui.examples.multipageeditor
vogella d71fe8a
Replace GIF icon with SVG in org.eclipse.e4.demo.cssbridge
vogella ab945c7
Replace GIF icon with SVG in org.eclipse.ui.examples.propertysheet
vogella 42da72a
Replace some GIF icons with SVGs in org.eclipse.ui.examples.readmetool
vogella 0c0dbd5
Add CSS functionality for setting the color of SVG icons
vogella File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
80 changes: 80 additions & 0 deletions
80
...s.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertySVGFilterSWTHandler.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2021, 2025 IBM Corporation and others. | ||
| * | ||
| * This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License 2.0 | ||
| * which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Contributors: | ||
| * IBM Corporation - initial API and implementation | ||
| *******************************************************************************/ | ||
| package org.eclipse.e4.ui.css.swt.properties.custom; | ||
|
|
||
| import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler; | ||
| import org.eclipse.e4.ui.css.core.engine.CSSEngine; | ||
| import org.eclipse.e4.ui.css.swt.CSSSWTConstants; | ||
| import org.eclipse.e4.ui.css.swt.helpers.SWTElementHelpers; | ||
| import org.eclipse.swt.graphics.Color; | ||
| import org.eclipse.swt.widgets.Widget; | ||
| import org.w3c.dom.css.CSSPrimitiveValue; | ||
| import org.w3c.dom.css.CSSValue; | ||
| import org.w3c.dom.css.CSSValueList; | ||
|
|
||
| public class CSSPropertySVGFilterSWTHandler implements ICSSPropertyHandler { | ||
|
|
||
| @Override | ||
| public boolean applyCSSProperty(Object element, String property, CSSValue value, String pseudo, CSSEngine engine) | ||
| throws Exception { | ||
| Widget widget = SWTElementHelpers.getWidget(element); | ||
| if (widget == null) { | ||
| return false; | ||
| } | ||
| if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) { | ||
| CSSValueList list = (CSSValueList) value; | ||
| if (list.getLength() == 2) { | ||
| CSSValue first = list.item(0); | ||
| if (first instanceof CSSPrimitiveValue) { | ||
| String text = ((CSSPrimitiveValue) first).getStringValue(); | ||
| if ("color".equalsIgnoreCase(text)) { //$NON-NLS-1$ | ||
| CSSValue second = list.item(1); | ||
| Color color = (Color) engine.convert(second, Color.class, widget.getDisplay()); | ||
| if (color != null) { | ||
| widget.setData(CSSSWTConstants.CSS_SVG_FILTER_COLOR, color.getRGB()); | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| if (value instanceof CSSPrimitiveValue) { | ||
| String text = ((CSSPrimitiveValue) value).getStringValue(); | ||
| if ("none".equalsIgnoreCase(text)) { //$NON-NLS-1$ | ||
| widget.setData(CSSSWTConstants.CSS_SVG_FILTER_COLOR, null); | ||
| return true; | ||
| } | ||
| // Handle single color value as well, just in case | ||
| Color color = (Color) engine.convert(value, Color.class, widget.getDisplay()); | ||
| if (color != null) { | ||
| widget.setData(CSSSWTConstants.CSS_SVG_FILTER_COLOR, color.getRGB()); | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public String retrieveCSSProperty(Object element, String property, String pseudo, CSSEngine engine) | ||
| throws Exception { | ||
| Widget widget = SWTElementHelpers.getWidget(element); | ||
| if (widget != null) { | ||
| Object data = widget.getData(CSSSWTConstants.CSS_SVG_FILTER_COLOR); | ||
| if (data != null) { | ||
| return "color " + data.toString(); //$NON-NLS-1$ | ||
| } | ||
| } | ||
| return "none"; //$NON-NLS-1$ | ||
| } | ||
| } | ||
69 changes: 69 additions & 0 deletions
69
bundles/org.eclipse.jface/src/org/eclipse/jface/resource/ColorMatrix.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2021, 2025 IBM Corporation and others. | ||
| * | ||
| * This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License 2.0 | ||
| * which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Contributors: | ||
| * IBM Corporation - initial API and implementation | ||
| *******************************************************************************/ | ||
| package org.eclipse.jface.resource; | ||
|
|
||
| import java.util.Arrays; | ||
|
|
||
| /** | ||
| * A color matrix is a 5x4 matrix that can be used to transform colors of an | ||
| * image. | ||
| * | ||
| * @since 3.24 | ||
| */ | ||
| public final class ColorMatrix { | ||
| private final float[] matrix; | ||
|
|
||
| /** | ||
| * Creates a new color matrix from the given 20 elements. | ||
| * | ||
| * @param matrix the 20 elements of the matrix | ||
| * @throws IllegalArgumentException if the matrix does not have 20 elements | ||
| */ | ||
| public ColorMatrix(float[] matrix) { | ||
| if (matrix.length != 20) { | ||
| throw new IllegalArgumentException("Matrix must have 20 elements"); //$NON-NLS-1$ | ||
| } | ||
| this.matrix = Arrays.copyOf(matrix, 20); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the 20 elements of the matrix. | ||
| * | ||
| * @return the matrix elements | ||
| */ | ||
| public float[] getMatrix() { | ||
| return Arrays.copyOf(matrix, 20); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object obj) { | ||
| if (this == obj) { | ||
| return true; | ||
| } | ||
| if (!(obj instanceof ColorMatrix other)) { | ||
| return false; | ||
| } | ||
| return Arrays.equals(matrix, other.matrix); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Arrays.hashCode(matrix); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "ColorMatrix " + Arrays.toString(matrix); //$NON-NLS-1$ | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
toString()method of anRGBobject returns a string representation likeRGB {r, g, b}, which is not a valid CSS color value. This will likely cause parsing errors when the CSS engine attempts to use this retrieved value. The property value should be formatted as a standard CSS color, such asrgb(r, g, b)or a hex string.