Merge lp:~bpierre/ubuntu-ui-toolkit/combobutton-standalone into lp:ubuntu-ui-toolkit/staging

Proposed by Pierre Bertet
Status: Merged
Approved by: Timo Jyrinki
Approved revision: 1783
Merged at revision: 1855
Proposed branch: lp:~bpierre/ubuntu-ui-toolkit/combobutton-standalone
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 542 lines (+242/-86)
4 files modified
components.api (+6/-1)
examples/ubuntu-ui-toolkit-gallery/Buttons.qml (+14/-10)
src/Ubuntu/Components/1.3/ComboButton.qml (+60/-11)
src/Ubuntu/Components/Themes/Ambiance/1.3/ComboButtonStyle.qml (+162/-64)
To merge this branch: bzr merge lp:~bpierre/ubuntu-ui-toolkit/combobutton-standalone
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Pierre Bertet (community) Approve
Zsombor Egri Approve
Timo Jyrinki trigger ci, not real review Approve
Review via email: mp+280703@code.launchpad.net

Commit message

ComboButton: not based on Button anymore + style update

Description of the change

Remove the ButtonStyle dependency from the ComboButton in preparation for the new Button style.

To post a comment you must log in.
Revision history for this message
Zsombor Egri (zsombi) wrote :

I wouldn't mind if the colors would be fixed here, so the palette would be used here as well.

review: Needs Fixing
Revision history for this message
Pierre Bertet (bpierre) wrote :

The component is now using the palette.

Consequently, we had to make a few visual changes, and the following properties are now disabled to prevent any issue:

- color
- gradient
- strokeColor
- dropdownColor

Revision history for this message
Timo Jyrinki (timo-jyrinki) :
review: Approve (trigger ci, not real review)
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

maybe not enough to trigger, hmm. top-approve by SDK team member will definitely trigger CI, so if you're happy you can just try merging.

Revision history for this message
Zsombor Egri (zsombi) wrote :

API file is not up to date, so staging sync must be performed. Please be careful with the deprecation and property removals especially - you can break apps!

LAF is good, and in addition you could fix the gallery page resizing, when the ComboButtons are cut if the page width is too narrow. See the Sliders how it is done in case you face issues.

Not bad otherwise :)

review: Needs Fixing
Revision history for this message
Pierre Bertet (bpierre) wrote :

> API file is not up to date, so staging sync must be performed.

It should be fine now.

> Please be careful with the deprecation and property removals especially - you can break apps!

Yes, I only disabled their effects to not break the new style, the actual properties are still there with a warning.

> and in addition you could fix the gallery page resizing

Done.

Thanks for your feedback!

review: Needs Resubmitting
Revision history for this message
Zsombor Egri (zsombi) wrote :

Good to land! Thanks Pierre, excellent job!

review: Approve
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :

FAILED: Autolanding.
No commit message was specified in the merge proposal. Hit 'Add commit message' on the merge proposal web page or follow the link below. You can approve the merge proposal yourself to rerun.
https://code.launchpad.net/~bpierre/ubuntu-ui-toolkit/combobutton-standalone/+merge/280703/+edit-commit-message

