~tiagosh/unity-2d/fix-arrow-warning

« back to all changes in this revision

Viewing changes to shell/Shell.qml

  • Committer: Tarmac
  • Author(s): Gerry Boland, Michał Sawicz
  • Date: 2012-02-28 11:30:52 UTC
  • mfrom: (915.1.61 hud-qml)
  • Revision ID: tarmac-20120228113052-ko3v4z076cq2aanr
Add HUD to Unity 2D

Known issue:
- on switching between Dash & Hud (tap Alt, then Super, then Alt...) blurred background image will contain Hud/Dash.. Fixes: https://bugs.launchpad.net/bugs/942045. Approved by Albert Astals Cid.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
    Accessible.name: "shell"
36
36
 
 
37
    property alias hudActive: hudLoader.active
 
38
 
37
39
    GestureHandler {
38
40
        id: gestureHandler
39
41
    }
75
77
        Binding {
76
78
            target: launcherLoader.item
77
79
            property: "showMenus"
78
 
            value: !dashLoader.item.active
 
80
            value: !dashLoader.item.active && !hudLoader.item.active
79
81
        }
80
82
 
81
83
        Behavior on x { NumberAnimation { id: launcherLoaderXAnimation; duration: 125 } }
83
85
        Connections {
84
86
            target: declarativeView
85
87
            onDashActiveChanged: {
86
 
                if (declarativeView.dashActive) launcherLoader.visibilityController.beginForceVisible("dash")
87
 
                else {
 
88
                if (declarativeView.dashActive) {
 
89
                    if (hudLoader.item.active) hudLoader.item.active = false
 
90
                    launcherLoader.visibilityController.beginForceVisible("dash")
 
91
                } else {
88
92
                    launcherLoader.visibilityController.endForceVisible("dash")
89
93
                    if (dashLoader.status == Loader.Ready) dashLoader.item.deactivateAllLenses()
90
94
                }
120
124
        }
121
125
    }
122
126
 
 
127
    Loader {
 
128
        id: hudLoader
 
129
        property bool animating: item.animating
 
130
        property bool active: item.active
 
131
        onActiveChanged: item.active = active
 
132
 
 
133
        source: "hud/Hud.qml"
 
134
        anchors.top: parent.top
 
135
        x: Utils.isLeftToRight() ? 0 : shell.width - width
 
136
        onLoaded: item.focus = true
 
137
        visible: item.active
 
138
        focus: item.active
 
139
        width: Math.min(shell.width, 1061)
 
140
    }
 
141
 
 
142
    Connections {
 
143
        target: hudLoader.item
 
144
        onActiveChanged: {
 
145
            if (hudLoader.item.active) {
 
146
                if (dashLoader.item.active) dashLoader.item.active = false
 
147
                launcherLoader.visibilityController.beginForceHidden("hud")
 
148
            } else {
 
149
                launcherLoader.visibilityController.endForceHidden("hud")
 
150
            }
 
151
        }
 
152
    }
 
153
 
123
154
    Connections {
124
155
        target: declarativeView
125
156
        onLauncherFocusRequested: {
127
158
            launcherLoader.item.focusBFB()
128
159
        }
129
160
        onFocusChanged: {
 
161
            if (!declarativeView.focus && hudLoader.item.active) hudLoader.item.active = false
 
162
 
130
163
            /* FIXME: The launcher is forceVisible while it has activeFocus. However even though
131
164
               the documentation says that setting focus=false will make an item lose activeFocus
132
165
               if it has it, this doesn't happen with FocusScopes (and Launcher is a FocusScope).
170
203
                enabled: declarativeView.dashMode == ShellDeclarativeView.DesktopMode
171
204
            }
172
205
        }
 
206
 
 
207
        InputShapeRectangle {
 
208
            id: hudInputShape
 
209
            enabled: hudLoader.status == Loader.Ready && hudLoader.item.active
 
210
 
 
211
            InputShapeMask {
 
212
                source: "shell/common/artwork/desktop_dash_background_no_transparency.png"
 
213
                color: "red"
 
214
                position: Qt.point(hudLoader.width - 50, hudLoader.height - 49)
 
215
            }
 
216
        }
173
217
    }
174
218
 
175
219
    Binding {
196
240
        when: !launcherLoaderXAnimation.running
197
241
    }
198
242
 
 
243
    Binding {
 
244
        target: hudInputShape
 
245
        property: "rectangle"
 
246
        value: {
 
247
            if (desktop.isCompositingManagerRunning) {
 
248
                return Qt.rect(hudLoader.x, hudLoader.y, hudLoader.width, hudLoader.height)
 
249
            } else {
 
250
                return Qt.rect(hudLoader.x, hudLoader.y, hudLoader.width - 7, hudLoader.height - 9)
 
251
            }
 
252
        }
 
253
        when: !hudLoader.animating
 
254
    }
 
255
 
199
256
    StrutManager {
200
257
        id: strutManager
201
258
        edge: Unity2dPanel.LeftEdge