~tpeeters/ubuntu-ui-toolkit/toolbarActions-hide

« back to all changes in this revision

Viewing changes to modules/Ubuntu/Components/MainView.qml

MainView: new API to choose the background colors.

That requires:
- HeaderStyle: removed background.
- MainView: clip the contents when necessary.
- PageTreeNode: new properties 'isLeaf' and 'activeLeafNode'.

Approved by Tim Peeters, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
135
135
      */
136
136
    property string applicationName: ""
137
137
 
 
138
    /*!
 
139
      \qmlproperty color headerColor
 
140
      Color of the header's background.
 
141
 
 
142
      \sa backgroundColor, footerColor
 
143
     */
 
144
    property alias headerColor: background.headerColor
 
145
    /*!
 
146
      \qmlproperty color backgroundColor
 
147
      Color of the background.
 
148
 
 
149
      The background is usually a single color. However if \l headerColor
 
150
      or \l footerColor are set then a gradient of colors will be drawn.
 
151
 
 
152
      For example, in order for the MainView to draw a color gradient beneath
 
153
      the content:
 
154
      \qml
 
155
          import QtQuick 2.0
 
156
          import Ubuntu.Components 0.1
 
157
 
 
158
          MainView {
 
159
              width: units.gu(40)
 
160
              height: units.gu(60)
 
161
 
 
162
              headerColor: "#343C60"
 
163
              backgroundColor: "#6A69A2"
 
164
              footerColor: "#8896D5"
 
165
          }
 
166
      \endqml
 
167
 
 
168
      \sa footerColor, headerColor
 
169
     */
 
170
    property alias backgroundColor: background.backgroundColor
 
171
    /*!
 
172
      \qmlproperty color footerColor
 
173
      Color of the footer's background.
 
174
 
 
175
      \sa backgroundColor, headerColor
 
176
     */
 
177
    property alias footerColor: background.footerColor
 
178
 
138
179
    // FIXME: Make sure that the theming is only in the background, and the style
139
180
    //  should not occlude contents of the MainView. When making changes here, make
140
181
    //  sure that bug https://bugs.launchpad.net/manhattan/+bug/1124076 does not come back.
142
183
        id: background
143
184
        anchors.fill: parent
144
185
        style: Theme.createStyleComponent("MainViewStyle.qml", background)
 
186
 
 
187
        property color headerColor: backgroundColor
 
188
        property color backgroundColor: Theme.palette.normal.background
 
189
        property color footerColor: backgroundColor
145
190
    }
146
191
 
147
192
    /*!
170
215
 
171
216
        automaticOrientation: false
172
217
 
 
218
        // clip the contents so that it does not overlap the header
173
219
        Item {
174
 
            id: contents
175
 
            anchors.fill: parent
 
220
            id: contentsClipper
 
221
            anchors {
 
222
                left: parent.left
 
223
                right: parent.right
 
224
                top: headerItem.bottom
 
225
                bottom: parent.bottom
 
226
            }
 
227
            // only clip when necessary
 
228
            clip: headerItem.bottomY > 0 && activePage && activePage.flickable
 
229
                  && -activePage.flickable.contentY < headerItem.bottomY
 
230
 
 
231
            property Page activePage: mainView.activeLeafNode
 
232
 
 
233
            Item {
 
234
                id: contents
 
235
                anchors {
 
236
                    fill: parent
 
237
                    // compensate so that the actual y is always 0
 
238
                    topMargin: -parent.y
 
239
                }
 
240
            }
176
241
        }
177
242
 
178
243
        /*!
181
246
         */
182
247
        Header {
183
248
            id: headerItem
 
249
            property real bottomY: headerItem.y + headerItem.height
184
250
        }
185
251
 
186
252
        Toolbar {