NCheckbox: edit sizing

NToggle: edit sizing, fix thumb vertical center
This commit is contained in:
Ly-sec 2025-09-14 16:01:00 +02:00
parent 7594651e05
commit 3cb838b455
2 changed files with 7 additions and 6 deletions

View file

@ -13,7 +13,7 @@ RowLayout {
property bool hovering: false property bool hovering: false
property color activeColor: Color.mPrimary property color activeColor: Color.mPrimary
property color activeOnColor: Color.mOnPrimary property color activeOnColor: Color.mOnPrimary
property int baseSize: Math.max(Style.baseWidgetSize * 0.8, 14) property int baseSize: Math.max(Style.baseWidgetSize * 0.7, 14)
signal toggled(bool checked) signal toggled(bool checked)
signal entered signal entered
@ -39,7 +39,7 @@ RowLayout {
implicitHeight: root.baseSize * scaling implicitHeight: root.baseSize * scaling
radius: Style.radiusXS * scaling radius: Style.radiusXS * scaling
color: root.checked ? root.activeColor : Color.mSurface color: root.checked ? root.activeColor : Color.mSurface
border.color: root.checked ? root.activeColor : Color.mOutline border.color: Color.mOutline
border.width: Math.max(1, Style.borderM * scaling) border.width: Math.max(1, Style.borderM * scaling)
Behavior on color { Behavior on color {
@ -57,9 +57,10 @@ RowLayout {
NIcon { NIcon {
visible: root.checked visible: root.checked
anchors.centerIn: parent anchors.centerIn: parent
anchors.horizontalCenterOffset: -1 * scaling
icon: "check" icon: "check"
color: root.activeOnColor color: root.activeOnColor
font.pointSize: Math.max(Style.fontSizeS, root.baseSize * 0.7) * scaling font.pointSize: Math.max(Style.fontSizeXS, root.baseSize * 0.6) * scaling
} }
MouseArea { MouseArea {

View file

@ -11,7 +11,7 @@ RowLayout {
property string description: "" property string description: ""
property bool checked: false property bool checked: false
property bool hovering: false property bool hovering: false
property int baseSize: Style.baseWidgetSize property int baseSize: Style.baseWidgetSize * 0.8
signal toggled(bool checked) signal toggled(bool checked)
signal entered signal entered
@ -31,7 +31,7 @@ RowLayout {
implicitHeight: root.baseSize * scaling implicitHeight: root.baseSize * scaling
radius: height * 0.5 radius: height * 0.5
color: root.checked ? Color.mPrimary : Color.mSurface color: root.checked ? Color.mPrimary : Color.mSurface
border.color: root.checked ? Color.mPrimary : Color.mOutline border.color: Color.mOutline
border.width: Math.max(1, Style.borderM * scaling) border.width: Math.max(1, Style.borderM * scaling)
Behavior on color { Behavior on color {
@ -53,7 +53,7 @@ RowLayout {
color: root.checked ? Color.mOnPrimary : Color.mPrimary color: root.checked ? Color.mOnPrimary : Color.mPrimary
border.color: root.checked ? Color.mSurface : Color.mSurface border.color: root.checked ? Color.mSurface : Color.mSurface
border.width: Math.max(1, Style.borderM * scaling) border.width: Math.max(1, Style.borderM * scaling)
y: 2 * scaling anchors.verticalCenter: parent.verticalCenter
x: root.checked ? switcher.width - width - 2 * scaling : 2 * scaling x: root.checked ? switcher.width - width - 2 * scaling : 2 * scaling
Behavior on x { Behavior on x {