Merge pull request #372 from MrDowntempo/Centered-Circles

Centered circles
This commit is contained in:
Lemmy
2025-09-27 13:24:17 -04:00
committed by GitHub
3 changed files with 18 additions and 18 deletions
+2 -3
View File
@@ -19,9 +19,8 @@ RadioButton {
anchors.verticalCenter: parent.verticalCenter
Rectangle {
anchors.centerIn: parent
implicitWidth: Style.marginS * scaling
implicitHeight: Style.marginS * scaling
anchors.fill: parent
anchors.margins: parent.width * 0.3
radius: width * 0.5
color: Qt.alpha(Color.mPrimary, root.checked ? 1 : 0)
+11 -11
View File
@@ -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,26 +95,26 @@ 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: knob.implicitWidth
height: knob.implicitHeight
x: root.leftPadding + Math.round(root.visualPosition * (root.availableWidth - width))
y: root.topPadding + root.availableHeight / 2 - height / 2
implicitWidth: knobDiameter
implicitHeight: knobDiameter
x: root.leftPadding + root.visualPosition * (root.availableWidth - width)
anchors.verticalCenter: parent.verticalCenter
Rectangle {
id: knob
implicitWidth: knobDiameter
implicitHeight: knobDiameter
radius: width * 0.5
radius: width / 2
color: root.pressed ? Color.mTertiary : Color.mSurface
border.color: Color.mPrimary
border.width: Math.max(1, Style.borderL * scaling)
+5 -4
View File
@@ -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)
implicitHeight: Math.round((root.baseSize * 0.8) * 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