Skip to content

Commit

Permalink
more improvements and fixes, waiting for outfoxxed to fix the mouse e…
Browse files Browse the repository at this point in the history
…vent propagation
  • Loading branch information
Xanazf committed Nov 28, 2024
1 parent 59a19df commit b8f5f34
Show file tree
Hide file tree
Showing 313 changed files with 3,377 additions and 497 deletions.
47 changes: 38 additions & 9 deletions Config.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,54 @@ import Quickshell.Services.Pipewire

Singleton {
id: root
property string username: "xnzf"
property string distro: "Arch Linux (btw)"

property QtObject colors: QtObject {
property string neutral: "#151515"
property string fontcolor: "#f9f9fa"
property string mainBG: "#404b7c"
property string mainFG: "#95d3af"
property string modularBG: "404b7c"
property string modularFG: "95d3af"
property string modularFG2: "f9f9fa"
property string secondaryFG: "#404b7c"
// surface colors
property string neutral: "#010C1D"
property string fontcolor: "#E2ECFE"

// main colors
property string mainColor0: "#111160"
property string mainColor1: "#0F0679"
property string mainColor2: "#1911A6"
property string mainColor3: "#8D1B82"
property string mainColor4: "#C80E65"
property string mainColor5: "#FF0044"
property string mainColor6: "#DB0037"

// ui colors
// -- danger
property string red900: "#DD0039"
property string red800: "#FF0042"
property string red700: "#FF225B"
property string red600: "#FF4575"
property string red500: "#FF668D"

// -- warning
property string yellow900: "#FFA500"
property string yellow800: "#EBC600"
property string yellow700: "#FFD700"
property string yellow600: "#FFEB3B"
property string yellow500: "#FFEC88"

// -- info
property string navy900: "#0C00DD"
property string navy800: "#2E22FF"
property string navy700: "#4E44FF"
property string navy600: "#6E66FF"
property string navy500: "#8E88FF"

// --success
property string green900: "#007742"
property string green800: "#00BB67"
property string green700: "#00FF8D"
property string green600: "#44FFAB"
property string green500: "#88FFCA"
}

property real opacityOffset: 0.75
property real opacityOffset: 0.84

// default font
property font font: Qt.font({
Expand Down
259 changes: 259 additions & 0 deletions HoverableShowcase.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
import QtQuick
import Quickshell
import Quickshell.Hyprland

Scope {
id: root
required property var bar

property TooltipItem activeTooltip: null
property TooltipItem activeMenu: null

readonly property TooltipItem activeItem: activeMenu ?? activeTooltip
property TooltipItem lastActiveItem: null
readonly property TooltipItem shownItem: activeItem ?? lastActiveItem
property real hangTime: lastActiveItem?.hangTime ?? 0

property Item tooltipItem: null

onActiveItemChanged: {
if (activeItem != null) {
hangTimer.stop();
activeItem.targetVisible = true;

if (tooltipItem) {
activeItem.parent = tooltipItem;
}
}

if (lastActiveItem != null && lastActiveItem != activeItem) {
if (activeItem != null)
lastActiveItem.targetVisible = false;
else if (root.hangTime == 0)
doLastHide();
else
hangTimer.start();
}

if (activeItem != null)
lastActiveItem = activeItem;
}

function setItem(item: TooltipItem) {
if (item.isMenu) {
activeMenu = item;
} else {
activeTooltip = item;
}
}

function removeItem(item: TooltipItem) {
if (item.isMenu && activeMenu == item) {
activeMenu = null;
} else if (!item.isMenu && activeTooltip == item) {
activeTooltip = null;
}
}

function doLastHide() {
lastActiveItem.targetVisible = false;
}

function onHidden(item: TooltipItem) {
if (item == lastActiveItem) {
lastActiveItem = null;
}
}

Timer {
id: hangTimer
interval: root.hangTime
onTriggered: doLastHide()
}

property real scaleMul: lastActiveItem && lastActiveItem.targetVisible ? 1000 : 0
Behavior on scaleMul {
SmoothedAnimation {
velocity: 5000
}
}

LazyLoader {
id: popupLoader
activeAsync: shownItem != null

PopupWindow {
id: popup

anchor {
window: bar
rect.x: bar.tooltipXOffset
rect.y: tooltipItem.highestAnimY
adjustment: PopupAdjustment.None
}

//height: bar.height
//width: Math.max(1, widthAnim.running ? Math.max(tooltipItem.targetWidth, tooltipItem.lastTargetWidth) : tooltipItem.targetWidth)
//width: Math.max(1, widthAnim.running ? Math.max(tooltipItem.targetWidth, tooltipItem.lastTargetWidth) : tooltipItem.targetWidth)
width: Math.max(700, tooltipItem.largestAnimWidth) // max due to qtwayland glitches
height: {
const h = tooltipItem.lowestAnimY - tooltipItem.highestAnimY;
//console.log(`seth ${h} ${tooltipItem.highestAnimY} ${tooltipItem.lowestAnimY}; ${tooltipItem.y1} ${tooltipItem.y2}`)
return h;
}
//width: tooltipItem.targetWidth
visible: true
//color: "transparent"
color: "#20000000"

mask: Region {
item: (shownItem?.hoverable ?? false) ? tooltipItem : null
}

HyprlandFocusGrab {
active: activeItem?.isMenu ?? false
windows: [popup, bar, ...(activeItem?.grabWindows ?? [])]
onActiveChanged: {
if (!active && activeItem?.isMenu) {
activeMenu.close();
}
}
}

/*Rectangle {
color: "#10ff0000"
//y: tooltipItem.highestAnimY
height: tooltipItem.lowestAnimY - tooltipItem.highestAnimY
width: parent.width
}
Rectangle {
color: "#1000ff00"
//y: tooltipItem.highestAnimY
height: popup.height
width: parent.width
}*/

Item {
id: tooltipItem
Component.onCompleted: {
root.tooltipItem = this;
if (root.shownItem) {
root.shownItem.parent = this;
}

//highestAnimY = targetY - targetHeight / 2;
//lowestAnimY = targetY + targetHeight / 2;
}

transform: Scale {
origin.x: 0
origin.y: tooltipItem.height / 2
xScale: 0.9 + (scaleMul / 10000)
yScale: xScale
}

clip: width != targetWidth || height != targetHeight

readonly property var targetWidth: shownItem?.implicitWidth ?? 0
readonly property var targetHeight: shownItem?.implicitHeight ?? 0

property var largestAnimWidth: 0
property var highestAnimY: 0 // unused due to reposition timing issues
property var lowestAnimY: bar.height

onTargetWidthChanged: {
if (targetWidth > largestAnimWidth) {
largestAnimWidth = targetWidth;
}
}

onTargetYChanged: updateYBounds()
onTargetHeightChanged: updateYBounds()
function updateYBounds() {
if (targetY - targetHeight / 2 < highestAnimY)
//highestAnimY = targetY - targetHeight / 2
{}

if (targetY + targetHeight / 2 > lowestAnimY)
//lowestAnimY = targetY + targetHeight / 2
{}
}

readonly property real targetY: {
if (shownItem == null)
return 0;
const target = bar.contentItem.mapFromItem(shownItem.owner, 0, shownItem.targetRelativeY).y;
return bar.boundedY(target, shownItem.implicitHeight / 2);
}

property var w: -1
width: Math.max(1, w)

property var y1: -1
property var y2: -1

y: y1 - popup.anchor.rect.y
height: y2 - y1

readonly property bool anyAnimsRunning: y1Anim.running || y2Anim.running || widthAnim.running

onAnyAnimsRunningChanged: {
if (!anyAnimsRunning) {
largestAnimWidth = targetWidth;
//highestAnimY = y1;
//lowestAnimY = y2;
}
}

SmoothedAnimation {
id: y1Anim
target: tooltipItem
property: "y1"
to: tooltipItem.targetY - tooltipItem.targetHeight / 2
onToChanged: {
if (tooltipItem.y1 == -1 || !(shownItem?.animateSize ?? true)) {
stop();
tooltipItem.y1 = to;
} else {
velocity = (Math.max(tooltipItem.y1, to) - Math.min(tooltipItem.y1, to)) * 5;
restart();
}
}
}

SmoothedAnimation {
id: y2Anim
target: tooltipItem
property: "y2"
to: tooltipItem.targetY + tooltipItem.targetHeight / 2
onToChanged: {
if (tooltipItem.y2 == -1 || !(shownItem?.animateSize ?? true)) {
stop();
tooltipItem.y2 = to;
} else {
velocity = (Math.max(tooltipItem.y2, to) - Math.min(tooltipItem.y2, to)) * 5;
restart();
}
}
}

SmoothedAnimation {
id: widthAnim
target: tooltipItem
property: "w"
to: tooltipItem.targetWidth
onToChanged: {
if (tooltipItem.w == -1) {
stop();
tooltipItem.w = to;
} else {
velocity = (Math.max(tooltipItem.width, to) - Math.min(tooltipItem.width, to)) * 5;
restart();
}
}
}
}
}
}
}
1 change: 1 addition & 0 deletions backgrounds/BackgroundItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Item {
anchors.fill: parent
width: parent.width
height: parent.height

layer {
enabled: true
effect: OpacityMask {
Expand Down
25 changes: 8 additions & 17 deletions backgrounds/MainGradient.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Rectangle {
blurMax: 32
blurMultiplier: 1.0
saturation: 1
brightness: -0.5
}
}
opacity: 1 - Config.opacityOffset
Expand All @@ -28,14 +27,7 @@ Rectangle {
id: gradient1
orientation: Gradient.Horizontal
property real positionOffset
GradientStop {
position: -0.4 + gradient1.positionOffset
color: Config.colors.mainColor2
}
GradientStop {
position: -0.2 + gradient1.positionOffset
color: Config.colors.mainColor3
}

GradientStop {
position: 0.0 + gradient1.positionOffset
color: Config.colors.mainColor1
Expand All @@ -54,11 +46,11 @@ Rectangle {
}
GradientStop {
position: 0.8 + gradient1.positionOffset
color: Config.colors.mainColor5
color: Config.colors.mainColor6
}
GradientStop {
position: 1.0 + gradient1.positionOffset
color: Config.colors.mainColor6
color: Config.colors.mainColor4
}
GradientStop {
position: 1.2 + gradient1.positionOffset
Expand All @@ -68,17 +60,16 @@ Rectangle {
position: 1.4 + gradient1.positionOffset
color: Config.colors.mainColor2
}
GradientStop {
position: 1.6 + gradient1.positionOffset
color: Config.colors.mainColor1
}
NumberAnimation on positionOffset {
id: numanim
loops: Animation.Infinite
property bool reverse
duration: 60000
duration: 30000
from: -2.0
to: 1.0
onFinished: {
numanim.reverse = !numanim.reverse;
numanim.start();
}
}
}
}
Loading

0 comments on commit b8f5f34

Please sign in to comment.