review: Needs Fixing (continuous-integration)
Revision history for this message
Pierre Bertet (bpierre) :
review: Approve
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)

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 2016-02-11 09:49:55 +0000
3+++ components.api 2016-02-12 10:57:08 +0000
4@@ -277,13 +277,18 @@
5 property color dropdownColor
6 property bool expanded
7 property double expandedHeight
8-Ubuntu.Components.ComboButton 1.3: Button
9+Ubuntu.Components.ComboButton 1.3: AbstractButton
10 property double collapsedHeight
11+ property color color
12 default property list<QtObject> comboList
13 readonly property double comboListHeight
14 property color dropdownColor
15 property bool expanded
16 property double expandedHeight
17+ property QFont font
18+ property Gradient gradient
19+ property string iconPosition
20+ property color strokeColor
21 Ubuntu.Components.Styles.ComboButtonStyle 1.1: Item
22 property Item comboListHolder
23 property double comboListMargin
24
25=== modified file 'examples/ubuntu-ui-toolkit-gallery/Buttons.qml'
26--- examples/ubuntu-ui-toolkit-gallery/Buttons.qml 2015-12-21 20:17:16 +0000
27+++ examples/ubuntu-ui-toolkit-gallery/Buttons.qml 2016-02-12 10:57:08 +0000
28@@ -24,7 +24,7 @@
29 TemplateSection {
30 className: "Button"
31
32- TemplateRow {
33+ TemplateFlow {
34 title: i18n.tr("Standard")
35
36 Button {
37@@ -33,7 +33,7 @@
38 }
39 }
40
41- TemplateRow {
42+ TemplateFlow {
43 title: i18n.tr("Stroke")
44
45 Button {
46@@ -43,7 +43,7 @@
47 }
48 }
49
50- TemplateRow {
51+ TemplateFlow {
52 title: i18n.tr("Color")
53
54 Button {
55@@ -59,7 +59,7 @@
56 }
57 }
58
59- TemplateRow {
60+ TemplateFlow {
61 title: i18n.tr("Icon")
62
63 Button {
64@@ -68,7 +68,7 @@
65 }
66 }
67
68- TemplateRow {
69+ TemplateFlow {
70 title: i18n.tr("Icon+Text")
71
72 Button {
73@@ -87,7 +87,7 @@
74 }
75 }
76
77- TemplateRow {
78+ TemplateFlow {
79 title: i18n.tr("Disabled")
80
81 Button {
82@@ -101,12 +101,13 @@
83 TemplateSection {
84 className: "ComboButton"
85
86- TemplateRow {
87+ TemplateFlow {
88 title: i18n.tr("Collapsed")
89
90 ComboButton {
91 text: "Press me"
92 objectName: "combobutton_collapsed"
93+ width: parent.width < units.gu(30)? parent.width : units.gu(30)
94 comboList: UbuntuListView {
95 model: 10
96 delegate: Standard {
97@@ -116,11 +117,12 @@
98 }
99 }
100
101- TemplateRow {
102+ TemplateFlow {
103 title: i18n.tr("Icon")
104
105 ComboButton {
106 iconSource: "call.png"
107+ width: parent.width < units.gu(30)? parent.width : units.gu(30)
108 comboList: UbuntuListView {
109 model: 10
110 delegate: Standard {
111@@ -130,12 +132,13 @@
112 }
113 }
114
115- TemplateRow {
116+ TemplateFlow {
117 title: i18n.tr("Icon+Text")
118
119 ComboButton {
120 text: "Answer"
121 iconSource: "call.png"
122+ width: parent.width < units.gu(30)? parent.width : units.gu(30)
123 comboList: UbuntuListView {
124 model: 10
125 delegate: Standard {
126@@ -144,13 +147,14 @@
127 }
128 }
129 }
130- TemplateRow {
131+ TemplateFlow {
132 title: i18n.tr("Expanded")
133
134 ComboButton {
135 text: "Press me"
136 objectName: "combobutton_expanded"
137 expanded: true
138+ width: parent.width < units.gu(30)? parent.width : units.gu(30)
139 comboList: UbuntuListView {
140 model: 10
141 delegate: Standard {
142
143=== modified file 'examples/ubuntu-ui-toolkit-gallery/call@30.png'
144Binary files examples/ubuntu-ui-toolkit-gallery/call@30.png 2013-06-29 22:36:27 +0000 and examples/ubuntu-ui-toolkit-gallery/call@30.png 2016-02-12 10:57:08 +0000 differ
145=== modified file 'src/Ubuntu/Components/1.3/ComboButton.qml'
146--- src/Ubuntu/Components/1.3/ComboButton.qml 2015-08-20 06:56:44 +0000
147+++ src/Ubuntu/Components/1.3/ComboButton.qml 2016-02-12 10:57:08 +0000
148@@ -161,10 +161,68 @@
149 \section2 Styling
150 The style of the component is defined in \l ComboButtonStyle.
151 */
152-Button {
153+AbstractButton {
154 id: combo
155
156 /*!
157+ \deprecated
158+ If set to a color, the button has a stroke border instead of a filled
159+ shape.
160+ */
161+ property color strokeColor
162+ onStrokeColorChanged: console.warn(
163+ "WARNING: ComboButton.strokeColor is deprecated."
164+ )
165+
166+ /*!
167+ \deprecated
168+ The background color of the button.
169+ */
170+ property color color
171+ onColorChanged: console.warn("WARNING: ComboButton.color is deprecated.")
172+
173+ /*!
174+ \deprecated
175+ The gradient used to fill the background of the button.
176+ Standard Ubuntu gradients are defined in \l UbuntuColors.
177+ If both a gradient and a color are specified, the gradient will be used.
178+ */
179+ property Gradient gradient
180+ onGradientChanged: console.warn(
181+ "WARNING: ComboButton.gradient is deprecated."
182+ )
183+
184+ /*!
185+ \deprecated
186+ The property specifies the color of the dropdown button and the combo
187+ list for both collapsed and expanded states. You can use \l expanded to
188+ define different colors for expanded or collapsed states.
189+ */
190+ property color dropdownColor
191+ onDropdownColorChanged: console.warn(
192+ "WARNING: ComboButton.dropdownColor is deprecated."
193+ )
194+
195+ /*!
196+ The font used for the button's text.
197+ */
198+ property font font: __styleInstance.defaultFont
199+
200+ /*!
201+ The position of the icon relative to the text. Options
202+ are "left" and "right". The default value is "left".
203+
204+ If only text or only an icon is defined, this
205+ property is ignored and the text or icon is
206+ centered horizontally and vertically in the button.
207+
208+ Currently this is a string value. We are waiting for
209+ support for enums:
210+ https://bugreports.qt-project.org/browse/QTBUG-14861
211+ */
212+ property string iconPosition: "left"
213+
214+ /*!
215 Specifies whether the combo list is expanded or not. The default falue is
216 false.
217 */
218@@ -239,15 +297,6 @@
219 */
220 default property alias comboList: comboListHolder.data
221
222- /* ----------------- Color and font configurations ----------------- */
223- /*!
224- The property specifies the color of the dropdown button and the combo list
225- for both collapsed and expanded states. You can use \l expanded to define
226- different colors for expanded or collapsed states.
227- */
228- property color dropdownColor: __styleInstance ? __styleInstance.defaultDropdownColor : color
229-
230-
231 styleName: "ComboButtonStyle"
232
233 Component.onCompleted: {
234@@ -258,7 +307,7 @@
235 __mouseArea.anchors.left = Qt.binding(function() {return combo.left;});
236 __mouseArea.anchors.top = Qt.binding(function() {return combo.top;});
237 __mouseArea.anchors.right = Qt.binding(function() {return combo.right;});
238- __mouseArea.anchors.rightMargin = Qt.binding(function() {return combo.__styleInstance.dropDownWidth + combo.__styleInstance.dropDownSeparatorWidth;});
239+ __mouseArea.anchors.rightMargin = Qt.binding(function() {return combo.__styleInstance.dropDownWidth;});
240 __mouseArea.height = Qt.binding(function() {return collapsedHeight;});
241 // for autopilot, set the main button name
242 __mouseArea.objectName = "combobutton_mainbutton";
243
244=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/ComboButtonStyle.qml'
245--- src/Ubuntu/Components/Themes/Ambiance/1.3/ComboButtonStyle.qml 2015-12-09 14:25:50 +0000
246+++ src/Ubuntu/Components/Themes/Ambiance/1.3/ComboButtonStyle.qml 2016-02-12 10:57:08 +0000
247@@ -23,20 +23,16 @@
248
249 // configurations
250 dropDownWidth: units.gu(5)
251- dropDownSeparatorWidth: units.dp(2)
252 comboListMargin: units.gu(0.8)
253 comboListHolder: comboListContent
254 comboListPanel: panelItem
255 defaultColor: mainButton.defaultColor
256 defaultGradient: mainButton.defaultGradient
257- defaultDropdownColor: combo.expanded ? Qt.rgba(0, 0, 0, 0.05) : defaultColor
258+ defaultDropdownColor: mainButton.defaultColor
259 defaultFont: mainButton.defaultFont
260
261-
262- width: combo.width
263- height: combo.collapsedHeight
264-
265- property ComboButton combo: styledItem
266+ width: styledItem.width
267+ height: styledItem.collapsedHeight
268
269 implicitWidth: mainButton.implicitWidth
270 implicitHeight: mainButton.implicitHeight
271@@ -44,25 +40,159 @@
272 LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft
273 LayoutMirroring.childrenInherit: true
274
275- ButtonStyle {
276+ Item {
277 id: mainButton
278+
279+ property real minimumWidth: units.gu(36)
280+ property real horizontalPadding: units.gu(4)
281+ property color defaultColor: theme.palette.normal.foreground
282+ property font defaultFont: Qt.font({family: "Ubuntu", pixelSize: FontUtils.sizeToPixels("medium")})
283+ property Gradient defaultGradient: null
284+ property real buttonFaceOffset: -dropDownWidth/2
285+ property bool stroke: false
286+
287+ /*!
288+ The property overrides the button's default background with an item. This
289+ item can be used by derived styles to reuse the ButtonStyle and override
290+ the default coloured background with an image or any other drawing.
291+ The default value is null.
292+ */
293+ property Item backgroundSource: comboFace
294+
295 anchors {
296 left: parent.left
297 top: parent.top
298 right: parent.right
299 }
300- height: combo.collapsedHeight
301- // overrides
302- backgroundSource: comboFace
303- buttonFaceOffset: -dropDownWidth/2 - dropDownSeparatorWidth
304- horizontalPadding: units.gu(4) - dropDownSeparatorWidth
305- minimumWidth: units.gu(36)
306-
307- // FIXME: use hardcoded color while we get the theme palette updated
308- defaultColor: "#b2b2b2"
309- defaultGradient: null
310-
311- // button face
312+ width: styledItem.width
313+ height: styledItem.collapsedHeight
314+ implicitWidth: Math.max(
315+ minimumWidth, foreground.implicitWidth + 2 * mainButton.horizontalPadding
316+ )
317+ implicitHeight: units.gu(4)
318+
319+ LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft
320+ LayoutMirroring.childrenInherit: true
321+
322+ UbuntuShape {
323+ id: background
324+ anchors.fill: parent
325+ borderSource: "radius_idle.sci" // Deprecated, use a dedicated shape.
326+ visible: mainButton.stroke ? false : ((backgroundColor.a != 0.0) || mainButton.backgroundSource)
327+ source: mainButton.backgroundSource
328+
329+ backgroundColor: defaultColor
330+ backgroundMode: UbuntuShape.SolidColor
331+ opacity: styledItem.enabled ? 1.0 : 0.6
332+ }
333+
334+ Item {
335+ id: foreground
336+
337+ property string iconPosition: styledItem.iconPosition
338+ property real iconSize: units.gu(2)
339+ property real spacing: mainButton.horizontalPadding
340+ property bool hasIcon: styledItem.iconSource != ""
341+ property bool hasText: styledItem.text != ""
342+
343+ anchors {
344+ centerIn: parent
345+ horizontalCenterOffset: mainButton.buttonFaceOffset
346+ }
347+ transformOrigin: Item.Top
348+ width: parent.width - 2*mainButton.horizontalPadding
349+ implicitHeight: Math.max(foregroundIcon.height, foregroundLabel.height)
350+ scale: styledItem.pressed ? 0.98 : 1.0
351+ Behavior on scale {
352+ NumberAnimation {
353+ duration: UbuntuAnimation.SnapDuration
354+ easing.type: Easing.Linear
355+ }
356+ }
357+ state: foreground.hasIcon && hasText ? iconPosition : "center"
358+
359+ Icon {
360+ id: foregroundIcon
361+ visible: foreground.hasIcon
362+ anchors.verticalCenter: parent.verticalCenter
363+ width: foreground.iconSize
364+ height: foreground.iconSize
365+ color: foregroundLabel.color
366+ source: styledItem.iconSource
367+ }
368+
369+ Label {
370+ id: foregroundLabel
371+ anchors.verticalCenter: parent.verticalCenter
372+ elide: Text.ElideRight
373+ color: theme.palette.normal.foregroundText
374+ font: styledItem.font
375+ text: styledItem.text
376+ }
377+
378+ states: [
379+ State {
380+ name: "left"
381+ AnchorChanges {
382+ target: foregroundIcon
383+ anchors.left: foreground.left
384+ }
385+ AnchorChanges {
386+ target: foregroundLabel
387+ anchors.left: foregroundIcon.right
388+ }
389+ PropertyChanges {
390+ target: foregroundLabel
391+ anchors.leftMargin: spacing
392+ width: foreground.width - foregroundIcon.width - spacing
393+ }
394+ PropertyChanges {
395+ target: foreground
396+ implicitWidth: foregroundIcon.implicitWidth + spacing + foregroundLabel.implicitWidth
397+ }
398+ },
399+ State {
400+ name: "right"
401+ AnchorChanges {
402+ target: foregroundIcon
403+ anchors.right: foreground.right
404+ }
405+ AnchorChanges {
406+ target: foregroundLabel
407+ anchors.right: foregroundIcon.left
408+ }
409+ PropertyChanges {
410+ target: foregroundLabel
411+ anchors.rightMargin: spacing
412+ width: foreground.width - foregroundIcon.width - spacing
413+ }
414+ PropertyChanges {
415+ target: foreground
416+ implicitWidth: foregroundIcon.implicitWidth + spacing + foregroundLabel.implicitWidth
417+ }
418+ },
419+ State {
420+ name: "center"
421+ AnchorChanges {
422+ target: foregroundIcon
423+ anchors.horizontalCenter: foreground.horizontalCenter
424+ }
425+ AnchorChanges {
426+ target: foregroundLabel
427+ anchors.horizontalCenter: foreground.horizontalCenter
428+ }
429+ PropertyChanges {
430+ target: foregroundLabel
431+ width: Math.min(foregroundLabel.implicitWidth, foreground.width)
432+ }
433+ PropertyChanges {
434+ target: foreground
435+ implicitWidth: foreground.hasText ? foregroundLabel.implicitWidth : foregroundIcon.implicitWidth
436+ }
437+ }
438+ ]
439+ }
440+
441 ShaderEffectSource {
442 id: comboFace
443 sourceItem: content
444@@ -79,23 +209,13 @@
445 width: mainButton.width
446 height: mainButton.height
447
448+ // button background
449 Rectangle {
450 anchors {
451 fill: parent
452- rightMargin: comboStyle.dropDownSeparatorWidth + comboStyle.dropDownWidth
453- }
454- color: combo.color
455- gradient: mainButton.isGradient ? combo.gradient : null
456- }
457-
458- // distancer
459- Item {
460- anchors {
461- right: dropDownButton.right
462- top: parent.top
463- bottom: parent.bottom
464- }
465- width: comboStyle.dropDownSeparatorWidth
466+ rightMargin: comboStyle.dropDownWidth
467+ }
468+ color: defaultColor
469 }
470
471 Rectangle {
472@@ -107,11 +227,13 @@
473 bottom: parent.bottom
474 }
475 width: comboStyle.dropDownWidth
476- color: mainButton.__colorHack(combo.dropdownColor)
477- Image {
478- source: Qt.resolvedUrl("../artwork/chevron.png")
479+ color: defaultDropdownColor
480+ Icon {
481 anchors.centerIn: parent
482- rotation: combo.expanded ? -90 : 90
483+ height: parent.height / 2
484+ width: height
485+ name: styledItem.expanded? "up" : "down"
486+ color: foregroundLabel.color
487 }
488 }
489 }
490@@ -125,7 +247,7 @@
491 top: mainButton.bottom
492 right: parent.right
493 }
494- opacity: combo.expanded && (combo.comboList.length > 0)? 1.0 : 0.0
495+ opacity: styledItem.expanded && (styledItem.comboList.length > 0)? 1.0 : 0.0
496
497 ShaderEffectSource {
498 id: listContent
499@@ -144,42 +266,18 @@
500 topMargin: comboListMargin
501 }
502 clip: true
503- color: mainButton.__colorHack(combo.dropdownColor)
504+ color: defaultDropdownColor
505 }
506
507- BorderImage {
508- id: shadow
509- anchors {
510- fill: parent
511- leftMargin: -units.gu(0.5)
512- topMargin: comboListMargin - units.gu(0.5)
513- rightMargin: -units.gu(0.5)
514- bottomMargin: -units.gu(0.5)
515- }
516- source: Qt.resolvedUrl("../artwork/bubble_shadow.sci")
517- }
518 UbuntuShape {
519 id: shape
520 anchors {
521 fill: parent
522 topMargin: comboListMargin
523 }
524- visible: true
525 source: listContent
526 }
527
528- Image {
529- source: Qt.resolvedUrl("../artwork/bubble_arrow.png")
530- rotation: 180
531- anchors {
532- bottom: shape.top
533- bottomMargin: -1
534- right: parent.right
535- rightMargin: dropDownWidth / 2 - units.gu(0.5)
536- }
537-
538- }
539-
540 Behavior on height {
541 NumberAnimation {
542 duration: UbuntuAnimation.FastDuration

Subscribers

People subscribed via source and target branches