refactor: no need for clippingbox
Just use clip property of Item
This commit is contained in:
parent
f7b0e4665b
commit
65e0928670
3 changed files with 2 additions and 186 deletions
|
|
@ -5,12 +5,13 @@ import "root:/config"
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
||||||
ClippingBoxLayout {
|
BoxLayout {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
readonly property color colour: Appearance.colours.pink
|
readonly property color colour: Appearance.colours.pink
|
||||||
|
|
||||||
animated: true
|
animated: true
|
||||||
|
clip: true
|
||||||
|
|
||||||
MaterialIcon {
|
MaterialIcon {
|
||||||
text: Icons.getAppCategoryIcon(Hyprland.activeClient?.class) ?? "desktop_windows"
|
text: Icons.getAppCategoryIcon(Hyprland.activeClient?.class) ?? "desktop_windows"
|
||||||
|
|
|
||||||
|
|
@ -1,87 +0,0 @@
|
||||||
import "root:/config"
|
|
||||||
import Quickshell.Widgets
|
|
||||||
import QtQuick
|
|
||||||
|
|
||||||
ClippingRectangle {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
property bool vertical: false
|
|
||||||
property bool homogenous: false
|
|
||||||
property bool animated: false
|
|
||||||
property int spacing: Appearance.spacing.small
|
|
||||||
property var padding: 0
|
|
||||||
|
|
||||||
readonly property int paddingTop: getRealPadding().top
|
|
||||||
readonly property int paddingRight: getRealPadding().right
|
|
||||||
readonly property int paddingBottom: getRealPadding().bottom
|
|
||||||
readonly property int paddingLeft: getRealPadding().left
|
|
||||||
readonly property int paddingX: getRealPadding().x
|
|
||||||
readonly property int paddingY: getRealPadding().y
|
|
||||||
|
|
||||||
function getRealPadding() {
|
|
||||||
const pad = {};
|
|
||||||
|
|
||||||
if (Array.isArray(padding)) {
|
|
||||||
if (padding.length === 2) {
|
|
||||||
pad.top = pad.bottom = padding[0];
|
|
||||||
pad.left = pad.right = padding[1];
|
|
||||||
} else if (padding.length === 3) {
|
|
||||||
pad.top = padding[0];
|
|
||||||
pad.left = pad.right = padding[1];
|
|
||||||
pad.bottom = padding[2];
|
|
||||||
} else if (padding.length === 4) {
|
|
||||||
pad.top = padding[0];
|
|
||||||
pad.right = padding[1];
|
|
||||||
pad.bottom = padding[2];
|
|
||||||
pad.left = padding[3];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pad.top = pad.bottom = pad.left = pad.right = padding;
|
|
||||||
}
|
|
||||||
|
|
||||||
pad.x = pad.left + pad.right;
|
|
||||||
pad.y = pad.top + pad.bottom;
|
|
||||||
|
|
||||||
return pad;
|
|
||||||
}
|
|
||||||
|
|
||||||
color: "transparent"
|
|
||||||
|
|
||||||
implicitWidth: childrenRect.width + paddingX
|
|
||||||
implicitHeight: childrenRect.height + paddingY
|
|
||||||
|
|
||||||
onChildrenChanged: {
|
|
||||||
for (const child of children) {
|
|
||||||
child.x = Qt.binding(() => paddingLeft);
|
|
||||||
child.y = Qt.binding(() => paddingTop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on color {
|
|
||||||
ColorAnimation {
|
|
||||||
duration: Appearance.anim.durations.normal
|
|
||||||
easing.type: Easing.BezierSpline
|
|
||||||
easing.bezierCurve: Appearance.anim.curves.standard
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on implicitWidth {
|
|
||||||
enabled: root.animated
|
|
||||||
|
|
||||||
NumberAnimation {
|
|
||||||
duration: Appearance.anim.durations.normal
|
|
||||||
easing.type: Easing.BezierSpline
|
|
||||||
easing.bezierCurve: Appearance.anim.curves.emphasized
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on implicitHeight {
|
|
||||||
enabled: root.animated
|
|
||||||
|
|
||||||
NumberAnimation {
|
|
||||||
duration: Appearance.anim.durations.normal
|
|
||||||
easing.type: Easing.BezierSpline
|
|
||||||
easing.bezierCurve: Appearance.anim.curves.emphasized
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,98 +0,0 @@
|
||||||
import "root:/config"
|
|
||||||
import Quickshell.Widgets
|
|
||||||
import QtQuick
|
|
||||||
import QtQuick.Layouts
|
|
||||||
|
|
||||||
ClippingRectangle {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
default property alias children: layout.children
|
|
||||||
|
|
||||||
property bool vertical: false
|
|
||||||
property bool homogenous: false
|
|
||||||
property bool animated: false
|
|
||||||
property int spacing: Appearance.spacing.small
|
|
||||||
property var padding: 0
|
|
||||||
|
|
||||||
readonly property int paddingTop: getRealPadding().top
|
|
||||||
readonly property int paddingRight: getRealPadding().right
|
|
||||||
readonly property int paddingBottom: getRealPadding().bottom
|
|
||||||
readonly property int paddingLeft: getRealPadding().left
|
|
||||||
readonly property int paddingX: getRealPadding().x
|
|
||||||
readonly property int paddingY: getRealPadding().y
|
|
||||||
|
|
||||||
function getRealPadding() {
|
|
||||||
const pad = {};
|
|
||||||
|
|
||||||
if (Array.isArray(padding)) {
|
|
||||||
if (padding.length === 2) {
|
|
||||||
pad.top = pad.bottom = padding[0];
|
|
||||||
pad.left = pad.right = padding[1];
|
|
||||||
} else if (padding.length === 3) {
|
|
||||||
pad.top = padding[0];
|
|
||||||
pad.left = pad.right = padding[1];
|
|
||||||
pad.bottom = padding[2];
|
|
||||||
} else if (padding.length === 4) {
|
|
||||||
pad.top = padding[0];
|
|
||||||
pad.right = padding[1];
|
|
||||||
pad.bottom = padding[2];
|
|
||||||
pad.left = padding[3];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pad.top = pad.bottom = pad.left = pad.right = padding;
|
|
||||||
}
|
|
||||||
|
|
||||||
pad.x = pad.left + pad.right;
|
|
||||||
pad.y = pad.top + pad.bottom;
|
|
||||||
|
|
||||||
return pad;
|
|
||||||
}
|
|
||||||
|
|
||||||
color: "transparent"
|
|
||||||
|
|
||||||
implicitWidth: layout.implicitWidth + paddingX
|
|
||||||
implicitHeight: layout.implicitHeight + paddingY
|
|
||||||
|
|
||||||
GridLayout {
|
|
||||||
id: layout
|
|
||||||
|
|
||||||
x: root.paddingLeft
|
|
||||||
y: root.paddingTop
|
|
||||||
|
|
||||||
flow: root.vertical ? GridLayout.TopToBottom : GridLayout.LeftToRight
|
|
||||||
uniformCellWidths: root.homogenous || root.vertical
|
|
||||||
uniformCellHeights: root.homogenous || !root.vertical
|
|
||||||
rows: root.vertical ? -1 : 1
|
|
||||||
columns: root.vertical ? 1 : -1
|
|
||||||
rowSpacing: root.spacing
|
|
||||||
columnSpacing: root.spacing
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on color {
|
|
||||||
ColorAnimation {
|
|
||||||
duration: Appearance.anim.durations.normal
|
|
||||||
easing.type: Easing.BezierSpline
|
|
||||||
easing.bezierCurve: Appearance.anim.curves.standard
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on implicitWidth {
|
|
||||||
enabled: root.animated
|
|
||||||
|
|
||||||
NumberAnimation {
|
|
||||||
duration: Appearance.anim.durations.normal
|
|
||||||
easing.type: Easing.BezierSpline
|
|
||||||
easing.bezierCurve: Appearance.anim.curves.emphasized
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on implicitHeight {
|
|
||||||
enabled: root.animated
|
|
||||||
|
|
||||||
NumberAnimation {
|
|
||||||
duration: Appearance.anim.durations.normal
|
|
||||||
easing.type: Easing.BezierSpline
|
|
||||||
easing.bezierCurve: Appearance.anim.curves.emphasized
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Reference in a new issue