Is it possible to change the ToggleSwitch colour in ControlsFX - javafx

I'm using ToggleSwitch in controlsFX which is wonderful. I'd like to change the colour from the default sky blue to another colour. I've used css styling but it changes the background behind the ToggleSwitch. Is there a way to customise the actual switch?
Here is my ToggleSwitch:
<ToggleSwitch styleClass="purple" text="No"/>
Here is my styling:
.purple{
-fx-background-color: #57379b
}

Style the background of the thumb area of a selected ToggleSwitch:
.purple:selected .thumb-area {
-fx-background-color: #57379b;
}

Related

How to change the standard blue hover and frame effect?

I am using Vaadin version 14.6.3.
Hover and selection effect
In the image above you can see that my app has a greenish color scheme, but the context menu I implemented will always have a blue hover effect and also some blue frame for the active item.
I tried to play around with stlyes.css and shared-styles.js, but I could not manage to find the correct place where to add/overwrite the standard blue "lumo" behavior.
What can I do to customize this behavior to a color of my choice?
#Route(Pages.CUSTOMER_ROUTE)
#StyleSheet("styles.css")
#PageTitle(Pages.CUSTOMER_PAGE_TITLE)
#JsModule("./shared-styles.js")
public class CustomerUI extends VerticalLayout implements RouterLayout, PageConfigurator, RoleSecured, AfterNavigationObserver {...}
Thank you for your help.
You have very likely only set the primary color and not also the 50% and 10% shade colors. See https://vaadin.com/docs/latest/styling/lumo/design-tokens/color/#primary
E.g. try:
html, :host {
--lumo-primary-color: hsl(122, 96%, 47%);
--lumo-primary-color-50pct: hsl(122, 96%, 47%, 0.5);
--lumo-primary-color-10pct: hsl(122, 96%, 47%, 0.1);
}

Codename One CSS Material Icon color not changing

I have created an application to test the new CN1 CSS support.
The plugin is great and everything works fine and out-of-the-box, except that the material icon on a button does not change its color with the button's text color. It just stays always the same (black) color.
Before using the CSS support, I changed the theme editor's default foreground color setting to reach the material icon, but now the theme editor seems to be dis-attached from the styling and it does not have any effect anymore.
Is there a UIID for the icon or any other way to change the color of the material icon?
Here is my code:
FontImage icon = FontImage.createMaterial(FontImage.MATERIAL_CHECK, "TitleCommand", 3);
Button buttonTest = new Button("Test css");
buttonTest.setUIID("ButtonTest");
buttonTest.setIcon(icon);
And the CSS:
ButtonTest {
color: red;
}
try it
FontImage img = FontImage.createMaterial(FontImage.MATERIAL_THUMB_UP, style);
Just to post a complete answer that might be able to guide someone:
Style style = new Style();
style.setBgColor(ColorUtil.GREEN);
style.setFgColor(ColorUtil.WHITE);
style.setBgTransparency(255);
FontImage imageBack = FontImage.createMaterial(FontImage.MATERIAL_NEXT_WEEK, style);

Keeping the same selection color in a TableView whether it's active or not

I'm using QTableView class in my GUI and I would like the selected row to have the same color whether the TableView is active or inactive.
I tried to set this CSS stylesheet to achieve this:
QTableView:!active {
selection-background-color: palette(Highlight);
selection-color: palette(HighlightedText)
}
On Linux, it works just fine, but on Windows 7, when the TableView loses its focus, the text turns black instead of staying white (the background stays blue, so that part is OK). Am I missing something here ?
You also have to style text color, for example just add:
QTableView:!active {
...
selection-color: white;
}
This works well in python
pal = tbl_list.palette()
pal.setColor(QPalette.Inactive, QPalette.Highlight, pal.color(QPalette.Active, QPalette.Highlight))
tbl_list.setPalette(pal)

Is it possible to make existing icon lighter on hover

For example I've QToolButton with custom icon
Can I make this icon lighter on hover using QToolButton:hover qss?
Could you please try below options:
option 1:
Try PaletteRole property type
http://doc.qt.io/qt-5/stylesheet-reference.html#paletterole
As you require for hovering,
QToolButton:hover { color: palette(light); }
option 2:
Create a different image with lighter view Icon.
And set the background when you hover on it.
QToolButton:hover { background: url("LighterView.png") ; }

Change the selection color of a QTableWidget

The default is for the selected row to be colored gray if the QTableWidget does not have focus, and orange if it does have focus. I would like to, instead, make the selected row be red whether or not the widget has focus. I tried adding this to the style sheet:
QTableWidget{ selection-background-color: red}
I also tried
QTableWidget:edit-focus{ selection-background-color: red}
and
QTableWidget:focus{ selection-background-color: red}
but none of them seem to turn anything red, it still seems to remain orange if focused and gray if not. What properties do I have to set to make the selected row always the same color, whether or not it has focus?
Thanks,
David
You almost had it. Technically speaking, you're adjusting the selection color of the items within your table widget, so:
QTableWidget::item{ selection-background-color: red}
should do the trick.
Alternatively:
QTableWidget::item{ background-color: blue }
QTableWidget::item:selected{ background-color: red }
background-color will set background color of the items in row and selection-color will set the text color because when the row is selected then if text are present in the row then it might become unreadable due to color so setting proper text color is important.
#d9fffb : light blue
#000000 : black
self.table.setStyleSheet(
"QTableView::item:selected"
"{"
"background-color : #d9fffb;"
"selection-color : #000000;"
"}"
)

Resources