on xenial help sign in
Fixed tests & regressions
commit2274059c305a471af733d3612d0e1c9d6d8d954b authorNick Dedekind <nicholas.dedekind@gmail.com> dateWed 18 Dec 2013, 12:44 (13 years ago) parent2700f8b
6 files changed+42−25
Panel/IndicatorItem.qml−1 Panel/IndicatorRow.qml+15−8 Panel/Indicators.qml+8 Panel/Panel.qml+1−1 tests/qmltests/Panel/tst_IndicatorItem.qml−11 tests/qmltests/Panel/tst_IndicatorRow.qml+18−4
Panel/IndicatorItem.qml−1
@@ -23,7 +23,6 @@ Item {
2323 id: indicatorItem
2424
2525 property alias widgetSource: loader.source
26− property bool highlighted: false
2726 property bool dimmed: false
2827 property var indicatorProperties: undefined
2928 property bool indicatorVisible: loader.item ? loader.item.enabled : false
Panel/IndicatorRow.qml+15−8
@@ -30,6 +30,7 @@ Item {
3030 property int overFlowWidth: width
3131 property bool showAll: false
3232 property real currentItemOffset: 0.0
33+ property real unitProgress: 0.0
3334
3435 width: units.gu(40)
3536 height: units.gu(3)
@@ -80,23 +81,23 @@ Item {
8081 height: indicatorRow.height
8182 width: indicatorItem.width
8283 visible: indicatorItem.indicatorVisible
83− opacity: 1.0
84+ opacity: 1.0 * opacityMultiplier
8485 y: 0
8586 state: "standard"
8687
8788 property int ownIndex: index
88− property alias highlighted: indicatorItem.highlighted
89− property alias dimmed: indicatorItem.dimmed
89+ property bool highlighted: indicatorRow.state != "initial" ? ownIndex == indicatorRow.currentItemIndex : false
90+ property bool dimmed: indicatorRow.state != "initial" ? ownIndex != indicatorRow.currentItemIndex : false
9091
91− property bool hidden: !showAll && !indicatorItem.highlighted && (indicatorRow.state == "locked" || indicatorRow.state == "commit")
92+ property bool hidden: !showAll && !highlighted && (indicatorRow.state == "locked" || indicatorRow.state == "commit")
9293 property bool overflow: row.width - itemWrapper.x > overFlowWidth
94+ property real opacityMultiplier: highlighted ? 1 : (1 -indicatorRow.unitProgress)
9395
9496 IndicatorItem {
9597 id: indicatorItem
9698 height: parent.height
9799
98− highlighted: indicatorRow.state != "initial" ? itemWrapper.ownIndex == indicatorRow.currentItemIndex : false
99− dimmed: indicatorRow.state != "initial" ? itemWrapper.ownIndex != indicatorRow.currentItemIndex : false
100+ dimmed: itemWrapper.dimmed
100101
101102 widgetSource: model.widgetSource
102103 indicatorProperties : model.indicatorProperties
@@ -166,7 +167,13 @@ Item {
166167 return 0.0;
167168 }
168169
169− Behavior on width { UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration } }
170− Behavior on x { UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration } }
170+ Behavior on width {
171+ enabled: unitProgress > 0;
172+ UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
173+ }
174+ Behavior on x {
175+ enabled: unitProgress > 0;
176+ UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
177+ }
171178 }
172179}
Panel/Indicators.qml+8
@@ -39,6 +39,7 @@ Showable {
3939 property bool contentEnabled: true
4040 property bool initalizeItem: true
4141 readonly property alias content: menuContent
42+ property real unitProgress: 0.0
4243
4344 // TODO: Perhaps we need a animation standard for showing/hiding? Each showable seems to
4445 // use its own values. Need to ask design about this.
@@ -142,6 +143,9 @@ Showable {
142143 }
143144 }
144145 if ((!useBuffer || (useBuffer && bufferExceeded)) || indicatorRow.currentItemIndex < 0 || indicatorRow.currentItem == null) {
146+ if (initalizeItem) {
147+ indicatorRow.currentItem = null;
148+ }
145149 indicatorRow.currentItem = currentItem;
146150 }
147151
@@ -151,6 +155,9 @@ Showable {
151155 }
152156 indicatorRow.currentItemOffset = 1 - (distanceFromRightEdge * 2);
153157 } else {
158+ if (initalizeItem) {
159+ indicatorRow.currentItem = null;
160+ }
154161 indicatorRow.setDefaultItem();
155162 indicatorRow.currentItemOffset = 0;
156163 }
@@ -276,6 +283,7 @@ Showable {
276283 height: indicators.panelHeight
277284 indicatorsModel: indicatorsModel
278285 state: indicators.state
286+ unitProgress: indicators.unitProgress
279287
280288 Connections {
281289 property bool enableIndexChangeSignal: true
Panel/Panel.qml+1−1
@@ -107,7 +107,7 @@ Item {
107107 pinnedMode: !fullscreenMode
108108 overFlowWidth: search.state=="hidden" ? parent.width : parent.width - search.width
109109
110− property real unitProgress: (height - panelHeight) / (openedHeight - panelHeight)
110+ unitProgress: (height - panelHeight) / (openedHeight - panelHeight)
111111 }
112112
113113 PanelSeparatorLine {
tests/qmltests/Panel/tst_IndicatorItem.qml−11
@@ -41,17 +41,6 @@ Rectangle {
4141 tryCompareFunction(function(){return indicatorItem.opacity < 1.0}, true);
4242 }
4343
44− function test_highlight() {
45− var itemHighlight = findChild(indicatorItem, "highlight");
46− verify(itemHighlight != undefined);
47−
48− indicatorItem.highlighted = true;
49− compare(itemHighlight.visible, true, "Indicator should be highlighted");
50−
51− indicatorItem.highlighted = false;
52− compare(itemHighlight.visible, false, "Indicator should not be highlighted");
53− }
54−
5544 function test_empty() {
5645 compare(indicatorItem.indicatorVisible, false, "IndicatorItem should not be visible.");
5746 indicatorItem.widgetSource = "qrc:/tests/indciators/qml/fake_menu_widget1.qml";
tests/qmltests/Panel/tst_IndicatorRow.qml+18−4
@@ -34,6 +34,7 @@ Item {
3434 {
3535 indicatorRow.state = "initial";
3636 indicatorRow.currentItem = null;
37+ indicatorRow.unitProgress = 0.0;
3738 }
3839
3940 PanelBackground {
@@ -83,14 +84,13 @@ Item {
8384 function test_current_item_commit() {
8485 init_test();
8586
86− indicatorRow.setCurrentItem(1);
87+ indicatorRow.setCurrentItem(2);
8788 indicatorRow.state = "commit";
8889 tryCompare(get_indicator_item_at(0), "opacity", 0.0);
89− tryCompare(get_indicator_item_at(1), "opacity", 1.0);
90− tryCompare(get_indicator_item_at(2), "opacity", 0.0);
90+ tryCompare(get_indicator_item_at(1), "opacity", 0.0);
91+ tryCompare(get_indicator_item_at(2), "opacity", 1.0);
9192 tryCompare(get_indicator_item_at(3), "opacity", 0.0);
9293 tryCompare(get_indicator_item_at(4), "opacity", 0.0);
93−
9494 }
9595 }
9696
@@ -166,6 +166,20 @@ Item {
166166 compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in locked state");
167167 compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in locked state");
168168 }
169+
170+ function test_opacity() {
171+ init_test();
172+
173+ indicatorRow.state = "reveal";
174+ indicatorRow.unitProgress = 0.5;
175+ indicatorRow.setCurrentItem(2);
176+
177+ compare(get_indicator_item_at(0).opacity, 0.5, "Indicator should highlight when in locked state");
178+ compare(get_indicator_item_at(1).opacity, 0.5, "Other indicators should not highlight when in locked state");
179+ compare(get_indicator_item_at(2).opacity, 1.0, "Other indicators should not highlight when in locked state");
180+ compare(get_indicator_item_at(3).opacity, 0.5, "Other indicators should not highlight when in locked state");
181+ compare(get_indicator_item_at(4).opacity, 0.5, "Other indicators should not highlight when in locked state");
182+ }
169183 }
170184
171185 UT.UnityTestCase {