Commit 385e0ef0 authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

instantiate horizontal/vertical splitters separately

parent 90ca9a1b
......@@ -97,9 +97,9 @@ Control {
anchors.fill: parent
Repeater {
model: root.majorCount
model: root.majorOrientation !== Qt.Horizontal ? root.majorCount : 0
Item {
id: minorHandleArea
id: minorHandleAreaH
required property int index
readonly property real position: root._majorPositions[index]
......@@ -107,69 +107,104 @@ Control {
(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
anchors.left: parent.left
anchors.right: parent.right
y: contentArea.height * position
height: contentArea.height * size
Repeater {
model: root.minorCounts[minorHandleArea.index]
model: root.minorCounts[minorHandleAreaH.index]
Rectangle {
id: minorHandle
id: minorHandleH
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
anchors.top: parent.top
anchors.bottom: parent.bottom
width: 5
height: 5
visible: index > 0
color: "gray"
onXChanged: {
if (root.majorOrientation === Qt.Horizontal || !minorDragHandler.active)
if (!minorDragHandlerH.active)
return;
let positions = root._minorPositions;
positions[index] = x / minorHandleArea.width;
positions[index] = x / minorHandleAreaH.width;
root._minorPositions = positions;
}
Binding on x {
when: !minorDragHandlerH.active
value: minorHandleAreaH.width * root._minorPositions[minorHandleH.index]
restoreMode: Binding.RestoreNone
}
HoverHandler {
cursorShape: Qt.SplitHCursor
}
DragHandler {
id: minorDragHandlerH
xAxis.enabled: root.majorOrientation !== Qt.Horizontal
yAxis.enabled: root.majorOrientation === Qt.Horizontal
// TODO: minimum/maximum
}
}
}
}
}
Repeater {
model: root.majorOrientation === Qt.Horizontal ? root.majorCount : 0
Item {
id: minorHandleAreaV
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
}
anchors.top: parent.top
anchors.bottom: parent.bottom
x: contentArea.width * position
width: contentArea.width * size
Repeater {
model: root.minorCounts[minorHandleAreaV.index]
Rectangle {
id: minorHandleV
required property int index
anchors.left: parent.left
anchors.right: parent.right
height: 5
visible: index > 0
color: "gray"
onYChanged: {
if (root.majorOrientation !== Qt.Horizontal || !minorDragHandler.active)
if (!minorDragHandlerV.active)
return;
let positions = root._minorPositions;
positions[index] = y / minorHandleArea.height;
positions[index] = y / minorHandleAreaV.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]
when: !minorDragHandlerV.active
value: minorHandleAreaV.height * root._minorPositions[minorHandleV.index]
restoreMode: Binding.RestoreNone
}
HoverHandler {
cursorShape: root.majorOrientation !== Qt.Horizontal ? Qt.SplitHCursor : Qt.SplitVCursor
cursorShape: Qt.SplitVCursor
}
DragHandler {
id: minorDragHandler
xAxis.enabled: root.majorOrientation !== Qt.Horizontal
yAxis.enabled: root.majorOrientation === Qt.Horizontal
id: minorDragHandlerV
xAxis.enabled: false
yAxis.enabled: true
// TODO: minimum/maximum
}
}
......@@ -178,58 +213,80 @@ Control {
}
Repeater {
model: root.majorCount
model: root.majorOrientation === Qt.Horizontal ? root.majorCount : 0
Rectangle {
id: majorHandle
id: majorHandleH
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
anchors.top: parent.top
anchors.bottom: parent.bottom
width: 5
height: 5
visible: index > 0
color: "gray"
onXChanged: {
if (root.majorOrientation !== Qt.Horizontal || !majorDragHandler.active)
if (!majorDragHandlerH.active)
return;
let positions = root._majorPositions;
positions[index] = x / contentArea.width;
root._majorPositions = positions;
}
Binding on x {
when: !majorDragHandlerH.active
value: contentArea.width * root._majorPositions[majorHandleH.index]
restoreMode: Binding.RestoreNone
}
HoverHandler {
cursorShape: Qt.SplitHCursor
}
DragHandler {
id: majorDragHandlerH
xAxis.enabled: true
yAxis.enabled: false
// TODO: minimum/maximum
}
}
}
Repeater {
model: root.majorOrientation !== Qt.Horizontal ? root.majorCount : 0
Rectangle {
id: majorHandleV
required property int index
anchors.left: parent.left
anchors.right: parent.right
height: 5
visible: index > 0
color: "gray"
onYChanged: {
if (root.majorOrientation === Qt.Horizontal || !majorDragHandler.active)
if (!majorDragHandlerV.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]
when: !majorDragHandlerV.active
value: contentArea.height * root._majorPositions[majorHandleV.index]
restoreMode: Binding.RestoreNone
}
HoverHandler {
cursorShape: root.majorOrientation === Qt.Horizontal ? Qt.SplitHCursor : Qt.SplitVCursor
cursorShape: Qt.SplitVCursor
}
DragHandler {
id: majorDragHandler
xAxis.enabled: root.majorOrientation === Qt.Horizontal
yAxis.enabled: root.majorOrientation !== Qt.Horizontal
id: majorDragHandlerV
xAxis.enabled: false
yAxis.enabled: true
// 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