Add toggle switch pseudo-classes support
This commit is contained in:
parent
0afed4dca3
commit
188ee75986
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
- (Base) Improved Javadoc. See full API reference in [docs](https://mkpaz.github.io/atlantafx/apidocs/atlantafx.base/module-summary.html).
|
- (Base) Improved Javadoc. See full API reference in [docs](https://mkpaz.github.io/atlantafx/apidocs/atlantafx.base/module-summary.html).
|
||||||
- (Base) `ToggleSwitch` label position support (left or right).
|
- (Base) `ToggleSwitch` label position support (left or right).
|
||||||
|
- (CSS) `ToggleSwitch` pseudo-classes (`success`, `danger`) support.
|
||||||
- (CSS) `Button` shadow support (`-color-button-shadow`). Only for themes compiled with the `button.$use-shadow` flag enabled.
|
- (CSS) `Button` shadow support (`-color-button-shadow`). Only for themes compiled with the `button.$use-shadow` flag enabled.
|
||||||
- (CSS) Looked-up color variables support: `Separator`.
|
- (CSS) Looked-up color variables support: `Separator`.
|
||||||
- (CSS) Added border radius/shadow to popup menu for `ComboBox` (and all `ComboBox`-based) controls.
|
- (CSS) Added border radius/shadow to popup menu for `ComboBox` (and all `ComboBox`-based) controls.
|
||||||
|
@ -280,3 +280,9 @@ Color variables:
|
|||||||
|
|
||||||
* `-color-button-bg-selected`
|
* `-color-button-bg-selected`
|
||||||
* `-color-button-fg-selected`
|
* `-color-button-fg-selected`
|
||||||
|
|
||||||
|
## Toggle Switch
|
||||||
|
|
||||||
|
Pseudo-classes:
|
||||||
|
|
||||||
|
* `:success`, `:danger`
|
@ -3,6 +3,7 @@
|
|||||||
package atlantafx.sampler.page.components;
|
package atlantafx.sampler.page.components;
|
||||||
|
|
||||||
import atlantafx.base.controls.ToggleSwitch;
|
import atlantafx.base.controls.ToggleSwitch;
|
||||||
|
import atlantafx.base.theme.Styles;
|
||||||
import atlantafx.sampler.page.AbstractPage;
|
import atlantafx.sampler.page.AbstractPage;
|
||||||
import atlantafx.sampler.page.Page;
|
import atlantafx.sampler.page.Page;
|
||||||
import atlantafx.sampler.page.SampleBlock;
|
import atlantafx.sampler.page.SampleBlock;
|
||||||
@ -23,18 +24,19 @@ public class ToggleSwitchPage extends AbstractPage {
|
|||||||
super();
|
super();
|
||||||
setUserContent(new FlowPane(
|
setUserContent(new FlowPane(
|
||||||
Page.PAGE_HGAP, Page.PAGE_VGAP,
|
Page.PAGE_HGAP, Page.PAGE_VGAP,
|
||||||
basicSample()
|
basicSample(),
|
||||||
|
stateSample()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private SampleBlock basicSample() {
|
private SampleBlock basicSample() {
|
||||||
var leftToggle = new ToggleSwitch("Enable");
|
var leftToggle = new ToggleSwitch("Enabled");
|
||||||
leftToggle.selectedProperty().addListener(
|
leftToggle.selectedProperty().addListener(
|
||||||
(obs, old, val) -> leftToggle.setText(val ? "Enabled" : "Disabled")
|
(obs, old, val) -> leftToggle.setText(val ? "Enabled" : "Disabled")
|
||||||
);
|
);
|
||||||
leftToggle.setSelected(true);
|
leftToggle.setSelected(true);
|
||||||
|
|
||||||
var rightToggle = new ToggleSwitch("Disable");
|
var rightToggle = new ToggleSwitch("Disabled");
|
||||||
rightToggle.selectedProperty().addListener(
|
rightToggle.selectedProperty().addListener(
|
||||||
(obs, old, val) -> rightToggle.setText(val ? "Enabled" : "Disabled")
|
(obs, old, val) -> rightToggle.setText(val ? "Enabled" : "Disabled")
|
||||||
);
|
);
|
||||||
@ -43,4 +45,26 @@ public class ToggleSwitchPage extends AbstractPage {
|
|||||||
|
|
||||||
return new SampleBlock("Basic", new VBox(SampleBlock.BLOCK_VGAP, leftToggle, rightToggle));
|
return new SampleBlock("Basic", new VBox(SampleBlock.BLOCK_VGAP, leftToggle, rightToggle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SampleBlock stateSample() {
|
||||||
|
var successToggle = new ToggleSwitch("Enabled");
|
||||||
|
successToggle.selectedProperty().addListener((obs, old, val) -> {
|
||||||
|
successToggle.setText(val ? "Enabled" : "Disabled");
|
||||||
|
successToggle.pseudoClassStateChanged(Styles.STATE_SUCCESS, val);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
successToggle.setSelected(true);
|
||||||
|
successToggle.pseudoClassStateChanged(Styles.STATE_SUCCESS, true);
|
||||||
|
|
||||||
|
var dangerToggle = new ToggleSwitch("Disabled");
|
||||||
|
dangerToggle.selectedProperty().addListener((obs, old, val) -> {
|
||||||
|
dangerToggle.setText(val ? "Enabled" : "Disabled");
|
||||||
|
dangerToggle.pseudoClassStateChanged(Styles.STATE_DANGER, val);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
dangerToggle.setLabelPosition(HorizontalDirection.RIGHT);
|
||||||
|
dangerToggle.setSelected(false);
|
||||||
|
|
||||||
|
return new SampleBlock("State", new VBox(SampleBlock.BLOCK_VGAP, successToggle, dangerToggle));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,26 @@ $thumb-area-padding: 0.85em 1.4em 0.85em 1.4em !default;
|
|||||||
>.thumb-area {
|
>.thumb-area {
|
||||||
-fx-background-color: $color-thumb-area-border-selected, $color-thumb-area-selected;
|
-fx-background-color: $color-thumb-area-border-selected, $color-thumb-area-selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:success {
|
||||||
|
>.thumb {
|
||||||
|
-fx-background-color: -color-success-emphasis, $color-thumb-selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
>.thumb-area {
|
||||||
|
-fx-background-color: -color-success-emphasis, -color-success-emphasis;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:danger {
|
||||||
|
>.thumb {
|
||||||
|
-fx-background-color: -color-danger-emphasis, $color-thumb-selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
>.thumb-area {
|
||||||
|
-fx-background-color: -color-danger-emphasis, -color-danger-emphasis;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&:right {
|
&:right {
|
||||||
|
Loading…
Reference in New Issue
Block a user