From 42446dbb0fbd081416e19b29861c2de2785a6c38 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sat, 2 May 2026 22:34:58 +1000 Subject: [PATCH] fix: shape morph expands by static 24dp We don't have dp and I'm not adding dp everywhere, so assume 1dp == 1px Also enable radius morph by default --- components/StateLayer.qml | 2 +- components/controls/ButtonBase.qml | 4 ++-- plugin/src/Caelestia/Components/buttonrow.cpp | 13 +++++++------ plugin/src/Caelestia/Components/buttonrow.hpp | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/components/StateLayer.qml b/components/StateLayer.qml index 72af9b93..ca177f49 100644 --- a/components/StateLayer.qml +++ b/components/StateLayer.qml @@ -29,7 +29,7 @@ MouseArea { const d2 = distSq(width, 0); const d3 = distSq(0, height); const d4 = distSq(width, height); - return Math.sqrt(Math.max(d1, d2, d3, d4)) * (shapeMorph ? 1.16 : 1); + return Math.sqrt(Math.max(d1, d2, d3, d4)) + (shapeMorph ? 24 : 0); } property real endRadiusAtPress diff --git a/components/controls/ButtonBase.qml b/components/controls/ButtonBase.qml index e30d5f5e..44ed2c09 100644 --- a/components/controls/ButtonBase.qml +++ b/components/controls/ButtonBase.qml @@ -19,7 +19,7 @@ StyledRect { property bool isToggle property bool isRound - property bool radiusMorph + property bool radiusMorph: true property alias shapeMorph: stateLayer.shapeMorph property bool fillWidth // For ButtonRow @@ -43,7 +43,7 @@ StyledRect { property color disabledOnColour: Qt.alpha(Colours.palette.m3onSurface, 0.38) property bool internalChecked - property real shapeMorphExpansion: shapeMorph && pressed ? 1.16 : 1 + property real shapeMorphExpansion: shapeMorph && pressed ? 24 : 0 // Apparently it's always 24px no matter the width of the button readonly property color onColour: disabled ? disabledOnColour : internalChecked ? activeOnColour : inactiveOnColour signal clicked diff --git a/plugin/src/Caelestia/Components/buttonrow.cpp b/plugin/src/Caelestia/Components/buttonrow.cpp index 3c1393ae..6177ae4f 100644 --- a/plugin/src/Caelestia/Components/buttonrow.cpp +++ b/plugin/src/Caelestia/Components/buttonrow.cpp @@ -102,8 +102,10 @@ void ButtonRow::relayout() { for (int i = 0; i < nChildren; ++i) { auto* const child = validChildren[i]; - auto prevExtraWidth = i > 0 ? getMorphExpansion(validChildren[i - 1], baseWidths[i - 1]) : 0.0; - auto nextExtraWidth = i < nChildren - 1 ? getMorphExpansion(validChildren[i + 1], baseWidths[i + 1]) : 0.0; + // clang-format off + auto prevExtraWidth = i > 0 ? getMorphExpansion(validChildren[i - 1]) : 0.0; + auto nextExtraWidth = i < nChildren - 1 ? getMorphExpansion(validChildren[i + 1]) : 0.0; + // clang-format on // Items at edges push by full amount, items in middle push by half if (i > 1) @@ -111,7 +113,7 @@ void ButtonRow::relayout() { if (i < nChildren - 2) nextExtraWidth /= 2; - child->setWidth(baseWidths[i] + getMorphExpansion(child, baseWidths[i]) - prevExtraWidth - nextExtraWidth); + child->setWidth(baseWidths[i] + getMorphExpansion(child) - prevExtraWidth - nextExtraWidth); child->setHeight(maxHeight); child->setX(accX); @@ -123,9 +125,8 @@ void ButtonRow::relayout() { setImplicitHeight(maxHeight); } -qreal ButtonRow::getMorphExpansion(const QQuickItem* item, qreal width) { - const auto prop = item->property("shapeMorphExpansion"); - return width * (prop.isValid() ? prop.toReal() - 1 : 0.0); +qreal ButtonRow::getMorphExpansion(const QQuickItem* item) { + return item->property("shapeMorphExpansion").toReal(); } } // namespace caelestia::components diff --git a/plugin/src/Caelestia/Components/buttonrow.hpp b/plugin/src/Caelestia/Components/buttonrow.hpp index 3506c793..1d138d8b 100644 --- a/plugin/src/Caelestia/Components/buttonrow.hpp +++ b/plugin/src/Caelestia/Components/buttonrow.hpp @@ -28,7 +28,7 @@ private slots: private: void relayout(); - static qreal getMorphExpansion(const QQuickItem* item, qreal width); + static qreal getMorphExpansion(const QQuickItem* item); bool m_dirty; qreal m_spacing;