Commit 2cbc5277 authored by Leander Schulten's avatar Leander Schulten
Browse files

GUI: ColorSlider: Make it possible to use the ColorSlider vertical

parent b8555ed2
......@@ -8,22 +8,28 @@ Rectangle{
border.width: 1
property alias selectorColor: selector.color
property real value: 0
property int orientation: Gradient.Horizontal
Rectangle{
id: selector
x: 1 + value * (parent.width-3)
y: 1 + value * (parent.height-3)
width: 1
height: 1
color: "black"
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.top: orientation === Gradient.Horizontal ? parent.top : undefined
anchors.bottom: orientation === Gradient.Horizontal ? parent.bottom : undefined
anchors.left: orientation === Gradient.Vertical ? parent.left : undefined
anchors.right: orientation === Gradient.Vertical ? parent.right : undefined
}
Component.onCompleted: {
if(gradient){
gradient.orientation = Gradient.Horizontal;
gradient.orientation = orientation;
}
}
MouseArea{
anchors.fill: parent
onMouseXChanged: value = Math.max(0,Math.min(1,mouseX/width));
onMouseXChanged: if(orientation === Gradient.Horizontal)value = Math.max(0,Math.min(1,mouseX/width));
onMouseYChanged: if(orientation === Gradient.Vertical)value = Math.max(0,Math.min(1,mouseY/height));
}
}
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