Commit 50a7c684 authored by eekkelund's avatar eekkelund

[Controls] Slider: Three different types of design suggestions. One like in...

[Controls] Slider: Three different types of design suggestions. One like in spec, one like it was earlier and one where handle is always up when pressed
parent 01db4fc5
...@@ -55,6 +55,16 @@ Page { ...@@ -55,6 +55,16 @@ Page {
Slider { Slider {
anchors.margins: 20 anchors.margins: 20
value: 0 value: 0
useSpecSlider: false
}
Slider {
anchors.margins: 20
value: 50
showValue: true
minimumValue: 1
maximumValue: 100
stepSize: 1
alwaysUp: true
} }
Slider { Slider {
anchors.margins: 20 anchors.margins: 20
......
...@@ -8,6 +8,8 @@ Slider { ...@@ -8,6 +8,8 @@ Slider {
id: slider id: slider
property bool showValue: false property bool showValue: false
property int valueFontSize: Theme.fontSizeTiny property int valueFontSize: Theme.fontSizeTiny
property bool useSpecSlider: true
property bool alwaysUp: false
style: SliderStyle{} style: SliderStyle{}
} }
...@@ -23,17 +23,26 @@ import QtQuick.Controls.Styles 1.0 ...@@ -23,17 +23,26 @@ import QtQuick.Controls.Styles 1.0
import QtQuick.Controls.Nemo 1.0 import QtQuick.Controls.Nemo 1.0
SliderStyle{ SliderStyle{
readonly property double handleValue: control.value / control.maximumValue
readonly property double _multiple: (handleValue > 0.8) ? (control.maximumValue/control.value-1) / 0.25 : 1
readonly property double _multiple2: (handleValue > 0.8) ? (handleValue - 0.8) / 0.2 : 1
property bool useSpecSlider: control.useSpecSlider
property bool alwaysUp: control.alwaysUp
handle: Rectangle { handle: Rectangle {
id: handle id: handle
anchors.centerIn: parent anchors.verticalCenter:useSpecSlider ? undefined : parent.verticalCenter
y: useSpecSlider ? (control.pressed ? alwaysUp ? parent.y - Theme.itemHeightLarge : ((handleValue > 0.8) ? parent.y - (Theme.itemHeightLarge*_multiple2) : parent.y ) : parent.y) : undefined
x: useSpecSlider ? (control.pressed ? alwaysUp ? Theme.itemHeightExtraSmall / 2 : (handleValue > 0.8) ? (_multiple*Theme.itemHeightHuge) : Theme.itemHeightHuge : 0) : undefined
color: Theme.backgroundColor color: Theme.backgroundColor
border.color: Theme.accentColor border.color: Theme.textColor
border.width: 2 border.width: size.ratio(2)
implicitWidth: Theme.itemHeightExtraSmall implicitWidth: Theme.itemHeightExtraSmall
implicitHeight: Theme.itemHeightExtraSmall implicitHeight: Theme.itemHeightExtraSmall
radius: implicitHeight / 2 radius: implicitHeight / 2
visible: control.enabled visible: control.enabled
scale: control.pressed ? 1.2 : 1
Text{ Text{
id: valueLabel id: valueLabel
anchors.centerIn: parent anchors.centerIn: parent
...@@ -58,6 +67,16 @@ SliderStyle{ ...@@ -58,6 +67,16 @@ SliderStyle{
color: Theme.accentColor color: Theme.accentColor
} }
Rectangle{
id: strecthLine
x: dataLine.width
width: left.x-x + (handleValue < 0.85 ? Theme.itemSpacingLarge : 0)
visible: useSpecSlider ? alwaysUp ? false : (control.pressed && handleValue > 0.80) : false
height: parent.height
color: Theme.accentColor
opacity:0.3
}
Image { Image {
id: disabledImg id: disabledImg
anchors.fill: parent anchors.fill: parent
...@@ -68,14 +87,15 @@ SliderStyle{ ...@@ -68,14 +87,15 @@ SliderStyle{
Image{ Image{
id: left id: left
x: (useSpecSlider && control.pressed ? alwaysUp ? dataLine.width+width : (handleValue > 0.80) ? dataLine.width +Theme.itemHeightExtraSmall/2 +_multiple*Theme.itemHeightHuge : dataLine.width + Theme.itemHeightHuge : dataLine.width) - width
anchors{ anchors{
right: dataLine.right bottom: useSpecSlider ? ((control.pressed && (handleValue > 0.80 || alwaysUp)) ? dataLine.bottom : undefined) : undefined
verticalCenter: dataLine.verticalCenter verticalCenter: useSpecSlider ? ((control.pressed && (handleValue > 0.80 || alwaysUp)) ? undefined : dataLine.verticalCenter) : dataLine.verticalCenter
} }
source: "images/slider-handle-left.svg" source: useSpecSlider && control.pressed ? (handleValue > 0.80) || alwaysUp ? "images/slider-trumpet-up.png" : "images/slider-trumpet-stretch.png" : "images/slider-trumpet.png"
height:Theme.itemHeightExtraSmall height: control.pressed && useSpecSlider ? alwaysUp ? Theme.itemHeightLarge : (handleValue > 0.80) ? (Theme.itemHeightLarge*_multiple2) : Theme.itemHeightExtraSmall : Theme.itemHeightExtraSmall
visible: control.enabled visible: control.enabled
width: (styleData.handlePosition > Theme.itemHeightHuge) ? Theme.itemHeightHuge : styleData.handlePosition width: control.pressed && useSpecSlider ? ((handleValue > 0.80) || alwaysUp ? Theme.itemHeightExtraSmall : Theme.itemHeightHuge) : (styleData.handlePosition > Theme.itemHeightHuge) ? Theme.itemHeightHuge : styleData.handlePosition
sourceSize.width: width sourceSize.width: width
sourceSize.height: height sourceSize.height: height
} }
......
...@@ -53,7 +53,10 @@ QML_FILES += \ ...@@ -53,7 +53,10 @@ QML_FILES += \
images/disabled-overlay.png \ images/disabled-overlay.png \
images/switch-ball.png \ images/switch-ball.png \
images/slider-ball.png \ images/slider-ball.png \
images/slider-handle-left.svg images/slider-handle-left.svg \
images/slider-trumpet-stretch.png \
images/slider-trumpet-up.png \
images/slider-trumpet.png
OTHER_FILES += qmldir \ OTHER_FILES += qmldir \
themes/Theme1.js \ themes/Theme1.js \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment