From 7dc8d2cd88b17b23dbe9080aebf927cf15c3da99 Mon Sep 17 00:00:00 2001 From: Corey Woodworth Date: Sat, 27 Sep 2025 12:34:58 -0400 Subject: [PATCH] Fix: Works regardless of scaling value --- Widgets/NSlider.qml | 20 ++++++++++---------- Widgets/NToggle.qml | 9 +++++---- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Widgets/NSlider.qml b/Widgets/NSlider.qml index 372110229..1bd0fda41 100644 --- a/Widgets/NSlider.qml +++ b/Widgets/NSlider.qml @@ -11,9 +11,9 @@ Slider { property bool snapAlways: true property real heightRatio: 0.7 - readonly property real knobDiameter: Math.round(Style.baseWidgetSize * heightRatio * scaling) - readonly property real trackHeight: knobDiameter * 0.4 - readonly property real cutoutExtra: Math.round(Style.baseWidgetSize * 0.1 * scaling) + readonly property real knobDiameter: Math.round((Style.baseWidgetSize * heightRatio * scaling) / 2) * 2 + readonly property real trackHeight: Math.round((knobDiameter * 0.4) /2) * 2 + readonly property real cutoutExtra: Math.round((Style.baseWidgetSize * 0.1 * scaling) / 2) * 2 padding: cutoutExtra / 2 @@ -95,20 +95,20 @@ Slider { // Circular cutout Rectangle { id: knobCutout - width: knobDiameter + cutoutExtra - height: knobDiameter + cutoutExtra + implicitWidth: knobDiameter + cutoutExtra + implicitHeight: knobDiameter + cutoutExtra radius: width / 2 color: root.cutoutColor !== undefined ? root.cutoutColor : Color.mSurface - x: root.leftPadding + Math.round(root.visualPosition * (root.availableWidth - root.knobDiameter) - cutoutExtra) + x: root.leftPadding + root.visualPosition * (root.availableWidth - root.knobDiameter) - cutoutExtra anchors.verticalCenter: parent.verticalCenter } } handle: Item { - width: knobDiameter - height: knobDiameter - x: root.leftPadding + Math.round(root.visualPosition * (root.availableWidth - width)) - y: root.topPadding + Math.round(root.availableHeight / 2 - height / 2) + implicitWidth: knobDiameter + implicitHeight: knobDiameter + x: root.leftPadding + root.visualPosition * (root.availableWidth - width) + anchors.verticalCenter: parent.verticalCenter Rectangle { id: knob diff --git a/Widgets/NToggle.qml b/Widgets/NToggle.qml index 9b4afa353..3e464bb8e 100644 --- a/Widgets/NToggle.qml +++ b/Widgets/NToggle.qml @@ -27,8 +27,8 @@ RowLayout { Rectangle { id: switcher - implicitWidth: Math.round(root.baseSize * 1.625 * scaling) - implicitHeight: Math.round(root.baseSize * scaling) + implicitWidth: Math.round(root.baseSize * .85 * scaling) * 2 + implicitHeight: Math.round(root.baseSize * scaling * .5) * 2 radius: height * 0.5 color: root.checked ? Color.mPrimary : Color.mSurface border.color: Color.mOutline @@ -47,8 +47,9 @@ RowLayout { } Rectangle { - implicitWidth: Math.round((root.baseSize * 0.8) * scaling) - height: parent.height - (4 * scaling) + + implicitWidth: Math.round(root.baseSize * 0.4 * scaling) * 2 + implicitHeight: Math.round(root.baseSize * 0.4 * scaling) * 2 radius: height * 0.5 color: root.checked ? Color.mOnPrimary : Color.mPrimary border.color: root.checked ? Color.mSurface : Color.mSurface