HDrawer: snap around default size when resize-drag
This commit is contained in:
parent
b4df752f8a
commit
e9efca76d4
1
TODO.md
1
TODO.md
|
@ -86,7 +86,6 @@
|
||||||
- Drop the `buttonModel`/`buttonCallbacks` HBox approach
|
- Drop the `buttonModel`/`buttonCallbacks` HBox approach
|
||||||
- Scrollable popups and room settings
|
- Scrollable popups and room settings
|
||||||
- Improve when HDrawer should collapse when the ui is zoomed
|
- Improve when HDrawer should collapse when the ui is zoomed
|
||||||
- HDrawer snapping
|
|
||||||
- Make theme error/etc text colors more like name colors
|
- Make theme error/etc text colors more like name colors
|
||||||
- In account settings, display name field text should be colored
|
- In account settings, display name field text should be colored
|
||||||
- Way to open context menus without a right mouse button
|
- Way to open context menus without a right mouse button
|
||||||
|
|
|
@ -46,6 +46,9 @@ Drawer {
|
||||||
property int maximumSize:
|
property int maximumSize:
|
||||||
horizontal ? referenceSizeParent.width : referenceSizeParent.height
|
horizontal ? referenceSizeParent.width : referenceSizeParent.height
|
||||||
|
|
||||||
|
property int snapAt: defaultSize
|
||||||
|
property int snapZone: theme.spacing * 2
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
property Item referenceSizeParent: parent
|
property Item referenceSizeParent: parent
|
||||||
|
@ -105,19 +108,26 @@ Drawer {
|
||||||
|
|
||||||
onMouseXChanged:
|
onMouseXChanged:
|
||||||
if (horizontal && pressed) {
|
if (horizontal && pressed) {
|
||||||
drawer.preferredSize =
|
drawer.preferredSize = snapSize(
|
||||||
drawer.calculatedSize +
|
drawer.calculatedSize +
|
||||||
(drawer.edge === Qt.RightEdge ? -mouseX : mouseX)
|
(drawer.edge === Qt.RightEdge ? -mouseX : mouseX)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
onMouseYChanged:
|
onMouseYChanged:
|
||||||
if (vertical && pressed) {
|
if (vertical && pressed) {
|
||||||
drawer.preferredSize =
|
drawer.preferredSize = snapSize(
|
||||||
drawer.calculatedSize +
|
drawer.calculatedSize +
|
||||||
(drawer.edge === Qt.BottomEdge ? -mouseY : mouseY)
|
(drawer.edge === Qt.BottomEdge ? -mouseY : mouseY)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
onReleased: window.saveState(drawer)
|
onReleased: window.saveState(drawer)
|
||||||
|
|
||||||
|
function snapSize(num) {
|
||||||
|
return num < snapAt + snapZone && num > snapAt - snapZone ?
|
||||||
|
snapAt : num
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user