Commit f269bda9 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(Paned): display only visible panel(s)

parent 1d681621
...@@ -27,7 +27,7 @@ Item { ...@@ -27,7 +27,7 @@ Item {
property alias childA: contentA.data property alias childA: contentA.data
property alias childB: contentB.data property alias childB: contentB.data
property bool defaultClosed: false property bool defaultClosed: false
property int closingEdge: Qt.LeftEdge property int closingEdge: Qt.LeftEdge // `LeftEdge` or `RightEdge`.
property int defaultChildAWidth property int defaultChildAWidth
property bool resizeAInPriority: false property bool resizeAInPriority: false
...@@ -90,7 +90,7 @@ Item { ...@@ -90,7 +90,7 @@ Item {
// If closed, set correctly the handle position to left or right. // If closed, set correctly the handle position to left or right.
if (_isClosed) { if (_isClosed) {
contentA.width = (closingEdge === Qt.RightEdge) contentA.width = (closingEdge !== Qt.LeftEdge)
? container.width - handle.width ? container.width - handle.width
: 0 : 0
} }
...@@ -161,7 +161,7 @@ Item { ...@@ -161,7 +161,7 @@ Item {
else if (theoreticalBWidth < minimumRightLimit) { else if (theoreticalBWidth < minimumRightLimit) {
contentA.width = container.width - handle.width - minimumRightLimit contentA.width = container.width - handle.width - minimumRightLimit
if (closingEdge === Qt.RightEdge && offset > minimumRightLimit / 2) { if (closingEdge !== Qt.LeftEdge && offset > minimumRightLimit / 2) {
if (_isClosed) { if (_isClosed) {
_open() _open()
} else { } else {
...@@ -202,6 +202,14 @@ Item { ...@@ -202,6 +202,14 @@ Item {
} }
} }
function _isVisible (edge) {
return (
!_isClosed ||
openingTransition.running ||
closingTransition.running
) || closingEdge !== edge
}
// ----------------------------------------------------------------- // -----------------------------------------------------------------
onWidthChanged: _applyLimits() onWidthChanged: _applyLimits()
...@@ -226,6 +234,7 @@ Item { ...@@ -226,6 +234,7 @@ Item {
id: contentA id: contentA
height: parent.height height: parent.height
visible: _isVisible(Qt.LeftEdge)
} }
MouseArea { MouseArea {
...@@ -241,7 +250,7 @@ Item { ...@@ -241,7 +250,7 @@ Item {
onDoubleClicked: _inverseClosingState() onDoubleClicked: _inverseClosingState()
onMouseXChanged: pressed && onMouseXChanged: pressed &&
_applyLimitsOnUserMove(handle.mouseX - _mouseStart) _applyLimitsOnUserMove(mouseX - _mouseStart)
onPressed: _mouseStart = mouseX onPressed: _mouseStart = mouseX
...@@ -261,6 +270,7 @@ Item { ...@@ -261,6 +270,7 @@ Item {
anchors.left: handle.right anchors.left: handle.right
height: parent.height height: parent.height
visible: _isVisible(Qt.RightEdge)
width: container.width - contentA.width - handle.width width: container.width - contentA.width - handle.width
} }
......
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