on xenial help sign in
Fixed up reveal states. Removed pin/unpin states from indicators
commitf08940776719208cbd9975848f56c95ff539c105 authorNick Dedekind <nicholas.dedekind@gmail.com> dateWed 17 Jul 2013, 16:38 (13 years ago) parentffca0a3
3 files changed+22−53
Panel/IndicatorRow.qml+3−12 Panel/Indicators.qml+17−39 tests/qmltests/Panel/tst_IndicatorRow.qml+2−2
Panel/IndicatorRow.qml+3−12
@@ -63,20 +63,11 @@ Item {
6363 widgetSource: model.widgetSource
6464
6565 indicatorProperties : model.indicatorProperties
66− highlighted: indicatorRow.state == "reveal" || indicatorRow.state == "locked" || indicatorRow.state == "commit" ? ownIndex == indicatorRow.currentItemIndex : false
67− dimmed: { //See FIXME in Indicators regarding the "states" change
68− if (indicatorRow.state == "initial" || indicatorRow.state == "") {
69− return false;
70− } else if (indicatorRow.state == "hint") {
71− return true
72− } else {
73− return ownIndex != indicatorRow.currentItemIndex
74− }
75− }
66+ highlighted: indicatorRow.state != "initial" ? ownIndex == indicatorRow.currentItemIndex : false
67+ dimmed: indicatorRow.state != "initial" ? ownIndex != indicatorRow.currentItemIndex : false
7668 height: indicatorRow.height
7769 y: {
78− //FIXME: all indicators will be initial for now.
79− if (!highlighted && (indicatorRow.state == "locked" || indicatorRow.state == "commit")) {
70+ if (!highlighted && (indicatorRow.state == "locked" || indicatorRow.state == "commit")) {
8071 return -indicatorRow.height
8172 } else {
8273 return 0
Panel/Indicators.qml+17−39
@@ -58,7 +58,7 @@ Showable {
5858 if (!showAnimation.running && !hideAnimation.running) {
5959 if (revealProgress == 0) {
6060 indicators.state = "initial"
61− } else if (revealProgress <= hintValue && indicators.state == "reveal") {
61+ } else if (revealProgress <= hintValue) {
6262 indicators.state = "hint";
6363 } else if (revealProgress > hintValue && revealProgress < lockThreshold) {
6464 indicators.state = "reveal";
@@ -123,6 +123,8 @@ Showable {
123123 if ((!useBuffer || (useBuffer && bufferExceeded)) || indicatorRow.currentItem < 0 || indicatorRow.currentItem == null) {
124124 indicatorRow.currentItem = currentItem;
125125 }
126+ } else if (!currentItem) {
127+ indicatorRow.setDefaultItem();
126128 }
127129 }
128130
@@ -239,10 +241,7 @@ Showable {
239241 onRunningChanged: {
240242 if (hideAnimation.running) {
241243 indicators.state = "initial"
242− } else {
243− if (state == "initial") {
244− indicatorRow.setDefaultItem()
245− }
244+ indicatorRow.currentItem = null;
246245 }
247246 }
248247 }
@@ -264,18 +263,6 @@ Showable {
264263 }
265264 }
266265
267− // We start with pinned states. (default pinnedMode: true)
268− states: pinnedModeStates
269− // because of dynamic assignment of states, we need to assign state after completion.
270− Component.onCompleted: state = "initial"
271−
272− // changing states will reset state to "".
273− onPinnedModeChanged: {
274− var last_state = state;
275− states = (pinnedMode) ? pinnedModeStates : offScreenModeStates;
276− state = last_state;
277− }
278−
279266 property var dragHandle: showDragHandle.dragging ? showDragHandle : hideDragHandle
280267 DragHandle {
281268 id: showDragHandle
@@ -311,18 +298,27 @@ Showable {
311298 distanceThreshold: 0
312299 }
313300
314− property list<State> offScreenModeStates: [
301+ states: [
315302 State {
316303 name: "initial"
317304 },
318305 State {
319306 name: "hint"
320− PropertyChanges { target: indicatorRow; y: panelHeight }
307+ PropertyChanges {
308+ target: indicatorRow;
309+ y: pinnedMode ? 0 : panelHeight
310+ }
311+ StateChangeScript {
312+ script: {
313+ if (dragHandle) {
314+ calculateCurrentItem(dragHandle.touchX, false);
315+ }
316+ }
317+ }
321318 },
322319 State {
323320 name: "reveal"
324321 extend: "hint"
325− StateChangeScript { script: calculateCurrentItem(dragHandle.touchX, false); }
326322 },
327323 State {
328324 name: "locked"
@@ -333,25 +329,7 @@ Showable {
333329 extend: "hint"
334330 }
335331 ]
336−
337− property list<State> pinnedModeStates: [
338− State {
339− name: "initial"
340− },
341− State {
342− name: "hint"
343− },
344− State {
345− name: "reveal"
346− StateChangeScript { script: calculateCurrentItem(dragHandle.touchX, false); }
347− },
348− State {
349− name: "locked"
350− },
351− State {
352− name: "commit"
353− }
354− ]
332+ state: "initial"
355333
356334 transitions: [
357335 Transition {
tests/qmltests/Panel/tst_IndicatorRow.qml+2−2
@@ -121,7 +121,7 @@ Item {
121121 indicatorRow.state = "hint";
122122 indicatorRow.setItem(0);
123123
124− compare(indicatorRow.currentItem.highlighted, false, "Indicator should not highlight when in hint state");
124+ compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in hint state");
125125 compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in hint state");
126126 compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in hint state");
127127 compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in hint state");
@@ -195,7 +195,7 @@ Item {
195195 indicatorRow.state = "hint";
196196 indicatorRow.setItem(0);
197197
198− compare(get_indicator_item_at(0).dimmed, true, "Current indicator should dim when in hint state");
198+ compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in hint state");
199199 compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in hint state");
200200 compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in hint state");
201201 compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in hint state");