refactor: move popout position logic to wrapper
This commit is contained in:
parent
eaa6aefa6c
commit
e1e0c314c6
2 changed files with 14 additions and 12 deletions
|
|
@ -9,6 +9,7 @@ Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
required property ShellScreen screen
|
required property ShellScreen screen
|
||||||
|
required property real borderThickness
|
||||||
|
|
||||||
readonly property alias content: content
|
readonly property alias content: content
|
||||||
property real offsetScale: x > 0 || content.hasCurrent ? 0 : 1
|
property real offsetScale: x > 0 || content.hasCurrent ? 0 : 1
|
||||||
|
|
@ -19,6 +20,18 @@ Item {
|
||||||
implicitWidth: content.implicitWidth * (1 - offsetScale)
|
implicitWidth: content.implicitWidth * (1 - offsetScale)
|
||||||
implicitHeight: content.implicitHeight
|
implicitHeight: content.implicitHeight
|
||||||
|
|
||||||
|
x: content.isDetached ? (parent.width - content.nonAnimWidth) / 2 : 0
|
||||||
|
y: {
|
||||||
|
if (content.isDetached)
|
||||||
|
return (parent.height - content.nonAnimHeight) / 2;
|
||||||
|
|
||||||
|
const off = content.currentCenter - borderThickness - content.nonAnimHeight / 2;
|
||||||
|
const diff = parent.height - Math.floor(off + content.nonAnimHeight);
|
||||||
|
if (diff < 0)
|
||||||
|
return off + diff;
|
||||||
|
return Math.max(off, 0);
|
||||||
|
}
|
||||||
|
|
||||||
Behavior on offsetScale {
|
Behavior on offsetScale {
|
||||||
Anim {
|
Anim {
|
||||||
duration: Appearance.anim.durations.expressiveDefaultSpatial
|
duration: Appearance.anim.durations.expressiveDefaultSpatial
|
||||||
|
|
|
||||||
|
|
@ -119,18 +119,7 @@ Item {
|
||||||
id: popoutsWrapper
|
id: popoutsWrapper
|
||||||
|
|
||||||
screen: root.screen
|
screen: root.screen
|
||||||
|
borderThickness: root.borderThickness
|
||||||
x: content.isDetached ? (root.width - content.nonAnimWidth) / 2 : 0
|
|
||||||
y: {
|
|
||||||
if (content.isDetached)
|
|
||||||
return (root.height - content.nonAnimHeight) / 2;
|
|
||||||
|
|
||||||
const off = content.currentCenter - root.borderThickness - content.nonAnimHeight / 2;
|
|
||||||
const diff = root.height - Math.floor(off + content.nonAnimHeight);
|
|
||||||
if (diff < 0)
|
|
||||||
return off + diff;
|
|
||||||
return Math.max(off, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Utilities.Wrapper {
|
Utilities.Wrapper {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue