summaryrefslogtreecommitdiffstats
path: root/src/controls/Styles/Android/drawables
diff options
context:
space:
mode:
Diffstat (limited to 'src/controls/Styles/Android/drawables')
-rw-r--r--src/controls/Styles/Android/drawables/AnimationDrawable.qml82
-rw-r--r--src/controls/Styles/Android/drawables/ClipDrawable.qml76
-rw-r--r--src/controls/Styles/Android/drawables/ColorDrawable.qml51
-rw-r--r--src/controls/Styles/Android/drawables/Drawable.qml75
-rw-r--r--src/controls/Styles/Android/drawables/DrawableLoader.qml102
-rw-r--r--src/controls/Styles/Android/drawables/GradientDrawable.qml76
-rw-r--r--src/controls/Styles/Android/drawables/ImageDrawable.qml56
-rw-r--r--src/controls/Styles/Android/drawables/LayerDrawable.qml75
-rw-r--r--src/controls/Styles/Android/drawables/NinePatchDrawable.qml63
-rw-r--r--src/controls/Styles/Android/drawables/RotateDrawable.qml80
-rw-r--r--src/controls/Styles/Android/drawables/StateDrawable.qml105
11 files changed, 841 insertions, 0 deletions
diff --git a/src/controls/Styles/Android/drawables/AnimationDrawable.qml b/src/controls/Styles/Android/drawables/AnimationDrawable.qml
new file mode 100644
index 000000000..a522bfa7c
--- /dev/null
+++ b/src/controls/Styles/Android/drawables/AnimationDrawable.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+
+Drawable {
+ id: root
+
+ implicitWidth: Math.max(loader.implicitWidth, styleDef.width || 0)
+ implicitHeight: Math.max(loader.implicitHeight, styleDef.height || 0)
+
+ property int currentFrame: 0
+ readonly property int frameCount: styleDef.frames ? styleDef.frames.length : 0
+ readonly property var frameDef: styleDef.frames ? styleDef.frames[currentFrame] : undefined
+
+ Timer {
+ repeat: true
+ running: root.frameCount && root.visible && Qt.application.active
+ interval: root.frameDef ? root.frameDef.duration : 0
+ onTriggered: {
+ var frame = root.currentFrame + 1
+ repeat = !root.styleDef.oneshot || frame < root.frameCount - 1
+ root.currentFrame = frame % root.frameCount
+ }
+ }
+
+ DrawableLoader {
+ id: loader
+ anchors.fill: parent
+ styleDef: root.frameDef ? root.frameDef.drawable : undefined
+ focused: root.focused
+ pressed: root.pressed
+ checked: root.checked
+ selected: root.selected
+ accelerated: root.accelerated
+ window_focused: root.window_focused
+ index: root.index
+ level: root.level
+ levelId: root.levelId
+ orientations: root.orientations
+ duration: root.duration
+ excludes: root.excludes
+ clippables: root.clippables
+ }
+}
diff --git a/src/controls/Styles/Android/drawables/ClipDrawable.qml b/src/controls/Styles/Android/drawables/ClipDrawable.qml
new file mode 100644
index 000000000..8a76997a0
--- /dev/null
+++ b/src/controls/Styles/Android/drawables/ClipDrawable.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+
+Drawable {
+ id: root
+
+ implicitWidth: Math.max(loader.implicitWidth, styleDef.width || 0)
+ implicitHeight: Math.max(loader.implicitHeight, styleDef.height || 0)
+
+ readonly property bool isClippable: styleDef.id && clippables.indexOf(styleDef.id) !== -1
+
+ Item {
+ clip: true
+ width: orientations & Qt.Horizontal ? level * parent.width : parent.width
+ height: orientations & Qt.Vertical ? level * parent.height : parent.height
+
+ DrawableLoader {
+ id: loader
+ width: root.width
+ height: root.height
+ styleDef: isClippable ? root.styleDef : root.styleDef.drawable
+ focused: root.focused
+ pressed: root.pressed
+ checked: root.checked
+ selected: root.selected
+ accelerated: root.accelerated
+ window_focused: root.window_focused
+ index: root.index
+ level: root.level
+ levelId: root.levelId
+ orientations: root.orientations
+ duration: root.duration
+ excludes: root.excludes
+ clippables: root.clippables
+ }
+ }
+}
diff --git a/src/controls/Styles/Android/drawables/ColorDrawable.qml b/src/controls/Styles/Android/drawables/ColorDrawable.qml
new file mode 100644
index 000000000..7dfd2f036
--- /dev/null
+++ b/src/controls/Styles/Android/drawables/ColorDrawable.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtQuick.Controls.Styles.Android 1.0
+
+Drawable {
+ id: root
+
+ Rectangle {
+ anchors.fill: parent
+ color: AndroidStyle.colorValue(styleDef.color)
+ }
+}
diff --git a/src/controls/Styles/Android/drawables/Drawable.qml b/src/controls/Styles/Android/drawables/Drawable.qml
new file mode 100644
index 000000000..54b3e3e47
--- /dev/null
+++ b/src/controls/Styles/Android/drawables/Drawable.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtQuick.Controls 1.2
+import QtQuick.Controls.Private 1.0
+
+Item {
+ id: root
+
+ property var styleDef
+
+ property bool focused
+ property bool pressed
+ property bool checked
+ property bool selected
+ property bool accelerated
+ property bool window_focused
+
+ property int index: -1
+ property real level: 0
+ property string levelId: ""
+ property int orientations: Qt.Horizontal
+ property int duration: 0
+
+ property var excludes: []
+ property var clippables: []
+
+ property Padding padding: Padding {
+ top: styleDef.padding ? styleDef.padding.top : 0
+ left: styleDef.padding ? styleDef.padding.left : 0
+ right: styleDef.padding ? styleDef.padding.right : 0
+ bottom: styleDef.padding ? styleDef.padding.bottom : 0
+ }
+
+ implicitWidth: styleDef.width || 0
+ implicitHeight: styleDef.height || 0
+}
diff --git a/src/controls/Styles/Android/drawables/DrawableLoader.qml b/src/controls/Styles/Android/drawables/DrawableLoader.qml
new file mode 100644
index 000000000..4dd82c03e
--- /dev/null
+++ b/src/controls/Styles/Android/drawables/DrawableLoader.qml
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtQuick.Controls 1.2
+import QtQuick.Controls.Private 1.0
+
+Loader {
+ id: loader
+
+ property var styleDef
+
+ property bool focused
+ property bool pressed
+ property bool checked
+ property bool selected
+ property bool accelerated
+ property bool window_focused
+
+ property int index: 0
+ property real level: 0
+ property string levelId: ""
+ property int orientations: Qt.Horizontal
+ property int duration: 0
+
+ property var excludes: []
+ property var clippables: []
+
+ property Padding padding: Padding {
+ top: loader.item ? loader.item.padding.top : 0
+ left: loader.item ? loader.item.padding.left : 0
+ right: loader.item ? loader.item.padding.right : 0
+ bottom: loader.item ? loader.item.padding.bottom : 0
+ }
+
+ readonly property string type: styleDef ? styleDef.type : ""
+
+ readonly property bool isExcluded: !!styleDef && excludes.indexOf(styleDef.id) !== -1
+ readonly property bool isClippable: !!styleDef && clippables.indexOf(styleDef.id) !== -1
+
+ active: !!styleDef && !isExcluded
+ sourceComponent: type === "animation" ? Qt.createComponent("AnimationDrawable.qml") :
+ isClippable || type === "clipDrawable" ? Qt.createComponent("ClipDrawable.qml") :
+ type === "color" ? Qt.createComponent("ColorDrawable.qml") :
+ type === "gradient" ? Qt.createComponent("GradientDrawable.qml") :
+ type === "image" ? Qt.createComponent("ImageDrawable.qml") :
+ type === "layer" ? Qt.createComponent("LayerDrawable.qml") :
+ type === "9patch" ? Qt.createComponent("NinePatchDrawable.qml") :
+ type === "rotate" ? Qt.createComponent("RotateDrawable.qml") :
+ type === "stateslist" ? Qt.createComponent("StateDrawable.qml") : null
+
+ Binding { target: loader.item; property: "styleDef"; value: loader.styleDef }
+ Binding { target: loader.item; property: "focused"; value: loader.focused }
+ Binding { target: loader.item; property: "pressed"; value: loader.pressed }
+ Binding { target: loader.item; property: "checked"; value: loader.checked }
+ Binding { target: loader.item; property: "selected"; value: loader.selected }
+ Binding { target: loader.item; property: "accelerated"; value: loader.accelerated }
+ Binding { target: loader.item; property: "window_focused"; value: loader.window_focused }
+ Binding { target: loader.item; property: "level"; value: loader.level }
+ Binding { target: loader.item; property: "levelId"; value: loader.levelId }
+ Binding { target: loader.item; property: "orientations"; value: loader.orientations }
+ Binding { target: loader.item; property: "duration"; value: loader.duration }
+ Binding { target: loader.item; property: "excludes"; value: loader.excludes }
+ Binding { target: loader.item; property: "clippables"; value: loader.clippables }
+}
diff --git a/src/controls/Styles/Android/drawables/GradientDrawable.qml b/src/controls/Styles/Android/drawables/GradientDrawable.qml
new file mode 100644
index 000000000..a94747378
--- /dev/null
+++ b/src/controls/Styles/Android/drawables/GradientDrawable.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtQuick.Controls.Styles.Android 1.0
+
+ColorDrawable {
+ id: root
+
+ Component {
+ id: component
+ GradientStop { }
+ }
+
+ Rectangle {
+ anchors.fill: parent
+ gradient: Gradient {
+ id: gradient
+ function reload() {
+ var stops = []
+ if (styleDef && styleDef.colors) {
+ for (var i = 0; i < styleDef.colors.length; ++i) {
+ var stop = component.createObject(root)
+ stop.color = AndroidStyle.colorValue(styleDef.colors[i])
+ if (styleDef.positions[i] !== undefined)
+ stop.position = styleDef.positions[i]
+ else // spread evenly if positions are not defined
+ stop.position = i / (styleDef.colors.length - 1)
+ stops.push(stop)
+ }
+ }
+ gradient.stops = stops
+ }
+ }
+ }
+
+ onStyleDefChanged: gradient.reload()
+ Component.onCompleted: gradient.reload()
+}
diff --git a/src/controls/Styles/Android/drawables/ImageDrawable.qml b/src/controls/Styles/Android/drawables/ImageDrawable.qml
new file mode 100644
index 000000000..1e71a389a
--- /dev/null
+++ b/src/controls/Styles/Android/drawables/ImageDrawable.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtQuick.Controls.Styles.Android 1.0
+
+Drawable {
+ id: root
+
+ implicitWidth: Math.max(image.implicitWidth, styleDef.width || 0)
+ implicitHeight: Math.max(image.implicitHeight, styleDef.height || 0)
+
+ Image {
+ id: image
+ anchors.fill: parent
+ fillMode: Image.TileHorizontally
+ source: AndroidStyle.filePath(styleDef.path)
+ }
+}
diff --git a/src/controls/Styles/Android/drawables/LayerDrawable.qml b/src/controls/Styles/Android/drawables/LayerDrawable.qml
new file mode 100644
index 000000000..74122a23d
--- /dev/null
+++ b/src/controls/Styles/Android/drawables/LayerDrawable.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+
+Drawable {
+ id: root
+
+ implicitWidth: Math.max(repeater.implicitWidth, styleDef.width || 0)
+ implicitHeight: Math.max(repeater.implicitHeight, styleDef.height || 0)
+
+ Repeater {
+ id: repeater
+ anchors.fill: parent
+ model: index >= 0 ? [styleDef.layers[index]] : styleDef.layers
+ DrawableLoader {
+ id: loader
+ anchors.fill: parent
+ styleDef: modelData
+ focused: root.focused
+ pressed: root.pressed
+ checked: root.checked
+ selected: root.selected
+ accelerated: root.accelerated
+ window_focused: root.window_focused
+ index: root.index
+ level: root.level
+ levelId: root.levelId
+ orientations: root.orientations
+ duration: root.duration
+ excludes: root.excludes
+ clippables: root.clippables
+ // TODO: find a cleaner way to promote the implicit size of the largest layer
+ onImplicitWidthChanged: repeater.implicitWidth = Math.max(implicitWidth, repeater.implicitWidth)
+ onImplicitHeightChanged: repeater.implicitHeight = Math.max(implicitHeight, repeater.implicitHeight)
+ }
+ }
+}
diff --git a/src/controls/Styles/Android/drawables/NinePatchDrawable.qml b/src/controls/Styles/Android/drawables/NinePatchDrawable.qml
new file mode 100644
index 000000000..c641089a2
--- /dev/null
+++ b/src/controls/Styles/Android/drawables/NinePatchDrawable.qml
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtQuick.Controls.Styles.Android 1.0
+
+Drawable {
+ id: root
+
+ readonly property bool isLevelId: levelId == styleDef.id
+ implicitWidth: Math.max(image.implicitWidth, styleDef.width || 0)
+ implicitHeight: Math.max(image.implicitHeight, styleDef.height || 0)
+ clip: image.usesLevelWidth && image.width < image.sourceSize.width
+ || image.usesLevelHeight && height < image.sourceSize.height
+
+ Android9Patch {
+ id: image
+ readonly property bool usesLevelWidth: isLevelId && (orientations & Qt.Horizontal)
+ readonly property bool usesLevelHeight: isLevelId && (orientations & Qt.Vertical)
+ width: usesLevelWidth ? level * parent.width : parent.width
+ height: usesLevelHeight ? level * parent.height : parent.height
+ xDivs: styleDef.chunkInfo ? styleDef.chunkInfo.xdivs : []
+ yDivs: styleDef.chunkInfo ? styleDef.chunkInfo.ydivs : []
+ source: styleDef.drawable ? AndroidStyle.filePath(styleDef.drawable.path) : ""
+ }
+}
diff --git a/src/controls/Styles/Android/drawables/RotateDrawable.qml b/src/controls/Styles/Android/drawables/RotateDrawable.qml
new file mode 100644
index 000000000..7ca75c464
--- /dev/null
+++ b/src/controls/Styles/Android/drawables/RotateDrawable.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+
+Drawable {
+ id: root
+
+ implicitWidth: Math.max(loader.implicitWidth, styleDef.width || 0)
+ implicitHeight: Math.max(loader.implicitHeight, styleDef.height || 0)
+
+ DrawableLoader {
+ id: loader
+ anchors.centerIn: parent
+ anchors.alignWhenCentered: true
+ styleDef: root.styleDef.drawable
+ focused: root.focused
+ pressed: root.pressed
+ checked: root.checked
+ selected: root.selected
+ accelerated: root.accelerated
+ window_focused: root.window_focused
+ index: root.index
+ level: root.level
+ levelId: root.levelId
+ orientations: root.orientations
+ duration: root.duration
+ excludes: root.excludes
+ clippables: root.clippables
+
+ // TODO:
+ // - real root.styleDef.pivotX, pivotXRel (bool)
+ // - real root.styleDef.pivotY, pivotYRel (bool)
+
+ RotationAnimator on rotation {
+ duration: root.duration
+ loops: Animation.Infinite
+ from: root.styleDef.fromDegrees
+ to: root.styleDef.toDegrees
+ running: (from || to) && root.visible && Qt.application.active
+ }
+ }
+}
diff --git a/src/controls/Styles/Android/drawables/StateDrawable.qml b/src/controls/Styles/Android/drawables/StateDrawable.qml
new file mode 100644
index 000000000..d446542d9
--- /dev/null
+++ b/src/controls/Styles/Android/drawables/StateDrawable.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+
+Drawable {
+ id: root
+
+ implicitWidth: Math.max(loader.implicitWidth, styleDef.width || 0)
+ implicitHeight: Math.max(loader.implicitHeight, styleDef.height || 0)
+
+ DrawableLoader {
+ id: loader
+ anchors.fill: parent
+ styleDef: bestStateMatch()
+ focused: root.focused
+ pressed: root.pressed
+ checked: root.checked
+ selected: root.selected
+ accelerated: root.accelerated
+ window_focused: root.window_focused
+ index: root.index
+ level: root.level
+ levelId: root.levelId
+ orientations: root.orientations
+ duration: root.duration
+ excludes: root.excludes
+ clippables: root.clippables
+ }
+
+ function bestStateMatch () {
+ if (styleDef && styleDef.stateslist) {
+ var bestMatch = 0
+ var highestScore = -1
+ var stateslist = styleDef.stateslist
+
+ for (var i = 0; i < stateslist.length; ++i) {
+
+ var score = 0
+ var state = stateslist[i]
+
+ for (var s in state.states) {
+ if (s === "pressed")
+ score += (pressed === state.states[s]) ? 1 : -10
+ if (s === "checked")
+ score += (checked === state.states[s]) ? 1 : -10
+ if (s === "selected")
+ score += (selected === state.states[s]) ? 1 : -10
+ if (s === "focused")
+ score += (focused === state.states[s]) ? 1 : -10
+ if (s === "enabled")
+ score += (enabled === state.states[s]) ? 1 : -1
+ if (s === "window_focused")
+ score += (window_focused === state.states[s]) ? 1 : -1
+ if (s === "accelerated")
+ score += (accelerated === state.states[s]) ? 1 : -1
+ }
+
+ if (score > highestScore) {
+ bestMatch = i
+ highestScore = score
+ }
+ }
+ return stateslist[bestMatch].drawable
+ }
+ return undefined
+ }
+}