Remove toggle switch left padding when text is empty

This commit is contained in:
mkpaz 2023-02-11 10:31:45 +04:00
parent ab0c6a5012
commit bda80a6d06
2 changed files with 5 additions and 2 deletions

@ -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

@ -144,12 +144,14 @@ public class ToggleSwitchSkin extends SkinBase<ToggleSwitch> {
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