bar: wrap onto two rows when one row doesn't fit
On narrow outputs (portrait rotation) the single-row layout overflowed. Compare the needed width (implicit sizes of all three clusters) against the window width; when it doesn't fit, double the bar height and move the metric pills to a second row, keeping workspaces + clock/tray on the first. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,20 @@ PanelWindow {
|
|||||||
left: true
|
left: true
|
||||||
right: true
|
right: true
|
||||||
}
|
}
|
||||||
implicitHeight: Theme.barHeight
|
|
||||||
|
// Wrap onto two rows when a single row can't hold everything (portrait
|
||||||
|
// outputs). Needed width is computed from implicit sizes, which don't
|
||||||
|
// depend on which row anything sits in, so this can't bind-loop.
|
||||||
|
readonly property real neededWidth:
|
||||||
|
(Theme.gap + 2) * 2 // outer margins
|
||||||
|
+ workspaces.implicitWidth
|
||||||
|
+ Theme.gap * 4 // breathing room between clusters
|
||||||
|
+ metricsRow.implicitWidth
|
||||||
|
+ Theme.gap
|
||||||
|
+ endRow.implicitWidth
|
||||||
|
readonly property bool twoRows: width > 0 && neededWidth > width
|
||||||
|
|
||||||
|
implicitHeight: twoRows ? Theme.barHeight * 2 : Theme.barHeight
|
||||||
|
|
||||||
// background strip
|
// background strip
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -37,19 +50,35 @@ PanelWindow {
|
|||||||
color: Theme.barColor
|
color: Theme.barColor
|
||||||
}
|
}
|
||||||
|
|
||||||
// left: workspaces
|
// row 1 left: workspaces
|
||||||
Workspaces {
|
Workspaces {
|
||||||
|
id: workspaces
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.leftMargin: Theme.gap + 2
|
anchors.leftMargin: Theme.gap + 2
|
||||||
|
y: (Theme.barHeight - height) / 2
|
||||||
screen: panel.modelData
|
screen: panel.modelData
|
||||||
}
|
}
|
||||||
|
|
||||||
// right: battery, system metrics, volume, clock, tray
|
// row 1 right: clock, tray
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
id: endRow
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.rightMargin: Theme.gap + 2
|
anchors.rightMargin: Theme.gap + 2
|
||||||
|
y: (Theme.barHeight - height) / 2
|
||||||
|
spacing: Theme.gap
|
||||||
|
|
||||||
|
Clock {}
|
||||||
|
Tray { panelWindow: panel }
|
||||||
|
}
|
||||||
|
|
||||||
|
// metrics: left of the clock in one-row mode, own second row when narrow
|
||||||
|
RowLayout {
|
||||||
|
id: metricsRow
|
||||||
|
anchors.right: panel.twoRows ? parent.right : endRow.left
|
||||||
|
anchors.rightMargin: panel.twoRows ? Theme.gap + 2 : Theme.gap
|
||||||
|
y: panel.twoRows
|
||||||
|
? Theme.barHeight + (Theme.barHeight - height) / 2
|
||||||
|
: (Theme.barHeight - height) / 2
|
||||||
spacing: Theme.gap
|
spacing: Theme.gap
|
||||||
|
|
||||||
Battery {}
|
Battery {}
|
||||||
@@ -59,7 +88,5 @@ PanelWindow {
|
|||||||
Disk {}
|
Disk {}
|
||||||
Network {}
|
Network {}
|
||||||
Volume {}
|
Volume {}
|
||||||
Clock {}
|
|
||||||
Tray { panelWindow: panel }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user