overlay-split-view: Add sidebar resizing via drag gestures
This MR adds the ability to resize the sidebar via dragging. Both touch and pointer gestures are supported.
I expect that this will mostly be useful for desktop applications that need to implement the utility pane pattern but use / require manual resizing. Two examples that immediately come to mind are cambalache and gnome-builder. Admittedly, manually resizing a sidebar is "busy work" that would be better if the user did not have to do at all, but sometimes it is unavoidable or expected for a better user experience.
Benefits:
-
I think this would obviate the need for a great deal of libpanel, easing the burden of maintainership on @chergert. gnome-builder would have to be adapted to use(edit: see comments, would be difficult to removeOverlaySplitView
s and anAdwDialog
orAdwBottomSheet
for the bottom utility pane, but this would allow gnome-builder to be fully adaptable and stay up-to-date with libadwaita widgets/features/theming.PanelDock
and libpanel interdependencies from builder). - It could potentially solve issues like this (nautilus#3010) by adding a setting to enable resizing.
- Applications that want or need a resizable sidebar can (potentially) use libadwaita instead of libpanel or something like
GtkPaned
which would be nice! - libpanel wouldn't need (as many?) style updates to maintain compatibility with libadwaita.
Drawbacks:
- More code to maintain.
- ???
Things to note about the implementation / behavior:
- The property (
enable-drag-resize
) isFALSE
by default. - The width set via drag is constrained by the
min-sidebar-width
andmax-sidebar-width
properties, and it cannot exceed the width of theOverlaySplitView
. - Resizing (changing the width) of the
OverlaySplitView
will cause the sidebar to not use the width set via drag and revert to using its other properties likemin-sidebar-width
andmax-sidebar-width
to adjust its size. This preserves its adaptability. Settingenable-drag-resize
toFALSE
will do the same. - The drag width is not constrained by the width of the
content
and if set too large may cause allocation errors as thecontent
no longer has space to layout. Ifenable-drag-resize
is set toTRUE
it would be wise to ensure thatmax-sidebar-width
leaves enough space for thecontent
. This could be changed.
Note: much of this was shamelessly taken and adapted from GtkPaned
.
Edited by Caleb Gartner