diff --git a/widgets/Bar.qml b/widgets/Bar.qml index 86725af..1a0f653 100644 --- a/widgets/Bar.qml +++ b/widgets/Bar.qml @@ -29,7 +29,20 @@ PanelWindow { left: 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 Rectangle { @@ -37,19 +50,35 @@ PanelWindow { color: Theme.barColor } - // left: workspaces + // row 1 left: workspaces Workspaces { + id: workspaces anchors.left: parent.left - anchors.verticalCenter: parent.verticalCenter anchors.leftMargin: Theme.gap + 2 + y: (Theme.barHeight - height) / 2 screen: panel.modelData } - // right: battery, system metrics, volume, clock, tray + // row 1 right: clock, tray RowLayout { + id: endRow anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter 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 Battery {} @@ -59,7 +88,5 @@ PanelWindow { Disk {} Network {} Volume {} - Clock {} - Tray { panelWindow: panel } } }