Commit f50a401a authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

implement major splitter handle

parent 15e732dc
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQml 2.15 // Binding.restoreMode
Control {
id: root
......@@ -91,5 +92,67 @@ Control {
}
}
}
Item {
anchors.fill: parent
Repeater {
model: root.majorCount
Rectangle {
id: majorHandle
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 || !majorDragHandler.active)
return;
let positions = root._majorPositions;
positions[index] = x / contentArea.width;
root._majorPositions = positions;
}
onYChanged: {
if (root.majorOrientation === Qt.Horizontal || !majorDragHandler.active)
return;
let positions = root._majorPositions;
positions[index] = y / contentArea.height;
root._majorPositions = positions;
}
Binding on x {
when: root.majorOrientation === Qt.Horizontal && !majorDragHandler.active
value: contentArea.width * root._majorPositions[majorHandle.index]
restoreMode: Binding.RestoreNone
}
Binding on y {
when: root.majorOrientation !== Qt.Horizontal && !majorDragHandler.active
value: contentArea.height * root._majorPositions[majorHandle.index]
restoreMode: Binding.RestoreNone
}
HoverHandler {
cursorShape: root.majorOrientation === Qt.Horizontal ? Qt.SplitHCursor : Qt.SplitVCursor
}
DragHandler {
id: majorDragHandler
xAxis.enabled: root.majorOrientation === Qt.Horizontal
yAxis.enabled: root.majorOrientation !== Qt.Horizontal
// TODO: minimum/maximum
}
}
}
}
}
}
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