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