Bar Density: improved workspace widget + slight density adjustments

This commit is contained in:
LemmyCook 2025-09-16 08:10:10 -04:00
parent 03698e7bb9
commit a2caebb8e5
2 changed files with 33 additions and 32 deletions

View file

@ -77,10 +77,10 @@ Singleton {
// Bar Dimensions // Bar Dimensions
property real barHeight: { property real barHeight: {
if (Settings.data.bar.density === "compact") { if (Settings.data.bar.density === "compact") {
return (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? 25 : 23 return (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? 27 : 25
} }
if (Settings.data.bar.density === "default") { if (Settings.data.bar.density === "default") {
return (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? 29 : 27 return (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? 33 : 31
} }
if (Settings.data.bar.density === "comfortable") { if (Settings.data.bar.density === "comfortable") {
return (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? 39 : 37 return (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? 39 : 37
@ -88,13 +88,13 @@ Singleton {
} }
property real capsuleHeight: { property real capsuleHeight: {
if (Settings.data.bar.density === "compact") { if (Settings.data.bar.density === "compact") {
return barHeight return barHeight * 0.95
} }
if (Settings.data.bar.density === "default") { if (Settings.data.bar.density === "default") {
return barHeight * 0.9 return barHeight * 0.85
} }
if (Settings.data.bar.density === "comfortable") { if (Settings.data.bar.density === "comfortable") {
return Math.round(barHeight * 0.73) return barHeight * 0.73
} }
} }
} }

View file

@ -32,7 +32,9 @@ Item {
} }
readonly property string barPosition: Settings.data.bar.position readonly property string barPosition: Settings.data.bar.position
readonly property bool isVertical: barPosition === "left" || barPosition === "right"
readonly property bool compact: (Settings.data.bar.density === "compact") readonly property bool compact: (Settings.data.bar.density === "compact")
readonly property real baseDimensionRatio: compact ? 0.85 : 0.73
readonly property string labelMode: (widgetSettings.labelMode !== undefined) ? widgetSettings.labelMode : widgetMetadata.labelMode readonly property string labelMode: (widgetSettings.labelMode !== undefined) ? widgetSettings.labelMode : widgetMetadata.labelMode
readonly property bool hideUnoccupied: (widgetSettings.hideUnoccupied !== undefined) ? widgetSettings.hideUnoccupied : widgetMetadata.hideUnoccupied readonly property bool hideUnoccupied: (widgetSettings.hideUnoccupied !== undefined) ? widgetSettings.hideUnoccupied : widgetMetadata.hideUnoccupied
@ -50,43 +52,42 @@ Item {
signal workspaceChanged(int workspaceId, color accentColor) signal workspaceChanged(int workspaceId, color accentColor)
implicitHeight: (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling) implicitWidth: isVertical ? Math.round(Style.barHeight * scaling) : computeWidth()
implicitWidth: (barPosition === "left" || barPosition === "right") ? Math.round(Style.barHeight * scaling) : calculatedHorizontalWidth() implicitHeight: isVertical ? computeHeight() : Math.round(Style.barHeight * scaling)
function calculatedWsWidth(ws) {
function getWorkspaceWidth(ws) {
const d = Style.capsuleHeight * root.baseDimensionRatio
if (ws.isFocused) if (ws.isFocused)
return Math.round(44 * scaling) return d * 2.5
else if (ws.isActive) else
return Math.round(28 * scaling) return d
else
return Math.round(20 * scaling)
} }
function calculatedWsHeight(ws) { function getWorkspaceHeight(ws) {
const d = Style.capsuleHeight * root.baseDimensionRatio
if (ws.isFocused) if (ws.isFocused)
return Math.round(44 * scaling) return d * 3
else if (ws.isActive) else
return Math.round(28 * scaling) return d
else
return Math.round(20 * scaling)
} }
function calculatedVerticalHeight() { function computeWidth() {
let total = 0 let total = 0
for (var i = 0; i < localWorkspaces.count; i++) { for (var i = 0; i < localWorkspaces.count; i++) {
const ws = localWorkspaces.get(i) const ws = localWorkspaces.get(i)
total += calculatedWsHeight(ws) total += getWorkspaceWidth(ws)
} }
total += Math.max(localWorkspaces.count - 1, 0) * spacingBetweenPills total += Math.max(localWorkspaces.count - 1, 0) * spacingBetweenPills
total += horizontalPadding * 2 total += horizontalPadding * 2
return total return total
} }
function calculatedHorizontalWidth() { function computeHeight() {
let total = 0 let total = 0
for (var i = 0; i < localWorkspaces.count; i++) { for (var i = 0; i < localWorkspaces.count; i++) {
const ws = localWorkspaces.get(i) const ws = localWorkspaces.get(i)
total += calculatedWsWidth(ws) total += getWorkspaceHeight(ws)
} }
total += Math.max(localWorkspaces.count - 1, 0) * spacingBetweenPills total += Math.max(localWorkspaces.count - 1, 0) * spacingBetweenPills
total += horizontalPadding * 2 total += horizontalPadding * 2
@ -174,8 +175,8 @@ Item {
Rectangle { Rectangle {
id: workspaceBackground id: workspaceBackground
width: (barPosition === "left" || barPosition === "right") ? Math.round(Style.capsuleHeight * scaling) : parent.width width: isVertical ? Math.round(Style.capsuleHeight * scaling) : parent.width
height: (barPosition === "left" || barPosition === "right") ? parent.height : Math.round(Style.capsuleHeight * scaling) height: isVertical ? parent.height : Math.round(Style.capsuleHeight * scaling)
radius: Math.round(Style.radiusM * scaling) radius: Math.round(Style.radiusM * scaling)
color: compact ? Color.transparent : Color.mSurfaceVariant color: compact ? Color.transparent : Color.mSurfaceVariant
@ -189,16 +190,16 @@ Item {
spacing: spacingBetweenPills spacing: spacingBetweenPills
anchors.verticalCenter: workspaceBackground.verticalCenter anchors.verticalCenter: workspaceBackground.verticalCenter
x: horizontalPadding x: horizontalPadding
visible: barPosition === "top" || barPosition === "bottom" visible: !isVertical
Repeater { Repeater {
id: workspaceRepeaterHorizontal id: workspaceRepeaterHorizontal
model: localWorkspaces model: localWorkspaces
Item { Item {
id: workspacePillContainer id: workspacePillContainer
height: compact ? root.height : workspaceBackground.height * 0.75 width: root.getWorkspaceWidth(model)
width: root.calculatedWsWidth(model) height: Style.capsuleHeight * root.baseDimensionRatio
Rectangle { Rectangle {
id: pill id: pill
anchors.fill: parent anchors.fill: parent
@ -333,15 +334,15 @@ Item {
spacing: spacingBetweenPills spacing: spacingBetweenPills
anchors.horizontalCenter: workspaceBackground.horizontalCenter anchors.horizontalCenter: workspaceBackground.horizontalCenter
y: horizontalPadding y: horizontalPadding
visible: barPosition === "left" || barPosition === "right" visible: isVertical
Repeater { Repeater {
id: workspaceRepeaterVertical id: workspaceRepeaterVertical
model: localWorkspaces model: localWorkspaces
Item { Item {
id: workspacePillContainerVertical id: workspacePillContainerVertical
width: compact ? root.width : workspaceBackground.width * 0.75 width: Style.capsuleHeight * root.baseDimensionRatio
height: root.calculatedWsHeight(model) height: root.getWorkspaceHeight(model)
Rectangle { Rectangle {
id: pillVertical id: pillVertical