2 * Copyright (C) 2017 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18import QtMir.Application 0.1
19import Lomiri.Components 1.3
25 property int itemIndex: 0
26 property int nextInStack: 0
27 property int sceneWidth: 0
28 property int sideStageWidth: 0
29 property int sideStageHandleWidth: 0
30 property int sideStageX: sceneWidth
31 property bool animateX: false
33 property int stage: ApplicationInfoInterface.MainStage
34 property var thisDelegate: null
35 property var mainStageDelegate: null
36 property var sideStageDelegate: null
38 property int animationDuration: LomiriAnimation.FastDuration
42 // We need to shuffle z ordering a bit in order to keep side stage apps above main stage apps.
43 // We don't want to really reorder them in the model because that allows us to keep track
44 // of the last focused order.
45 readonly property int itemZ: {
46 // only shuffle when we've got a main and side stage
47 if (!sideStageDelegate) return itemIndex;
49 // don't shuffle indexes greater than "actives or next"
50 if (itemIndex > 2) return itemIndex;
52 if (thisDelegate == mainStageDelegate) {
53 // Active main stage always at 0
57 if (nextInStack > 0) {
58 var stageOfNextInStack = appRepeater.itemAt(nextInStack).stage;
60 if (itemIndex === nextInStack) {
61 // this is the next app in stack.
63 if (stage === ApplicationInfoInterface.SideStage) {
64 // if the next app in stack is a sidestage app, it must order on top of other side stage app
65 return Math.min(2, topLevelSurfaceList.count-1);
69 if (stageOfNextInStack === ApplicationInfoInterface.SideStage) {
70 // if the next app in stack is a sidestage app, it must order on top of other side stage app
73 return Math.min(2, topLevelSurfaceList.count-1);
75 return Math.min(index+1, topLevelSurfaceList.count-1);
80 if (mainStageDelegate == thisDelegate) {
83 if (sideStageDelegate == thisDelegate) {
88 Behavior on itemX { enabled: root.animateX; LomiriNumberAnimation {duration: animationDuration} }
90 readonly property int itemWidth: stage == ApplicationInfoInterface.MainStage ?
91 sideStageDelegate != null ? sideStageX - sideStageHandleWidth : sceneWidth :
92 stage == ApplicationInfoInterface.SideStage ? sideStageWidth : sceneWidth