diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bba9c3..53925d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ This is a bugfix/maintenance release that also contains a few style improvements - (CSS) Fix `Tooltip` text not showing for circular buttons. - (CSS) Prevent context menu from inheriting text input font properties. - (CSS) Fix invalid `DatePicker` cell size. +- (Base) Remove `ToggleSwitch` left padding when text is empty. - (Base) Fix `PasswordTextFormatter` garbled input. ## [1.1.0] - 2022-10-10 diff --git a/base/src/main/java/atlantafx/base/controls/ToggleSwitchSkin.java b/base/src/main/java/atlantafx/base/controls/ToggleSwitchSkin.java index 7224ca2..fc07539 100755 --- a/base/src/main/java/atlantafx/base/controls/ToggleSwitchSkin.java +++ b/base/src/main/java/atlantafx/base/controls/ToggleSwitchSkin.java @@ -144,12 +144,14 @@ public class ToggleSwitchSkin extends SkinBase { double thumbAreaWidth = snapSizeX(thumbArea.prefWidth(-1)); double thumbAreaHeight = snapSizeX(thumbArea.prefHeight(-1)); double thumbAreaY = snapPositionX(contentY + (contentHeight / 2) - (thumbAreaHeight / 2)); + double labelContainerWidth = label.getText() != null && !label.getText().isEmpty() + ? contentWidth - thumbAreaWidth : 0; thumbArea.resize(thumbAreaWidth, thumbAreaHeight); - thumbArea.setLayoutX(contentWidth - thumbAreaWidth); + thumbArea.setLayoutX(labelContainerWidth); thumbArea.setLayoutY(thumbAreaY); - labelContainer.resize(contentWidth - thumbAreaWidth, thumbAreaHeight); + labelContainer.resize(labelContainerWidth, thumbAreaHeight); labelContainer.setLayoutY(thumbAreaY); // layout the thumb on the "unselected" position