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/>.
18 import Unity.Application 0.1
19 import Ubuntu.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 sideStageX: sceneWidth
30 property bool animateX: false
32 property int stage: ApplicationInfoInterface.MainStage
33 property var thisDelegate: null
34 property var mainStageDelegate: null
35 property var sideStageDelegate: null
37 property int animationDuration: UbuntuAnimation.FastDuration
41 // We need to shuffle z ordering a bit in order to keep side stage apps above main stage apps.
42 // We don't want to really reorder them in the model because that allows us to keep track
43 // of the last focused order.
44 readonly property int itemZ: {
45 // only shuffle when we've got a main and side stage
46 if (!sideStageDelegate) return itemIndex;
48 // don't shuffle indexes greater than "actives or next"
49 if (itemIndex > 2) return itemIndex;
51 if (thisDelegate == mainStageDelegate) {
52 // Active main stage always at 0
56 if (nextInStack > 0) {
57 var stageOfNextInStack = appRepeater.itemAt(nextInStack).stage;
59 if (itemIndex === nextInStack) {
60 // this is the next app in stack.
62 if (stage === ApplicationInfoInterface.SideStage) {
63 // if the next app in stack is a sidestage app, it must order on top of other side stage app
64 return Math.min(2, topLevelSurfaceList.count-1);
68 if (stageOfNextInStack === ApplicationInfoInterface.SideStage) {
69 // if the next app in stack is a sidestage app, it must order on top of other side stage app
72 return Math.min(2, topLevelSurfaceList.count-1);
74 return Math.min(index+1, topLevelSurfaceList.count-1);
79 if (mainStageDelegate == thisDelegate) {
82 if (sideStageDelegate == thisDelegate) {
87 Behavior on itemX { enabled: root.animateX; UbuntuNumberAnimation {duration: animationDuration} }
89 readonly property int itemWidth: stage == ApplicationInfoInterface.MainStage ?
90 sideStageDelegate != null ? sideStageX : sceneWidth :
91 stage == ApplicationInfoInterface.SideStage ? sideStageWidth : sceneWidth