Commit 90ca9a1b authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

implement minor splitter handle

parent f50a401a
......@@ -96,6 +96,87 @@ Control {
Item {
anchors.fill: parent
Repeater {
model: root.majorCount
Item {
id: minorHandleArea
required property int index
readonly property real position: root._majorPositions[index]
readonly property real size: {
(index + 1 < root.majorCount ? root._majorPositions[index + 1] : 1) - position
}
// TODO: maybe raced on majorOrientation changed
anchors.left: root.majorOrientation !== Qt.Horizontal ? parent.left : undefined
anchors.right: root.majorOrientation !== Qt.Horizontal ? parent.right : undefined
anchors.top: root.majorOrientation === Qt.Horizontal ? parent.top : undefined
anchors.bottom: root.majorOrientation === Qt.Horizontal ? parent.bottom : undefined
x: root.majorOrientation === Qt.Horizontal ? contentArea.width * position : 0
y: root.majorOrientation !== Qt.Horizontal ? contentArea.height * position : 0
width: root.majorOrientation === Qt.Horizontal ? contentArea.width * size : 0
height: root.majorOrientation !== Qt.Horizontal ? contentArea.height * size : 0
Repeater {
model: root.minorCounts[minorHandleArea.index]
Rectangle {
id: minorHandle
required property int index
// TODO: race on majorOrientation changed
anchors.left: root.majorOrientation === Qt.Horizontal ? parent.left : undefined
anchors.right: root.majorOrientation === Qt.Horizontal ? parent.right : undefined
anchors.top: root.majorOrientation !== Qt.Horizontal ? parent.top : undefined
anchors.bottom: root.majorOrientation !== Qt.Horizontal ? parent.bottom : undefined
width: 5
height: 5
visible: index > 0
color: "gray"
onXChanged: {
if (root.majorOrientation === Qt.Horizontal || !minorDragHandler.active)
return;
let positions = root._minorPositions;
positions[index] = x / minorHandleArea.width;
root._minorPositions = positions;
}
onYChanged: {
if (root.majorOrientation !== Qt.Horizontal || !minorDragHandler.active)
return;
let positions = root._minorPositions;
positions[index] = y / minorHandleArea.height;
root._minorPositions = positions;
}
Binding on x {
when: root.majorOrientation !== Qt.Horizontal && !minorDragHandler.active
value: minorHandleArea.width * root._minorPositions[minorHandle.index]
restoreMode: Binding.RestoreNone
}
Binding on y {
when: root.majorOrientation === Qt.Horizontal && !minorDragHandler.active
value: minorHandleArea.height * root._minorPositions[minorHandle.index]
restoreMode: Binding.RestoreNone
}
HoverHandler {
cursorShape: root.majorOrientation !== Qt.Horizontal ? Qt.SplitHCursor : Qt.SplitVCursor
}
DragHandler {
id: minorDragHandler
xAxis.enabled: root.majorOrientation !== Qt.Horizontal
yAxis.enabled: root.majorOrientation === Qt.Horizontal
// TODO: minimum/maximum
}
}
}
}
}
Repeater {
model: root.majorCount
Rectangle {
......
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