1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-29 16:02:51 -05:00

Modal/Popout layout alterations

This commit is contained in:
bbedward
2025-10-03 15:15:44 -04:00
parent 5da265bf0b
commit e95d3126b2
3 changed files with 81 additions and 68 deletions

View File

@@ -678,6 +678,10 @@ Singleton {
function withAlpha(c, a) { return Qt.rgba(c.r, c.g, c.b, a); } function withAlpha(c, a) { return Qt.rgba(c.r, c.g, c.b, a); }
function snap(value, dpr) {
return Math.round(value * dpr) / dpr
}
Process { Process {
id: matugenCheck id: matugenCheck
command: ["which", "matugen"] command: ["which", "matugen"]

View File

@@ -157,8 +157,7 @@ PanelWindow {
radius: root.cornerRadius radius: root.cornerRadius
border.color: root.borderColor border.color: root.borderColor
border.width: root.borderWidth border.width: root.borderWidth
layer.enabled: root.enableShadow layer.enabled: true
opacity: root.shouldBeVisible ? 1 : 0
transform: root.animationType === "slide" ? slideTransform : null transform: root.animationType === "slide" ? slideTransform : null
Translate { Translate {
@@ -176,13 +175,6 @@ PanelWindow {
asynchronous: false asynchronous: false
} }
Behavior on opacity {
NumberAnimation {
duration: root.animationDuration
easing.type: root.animationEasing
}
}
layer.effect: MultiEffect { layer.effect: MultiEffect {
shadowEnabled: true shadowEnabled: true
shadowHorizontalOffset: 0 shadowHorizontalOffset: 0
@@ -190,6 +182,15 @@ PanelWindow {
shadowBlur: 1 shadowBlur: 1
shadowColor: Theme.shadowStrong shadowColor: Theme.shadowStrong
shadowOpacity: 0.3 shadowOpacity: 0.3
source: contentContainer
opacity: root.shouldBeVisible ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: animationDuration
easing.type: animationEasing
}
}
} }
} }

View File

@@ -68,26 +68,10 @@ PanelWindow {
bottom: true bottom: true
} }
MouseArea {
anchors.fill: parent
enabled: shouldBeVisible
onClicked: mouse => {
var localPos = mapToItem(contentContainer, mouse.x, mouse.y)
if (localPos.x < 0 || localPos.x > contentContainer.width || localPos.y < 0 || localPos.y > contentContainer.height) {
backgroundClicked()
close()
}
}
}
Item {
id: contentContainer
// ! TODO - cannot figure out the proper fix for this, some texture artifacts with certain drivers screen scales
layer.enabled: Quickshell.env("DMS_DISABLE_LAYER") !== "true"
readonly property real screenWidth: root.screen.width readonly property real screenWidth: root.screen.width
readonly property real screenHeight: root.screen.height readonly property real screenHeight: root.screen.height
readonly property real gothOffset: SettingsData.dankBarGothCornersEnabled ? Theme.cornerRadius : 0 readonly property real dpr: root.screen.devicePixelRatio
readonly property real calculatedX: { readonly property real calculatedX: {
if (SettingsData.dankBarPosition === SettingsData.Position.Left) { if (SettingsData.dankBarPosition === SettingsData.Position.Left) {
return triggerY return triggerY
@@ -109,15 +93,36 @@ PanelWindow {
} }
} }
readonly property real dpr: root.screen.devicePixelRatio readonly property real alignedWidth: Theme.snap(popupWidth, dpr)
function snap(v) { return Math.round(v * dpr) / dpr } readonly property real alignedHeight: Theme.snap(popupHeight, dpr)
width: popupWidth readonly property real alignedX: Theme.snap(calculatedX, dpr)
height: popupHeight readonly property real alignedY: Theme.snap(calculatedY, dpr)
x: snap(calculatedX)
y: snap(calculatedY)
MouseArea {
anchors.fill: parent
enabled: shouldBeVisible
onClicked: mouse => {
if (mouse.x < alignedX || mouse.x > alignedX + alignedWidth ||
mouse.y < alignedY || mouse.y > alignedY + alignedHeight) {
backgroundClicked()
close()
}
}
}
Loader {
id: contentLoader
x: alignedX
y: alignedY
width: alignedWidth
height: alignedHeight
active: root.visible
asynchronous: false
opacity: Quickshell.env("DMS_DISABLE_LAYER") === "true" ? (shouldBeVisible ? 1 : 0) : 1
layer.enabled: Quickshell.env("DMS_DISABLE_LAYER") !== "true"
layer.effect: MultiEffect {
source: contentLoader
opacity: shouldBeVisible ? 1 : 0 opacity: shouldBeVisible ? 1 : 0
scale: 1
Behavior on opacity { Behavior on opacity {
NumberAnimation { NumberAnimation {
@@ -125,16 +130,21 @@ PanelWindow {
easing.type: animationEasing easing.type: animationEasing
} }
} }
}
Loader { Behavior on opacity {
id: contentLoader NumberAnimation {
anchors.fill: parent duration: animationDuration
active: root.visible easing.type: animationEasing
asynchronous: false }
}
} }
Item { Item {
anchors.fill: parent x: alignedX
y: alignedY
width: alignedWidth
height: alignedHeight
focus: true focus: true
Keys.onPressed: event => { Keys.onPressed: event => {
if (event.key === Qt.Key_Escape) { if (event.key === Qt.Key_Escape) {
@@ -143,8 +153,6 @@ PanelWindow {
} }
} }
Component.onCompleted: forceActiveFocus() Component.onCompleted: forceActiveFocus()
onVisibleChanged: if (visible) onVisibleChanged: if (visible) forceActiveFocus()
forceActiveFocus()
}
} }
} }