forked from Shinonome/dots-hyprland
130 lines
4.5 KiB
QML
130 lines
4.5 KiB
QML
import "root:/modules/common"
|
|
import "root:/modules/common/widgets"
|
|
import "root:/modules/common/functions/color_utils.js" as ColorUtils
|
|
import QtQuick
|
|
import QtQuick.Controls
|
|
import QtQuick.Layouts
|
|
import Quickshell.Io
|
|
|
|
TabButton {
|
|
id: root
|
|
|
|
property bool toggled: TabBar.tabBar.currentIndex === TabBar.index
|
|
property string buttonIcon
|
|
property string buttonText
|
|
property bool expanded: false
|
|
|
|
property real baseSize: 56
|
|
property real baseHighlightHeight: 32
|
|
padding: 0
|
|
|
|
implicitHeight: baseSize
|
|
implicitWidth: contentItem.implicitWidth
|
|
|
|
background: null
|
|
PointingHandInteraction {}
|
|
|
|
// Real stuff
|
|
contentItem: Item {
|
|
id: buttonContent
|
|
anchors {
|
|
left: parent.left
|
|
verticalCenter: parent.verticalCenter
|
|
}
|
|
|
|
implicitWidth: root.expanded ? itemIconBackground.implicitWidth + 20 + itemText.implicitWidth :
|
|
itemIconBackground.implicitWidth
|
|
implicitHeight: root.expanded ? itemIconBackground.implicitHeight : itemIconBackground.implicitHeight + itemText.implicitHeight
|
|
|
|
Rectangle {
|
|
id: itemBackground
|
|
anchors.top: itemIconBackground.top
|
|
anchors.left: itemIconBackground.left
|
|
anchors.right: itemIconBackground.right
|
|
anchors.bottom: itemIconBackground.bottom
|
|
radius: Appearance.rounding.full
|
|
color: toggled ?
|
|
(root.down ? Appearance.colors.colSecondaryContainerActive : root.hovered ? Appearance.colors.colSecondaryContainerHover : Appearance.colors.colSecondaryContainer) :
|
|
(root.down ? Appearance.colors.colLayer1Active : root.hovered ? Appearance.colors.colLayer1Hover : ColorUtils.transparentize(Appearance.colors.colLayer1Hover, 1))
|
|
|
|
states: State {
|
|
name: "expanded"
|
|
when: root.expanded
|
|
AnchorChanges {
|
|
target: itemBackground
|
|
anchors.top: buttonContent.top
|
|
anchors.left: buttonContent.left
|
|
anchors.right: buttonContent.right
|
|
anchors.bottom: buttonContent.bottom
|
|
}
|
|
}
|
|
transitions: Transition {
|
|
AnchorAnimation {
|
|
duration: Appearance.animation.elementMoveFast.duration
|
|
easing.type: Appearance.animation.elementMoveFast.type
|
|
easing.bezierCurve: Appearance.animation.elementMoveFast.bezierCurve
|
|
}
|
|
}
|
|
|
|
Behavior on color {
|
|
animation: Appearance.animation.elementMoveFast.colorAnimation.createObject(this)
|
|
}
|
|
}
|
|
|
|
Item {
|
|
id: itemIconBackground
|
|
implicitWidth: root.baseSize
|
|
implicitHeight: root.baseHighlightHeight
|
|
anchors {
|
|
left: parent.left
|
|
verticalCenter: parent.verticalCenter
|
|
}
|
|
MaterialSymbol {
|
|
id: navRailButtonIcon
|
|
anchors.centerIn: parent
|
|
iconSize: 24
|
|
fill: toggled ? 1 : 0
|
|
text: buttonIcon
|
|
color: toggled ? Appearance.m3colors.m3onSecondaryContainer : Appearance.colors.colOnLayer1
|
|
|
|
Behavior on color {
|
|
animation: Appearance.animation.elementMoveFast.colorAnimation.createObject(this)
|
|
}
|
|
}
|
|
}
|
|
|
|
StyledText {
|
|
id: itemText
|
|
anchors {
|
|
top: itemIconBackground.bottom
|
|
topMargin: 6
|
|
horizontalCenter: itemIconBackground.horizontalCenter
|
|
}
|
|
states: State {
|
|
name: "expanded"
|
|
when: root.expanded
|
|
AnchorChanges {
|
|
target: itemText
|
|
anchors {
|
|
top: undefined
|
|
horizontalCenter: undefined
|
|
left: itemIconBackground.right
|
|
verticalCenter: itemIconBackground.verticalCenter
|
|
}
|
|
}
|
|
}
|
|
transitions: Transition {
|
|
AnchorAnimation {
|
|
duration: Appearance.animation.elementMoveFast.duration
|
|
easing.type: Appearance.animation.elementMoveFast.type
|
|
easing.bezierCurve: Appearance.animation.elementMoveFast.bezierCurve
|
|
}
|
|
}
|
|
text: buttonText
|
|
font.pixelSize: 14
|
|
color: Appearance.colors.colOnLayer1
|
|
}
|
|
}
|
|
|
|
}
|