Merge lp:~nik90/component-store/add-radial-bottom-edge into lp:component-store

Proposed by Nekhelesh Ramananthan
Status: Merged
Merged at revision: 39
Proposed branch: lp:~nik90/component-store/add-radial-bottom-edge
Merge into: lp:component-store
Diff against target: 546 lines (+437/-1)
12 files modified
ComponentStore/RadialBottomEdge/RadialAction.qml (+8/-0)
ComponentStore/RadialBottomEdge/RadialBottomEdge.qml (+194/-0)
GallerySRC/RadialBottomEdgeWidget.qml (+56/-0)
GallerySRC/WidgetsModel.qml (+5/-0)
docs/_components/circleimage.rst (+2/-0)
docs/_components/emptystate.rst (+3/-1)
docs/_components/fastscroll.rst (+2/-0)
docs/_components/listitemwithactions.rst (+2/-0)
docs/_components/pagewithbottomedge.rst (+2/-0)
docs/_components/radialbottomedge.rst (+158/-0)
docs/index.rst (+1/-0)
docs/release.rst (+4/-0)
To merge this branch: bzr merge lp:~nik90/component-store/add-radial-bottom-edge
Reviewer Review Type Date Requested Status
Ubuntu Touch Community Dev Pending
Review via email: mp+241873@code.launchpad.net

Commit message

Added radial bottom edge component

Description of the change

