left-bar working, bottom bar semi-broken
This commit is contained in:
+39
-17
@@ -9,22 +9,32 @@ Item {
|
||||
id: root
|
||||
|
||||
required property var bar
|
||||
property color colour: DynamicColors.palette.m3primary
|
||||
property color color: DynamicColors.palette.m3primary
|
||||
property Title current: text1
|
||||
required property bool horizontal
|
||||
// readonly property int maxWidth: 300
|
||||
readonly property int maxWidth: {
|
||||
const otherModules = bar.children.filter(c => c.enabled && c.id && c.item !== this && c.id !== "spacer");
|
||||
const otherWidth = otherModules.reduce((acc, curr) => {
|
||||
return acc + (curr.item?.nonAnimWidth ?? curr.width ?? 0);
|
||||
}, 0);
|
||||
return bar.width - otherWidth - bar.spacing * (bar.children.length - 1) - bar.vPadding * 2;
|
||||
readonly property int maxSize: {
|
||||
const otherModules = bar.children.filter(c => c.enabled && c.entryId && c.item !== this && c.entryId !== "spacer");
|
||||
const otherSize = otherModules.reduce((acc, curr) => acc + (horizontal ? (curr.item?.nonAnimWidth ?? curr.width ?? 0) : (curr.item.nonAnimHeight ?? curr.height ?? 0)), 0);
|
||||
return horizontal ? bar.width - otherSize - bar.spacing * (bar.children.length - 1) - bar.vPadding * 2 : bar.height - otherSize - bar.vPadding * (bar.children.length - 1) - bar.vPadding * 4;
|
||||
}
|
||||
|
||||
anchors.centerIn: parent
|
||||
clip: true
|
||||
implicitHeight: current.implicitHeight
|
||||
implicitWidth: Math.min(current.implicitWidth, root.maxWidth)
|
||||
implicitHeight: horizontal ? current.implicitHeight : current.implicitWidth + current.anchors.topMargin
|
||||
implicitWidth: horizontal ? Math.min(current.implicitWidth, root.maxSize) : current.implicitHeight + current.anchors.topMargin
|
||||
|
||||
Behavior on implicitHeight {
|
||||
enabled: !root.horizontal
|
||||
|
||||
Anim {
|
||||
duration: MaterialEasing.expressiveEffectsTime
|
||||
easing.bezierCurve: MaterialEasing.expressiveEffects
|
||||
}
|
||||
}
|
||||
Behavior on implicitWidth {
|
||||
enabled: root.horizontal
|
||||
|
||||
Anim {
|
||||
duration: MaterialEasing.expressiveEffectsTime
|
||||
easing.bezierCurve: MaterialEasing.expressiveEffects
|
||||
@@ -33,19 +43,17 @@ Item {
|
||||
|
||||
Title {
|
||||
id: text1
|
||||
|
||||
}
|
||||
|
||||
Title {
|
||||
id: text2
|
||||
|
||||
}
|
||||
|
||||
TextMetrics {
|
||||
id: metrics
|
||||
|
||||
elide: Qt.ElideRight
|
||||
elideWidth: root.maxWidth
|
||||
elideWidth: root.maxSize - (root.horizontal ? root.current.anchors.leftMargin : 0)
|
||||
font.family: "Rubik"
|
||||
font.pointSize: Appearance.font.size.normal
|
||||
text: Hypr.activeToplevel?.title ?? qsTr("Desktop")
|
||||
@@ -61,18 +69,32 @@ Item {
|
||||
component Title: CustomText {
|
||||
id: text
|
||||
|
||||
anchors.leftMargin: 7
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: root.colour
|
||||
anchors.horizontalCenter: root.horizontal ? undefined : parent.horizontalCenter
|
||||
anchors.left: root.horizontal ? parent.left : undefined
|
||||
anchors.leftMargin: root.horizontal ? Appearance.spacing.small : 0
|
||||
anchors.top: root.horizontal ? undefined : parent.top
|
||||
anchors.topMargin: root.horizontal ? 0 : Appearance.spacing.small
|
||||
anchors.verticalCenter: root.horizontal ? parent.verticalCenter : undefined
|
||||
color: root.color
|
||||
font.family: metrics.font.family
|
||||
font.pointSize: metrics.font.pointSize
|
||||
height: implicitHeight
|
||||
height: root.horizontal ? implicitHeight : implicitWidth
|
||||
opacity: root.current === this ? 1 : 0
|
||||
width: implicitWidth
|
||||
width: root.horizontal ? implicitWidth : implicitHeight
|
||||
|
||||
Behavior on opacity {
|
||||
Anim {
|
||||
}
|
||||
}
|
||||
transform: [
|
||||
Translate {
|
||||
x: !root.horizontal ? -text.implicitWidth + text.implicitHeight : 0
|
||||
},
|
||||
Rotation {
|
||||
angle: root.horizontal ? 0 : 270
|
||||
origin.x: text.implicitHeight / 2
|
||||
origin.y: text.implicitHeight / 2
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user