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
This commit is contained in:
parent
8d3a915c49
commit
42446dbb0f
4 changed files with 11 additions and 10 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue