Compare commits
No commits in common. "2f31783ead870ba477da3632126c7093267f5e54" and "947770a5685682d07c3c9b8384b030a9d2eb4e96" have entirely different histories.
2f31783ead
...
947770a568
2 changed files with 64 additions and 38 deletions
|
|
@ -5,15 +5,17 @@ import "." as M
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
default property alias content: row.children
|
default property alias content: layout.children
|
||||||
property color borderColor: M.Theme.base02
|
property color borderColor: M.Theme.base02
|
||||||
|
|
||||||
visible: row.visibleChildren.length > 0
|
visible: layout.visibleChildren.length > 0
|
||||||
|
|
||||||
implicitWidth: row.implicitWidth + _pad * 2
|
implicitWidth: layout.implicitWidth + _pad * 2
|
||||||
implicitHeight: row.implicitHeight + _pad * 2
|
implicitHeight: layout.implicitHeight + _pad * 2
|
||||||
|
|
||||||
readonly property int _pad: 6
|
readonly property int _pad: 6
|
||||||
|
readonly property int _spacing: M.Theme.moduleSpacing + 2
|
||||||
|
readonly property int _sepWidth: 1
|
||||||
|
|
||||||
// Shadow source — rendered offscreen, only its glow is visible
|
// Shadow source — rendered offscreen, only its glow is visible
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|
@ -55,26 +57,68 @@ Item {
|
||||||
radius: M.Theme.radius
|
radius: M.Theme.radius
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
// Separator container — thin lines drawn between visible modules
|
||||||
id: row
|
Item {
|
||||||
anchors.centerIn: parent
|
id: sepContainer
|
||||||
spacing: M.Theme.moduleSpacing + 2
|
anchors.fill: layout
|
||||||
}
|
}
|
||||||
|
|
||||||
// Separator lines overlaid between visible row children
|
// Layout container — children are positioned horizontally with separators between them
|
||||||
Repeater {
|
Item {
|
||||||
model: row.visibleChildren.length > 1 ? row.visibleChildren.length - 1 : 0
|
id: layout
|
||||||
|
anchors.centerIn: parent
|
||||||
|
|
||||||
delegate: Rectangle {
|
onChildrenChanged: Qt.callLater(root._relayout)
|
||||||
required property int index
|
onVisibleChildrenChanged: Qt.callLater(root._relayout)
|
||||||
|
|
||||||
readonly property Item _left: row.visibleChildren[index]
|
// Also watch individual child width changes
|
||||||
readonly property real _rightEdge: _left ? _left.x + _left.width : 0
|
Component.onCompleted: Qt.callLater(root._relayout)
|
||||||
|
}
|
||||||
|
|
||||||
x: row.x + _rightEdge + row.spacing / 2
|
function _relayout() {
|
||||||
y: root._pad + row.implicitHeight * 0.2
|
// Remove old separators
|
||||||
width: 1
|
for (let i = sepContainer.children.length - 1; i >= 0; i--)
|
||||||
height: row.implicitHeight * 0.6
|
sepContainer.children[i].destroy();
|
||||||
|
|
||||||
|
// Position visible children horizontally, insert separators
|
||||||
|
let x = 0;
|
||||||
|
let first = true;
|
||||||
|
const visible = [];
|
||||||
|
for (let i = 0; i < layout.children.length; i++) {
|
||||||
|
const child = layout.children[i];
|
||||||
|
if (!child.visible || child.width <= 0) continue;
|
||||||
|
visible.push(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < visible.length; i++) {
|
||||||
|
const child = visible[i];
|
||||||
|
if (!first) {
|
||||||
|
// Add separator
|
||||||
|
const sep = _sepComp.createObject(sepContainer, {
|
||||||
|
x: x + _spacing / 2 - _sepWidth / 2,
|
||||||
|
height: Qt.binding(() => layout.implicitHeight * 0.6),
|
||||||
|
y: Qt.binding(() => layout.implicitHeight * 0.2)
|
||||||
|
});
|
||||||
|
x += _spacing;
|
||||||
|
}
|
||||||
|
child.x = x;
|
||||||
|
child.y = Qt.binding(function() { return (layout.implicitHeight - child.height) / 2; });
|
||||||
|
x += child.width;
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
layout.implicitWidth = x;
|
||||||
|
layout.implicitHeight = 0;
|
||||||
|
for (let i = 0; i < visible.length; i++) {
|
||||||
|
if (visible[i].height > layout.implicitHeight)
|
||||||
|
layout.implicitHeight = visible[i].height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: _sepComp
|
||||||
|
Rectangle {
|
||||||
|
width: root._sepWidth
|
||||||
color: Qt.rgba(root.borderColor.r, root.borderColor.g, root.borderColor.b, 0.4)
|
color: Qt.rgba(root.borderColor.r, root.borderColor.g, root.borderColor.b, 0.4)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,26 +8,8 @@ Text {
|
||||||
property string icon: ""
|
property string icon: ""
|
||||||
property string tooltip: ""
|
property string tooltip: ""
|
||||||
property bool _hovered: false
|
property bool _hovered: false
|
||||||
property string _displayIcon: icon
|
|
||||||
property string _pendingIcon: ""
|
|
||||||
|
|
||||||
text: _displayIcon
|
text: icon
|
||||||
|
|
||||||
onIconChanged: {
|
|
||||||
if (_crossfade.running) {
|
|
||||||
_pendingIcon = icon;
|
|
||||||
} else {
|
|
||||||
_pendingIcon = icon;
|
|
||||||
_crossfade.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SequentialAnimation {
|
|
||||||
id: _crossfade
|
|
||||||
NumberAnimation { target: root; property: "opacity"; to: 0; duration: 60; easing.type: Easing.InQuad }
|
|
||||||
ScriptAction { script: root._displayIcon = root._pendingIcon }
|
|
||||||
NumberAnimation { target: root; property: "opacity"; to: 1; duration: 100; easing.type: Easing.OutQuad }
|
|
||||||
}
|
|
||||||
color: M.Theme.base05
|
color: M.Theme.base05
|
||||||
font.pixelSize: M.Theme.fontSize + 1
|
font.pixelSize: M.Theme.fontSize + 1
|
||||||
font.family: M.Theme.iconFontFamily
|
font.family: M.Theme.iconFontFamily
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue