Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions com.vogella.eclipse.css/css/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,10 @@ ImageBasedFrame,
ToolBar {
background-color: inherit;
}

SegmentedBar {
background-color: #2b2b2b;
selection-color: #90caf9;
hover-color: black;
separator-color: #2b2b2b;
}
6 changes: 6 additions & 0 deletions com.vogella.eclipse.css/css/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ ImageBasedFrame,
ToolBar {
background-color: inherit;
}

SegmentedBar {
selection-color: #1565c0;
hover-color: white;
separator-color: white;
}
7 changes: 7 additions & 0 deletions com.vogella.eclipse.css/css/sepia.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,10 @@ ImageBasedFrame,
ToolBar {
background-color: inherit;
}

SegmentedBar {
background-color: #fbf6e9;
selection-color: #8a4b2a;
hover-color: #4a3728;
separator-color: #fbf6e9;
}
16 changes: 16 additions & 0 deletions com.vogella.eclipse.css/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,21 @@
label="Dark">
</theme>
</extension>
<extension
point="org.eclipse.e4.ui.css.core.propertyHandler">
<handler
adapter="org.eclipse.e4.ui.css.swt.dom.ControlElement"
handler="com.vogella.eclipse.css.internal.SegmentedBarPropertyHandler">
<property-name
name="selection-color">
</property-name>
<property-name
name="hover-color">
</property-name>
<property-name
name="separator-color">
</property-name>
</handler>
</extension>

</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.vogella.eclipse.css.internal;

import org.eclipse.e4.ui.css.core.dom.properties.converters.ICSSValueConverter;
import org.eclipse.e4.ui.css.core.engine.CSSEngine;
import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Control;
import org.w3c.dom.css.CSSValue;

import com.vogella.swt.widgets.SegmentedBar;

/** Supports the {@code selection-color}, {@code hover-color} and {@code separator-color} CSS properties for {@link SegmentedBar}. */
@SuppressWarnings("restriction")
public class SegmentedBarPropertyHandler extends AbstractCSSPropertySWTHandler {

private static final String SELECTION_COLOR = "selection-color";
private static final String HOVER_COLOR = "hover-color";
private static final String SEPARATOR_COLOR = "separator-color";

@Override
protected void applyCSSProperty(Control control, String property, CSSValue value, String pseudo, CSSEngine engine)
throws Exception {
if (control instanceof SegmentedBar bar && value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
Color color = (Color) engine.convert(value, Color.class, control.getDisplay());
if (SELECTION_COLOR.equalsIgnoreCase(property)) {
bar.setSelectionColor(color);
} else if (HOVER_COLOR.equalsIgnoreCase(property)) {
bar.setHoverColor(color);
} else if (SEPARATOR_COLOR.equalsIgnoreCase(property)) {
bar.setSeparatorColor(color);
}
}
}

@Override
protected String retrieveCSSProperty(Control control, String property, String pseudo, CSSEngine engine)
throws Exception {
if (control instanceof SegmentedBar bar) {
ICSSValueConverter converter = engine.getCSSValueConverter(String.class);
if (SELECTION_COLOR.equalsIgnoreCase(property)) {
return converter.convert(bar.getSelectionColor(), engine, null);
} else if (HOVER_COLOR.equalsIgnoreCase(property)) {
return converter.convert(bar.getHoverColor(), engine, null);
} else if (SEPARATOR_COLOR.equalsIgnoreCase(property)) {
return converter.convert(bar.getSeparatorColor(), engine, null);
}
}
return null;
}
}
Loading
Loading