Skip to content
Snippets Groups Projects
Commit f50a401a authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

implement major splitter handle

parent 15e732dc
No related branches found
No related tags found
No related merge requests found
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
}
}
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment