Scrolling
Everything that scrolls in GTK is one of four widgets. Gtk.ScrolledWindow is the
container you actually reach for; it puts its child in a Gtk.Viewport and
draws up to two **Gtk.Scrollbar**s beside it. Gtk.WindowHandle is not part of
that group at all — it is the titlebar strip — and it is here because it is the
fourth of the widgets this page covers.
None of the four is an Adwaita widget: libadwaita ships no scrolling widget and
styles only the scrollbars, which is what Gtk.Scrollbar’s block below shows
most of.
Scrolled Window
Section titled “Scrolled Window”One child, two adjustments, and a scrollbar per axis that appears only when there is something to scroll. The two policies decide whether a bar appears, window-placement which edge it takes, and overlay-scrolling turns the bars into the auto-hiding indicators GNOME draws over the content instead of beside it.
The keys are GTK’s, and they are not the obvious ones: every arrow and every Home/End needs Control, and Page Up/Down is the vertical axis bare while Ctrl+Page Up/Down is the horizontal one.
Scrollbar
Section titled “Scrollbar”A trough and a slider, positioned by an adjustment. Its geometry is GtkRange’s
and the two numbers it is made of do not share a denominator: the slider is
page_size over the WHOLE range long, and it sits at the position over the
SCROLLABLE range — the whole one less the page. That is why a long adjustment
keeps a grabbable thumb instead of shrinking to nothing.
GtkScrollbar has no adjustment of its own — unlike GtkRange, it makes none —
so the third bar below, which is given none, is a bar over an empty range: the
thumb fills the trough and cannot move.
Viewport
Section titled “Viewport”The widget under a scrolled window’s child: “implements scrollability for widgets that don’t support scrolling on their own”. It has one property of its own, scroll-to-focus — whether a widget that takes the focus is scrolled into view — and its adjustments are its own: a step is a tenth of the window and a page nine tenths of it, whatever it wraps.
The child is allocated its natural size and never shrunk, so content wider than the window scrolls sideways instead of being squeezed into it.
Window Handle
Section titled “Window Handle”The titlebar strip. It is the fourth widget on this page and the only one that is
not about scrolling: dragging it moves the window, and a double click, a middle
click and a right click raise the window actions the compositor names — or, where
there is none, the gtk-titlebar-double-click, -middle-click and -right-click
settings, whose values are toggle-maximize, lower, minimize, menu and
none.
A document cannot move or unmaximize the window it is rendered in, and no web API
asks it to. The web port therefore reads the same three settings as attributes
and raises the same action names as events: a titlebar-action event for every
gesture, plus one event named for the action it chose.
Related
Section titled “Related”- Layout: the separator and the layout widgets libadwaita only styles.
- Buttons: the button, the toggle button and the menu button.
- Adwaita Layout: header bars, clamps and toolbar views — and the toolbar view, whose content area is a scrolled window.
- Adwaita Storybook: the same widgets in a live component browser you can poke at.