Added radial bottom edge component

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'ComponentStore/RadialBottomEdge'
2=== added file 'ComponentStore/RadialBottomEdge/RadialAction.qml'
3--- ComponentStore/RadialBottomEdge/RadialAction.qml 1970-01-01 00:00:00 +0000
4+++ ComponentStore/RadialBottomEdge/RadialAction.qml 2014-11-15 15:00:12 +0000
5@@ -0,0 +1,8 @@
6+import QtQuick 2.0
7+import Ubuntu.Components 1.1
8+
9+Action {
10+ property string iconName: "add"
11+ property color iconColor: "Black"
12+ property color backgroundColor: "White"
13+}
14
15=== added file 'ComponentStore/RadialBottomEdge/RadialBottomEdge.qml'
16--- ComponentStore/RadialBottomEdge/RadialBottomEdge.qml 1970-01-01 00:00:00 +0000
17+++ ComponentStore/RadialBottomEdge/RadialBottomEdge.qml 2014-11-15 15:00:12 +0000
18@@ -0,0 +1,194 @@
19+import QtQuick 2.0
20+import Ubuntu.Components 1.1
21+
22+Item {
23+ id: bottomEdge
24+
25+ property int hintSize: units.gu(8)
26+ property color hintColor: Theme.palette.normal.overlay
27+ property string hintIconName: "view-grid-symbolic"
28+ property alias hintIconSource: hintIcon.source
29+ property color hintIconColor: UbuntuColors.coolGrey
30+ property bool bottomEdgeEnabled: true
31+
32+ property real expandedPosition: 0.6 * height
33+ property real collapsedPosition: height - hintSize/2
34+
35+ property list<RadialAction> actions
36+ property real actionButtonSize: units.gu(7)
37+ property real actionButtonDistance: 1.5* hintSize
38+
39+ anchors.fill: parent
40+
41+ Rectangle {
42+ id: bgVisual
43+
44+ z: 1
45+ color: "black"
46+ anchors.fill: parent
47+ opacity: 0.7 * ((bottomEdge.height - bottomEdgeHint.y) / bottomEdge.height)
48+ }
49+
50+ Rectangle {
51+ id: bottomEdgeHint
52+
53+ color: hintColor
54+ width: hintSize
55+ height: width
56+ radius: width/2
57+ visible: bottomEdgeEnabled
58+
59+ anchors.horizontalCenter: parent.horizontalCenter
60+ y: collapsedPosition
61+ z: parent.z + 1
62+
63+ Icon {
64+ id: hintIcon
65+ width: hintSize/4
66+ height: width
67+ name: hintIconName
68+ color: hintIconColor
69+ anchors {
70+ centerIn: parent
71+ verticalCenterOffset: width * ((bottomEdgeHint.y - expandedPosition)
72+ /(expandedPosition - collapsedPosition))
73+ }
74+ }
75+
76+ property real actionListDistance: -actionButtonDistance * ((bottomEdgeHint.y - collapsedPosition)
77+ /(collapsedPosition - expandedPosition))
78+
79+ Repeater {
80+ id: actionList
81+ model: actions
82+ delegate: Rectangle {
83+ id: actionDelegate
84+ readonly property real radAngle: (index % actionList.count * (360/actionList.count)) * Math.PI / 180
85+ property real distance: bottomEdgeHint.actionListDistance
86+ z: -1
87+ width: actionButtonSize
88+ height: width
89+ radius: width/2
90+ anchors.centerIn: parent
91+ color: modelData.backgroundColor
92+ transform: Translate {
93+ x: distance * Math.sin(radAngle)
94+ y: -distance * Math.cos(radAngle)
95+ }
96+
97+ Icon {
98+ anchors.centerIn: parent
99+ width: parent.width/2
100+ height: width
101+ name: modelData.iconName
102+ color: modelData.iconColor
103+ }
104+
105+ MouseArea {
106+ anchors.fill: parent
107+ onClicked: {
108+ bottomEdgeHint.state = "collapsed"
109+ modelData.triggered(null)
110+ }
111+ }
112+ }
113+ }
114+
115+ MouseArea {
116+ id: mouseArea
117+
118+ property real previousY: -1
119+ property string dragDirection: "None"
120+
121+ z: 1
122+ anchors.fill: parent
123+ visible: bottomEdgeEnabled
124+
125+ preventStealing: true
126+ drag {
127+ axis: Drag.YAxis
128+ target: bottomEdgeHint
129+ minimumY: expandedPosition
130+ maximumY: collapsedPosition
131+ }
132+
133+ onReleased: {
134+ if ((dragDirection === "BottomToTop") &&
135+ bottomEdgeHint.y < collapsedPosition) {
136+ bottomEdgeHint.state = "expanded"
137+ } else {
138+ if (bottomEdgeHint.state === "collapsed") {
139+ bottomEdgeHint.y = collapsedPosition
140+ }
141+ bottomEdgeHint.state = "collapsed"
142+ }
143+ previousY = -1
144+ dragDirection = "None"
145+ }
146+
147+ onClicked: {
148+ if (bottomEdgeHint.y === collapsedPosition)
149+ bottomEdgeHint.state = "expanded"
150+ else
151+ bottomEdgeHint.state = "collapsed"
152+ }
153+
154+ onPressed: {
155+ previousY = bottomEdgeHint.y
156+ }
157+
158+ onMouseYChanged: {
159+ var yOffset = previousY - bottomEdgeHint.y
160+ if (Math.abs(yOffset) <= units.gu(2)) {
161+ return
162+ }
163+ previousY = bottomEdgeHint.y
164+ dragDirection = yOffset > 0 ? "BottomToTop" : "TopToBottom"
165+ }
166+ }
167+
168+ state: "collapsed"
169+ states: [
170+ State {
171+ name: "collapsed"
172+ PropertyChanges {
173+ target: bottomEdgeHint
174+ y: collapsedPosition
175+ }
176+ },
177+ State {
178+ name: "expanded"
179+ PropertyChanges {
180+ target: bottomEdgeHint
181+ y: expandedPosition
182+ }
183+ },
184+
185+ State {
186+ name: "floating"
187+ when: mouseArea.drag.active
188+ }
189+ ]
190+
191+ transitions: [
192+ Transition {
193+ to: "expanded"
194+ SpringAnimation {
195+ target: bottomEdgeHint
196+ property: "y"
197+ spring: 2
198+ damping: 0.2
199+ }
200+ },
201+
202+ Transition {
203+ to: "collapsed"
204+ SmoothedAnimation {
205+ target: bottomEdgeHint
206+ property: "y"
207+ duration: UbuntuAnimation.BriskDuration
208+ }
209+ }
210+ ]
211+ }
212+}
213
214=== added file 'GallerySRC/RadialBottomEdgeWidget.qml'
215--- GallerySRC/RadialBottomEdgeWidget.qml 1970-01-01 00:00:00 +0000
216+++ GallerySRC/RadialBottomEdgeWidget.qml 2014-11-15 15:00:12 +0000
217@@ -0,0 +1,56 @@
218+import QtQuick 2.0
219+import Ubuntu.Components 1.1
220+import "../ComponentStore/RadialBottomEdge"
221+
222+TemplateWidgetPage {
223+ id: circleImageWidget
224+
225+ title: "Radial Bottom Edge"
226+ author: "Nekhelesh Ramananthan"
227+ email: "nik90@ubuntu.com"
228+ license: "GNU General Public License v3.0"
229+ description: "This widget adds a bottom edge which provides access to \
230+action buttons presented in a radial fashion."
231+
232+ content: RadialBottomEdge {
233+ actions: [
234+ RadialAction {
235+ iconName: "alarm-clock"
236+ iconColor: UbuntuColors.coolGrey
237+ onTriggered: console.log("Alarm..zZz")
238+ },
239+ RadialAction {
240+ iconName: "settings"
241+ iconColor: UbuntuColors.coolGrey
242+ },
243+
244+ RadialAction {
245+ iconName: "save"
246+ iconColor: "white"
247+ backgroundColor: UbuntuColors.green
248+ onTriggered: console.log("save")
249+ },
250+
251+ RadialAction {
252+ iconName: "delete"
253+ iconColor: "white"
254+ backgroundColor: UbuntuColors.red
255+ onTriggered: console.log("delete")
256+ },
257+
258+ RadialAction {
259+ iconName: "add"
260+ iconColor: "white"
261+ backgroundColor: UbuntuColors.green
262+ },
263+
264+ RadialAction {
265+ iconName: "stock_email"
266+ iconColor: UbuntuColors.coolGrey
267+ }
268+ ]
269+ }
270+}
271+
272+
273+
274
275=== modified file 'GallerySRC/WidgetsModel.qml'
276--- GallerySRC/WidgetsModel.qml 2014-11-12 15:27:00 +0000
277+++ GallerySRC/WidgetsModel.qml 2014-11-15 15:00:12 +0000
278@@ -27,4 +27,9 @@
279 label: "Page With Bottom Edge"
280 source: "GallerySRC/BottomEdgeWidget.qml"
281 }
282+
283+ ListElement {
284+ label: "Radial Bottom Edge"
285+ source: "GallerySRC/RadialBottomEdgeWidget.qml"
286+ }
287 }
288
289=== modified file 'docs/_components/circleimage.rst'
290--- docs/_components/circleimage.rst 2014-11-09 16:01:02 +0000
291+++ docs/_components/circleimage.rst 2014-11-15 15:00:12 +0000
292@@ -8,6 +8,8 @@
293 +----------+---------------------------------+
294 | Contact | mspencer@sonrisesoftware.com |
295 +----------+---------------------------------+
296+| Framework| ubuntu-sdk-14.10 |
297++----------+---------------------------------+
298
299 This widget converts any image into a circular sized image which can be useful for showing user profile pictures. As trivial as this might look, it is not a straightforward solution in QML.
300
301
302=== modified file 'docs/_components/emptystate.rst'
303--- docs/_components/emptystate.rst 2014-11-06 17:03:51 +0000
304+++ docs/_components/emptystate.rst 2014-11-15 15:00:12 +0000
305@@ -4,10 +4,12 @@
306 +----------+---------------------------------+
307 | Author | Nekhelesh Ramananthan |
308 +----------+-------------+-------------------+
309-| License | GNU General Public License v3.0 |
310+| License | BSD License |
311 +----------+---------------------------------+
312 | Contact | nik90@ubuntu.com |
313 +----------+---------------------------------+
314+| Framework| ubuntu-sdk-14.10 |
315++----------+---------------------------------+
316
317 This widget provides a standardized way to show an empty state (approved by Canonical designers)
318 to improve the user experience and avoid showing a blank page. This way the user is not left starring
319
320=== modified file 'docs/_components/fastscroll.rst'
321--- docs/_components/fastscroll.rst 2014-11-08 21:34:25 +0000
322+++ docs/_components/fastscroll.rst 2014-11-15 15:00:12 +0000
323@@ -8,6 +8,8 @@
324 +----------+---------------------------------+
325 | Contact | renato.filho@canonical.com |
326 +----------+---------------------------------+
327+| Framework| ubuntu-sdk-14.10 |
328++----------+---------------------------------+
329
330 This widget provides a quick way to navigate long list views by providing
331 a fast scroll. Example use cases are scrolling through an address book with
332
333=== modified file 'docs/_components/listitemwithactions.rst'
334--- docs/_components/listitemwithactions.rst 2014-11-12 16:25:04 +0000
335+++ docs/_components/listitemwithactions.rst 2014-11-15 15:00:12 +0000
336@@ -8,6 +8,8 @@
337 +----------+---------------------------------+
338 | Contact | renato.filho@canonical.com |
339 +----------+---------------------------------+
340+| Framework| ubuntu-sdk-14.10 |
341++----------+---------------------------------+
342
343 This widget provides an updated listitem which is what the core apps currently use.
344 These listitems will be provided by the SDK with vivid onwards. However current RMT
345
346=== modified file 'docs/_components/pagewithbottomedge.rst'
347--- docs/_components/pagewithbottomedge.rst 2014-11-09 16:01:02 +0000
348+++ docs/_components/pagewithbottomedge.rst 2014-11-15 15:00:12 +0000
349@@ -8,6 +8,8 @@
350 +----------+---------------------------------+
351 | Contact | renato.filho@canonical.com |
352 +----------+---------------------------------+
353+| Framework| ubuntu-sdk-14.10 |
354++----------+---------------------------------+
355
356 This component provides a bottom edge which can be used to house common actions. There is only one bottom edge
357 available for a page. Only one. The user can use it without looking where they are pressing. Think carefully
358
359=== added file 'docs/_components/radialbottomedge.rst'
360--- docs/_components/radialbottomedge.rst 1970-01-01 00:00:00 +0000
361+++ docs/_components/radialbottomedge.rst 2014-11-15 15:00:12 +0000
362@@ -0,0 +1,158 @@
363+Radial Bottom Edge
364+==================
365+
366++----------+---------------------------------+
367+| Author | Nekhelesh Ramananthan |
368++----------+-------------+-------------------+
369+| License | BSD License |
370++----------+---------------------------------+
371+| Contact | nik90@ubuntu.com |
372++----------+---------------------------------+
373+| Framework| ubuntu-sdk-14.10 |
374++----------+---------------------------------+
375+
376+This component provides a unique way to show actions buttons using the bottom
377+edge. It allows app developers to decide how many actions they want to show
378+and customize it to their liking.
379+
380+Example:
381+
382+.. code-block:: qml
383+
384+ RadialBottomEdge {
385+ actions: [
386+ RadialAction {
387+ iconName: "alarm-clock"
388+ iconColor: UbuntuColors.coolGrey
389+ onTriggered: console.log("Alarm..zZz")
390+ },
391+
392+ RadialAction {
393+ iconName: "settings"
394+ iconColor: UbuntuColors.coolGrey
395+ },
396+
397+ RadialAction {
398+ iconName: "save"
399+ iconColor: "white"
400+ backgroundColor: UbuntuColors.green
401+ onTriggered: console.log("save")
402+ },
403+
404+ RadialAction {
405+ iconName: "delete"
406+ iconColor: "white"
407+ backgroundColor: UbuntuColors.red
408+ onTriggered: console.log("delete")
409+ },
410+
411+ RadialAction {
412+ iconName: "add"
413+ iconColor: "white"
414+ backgroundColor: UbuntuColors.green
415+ },
416+
417+ RadialAction {
418+ iconName: "stock_email"
419+ iconColor: UbuntuColors.coolGrey
420+ }
421+ ]
422+ }
423+
424+.. image:: ../_images/radialbottomedge.png
425+ :align: center
426+
427+Properties
428+----------
429+
430+- :ref:`hintSize`: int
431+- :ref:`hintColor`: color
432+- :ref:`hintIconName`: string
433+- :ref:`hintIconSource`: url
434+- :ref:`hintIconColor`: color
435+- :ref:`bottomEdgeEnabled`: boolean
436+- :ref:`actions`: RadialAction <list>
437+- :ref:`actionButtonSize`: int
438+- :ref:`actionButtonDistance`: int
439+
440+.. note:: All properties except for *hintIconSource* have well defined defaults. As a developer, you could choose to go with the defaults or change them to your liking.
441+
442+Property Documentation
443+----------------------
444+
445+.. _hintSize:
446+
447+hintSize
448+^^^^^^^^
449+
450+The size of the hint shown in the bottom edge. It defaults to 8 grid units.
451+
452+.. _hintColor:
453+
454+hintColor
455+^^^^^^^^^
456+
457+The background color of the hint shown in the bottom edge. By default it uses
458+the ubuntu palette's overlay color.
459+
460+.. _hintIconName:
461+
462+hintIconName
463+^^^^^^^^^^^^
464+
465+The name of the icon to display. Valid icon names can be found in the suru-icon-theme.
466+
467+.. note:: If both :ref:`hintIconName` and :ref:`hintIconSource` are specified, then :ref:`hintIconName` will be ignored.
468+
469+.. _hintIconSource:
470+
471+hintIconSource
472+^^^^^^^^^^^^^^
473+
474+The source url of the icon to display. It has precedence over :ref:`hintIconName`.
475+
476+.. _hintIconColor:
477+
478+hintIconColor
479+^^^^^^^^^^^^^
480+
481+The color of the icon displayed in the hint.
482+
483+.. _bottomEdgeEnabled:
484+
485+bottomEdgeEnabled
486+^^^^^^^^^^^^^^^^^
487+
488+Property to enable/disable the bottom edge. When disabled, the bottom edge hint will be hidden.
489+
490+.. _actions:
491+
492+actions
493+^^^^^^^
494+
495+This property is used to define a list of actions to be shown in the radial menu. The list takes
496+a **RadialAction** which inherits **Action**. A RadialAction adds 3 properties on top of what Action
497+provides which are iconName, iconColor and backgroundColor. ::
498+
499+ RadialAction {
500+ iconName: "add"
501+ iconColor: "white"
502+ backgroundColor: "green"
503+ }
504+
505+This helps defining properties for each action separately and allow for customization.
506+
507+.. _actionButtonSize:
508+
509+actionButtonSize
510+^^^^^^^^^^^^^^^^
511+
512+The size of all the actions buttons. By default it is set to 7 grid units. Increasing this size would also
513+require increasing the :ref:`actionButtonDistance` value as well.
514+
515+.. _actionButtonDistance:
516+
517+actionButtonDistance
518+^^^^^^^^^^^^^^^^^^^^
519+
520+The distance (separation) between the action buttons and the center of the radial menu.
521
522=== added file 'docs/_images/radialbottomedge.png'
523Binary files docs/_images/radialbottomedge.png 1970-01-01 00:00:00 +0000 and docs/_images/radialbottomedge.png 2014-11-15 15:00:12 +0000 differ
524=== modified file 'docs/index.rst'
525--- docs/index.rst 2014-11-12 15:54:22 +0000
526+++ docs/index.rst 2014-11-15 15:00:12 +0000
527@@ -53,3 +53,4 @@
528 _components/fastscroll
529 _components/listitemwithactions
530 _components/pagewithbottomedge
531+ _components/radialbottomedge
532
533=== modified file 'docs/release.rst'
534--- docs/release.rst 2014-11-12 15:55:24 +0000
535+++ docs/release.rst 2014-11-15 15:00:12 +0000
536@@ -1,6 +1,10 @@
537 Release Notes
538 =============
539
540+**15th November 2014**
541+
542+* Added radial bottom edge component
543+
544 **12th November 2014**
545
546 * Fixed typos in the installation guide

Subscribers

People subscribed via source and target branches