mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
Fix scale calculation
This commit is contained in:
parent
89c0477b8d
commit
daa40c0759
2 changed files with 79 additions and 60 deletions
|
|
@ -22,8 +22,6 @@ Item {
|
||||||
readonly property point taskScreenPoint: Qt.point(model.ScreenGeometry.x, model.ScreenGeometry.y)
|
readonly property point taskScreenPoint: Qt.point(model.ScreenGeometry.x, model.ScreenGeometry.y)
|
||||||
readonly property real dragOffset: -control.y
|
readonly property real dragOffset: -control.y
|
||||||
|
|
||||||
readonly property real headerHeight: appHeader.height + PlasmaCore.Units.smallSpacing
|
|
||||||
|
|
||||||
property bool active: model.IsActive
|
property bool active: model.IsActive
|
||||||
|
|
||||||
required property real previewHeight
|
required property real previewHeight
|
||||||
|
|
@ -63,6 +61,11 @@ Item {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
|
||||||
|
leftPadding: 0
|
||||||
|
rightPadding: 0
|
||||||
|
topPadding: 0
|
||||||
|
bottomPadding: 0
|
||||||
|
|
||||||
// drag up gesture
|
// drag up gesture
|
||||||
DragHandler {
|
DragHandler {
|
||||||
id: dragHandler
|
id: dragHandler
|
||||||
|
|
@ -96,13 +99,16 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
// application
|
// application
|
||||||
ColumnLayout {
|
contentItem: ColumnLayout {
|
||||||
anchors.fill: parent
|
id: column
|
||||||
spacing: PlasmaCore.Units.smallSpacing
|
spacing: 0
|
||||||
|
|
||||||
|
// header
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: appHeader
|
id: appHeader
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.minimumHeight: column.height - appView.height
|
||||||
spacing: PlasmaCore.Units.smallSpacing * 2
|
spacing: PlasmaCore.Units.smallSpacing * 2
|
||||||
|
|
||||||
PlasmaCore.IconItem {
|
PlasmaCore.IconItem {
|
||||||
|
|
@ -125,6 +131,7 @@ Item {
|
||||||
id: rep
|
id: rep
|
||||||
model: plasmoid.nativeInterface.outputs
|
model: plasmoid.nativeInterface.outputs
|
||||||
delegate: PlasmaComponents.ToolButton {
|
delegate: PlasmaComponents.ToolButton {
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
text: model.modelName
|
text: model.modelName
|
||||||
visible: model.position !== delegate.taskScreenPoint
|
visible: model.position !== delegate.taskScreenPoint
|
||||||
display: rep.count < 3 ? QQC2.Button.IconOnly : QQC2.Button.TextBesideIcon
|
display: rep.count < 3 ? QQC2.Button.IconOnly : QQC2.Button.TextBesideIcon
|
||||||
|
|
@ -137,6 +144,7 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaComponents.ToolButton {
|
PlasmaComponents.ToolButton {
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
z: 99
|
z: 99
|
||||||
icon.name: "window-close"
|
icon.name: "window-close"
|
||||||
icon.width: PlasmaCore.Units.iconSizes.smallMedium
|
icon.width: PlasmaCore.Units.iconSizes.smallMedium
|
||||||
|
|
@ -145,11 +153,13 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// app preview
|
||||||
QQC2.Control {
|
QQC2.Control {
|
||||||
id: appView
|
id: appView
|
||||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
|
||||||
Layout.preferredWidth: delegate.previewWidth
|
Layout.preferredWidth: delegate.previewWidth
|
||||||
Layout.preferredHeight: delegate.previewHeight // keep same as window resolution
|
Layout.preferredHeight: delegate.previewHeight
|
||||||
|
Layout.maximumWidth: delegate.previewWidth
|
||||||
|
Layout.maximumHeight: delegate.previewHeight
|
||||||
|
|
||||||
leftPadding: 0
|
leftPadding: 0
|
||||||
rightPadding: 0
|
rightPadding: 0
|
||||||
|
|
|
||||||
|
|
@ -180,67 +180,76 @@ NanoShell.FullScreenOverlay {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView {
|
Item {
|
||||||
id: tasksView
|
id: container
|
||||||
z: 100
|
|
||||||
opacity: window.wasInActiveTask ? 1 : Math.min(1, window.yOffset / window.targetYOffsetDist)
|
|
||||||
|
|
||||||
property real horizontalMargin: PlasmaCore.Units.gridUnit * 3
|
// provide shell margins
|
||||||
anchors.centerIn: parent
|
anchors.fill: parent
|
||||||
|
anchors.rightMargin: navPanel.isPortrait ? 0 : window.taskPanelHeight
|
||||||
|
anchors.bottomMargin: navPanel.isPortrait ? window.taskPanelHeight : 0
|
||||||
|
anchors.topMargin: MobileShell.TopPanelControls.panelHeight
|
||||||
|
|
||||||
width: window.width - horizontalMargin * 2
|
// applications list
|
||||||
height: window.windowHeight - (PlasmaCore.Units.gridUnit * 2 + PlasmaCore.Units.largeSpacing * 2)
|
ListView {
|
||||||
|
id: tasksView
|
||||||
model: window.model
|
opacity: window.wasInActiveTask ? 1 : Math.min(1, window.yOffset / window.targetYOffsetDist)
|
||||||
orientation: ListView.Horizontal
|
anchors.centerIn: parent
|
||||||
|
|
||||||
highlightRangeMode: ListView.StrictlyEnforceRange // ensures currentIndex is updated
|
|
||||||
snapMode: ListView.SnapToItem
|
|
||||||
|
|
||||||
spacing: PlasmaCore.Units.largeSpacing
|
|
||||||
displayMarginBeginning: 2 * (width + spacing)
|
|
||||||
displayMarginEnd: 2 * (width + spacing)
|
|
||||||
|
|
||||||
displaced: Transition {
|
|
||||||
NumberAnimation { properties: "x,y"; duration: PlasmaCore.Units.longDuration; easing.type: Easing.InOutQuad }
|
|
||||||
}
|
|
||||||
|
|
||||||
// ensure that window previews are exactly to the scale of the device screen
|
|
||||||
property real scalingFactor: {
|
|
||||||
let candidateHeight = (tasksView.width / window.width) * window.windowHeight;
|
|
||||||
|
|
||||||
if (candidateHeight > tasksView.height) {
|
readonly property real sizeFactor: 0.75
|
||||||
return tasksView.height / window.windowHeight;
|
readonly property real taskHeaderHeight: PlasmaCore.Units.gridUnit * 2 + PlasmaCore.Units.smallSpacing * 2
|
||||||
} else {
|
|
||||||
return tasksView.width / window.windowWidth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: Task {
|
|
||||||
id: task
|
|
||||||
property int curIndex: model.index
|
|
||||||
z: window.currentTaskIndex === curIndex ? 1 : 0
|
|
||||||
width: tasksView.width
|
|
||||||
height: tasksView.height
|
|
||||||
|
|
||||||
// account for header offset (center the preview)
|
width: window.windowWidth * sizeFactor
|
||||||
y: task.headerHeight / 2
|
height: window.windowHeight * sizeFactor + taskHeaderHeight
|
||||||
|
|
||||||
// scale gesture
|
model: window.model
|
||||||
scale: {
|
orientation: ListView.Horizontal
|
||||||
let maxScale = 1 / tasksView.scalingFactor;
|
|
||||||
let subtract = (maxScale - 1) * (window.yOffset / window.targetYOffsetDist);
|
highlightRangeMode: ListView.StrictlyEnforceRange // ensures currentIndex is updated
|
||||||
let finalScale = Math.max(0, Math.min(maxScale, maxScale - subtract));
|
snapMode: ListView.SnapToItem
|
||||||
|
|
||||||
if ((window.wasInActiveTask || !taskSwitcher.currentlyDragging) && window.currentTaskIndex === task.curIndex) {
|
spacing: PlasmaCore.Units.largeSpacing
|
||||||
return finalScale;
|
displayMarginBeginning: 2 * (width + spacing)
|
||||||
}
|
displayMarginEnd: 2 * (width + spacing)
|
||||||
return 1;
|
displaced: Transition {
|
||||||
|
NumberAnimation { properties: "x,y"; duration: PlasmaCore.Units.longDuration; easing.type: Easing.InOutQuad }
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure that window previews are exactly to the scale of the device screen
|
// ensure that window previews are exactly to the scale of the device screen
|
||||||
previewWidth: tasksView.scalingFactor * window.windowWidth
|
property real scalingFactor: {
|
||||||
previewHeight: tasksView.scalingFactor * window.windowHeight
|
let candidateHeight = (tasksView.width / window.windowWidth) * window.windowHeight;
|
||||||
|
if (candidateHeight > tasksView.height) {
|
||||||
|
return tasksView.height / window.windowHeight;
|
||||||
|
} else {
|
||||||
|
return tasksView.width / window.windowWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: Task {
|
||||||
|
id: task
|
||||||
|
property int curIndex: model.index
|
||||||
|
z: window.currentTaskIndex === curIndex ? 1 : 0
|
||||||
|
width: tasksView.width
|
||||||
|
height: tasksView.height
|
||||||
|
|
||||||
|
// account for header offset (center the preview)
|
||||||
|
y: -tasksView.taskHeaderHeight / 2
|
||||||
|
|
||||||
|
// scale gesture
|
||||||
|
scale: {
|
||||||
|
let maxScale = 1 / tasksView.scalingFactor;
|
||||||
|
let subtract = (maxScale - 1) * (window.yOffset / window.targetYOffsetDist);
|
||||||
|
let finalScale = Math.max(0, Math.min(maxScale, maxScale - subtract));
|
||||||
|
|
||||||
|
if ((window.wasInActiveTask || !taskSwitcher.currentlyDragging) && window.currentTaskIndex === task.curIndex) {
|
||||||
|
return finalScale;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ensure that window previews are exactly to the scale of the device screen
|
||||||
|
previewWidth: tasksView.scalingFactor * window.windowWidth
|
||||||
|
previewHeight: tasksView.scalingFactor * window.windowHeight
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue