67 lines
2.1 KiB
QML
67 lines
2.1 KiB
QML
import QtQuick
|
|
import "../config"
|
|
|
|
// One workspace/tag chip. Every backend renders through this, so the left end
|
|
// of the bar looks the same whichever window manager is driving it.
|
|
//
|
|
// `dimmed` and `dot` are presentational rather than semantic on purpose: what
|
|
// counts as "empty" differs per backend (i3 only lists workspaces that exist,
|
|
// attwm always publishes all nine tags), so each call site decides and this
|
|
// stays a plain renderer.
|
|
Rectangle {
|
|
id: chip
|
|
|
|
property string label
|
|
property bool active: false // shown on this monitor
|
|
property bool focused: false // shown *and* holding input focus
|
|
property bool urgent: false
|
|
property bool dimmed: false // exists, but nothing on it
|
|
property bool dot: false // has windows but isn't shown (dwm's corner square)
|
|
|
|
signal clicked(int button)
|
|
|
|
implicitWidth: Math.max(implicitHeight, text.implicitWidth + 16)
|
|
implicitHeight: Theme.barHeight - Theme.gap * 2
|
|
width: implicitWidth
|
|
height: implicitHeight
|
|
radius: Theme.radius
|
|
|
|
color: urgent ? Theme.red
|
|
: focused ? Theme.blue
|
|
: active ? Theme.surface1
|
|
: Theme.surface0
|
|
|
|
Text {
|
|
id: text
|
|
anchors.centerIn: parent
|
|
text: chip.label
|
|
font.family: Theme.font
|
|
font.pixelSize: Theme.fontSize
|
|
font.bold: chip.focused || chip.urgent
|
|
color: (chip.focused || chip.urgent) ? Theme.mantle
|
|
: chip.dimmed ? Theme.overlay
|
|
: Theme.text
|
|
}
|
|
|
|
// dwm puts this in the tag's top-left corner, but the chip is only as wide
|
|
// as one digit -- a corner mark lands on the glyph. Underlining it says the
|
|
// same thing and suits the rounded chips.
|
|
Rectangle {
|
|
visible: chip.dot
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
anchors.bottom: parent.bottom
|
|
anchors.bottomMargin: 4
|
|
width: 6
|
|
height: 2
|
|
radius: 1
|
|
color: Theme.blue
|
|
}
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
cursorShape: Qt.PointingHandCursor
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
|
|
onClicked: event => chip.clicked(event.button)
|
|
}
|
|
}
|