Merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-relative-radius into lp:ubuntu-ui-toolkit/staging

Proposed by Loïc Molinari
Status: Superseded
Proposed branch: lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-relative-radius
Merge into: lp:ubuntu-ui-toolkit/staging
Prerequisite: lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-big-radius
Diff against target: 247 lines (+72/-27)
6 files modified
components.api (+15/-14)
src/Ubuntu/Components/plugin/plugin.cpp (+1/-0)
src/Ubuntu/Components/plugin/ucubuntushape.cpp (+37/-8)
src/Ubuntu/Components/plugin/ucubuntushape.h (+7/-1)
tests/resources/ubuntushape/UbuntuShapeOverlayTest.qml (+6/-2)
tests/resources/ubuntushape/UbuntuShapeTest.qml (+6/-2)
To merge this branch: bzr merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-relative-radius
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Zsombor Egri Approve
Review via email: mp+265514@code.launchpad.net

This proposal has been superseded by a proposal from 2015-07-24.

Commit message

[UbuntuShape] Added relative radius support.

Description of the change

[UbuntuShape] Added relative radius support.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zsombor Egri (zsombi) wrote :

Cool stuff, nothing to complain to!!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1576. By Loïc Molinari

Merged lp:ubuntu-ui-toolkit/staging.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components.api'
2--- components.api 2015-07-24 13:31:03 +0000
3+++ components.api 2015-07-24 17:59:55 +0000
4@@ -1292,26 +1292,27 @@
5 readonly property PullToRefresh pullToRefresh
6 Ubuntu.Components.UbuntuNumberAnimation 1.0 0.1: PropertyAnimation
7 Ubuntu.Components.UbuntuNumberAnimation 1.3: PropertyAnimation
8-Ubuntu.Components.UbuntuShape 1.2 1.0 0.1 Shape 1.0 0.1: Item
9- property Aspect aspect 1.2
10- property color backgroundColor 1.2
11- property BackgroundMode backgroundMode 1.2
12+Ubuntu.Components.UbuntuShape 1.3 1.2 1.0 0.1 Shape 1.0 0.1: Item
13+ property Aspect aspect 1.3
14+ property color backgroundColor 1.3
15+ property BackgroundMode backgroundMode 1.3
16 property string borderSource
17 property color color
18 property color gradientColor
19 property HAlignment horizontalAlignment
20 property var image
21 property string radius
22- property color secondaryBackgroundColor 1.2
23- property var source 1.2
24- property FillMode sourceFillMode 1.2
25- property HAlignment sourceHorizontalAlignment 1.2
26- property WrapMode sourceHorizontalWrapMode 1.2
27- property double sourceOpacity 1.2
28- property vector2d sourceScale 1.2
29- property vector2d sourceTranslation 1.2
30- property VAlignment sourceVerticalAlignment 1.2
31- property WrapMode sourceVerticalWrapMode 1.2
32+ property double relativeRadius 1.3
33+ property color secondaryBackgroundColor 1.3
34+ property var source 1.3
35+ property FillMode sourceFillMode 1.3
36+ property HAlignment sourceHorizontalAlignment 1.3
37+ property WrapMode sourceHorizontalWrapMode 1.3
38+ property double sourceOpacity 1.3
39+ property vector2d sourceScale 1.3
40+ property vector2d sourceTranslation 1.3
41+ property VAlignment sourceVerticalAlignment 1.3
42+ property WrapMode sourceVerticalWrapMode 1.3
43 property bool stretched
44 property VAlignment verticalAlignment
45 Ubuntu.Components.UbuntuShape.Aspect: Enum
46
47=== modified file 'src/Ubuntu/Components/plugin/plugin.cpp'
48--- src/Ubuntu/Components/plugin/plugin.cpp 2015-07-19 17:44:46 +0000
49+++ src/Ubuntu/Components/plugin/plugin.cpp 2015-07-24 17:59:55 +0000
50@@ -215,6 +215,7 @@
51 qmlRegisterType<UCStyledItemBase, 2>(uri, 1, 3, "StyledItem");
52 qmlRegisterCustomType<UCStyleHints>(uri, 1, 3, "StyleHints", new UCStyleHintsParser);
53 qmlRegisterType<UCAction, 1>(uri, 1, 3, "Action");
54+ qmlRegisterType<UCUbuntuShape, 2>(uri, 1, 3, "UbuntuShape");
55 }
56
57 void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
58
59=== modified file 'src/Ubuntu/Components/plugin/ucubuntushape.cpp'
60--- src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-07-24 10:37:47 +0000
61+++ src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-07-24 17:59:55 +0000
62@@ -294,6 +294,7 @@
63 , m_sourceTranslation(0.0f, 0.0f)
64 , m_sourceTransform(1.0f, 1.0f, 0.0f, 0.0f)
65 , m_radius(Small)
66+ , m_relativeRadius(0)
67 , m_aspect(Inset)
68 , m_imageHorizontalAlignment(AlignHCenter)
69 , m_imageVerticalAlignment(AlignVCenter)
70@@ -330,6 +331,8 @@
71
72 This property defines the corner radius. Three fixed values are supported: \c "small",
73 \c "medium" and \c "large". The default value is \c "small".
74+
75+ \note Setting a non-zero \l relativeRadius value disables this property temporarily.
76 */
77 void UCUbuntuShape::setRadius(const QString& radius)
78 {
79@@ -372,6 +375,26 @@
80 }
81 }
82
83+/*! \qmlproperty real UbuntuShape::relativeRadius
84+ \since Ubuntu.Components 1.3
85+
86+ This property defines a radius relative to the size of the UbuntuShape. It is specified as a
87+ number between 0.0 (0%) and 0.5 (50%) corresponding to the proportion of the radius with regards
88+ to the smallest side (divided by 2 since a side has 2 angles). The default value is 0.0.
89+
90+ \note Setting a non-zero value takes over the \l radius property.
91+*/
92+void UCUbuntuShape::setRelativeRadius(qreal relativeRadius)
93+{
94+ // m_relativeRadius is on 6 bits, increasing the higher bound might require higher precision.
95+ const quint8 relativeRadiusPacked = qRound(qBound(0.0, relativeRadius, 0.5) * 100.0);
96+ if (m_relativeRadius != relativeRadiusPacked) {
97+ m_relativeRadius = relativeRadiusPacked;
98+ update();
99+ Q_EMIT relativeRadiusChanged();
100+ }
101+}
102+
103 // Deprecation layer.
104 void UCUbuntuShape::dropImageSupport()
105 {
106@@ -1148,14 +1171,20 @@
107 m_sourceTextureProvider = provider;
108 }
109
110- // Get the radius size. When the item width and/or height is less than 2 * radius, the size is
111- // scaled down accordingly. The shape was using a fixed image for the corner before switching to
112- // a distance field, since the corner wasn't taking the whole image (ending at ~80%) we need
113- // to take that into account when the size is scaled down.
114- float radius = UCUnits::instance().gridUnit() * radiusGuMap[m_radius];
115- const float scaledDownRadius = qMin(itemSize.width(), itemSize.height()) * 0.5f * 0.8f;
116- if (radius > scaledDownRadius) {
117- radius = scaledDownRadius;
118+ // Get the radius size.
119+ float radius;
120+ if (m_relativeRadius == 0) {
121+ // When the item width and/or height is less than 2 * radius, the size is scaled down
122+ // accordingly. The shape was using a fixed image for the corner before switching to a
123+ // distance field, since the corner wasn't taking the whole image (ending at ~80%) we need
124+ // to take that into account when the size is scaled down.
125+ radius = UCUnits::instance().gridUnit() * radiusGuMap[m_radius];
126+ const float scaledDownRadius = qMin(itemSize.width(), itemSize.height()) * 0.5f * 0.8f;
127+ if (radius > scaledDownRadius) {
128+ radius = scaledDownRadius;
129+ }
130+ } else {
131+ radius = qMin(itemSize.width(), itemSize.height()) * 0.5f * (m_relativeRadius * 0.01f);
132 }
133
134 updateMaterial(node, radius, shapeTexture, sourceTexture && m_sourceOpacity);
135
136=== modified file 'src/Ubuntu/Components/plugin/ucubuntushape.h'
137--- src/Ubuntu/Components/plugin/ucubuntushape.h 2015-07-16 11:27:07 +0000
138+++ src/Ubuntu/Components/plugin/ucubuntushape.h 2015-07-24 17:59:55 +0000
139@@ -126,6 +126,8 @@
140 Q_ENUMS(Aspect)
141 Q_PROPERTY(QString radius READ radius WRITE setRadius NOTIFY radiusChanged)
142 Q_PROPERTY(Aspect aspect READ aspect WRITE setAspect NOTIFY aspectChanged REVISION 1)
143+ Q_PROPERTY(qreal relativeRadius READ relativeRadius WRITE setRelativeRadius
144+ NOTIFY relativeRadiusChanged REVISION 2)
145
146 // Source properties.
147 Q_ENUMS(FillMode)
148@@ -188,6 +190,8 @@
149 void setRadius(const QString& radius);
150 Aspect aspect() const { return (m_flags & AspectSet) ? static_cast<Aspect>(m_aspect) : Flat; }
151 void setAspect(Aspect aspect);
152+ qreal relativeRadius() const { return m_relativeRadius * 0.01; }
153+ void setRelativeRadius(qreal relativeRadius);
154
155 QVariant source() const {
156 return QVariant::fromValue((m_flags & SourceApiSet) ? m_source : NULL); }
157@@ -253,6 +257,7 @@
158 Q_SIGNALS:
159 void radiusChanged();
160 Q_REVISION(1) void aspectChanged();
161+ Q_REVISION(2) void relativeRadiusChanged();
162
163 Q_REVISION(1) void sourceChanged();
164 Q_REVISION(1) void sourceOpacityChanged();
165@@ -325,6 +330,7 @@
166 QVector2D m_sourceTranslation;
167 QVector4D m_sourceTransform;
168 Radius m_radius : 2;
169+ quint8 m_relativeRadius : 6;
170 quint8 m_aspect : 2;
171 HAlignment m_imageHorizontalAlignment : 2;
172 VAlignment m_imageVerticalAlignment : 2;
173@@ -334,7 +340,7 @@
174 FillMode m_sourceFillMode : 2;
175 WrapMode m_sourceHorizontalWrapMode : 1;
176 WrapMode m_sourceVerticalWrapMode : 1;
177- quint8 __explicit_padding : 7;
178+ quint8 __explicit_padding : 1;
179 quint8 m_sourceOpacity;
180 quint8 m_flags;
181
182
183=== modified file 'tests/resources/ubuntushape/UbuntuShapeOverlayTest.qml'
184--- tests/resources/ubuntushape/UbuntuShapeOverlayTest.qml 2015-07-16 11:27:07 +0000
185+++ tests/resources/ubuntushape/UbuntuShapeOverlayTest.qml 2015-07-24 17:59:55 +0000
186@@ -15,7 +15,7 @@
187 */
188
189 import QtQuick 2.0
190-import Ubuntu.Components 1.2
191+import Ubuntu.Components 1.3
192
193 Item {
194 id: root
195@@ -62,7 +62,8 @@
196 "Background colors (a/z): " + shape.backgroundColor + ", " + shape.secondaryBackgroundColor + "\n" +
197 "Background mode (e): " + root.backgroundModeTable[shape.backgroundMode] + "\n\n" +
198 "Radius (r): " + "\"" + shape.radius + "\"\n" +
199- "Aspect (t): " + root.aspectTable[shape.aspect] + "\n\n" +
200+ "Aspect (t): " + root.aspectTable[shape.aspect] + "\n" +
201+ "relativeRadius (y): " + shape.relativeRadius.toFixed(2) + "\n\n" +
202 "Source (o): " + shape.source + "\n" +
203 "Source opacity (p): " + shape.sourceOpacity.toFixed(2) + "\n" +
204 "Source fill (q): " + root.sourceFillModeTable[shape.sourceFillMode] + "\n" +
205@@ -225,6 +226,9 @@
206 ((shape.radius == "small") ? "medium" : "large");
207 } else if (event.key == Qt.Key_T) {
208 shape.aspect = (shape.aspect + 1) % 2;
209+ } else if (event.key == Qt.Key_Y) {
210+ shape.relativeRadius = Math.max(0.0, Math.min(
211+ 1.0, shape.relativeRadius + ((event.modifiers & shift) ? 0.01 : -0.01)));
212
213 // Source.
214 } else if (event.key == Qt.Key_O) {
215
216=== modified file 'tests/resources/ubuntushape/UbuntuShapeTest.qml'
217--- tests/resources/ubuntushape/UbuntuShapeTest.qml 2015-07-16 11:27:07 +0000
218+++ tests/resources/ubuntushape/UbuntuShapeTest.qml 2015-07-24 17:59:55 +0000
219@@ -15,7 +15,7 @@
220 */
221
222 import QtQuick 2.0
223-import Ubuntu.Components 1.2
224+import Ubuntu.Components 1.3
225
226 Item {
227 id: root
228@@ -62,7 +62,8 @@
229 "Background colors (a/z): " + shape.backgroundColor + ", " + shape.secondaryBackgroundColor + "\n" +
230 "Background mode (e): " + root.backgroundModeTable[shape.backgroundMode] + "\n\n" +
231 "Radius (r): " + "\"" + shape.radius + "\"\n" +
232- "Aspect (t): " + root.aspectTable[shape.aspect] + "\n\n" +
233+ "Aspect (t): " + root.aspectTable[shape.aspect] + "\n" +
234+ "relativeRadius (y): " + shape.relativeRadius.toFixed(2) + "\n\n" +
235 "Source (o): " + shape.source + "\n" +
236 "Source opacity (p): " + shape.sourceOpacity.toFixed(2) + "\n" +
237 "Source fill (q): " + root.sourceFillModeTable[shape.sourceFillMode] + "\n" +
238@@ -222,6 +223,9 @@
239 ((shape.radius == "small") ? "medium" : "large");
240 } else if (event.key == Qt.Key_T) {
241 shape.aspect = (shape.aspect + 1) % 2;
242+ } else if (event.key == Qt.Key_Y) {
243+ shape.relativeRadius = Math.max(0.0, Math.min(
244+ 1.0, shape.relativeRadius + ((event.modifiers & shift) ? 0.01 : -0.01)));
245
246 // Source.
247 } else if (event.key == Qt.Key_O) {

Subscribers

People subscribed via source and target branches