@@ -0,0 +1,162 @@
2+ * Copyright (C) 2014 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/>.
16+ * Authors: Michael Zanetti <michael.zanetti@canonical.com>
20+import Ubuntu.Components 1.1
21+import Unity.Application 0.1
29+ target: ApplicationManager
30+ onApplicationAdded: {
31+ // Initial placement to avoid having the window decoration behind the panel
32+ appRepeater.itemAt(ApplicationManager.count-1).y = units.gu(3)
33+ ApplicationManager.requestFocusApplication(ApplicationManager.get(ApplicationManager.count-1).appId)
37+ var appIndex = priv.indexOf(appId);
38+ var appDelegate = appRepeater.itemAt(appIndex);
39+ if (appDelegate.state === "minimized") {
40+ appDelegate.state = "normal"
42+ ApplicationManager.focusApplication(appId);
48+ function indexOf(appId) {
49+ for (var i = 0; i < ApplicationManager.count; i++) {
50+ if (ApplicationManager.get(i).appId == appId) {
60+ model: ApplicationManager
66+ z: ApplicationManager.count - index
74+ PropertyChanges { target: appDelegate; x: 0; y: 0; width: root.width; height: root.height }
78+ PropertyChanges { target: appDelegate; x: -appDelegate.width / 2; scale: units.gu(5) / appDelegate.width; opacity: 0 }
83+ PropertyAnimation { target: appDelegate; properties: "x,y,opacity,width,height,scale" }
90+ margins: -units.gu(2)
92+ source: "graphics/dropshadow2gu.sci"
94+ Behavior on opacity { UbuntuNumberAnimation {} }
99+ anchors.margins: -units.gu(0.5)
101+ property bool resizeWidth: false
102+ property bool resizeHeight: false
104+ property int startX: 0
105+ property int startWidth: 0
106+ property int startY: 0
107+ property int startHeight: 0
110+ ApplicationManager.requestFocusApplication(model.appId)
111+ if (mouseX > width - units.gu(1)) {
114+ startWidth = appDelegate.width;
116+ if (mouseY > height - units.gu(1)) {
117+ resizeHeight = true;
119+ startHeight = appDelegate.height;
121+ if (!resizeHeight && !resizeWidth) {
122+ drag.target = appDelegate;
128+ appDelegate.width = startWidth + (mouseX - startX)
133+ appDelegate.height = startHeight + (mouseY - startY)
138+ resizeWidth = false;
139+ resizeHeight = false;
140+ drag.target = undefined;
145+ anchors { left: parent.left; top: parent.top; right: parent.right }
148+ onClose: ApplicationManager.stopApplication(model.appId)
149+ onMaximize: appDelegate.state = (appDelegate.state == "maximized" ? "normal" : "maximized")
150+ onMinimize: appDelegate.state = "minimized"
151+ active: ApplicationManager.focusedApplicationId == model.appId
155+ anchors.fill: parent
156+ anchors.topMargin: units.gu(3)
157+ application: ApplicationManager.get(index)
158+ interactive: index == 0