qs: marquee effect of FocuedWindow component
This commit is contained in:
@@ -65,11 +65,20 @@ Item {
|
||||
Item {
|
||||
id: titleContainer
|
||||
|
||||
property bool shouldScroll: windowTitle.implicitWidth > width
|
||||
property int scrollSpacing: 30
|
||||
|
||||
implicitWidth: root.maxWidth
|
||||
implicitHeight: parent.height
|
||||
// Layout.alignment: Qt.AlignVCenter
|
||||
clip: true
|
||||
|
||||
Item {
|
||||
id: scrollContent
|
||||
|
||||
height: parent.height
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
Text {
|
||||
id: windowTitle
|
||||
|
||||
@@ -78,6 +87,35 @@ Item {
|
||||
font.pointSize: Fonts.medium
|
||||
font.family: Fonts.primary
|
||||
color: Colors.primary
|
||||
}
|
||||
|
||||
Text {
|
||||
text: Niri.focusedWindowTitle
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: windowTitle.right
|
||||
anchors.leftMargin: titleContainer.scrollSpacing
|
||||
font.pointSize: Fonts.medium
|
||||
font.family: Fonts.primary
|
||||
color: Colors.primary
|
||||
visible: titleContainer.shouldScroll
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
target: scrollContent
|
||||
property: "x"
|
||||
from: 0
|
||||
to: -(windowTitle.width + titleContainer.scrollSpacing)
|
||||
duration: (windowTitle.width + titleContainer.scrollSpacing) * 10
|
||||
loops: Animation.Infinite
|
||||
running: titleContainer.shouldScroll && mouseArea.containsMouse
|
||||
onRunningChanged: {
|
||||
if (!running)
|
||||
scrollContent.x = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
@@ -86,14 +124,6 @@ Item {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
hoverEnabled: true
|
||||
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
|
||||
onEntered: {
|
||||
if (windowTitle.implicitWidth > titleContainer.width)
|
||||
windowTitle.x = titleContainer.width - windowTitle.implicitWidth;
|
||||
|
||||
}
|
||||
onExited: {
|
||||
windowTitle.x = 0;
|
||||
}
|
||||
onClicked: function(mouse) {
|
||||
if (mouse.button === Qt.MiddleButton)
|
||||
Quickshell.execDetached(["niri", "msg", "action", "close-window"]);
|
||||
@@ -114,16 +144,6 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on x {
|
||||
NumberAnimation {
|
||||
duration: 1000
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user