@gjsify/adwaita-web 0.54.0 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/adwaita-web.css +8146 -3011
- package/dist/adwaita-web.css.map +1 -1
- package/lib/types/adw-application-window.spec.d.ts +1 -0
- package/lib/types/adw-bin.spec.d.ts +1 -0
- package/lib/types/adw-breakpoint-bin.spec.d.ts +1 -0
- package/lib/types/adw-clamp-scrollable.spec.d.ts +1 -0
- package/lib/types/adw-multi-layout-view.spec.d.ts +1 -0
- package/lib/types/adw-preferences-row.spec.d.ts +1 -0
- package/lib/types/adw-shortcuts.spec.d.ts +1 -0
- package/lib/types/adw-status-page.spec.d.ts +1 -0
- package/lib/types/adw-tab-bar.spec.d.ts +1 -0
- package/lib/types/adw-tab-button.spec.d.ts +1 -0
- package/lib/types/adw-tab-overview.spec.d.ts +1 -0
- package/lib/types/adw-view-switcher-sidebar.spec.d.ts +1 -0
- package/lib/types/adw-window.spec.d.ts +1 -0
- package/lib/types/attributes.d.ts +19 -0
- package/lib/types/breakpoints.d.ts +14 -3
- package/lib/types/construct-vectors.spec.d.ts +1 -0
- package/lib/types/elements/adw-action-row.d.ts +4 -0
- package/lib/types/elements/adw-application-window.d.ts +27 -0
- package/lib/types/elements/adw-bin.d.ts +17 -0
- package/lib/types/elements/adw-breakpoint-bin.d.ts +67 -0
- package/lib/types/elements/adw-clamp-scrollable.d.ts +38 -0
- package/lib/types/elements/adw-combo-row.d.ts +4 -0
- package/lib/types/elements/adw-dialog.d.ts +10 -0
- package/lib/types/elements/adw-entry-row.d.ts +6 -0
- package/lib/types/elements/adw-expander-row.d.ts +2 -0
- package/lib/types/elements/adw-header-bar.d.ts +6 -0
- package/lib/types/elements/adw-layout-slot.d.ts +19 -0
- package/lib/types/elements/adw-multi-layout-view.d.ts +101 -0
- package/lib/types/elements/adw-overlay-split-view.d.ts +13 -0
- package/lib/types/elements/adw-preferences-row.d.ts +31 -0
- package/lib/types/elements/adw-shortcuts-dialog.d.ts +13 -0
- package/lib/types/elements/adw-shortcuts-item.d.ts +36 -0
- package/lib/types/elements/adw-shortcuts-section.d.ts +14 -0
- package/lib/types/elements/adw-sidebar.d.ts +8 -2
- package/lib/types/elements/adw-spin-row.d.ts +6 -0
- package/lib/types/elements/adw-switch-row.d.ts +7 -0
- package/lib/types/elements/adw-tab-bar.d.ts +108 -0
- package/lib/types/elements/adw-tab-button.d.ts +32 -0
- package/lib/types/elements/adw-tab-overview.d.ts +199 -0
- package/lib/types/elements/adw-tab-view.d.ts +19 -23
- package/lib/types/elements/adw-toggle-group.d.ts +17 -0
- package/lib/types/elements/adw-view-switcher-sidebar.d.ts +84 -0
- package/lib/types/elements/adw-window.d.ts +40 -0
- package/lib/types/elements/gtk-about-dialog.d.ts +146 -0
- package/lib/types/elements/gtk-application-window.d.ts +34 -0
- package/lib/types/elements/gtk-aspect-frame.d.ts +27 -0
- package/lib/types/elements/gtk-button.d.ts +9 -0
- package/lib/types/elements/gtk-calendar.d.ts +159 -0
- package/lib/types/elements/gtk-center-box.d.ts +39 -0
- package/lib/types/elements/gtk-color-dialog-button.d.ts +69 -0
- package/lib/types/elements/gtk-column-view.d.ts +50 -0
- package/lib/types/elements/gtk-drag-icon.d.ts +78 -0
- package/lib/types/elements/gtk-drawing-area.d.ts +95 -0
- package/lib/types/elements/gtk-editable-label.d.ts +33 -0
- package/lib/types/elements/gtk-emoji-chooser.d.ts +84 -0
- package/lib/types/elements/gtk-entry.d.ts +20 -1
- package/lib/types/elements/gtk-expander.d.ts +49 -0
- package/lib/types/elements/gtk-fixed.d.ts +13 -0
- package/lib/types/elements/gtk-flow-box-child.d.ts +14 -0
- package/lib/types/elements/gtk-flow-box.d.ts +87 -0
- package/lib/types/elements/gtk-font-dialog-button.d.ts +83 -0
- package/lib/types/elements/gtk-frame.d.ts +24 -0
- package/lib/types/elements/gtk-gl-area.d.ts +136 -0
- package/lib/types/elements/gtk-graphics-offload.d.ts +24 -0
- package/lib/types/elements/gtk-grid-view.d.ts +39 -0
- package/lib/types/elements/gtk-grid.d.ts +27 -0
- package/lib/types/elements/gtk-header-bar.d.ts +60 -0
- package/lib/types/elements/gtk-inscription.d.ts +64 -0
- package/lib/types/elements/gtk-label.d.ts +3 -0
- package/lib/types/elements/gtk-level-bar.d.ts +59 -0
- package/lib/types/elements/gtk-link-button.d.ts +29 -0
- package/lib/types/elements/gtk-list-box-row.d.ts +54 -0
- package/lib/types/elements/gtk-list-box.d.ts +100 -0
- package/lib/types/elements/gtk-list-view.d.ts +73 -0
- package/lib/types/elements/gtk-media-controls.d.ts +142 -0
- package/lib/types/elements/gtk-notebook.d.ts +148 -0
- package/lib/types/elements/gtk-overlay.d.ts +22 -0
- package/lib/types/elements/gtk-page-setup-unix-dialog.d.ts +87 -0
- package/lib/types/elements/gtk-paned.d.ts +121 -0
- package/lib/types/elements/gtk-password-entry.d.ts +27 -0
- package/lib/types/elements/gtk-picture.d.ts +66 -0
- package/lib/types/elements/gtk-popover-bin.d.ts +82 -0
- package/lib/types/elements/gtk-popover-menu-bar.d.ts +66 -0
- package/lib/types/elements/gtk-popover-menu.d.ts +83 -0
- package/lib/types/elements/gtk-popover.d.ts +28 -3
- package/lib/types/elements/gtk-print-unix-dialog.d.ts +167 -0
- package/lib/types/elements/gtk-revealer.d.ts +55 -0
- package/lib/types/elements/gtk-scale-button.d.ts +59 -0
- package/lib/types/elements/gtk-scale.d.ts +98 -0
- package/lib/types/elements/gtk-scrollbar.d.ts +124 -0
- package/lib/types/elements/gtk-scrolled-window.d.ts +129 -0
- package/lib/types/elements/gtk-search-bar.d.ts +39 -0
- package/lib/types/elements/gtk-search-entry.d.ts +27 -0
- package/lib/types/elements/gtk-separator.d.ts +10 -0
- package/lib/types/elements/gtk-spin-button.d.ts +94 -0
- package/lib/types/elements/gtk-spinner.d.ts +14 -0
- package/lib/types/elements/gtk-stack-sidebar.d.ts +43 -0
- package/lib/types/elements/gtk-stack-switcher.d.ts +58 -0
- package/lib/types/elements/gtk-stack.d.ts +154 -0
- package/lib/types/elements/gtk-switch.d.ts +4 -1
- package/lib/types/elements/gtk-text-view.d.ts +62 -0
- package/lib/types/elements/gtk-text.d.ts +45 -0
- package/lib/types/elements/gtk-toggle-button.d.ts +45 -0
- package/lib/types/elements/gtk-tree-expander.d.ts +38 -0
- package/lib/types/elements/gtk-video.d.ts +97 -0
- package/lib/types/elements/gtk-viewport.d.ts +84 -0
- package/lib/types/elements/gtk-window-controls.d.ts +80 -0
- package/lib/types/elements/gtk-window-handle.d.ts +39 -0
- package/lib/types/elements/gtk-window.d.ts +103 -0
- package/lib/types/elements/justification.d.ts +2 -0
- package/lib/types/elements/popover-menu.d.ts +18 -0
- package/lib/types/elements/roving-focus.d.ts +29 -1
- package/lib/types/emoji-data.d.ts +38 -0
- package/lib/types/font-description.d.ts +96 -0
- package/lib/types/gtk-about-dialog.spec.d.ts +1 -0
- package/lib/types/gtk-action-bar.spec.d.ts +1 -0
- package/lib/types/gtk-application-window.spec.d.ts +1 -0
- package/lib/types/gtk-aspect-frame.spec.d.ts +1 -0
- package/lib/types/gtk-calendar.spec.d.ts +1 -0
- package/lib/types/gtk-center-box.spec.d.ts +1 -0
- package/lib/types/gtk-color-dialog-button.spec.d.ts +1 -0
- package/lib/types/gtk-column-view.spec.d.ts +1 -0
- package/lib/types/gtk-drag-icon.spec.d.ts +1 -0
- package/lib/types/gtk-drawing-area.spec.d.ts +1 -0
- package/lib/types/gtk-editable-label.spec.d.ts +1 -0
- package/lib/types/gtk-emoji-chooser.spec.d.ts +1 -0
- package/lib/types/gtk-expander.spec.d.ts +1 -0
- package/lib/types/gtk-fixed.spec.d.ts +1 -0
- package/lib/types/gtk-flow-box.spec.d.ts +1 -0
- package/lib/types/gtk-font-dialog-button.spec.d.ts +1 -0
- package/lib/types/gtk-frame.spec.d.ts +1 -0
- package/lib/types/gtk-gl-area.spec.d.ts +1 -0
- package/lib/types/gtk-graphics-offload.spec.d.ts +1 -0
- package/lib/types/gtk-grid-view.spec.d.ts +1 -0
- package/lib/types/gtk-grid.spec.d.ts +1 -0
- package/lib/types/gtk-header-bar.spec.d.ts +1 -0
- package/lib/types/gtk-inscription.spec.d.ts +1 -0
- package/lib/types/gtk-level-bar.spec.d.ts +1 -0
- package/lib/types/gtk-link-button.spec.d.ts +1 -0
- package/lib/types/gtk-list-box.spec.d.ts +1 -0
- package/lib/types/gtk-list-view.spec.d.ts +1 -0
- package/lib/types/gtk-media-controls.spec.d.ts +1 -0
- package/lib/types/gtk-notebook.spec.d.ts +1 -0
- package/lib/types/gtk-overlay.spec.d.ts +1 -0
- package/lib/types/gtk-paned.spec.d.ts +1 -0
- package/lib/types/gtk-password-entry.spec.d.ts +1 -0
- package/lib/types/gtk-picture.spec.d.ts +1 -0
- package/lib/types/gtk-popover-bin.spec.d.ts +1 -0
- package/lib/types/gtk-popover-menu-bar.spec.d.ts +1 -0
- package/lib/types/gtk-popover-menu.spec.d.ts +1 -0
- package/lib/types/gtk-popover-role.spec.d.ts +1 -0
- package/lib/types/gtk-popover.spec.d.ts +1 -0
- package/lib/types/gtk-print-dialogs.spec.d.ts +1 -0
- package/lib/types/gtk-revealer.spec.d.ts +1 -0
- package/lib/types/gtk-scale-button.spec.d.ts +1 -0
- package/lib/types/gtk-scale.spec.d.ts +1 -0
- package/lib/types/gtk-scrollbar.spec.d.ts +1 -0
- package/lib/types/gtk-scrolled-window.spec.d.ts +1 -0
- package/lib/types/gtk-search-bar.spec.d.ts +1 -0
- package/lib/types/gtk-search-entry.spec.d.ts +1 -0
- package/lib/types/gtk-separator.spec.d.ts +1 -0
- package/lib/types/gtk-spin-button.spec.d.ts +1 -0
- package/lib/types/gtk-spinner.spec.d.ts +1 -0
- package/lib/types/gtk-stack-sidebar.spec.d.ts +1 -0
- package/lib/types/gtk-stack-switcher.spec.d.ts +1 -0
- package/lib/types/gtk-stack.spec.d.ts +1 -0
- package/lib/types/gtk-text-view.spec.d.ts +1 -0
- package/lib/types/gtk-text.spec.d.ts +1 -0
- package/lib/types/gtk-toggle-button.spec.d.ts +1 -0
- package/lib/types/gtk-tree-expander.spec.d.ts +1 -0
- package/lib/types/gtk-video.spec.d.ts +1 -0
- package/lib/types/gtk-viewport.spec.d.ts +1 -0
- package/lib/types/gtk-window-controls.spec.d.ts +1 -0
- package/lib/types/gtk-window-handle.spec.d.ts +1 -0
- package/lib/types/gtk-window.spec.d.ts +1 -0
- package/lib/types/index.d.ts +4 -1
- package/lib/types/list-view-dom.d.ts +44 -0
- package/lib/types/namespace/adw.d.ts +12 -0
- package/lib/types/namespace/gtk.d.ts +61 -0
- package/lib/types/page-setup.d.ts +100 -0
- package/lib/types/row-line-clamp.d.ts +20 -0
- package/lib/types/row-tooltip.d.ts +8 -0
- package/lib/types/row-tooltip.spec.d.ts +1 -0
- package/lib/types/scroll-shading.d.ts +15 -1
- package/lib/types/shared-tree-builder.d.ts +75 -17
- package/lib/types/shared-tree-mount.spec.d.ts +1 -0
- package/lib/types/signals.d.ts +4 -0
- package/lib/types/styles.generated.d.ts +1 -1
- package/lib/types/tab-chip.d.ts +73 -0
- package/lib/types/template-classes.d.ts +11 -0
- package/lib/types/widget-size.spec.d.ts +1 -0
- package/package.json +12 -8
- package/scss/_action_row.scss +41 -17
- package/scss/_application_window.scss +26 -0
- package/scss/_aspect_frame.scss +25 -0
- package/scss/_bin.scss +26 -0
- package/scss/_button.scss +45 -0
- package/scss/_button_row.scss +5 -0
- package/scss/_calendar.scss +176 -0
- package/scss/_center_box.scss +25 -0
- package/scss/_checks.scss +6 -1
- package/scss/_clamp_scrollable.scss +28 -0
- package/scss/_color_button.scss +67 -0
- package/scss/_column_view.scss +126 -0
- package/scss/_drag_icon.scss +55 -0
- package/scss/_drawing.scss +85 -0
- package/scss/_emoji_chooser.scss +213 -0
- package/scss/_entry.scss +13 -5
- package/scss/_entry_row.scss +1 -1
- package/scss/_expander.scss +113 -0
- package/scss/_expander_row.scss +36 -3
- package/scss/_fixed.scss +29 -0
- package/scss/_flow_box.scss +94 -0
- package/scss/_font_button.scss +63 -0
- package/scss/_frame.scss +41 -0
- package/scss/_grid.scss +19 -0
- package/scss/_grid_view.scss +46 -0
- package/scss/_gtk_about_dialog.scss +186 -0
- package/scss/_headerbar.scss +134 -1
- package/scss/_icons.generated.scss +186 -0
- package/scss/_inscription.scss +125 -0
- package/scss/_level_bar.scss +190 -0
- package/scss/_link.scss +82 -0
- package/scss/_list_box.scss +88 -0
- package/scss/_list_view.scss +96 -0
- package/scss/_media_controls.scss +139 -0
- package/scss/_overlay.scss +68 -0
- package/scss/_paned.scss +130 -0
- package/scss/_password_entry.scss +83 -0
- package/scss/_picture.scss +80 -0
- package/scss/_popover_bin.scss +53 -0
- package/scss/_popover_menu_bar.scss +104 -0
- package/scss/_preferences_row.scss +60 -0
- package/scss/_print_dialogs.scss +328 -0
- package/scss/_reset.scss +21 -19
- package/scss/_revealer.scss +37 -0
- package/scss/_row.scss +36 -5
- package/scss/_scale.scss +298 -0
- package/scss/_scale_button.scss +167 -0
- package/scss/_scrollbar.scss +230 -0
- package/scss/_scrolled_window.scss +131 -0
- package/scss/_search_bar.scss +118 -0
- package/scss/_search_entry.scss +86 -0
- package/scss/_separator.scss +44 -0
- package/scss/_shortcuts_dialog.scss +100 -0
- package/scss/_spin_button.scss +172 -0
- package/scss/_spin_row.scss +56 -8
- package/scss/_spinner.scss +85 -4
- package/scss/_stack.scss +729 -0
- package/scss/_status_page.scss +1 -1
- package/scss/_switch.scss +13 -5
- package/scss/_switch_row.scss +10 -0
- package/scss/_tab_bar.scss +317 -0
- package/scss/_tab_button.scss +98 -0
- package/scss/_tab_overview.scss +483 -0
- package/scss/_text.scss +182 -0
- package/scss/_theme.scss +1 -1
- package/scss/_toggle_group.scss +28 -0
- package/scss/_tree_expander.scss +62 -0
- package/scss/_variables.scss +1 -1
- package/scss/_video.scss +146 -0
- package/scss/_view_switcher_sidebar.scss +112 -0
- package/scss/_viewport.scss +50 -0
- package/scss/_widget.scss +14 -3
- package/scss/_window.scss +131 -2
- package/scss/_window_handle.scss +20 -0
- package/scss/adwaita-skin.scss +109 -0
- package/src/adw-action-rows.spec.ts +331 -0
- package/src/adw-application-window.spec.ts +118 -0
- package/src/adw-bin.spec.ts +75 -0
- package/src/adw-breakpoint-bin.spec.ts +324 -0
- package/src/adw-clamp-scrollable.spec.ts +189 -0
- package/src/adw-header-bar.spec.ts +18 -0
- package/src/adw-multi-layout-view.spec.ts +243 -0
- package/src/adw-preferences-row.spec.ts +164 -0
- package/src/adw-row-state.spec.ts +142 -0
- package/src/adw-shortcuts.spec.ts +155 -0
- package/src/adw-status-page.spec.ts +124 -0
- package/src/adw-tab-bar.spec.ts +287 -0
- package/src/adw-tab-button.spec.ts +101 -0
- package/src/adw-tab-overview.spec.ts +443 -0
- package/src/adw-view-switcher-sidebar.spec.ts +281 -0
- package/src/adw-window.spec.ts +129 -0
- package/src/attributes.ts +52 -0
- package/src/breakpoints.ts +25 -8
- package/src/capabilities.d.mts +3 -0
- package/src/capabilities.mjs +21 -0
- package/src/connect-lifecycle.spec.ts +12 -0
- package/src/construct-vectors.spec.ts +175 -0
- package/src/elements/adw-action-row.ts +31 -2
- package/src/elements/adw-alert-dialog.ts +4 -1
- package/src/elements/adw-application-window.ts +154 -0
- package/src/elements/adw-bin.ts +101 -0
- package/src/elements/adw-breakpoint-bin.ts +287 -0
- package/src/elements/adw-button-row.ts +7 -1
- package/src/elements/adw-clamp-scrollable.ts +207 -0
- package/src/elements/adw-combo-row.ts +26 -1
- package/src/elements/adw-dialog.ts +19 -0
- package/src/elements/adw-entry-row.ts +22 -12
- package/src/elements/adw-expander-row.ts +34 -1
- package/src/elements/adw-header-bar.ts +18 -4
- package/src/elements/adw-layout-slot.ts +95 -0
- package/src/elements/adw-multi-layout-view.ts +326 -0
- package/src/elements/adw-overlay-split-view.ts +29 -6
- package/src/elements/adw-preferences-row.ts +153 -0
- package/src/elements/adw-shortcuts-dialog.ts +52 -0
- package/src/elements/adw-shortcuts-item.ts +171 -0
- package/src/elements/adw-shortcuts-section.ts +86 -0
- package/src/elements/adw-sidebar.ts +74 -7
- package/src/elements/adw-spin-row.ts +37 -2
- package/src/elements/adw-status-page.ts +10 -2
- package/src/elements/adw-switch-row.ts +53 -2
- package/src/elements/adw-tab-bar.ts +529 -0
- package/src/elements/adw-tab-button.ts +194 -0
- package/src/elements/adw-tab-overview.ts +1011 -0
- package/src/elements/adw-tab-view.ts +66 -145
- package/src/elements/adw-toggle-group.ts +138 -14
- package/src/elements/adw-view-stack.ts +18 -0
- package/src/elements/adw-view-switcher-sidebar.ts +332 -0
- package/src/elements/adw-window.ts +190 -11
- package/src/elements/checks.ts +35 -8
- package/src/elements/gtk-about-dialog.ts +811 -0
- package/src/elements/gtk-application-window.ts +108 -0
- package/src/elements/gtk-aspect-frame.ts +160 -0
- package/src/elements/gtk-button.ts +12 -0
- package/src/elements/gtk-calendar.ts +757 -0
- package/src/elements/gtk-center-box.ts +184 -0
- package/src/elements/gtk-color-dialog-button.ts +278 -0
- package/src/elements/gtk-column-view.ts +320 -0
- package/src/elements/gtk-drag-icon.ts +257 -0
- package/src/elements/gtk-drawing-area.ts +303 -0
- package/src/elements/gtk-editable-label.ts +204 -0
- package/src/elements/gtk-emoji-chooser.ts +542 -0
- package/src/elements/gtk-entry.ts +39 -5
- package/src/elements/gtk-expander.ts +301 -0
- package/src/elements/gtk-fixed.ts +99 -0
- package/src/elements/gtk-flow-box-child.ts +68 -0
- package/src/elements/gtk-flow-box.ts +480 -0
- package/src/elements/gtk-font-dialog-button.ts +432 -0
- package/src/elements/gtk-frame.ts +174 -0
- package/src/elements/gtk-gl-area.ts +476 -0
- package/src/elements/gtk-graphics-offload.ts +130 -0
- package/src/elements/gtk-grid-view.ts +168 -0
- package/src/elements/gtk-grid.ts +127 -0
- package/src/elements/gtk-header-bar.ts +273 -0
- package/src/elements/gtk-inscription.ts +387 -0
- package/src/elements/gtk-label.ts +19 -11
- package/src/elements/gtk-level-bar.ts +323 -0
- package/src/elements/gtk-link-button.ts +138 -0
- package/src/elements/gtk-list-box-row.ts +195 -0
- package/src/elements/gtk-list-box.ts +413 -0
- package/src/elements/gtk-list-view.ts +370 -0
- package/src/elements/gtk-media-controls.ts +509 -0
- package/src/elements/gtk-notebook.ts +664 -0
- package/src/elements/gtk-overlay.ts +149 -0
- package/src/elements/gtk-page-setup-unix-dialog.ts +420 -0
- package/src/elements/gtk-paned.ts +597 -0
- package/src/elements/gtk-password-entry.ts +170 -0
- package/src/elements/gtk-picture.ts +254 -0
- package/src/elements/gtk-popover-bin.ts +332 -0
- package/src/elements/gtk-popover-menu-bar.ts +355 -0
- package/src/elements/gtk-popover-menu.ts +339 -0
- package/src/elements/gtk-popover.ts +92 -10
- package/src/elements/gtk-print-unix-dialog.ts +989 -0
- package/src/elements/gtk-progress-bar.ts +24 -11
- package/src/elements/gtk-revealer.ts +406 -0
- package/src/elements/gtk-scale-button.ts +358 -0
- package/src/elements/gtk-scale.ts +492 -0
- package/src/elements/gtk-scrollbar.ts +528 -0
- package/src/elements/gtk-scrolled-window.ts +653 -0
- package/src/elements/gtk-search-bar.ts +200 -0
- package/src/elements/gtk-search-entry.ts +172 -0
- package/src/elements/gtk-separator.ts +52 -0
- package/src/elements/gtk-spin-button.ts +475 -0
- package/src/elements/gtk-spinner.ts +126 -0
- package/src/elements/gtk-stack-sidebar.ts +212 -0
- package/src/elements/gtk-stack-switcher.ts +279 -0
- package/src/elements/gtk-stack.ts +748 -0
- package/src/elements/gtk-switch.ts +52 -19
- package/src/elements/gtk-text-view.ts +290 -0
- package/src/elements/gtk-text.ts +219 -0
- package/src/elements/gtk-toggle-button.ts +239 -0
- package/src/elements/gtk-tree-expander.ts +243 -0
- package/src/elements/gtk-video.ts +423 -0
- package/src/elements/gtk-viewport.ts +277 -0
- package/src/elements/gtk-window-controls.ts +341 -0
- package/src/elements/gtk-window-handle.ts +221 -0
- package/src/elements/gtk-window.ts +372 -0
- package/src/elements/justification.ts +24 -0
- package/src/elements/popover-menu.ts +24 -0
- package/src/elements/roving-focus.ts +53 -21
- package/src/emoji-data.ts +577 -0
- package/src/entry-rows.spec.ts +31 -0
- package/src/font-description.ts +238 -0
- package/src/gtk-about-dialog.spec.ts +250 -0
- package/src/gtk-action-bar.spec.ts +89 -0
- package/src/gtk-application-window.spec.ts +107 -0
- package/src/gtk-aspect-frame.spec.ts +114 -0
- package/src/gtk-calendar.spec.ts +589 -0
- package/src/gtk-center-box.spec.ts +125 -0
- package/src/gtk-color-dialog-button.spec.ts +141 -0
- package/src/gtk-column-view.spec.ts +154 -0
- package/src/gtk-drag-icon.spec.ts +190 -0
- package/src/gtk-drawing-area.spec.ts +211 -0
- package/src/gtk-editable-label.spec.ts +190 -0
- package/src/gtk-emoji-chooser.spec.ts +173 -0
- package/src/gtk-entry.spec.ts +23 -0
- package/src/gtk-expander.spec.ts +170 -0
- package/src/gtk-fixed.spec.ts +97 -0
- package/src/gtk-flow-box.spec.ts +289 -0
- package/src/gtk-font-dialog-button.spec.ts +166 -0
- package/src/gtk-frame.spec.ts +119 -0
- package/src/gtk-gl-area.spec.ts +361 -0
- package/src/gtk-graphics-offload.spec.ts +119 -0
- package/src/gtk-grid-view.spec.ts +106 -0
- package/src/gtk-grid.spec.ts +122 -0
- package/src/gtk-header-bar.spec.ts +202 -0
- package/src/gtk-inscription.spec.ts +235 -0
- package/src/gtk-level-bar.spec.ts +199 -0
- package/src/gtk-link-button.spec.ts +117 -0
- package/src/gtk-list-box.spec.ts +422 -0
- package/src/gtk-list-view.spec.ts +203 -0
- package/src/gtk-media-controls.spec.ts +295 -0
- package/src/gtk-notebook.spec.ts +546 -0
- package/src/gtk-overlay.spec.ts +141 -0
- package/src/gtk-paned.spec.ts +267 -0
- package/src/gtk-password-entry.spec.ts +150 -0
- package/src/gtk-picture.spec.ts +172 -0
- package/src/gtk-popover-bin.spec.ts +229 -0
- package/src/gtk-popover-menu-bar.spec.ts +296 -0
- package/src/gtk-popover-menu.spec.ts +261 -0
- package/src/gtk-popover-role.spec.ts +138 -0
- package/src/gtk-popover.spec.ts +264 -0
- package/src/gtk-print-dialogs.spec.ts +251 -0
- package/src/gtk-revealer.spec.ts +164 -0
- package/src/gtk-scale-button.spec.ts +218 -0
- package/src/gtk-scale.spec.ts +213 -0
- package/src/gtk-scrollbar.spec.ts +244 -0
- package/src/gtk-scrolled-window.spec.ts +262 -0
- package/src/gtk-search-bar.spec.ts +179 -0
- package/src/gtk-search-entry.spec.ts +142 -0
- package/src/gtk-separator.spec.ts +74 -0
- package/src/gtk-spin-button.spec.ts +186 -0
- package/src/gtk-spinner.spec.ts +130 -0
- package/src/gtk-stack-sidebar.spec.ts +217 -0
- package/src/gtk-stack-switcher.spec.ts +249 -0
- package/src/gtk-stack.spec.ts +432 -0
- package/src/gtk-text-view.spec.ts +189 -0
- package/src/gtk-text.spec.ts +163 -0
- package/src/gtk-toggle-button.spec.ts +186 -0
- package/src/gtk-tree-expander.spec.ts +201 -0
- package/src/gtk-video.spec.ts +240 -0
- package/src/gtk-viewport.spec.ts +140 -0
- package/src/gtk-window-controls.spec.ts +232 -0
- package/src/gtk-window-handle.spec.ts +158 -0
- package/src/gtk-window.spec.ts +202 -0
- package/src/index.ts +9 -1
- package/src/keyboard-operable.spec.ts +77 -9
- package/src/list-view-dom.ts +121 -0
- package/src/namespace/adw.ts +12 -0
- package/src/namespace/gtk.ts +61 -0
- package/src/page-setup.ts +222 -0
- package/src/row-line-clamp.ts +74 -0
- package/src/row-tooltip.spec.ts +313 -0
- package/src/row-tooltip.ts +52 -0
- package/src/scroll-shading.ts +18 -1
- package/src/shared-tree-builder.ts +336 -41
- package/src/shared-tree-mount.spec.ts +130 -0
- package/src/shared-trees.spec.ts +15 -0
- package/src/signals.ts +15 -0
- package/src/style-classes.spec.ts +9 -8
- package/src/styles.generated.ts +1 -1
- package/src/tab-chip.ts +200 -0
- package/src/template-classes.ts +45 -0
- package/src/test.browser.mts +160 -0
- package/src/widget-size.spec.ts +117 -0
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
// <gtk-scrollbar> — the trough-and-slider a `GtkScrolledWindow` draws on each edge it can
|
|
2
|
+
// scroll, and a widget in its own right (GTK ships one; a caller rarely builds one).
|
|
3
|
+
//
|
|
4
|
+
// IT IS A `GtkRange`, AND THE RANGE IS ITS CHILD, NOT ITS SIBLING. `GtkScrollbar` creates a
|
|
5
|
+
// `GtkRange` and parents it to itself (`gtkscrollbar.c:263-278`), so the CSS node is
|
|
6
|
+
//
|
|
7
|
+
// scrollbar
|
|
8
|
+
// ╰── range[.fine-tune]
|
|
9
|
+
// ╰── trough
|
|
10
|
+
// ╰── slider
|
|
11
|
+
//
|
|
12
|
+
// and the slider's GEOMETRY is `GtkRange`'s: `gtk_range_compute_slider_position` makes the
|
|
13
|
+
// slider `trough * page_size / (upper - lower)` long and places it at
|
|
14
|
+
// `(trough - slider) * (value - lower) / (upper - lower - page_size)` — two DIFFERENT
|
|
15
|
+
// denominators, which is why both are computed here rather than written as two
|
|
16
|
+
// percentages of one length. The `range` level has no element of its own here; the
|
|
17
|
+
// trough-and-slider pair is the two nodes below it, and `_scrollbar.scss` says so where
|
|
18
|
+
// the selectors are rewritten.
|
|
19
|
+
//
|
|
20
|
+
// `GtkScrollbar` has TWO properties: `adjustment` and `orientation`, the second being
|
|
21
|
+
// `GtkOrientable`'s defaulted to HORIZONTAL in `gtk_scrollbar_init` (gtkscrollbar.c:263-278).
|
|
22
|
+
// There is no adjustment of its own — unlike `GtkRange`, which makes one — and a NULL one is
|
|
23
|
+
// not a null range: `gtk_range_set_adjustment` SUBSTITUTES a zero adjustment
|
|
24
|
+
// (`gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)`, gtkrange.c:687-688), so a bare
|
|
25
|
+
// `<gtk-scrollbar>` is a bar over `upper == lower`, where `upper - lower == 0` makes
|
|
26
|
+
// `gtk_range_compute_slider_position` fall back to the slider's OWN measured size and put it
|
|
27
|
+
// at 0 (gtkrange.c:2779-2793) — a full-length thumb that cannot move. The widget stays
|
|
28
|
+
// SENSITIVE: nothing in gtkscrollbar.c, gtkrange.c or gtkscrolledwindow.c ever calls
|
|
29
|
+
// `gtk_widget_set_sensitive` on it, so there is no insensitivity to report. The adjustment
|
|
30
|
+
// is the portable value (ADR 0047), so a bar authored here is the one a
|
|
31
|
+
// `<gtk-scrolled-window>` drives and the one a NativeScript `GtkAdjustment` would carry.
|
|
32
|
+
//
|
|
33
|
+
// THE POINTER RULES ARE `GtkRange`'s AT THE SETTINGS DEFAULT THEY SHIP WITH:
|
|
34
|
+
// `gtk-primary-button-warps-slider` is TRUE (gtksettings.c:734-736), so a primary click in
|
|
35
|
+
// the trough WARPS the slider to the click — onto the slider's own CENTRE, since the
|
|
36
|
+
// slider's size is not fixed (gtkrange.c:2074-2096) — while a middle click, or Shift with
|
|
37
|
+
// a primary one, PAGES toward it (gtkrange.c:2097-2115). Shift turns the drag into a FINE
|
|
38
|
+
// adjustment: `update_zoom_state` adds `.fine-tune`, and `update_slider_position` then
|
|
39
|
+
// scales the pointer's travel by `min(1, trough / range)` — `0.25` where that factor would
|
|
40
|
+
// come out at 1, which is what a scale forces (gtkrange.c:2163-2177, 1793-1804).
|
|
41
|
+
//
|
|
42
|
+
// A11y: `role="scrollbar"` with `aria-valuemin` / `aria-valuemax` / `aria-valuenow` —
|
|
43
|
+
// `GTK_ACCESSIBLE_ROLE_SCROLLBAR` (gtkscrollbar.c:259) and the `GtkAccessibleRange` interface,
|
|
44
|
+
// whose three numbers are the adjustment's own: `upper - page_size`, `lower` and `value`,
|
|
45
|
+
// in that order (gtkscrollbar.c:309-313, 322-324).
|
|
46
|
+
//
|
|
47
|
+
// NOT PORTED: the autoscroll a SECONDARY click in the trough starts
|
|
48
|
+
// (gtkrange.c:2116-2132) is a repeating timer against the trough's edge, and a browser
|
|
49
|
+
// opens its context menu there. Mark snapping (`update_slider_position`'s loop over
|
|
50
|
+
// `n_marks`) belongs to `GtkScale`, which is where marks are declared.
|
|
51
|
+
//
|
|
52
|
+
// Reference: refs/gtk/gtk/gtkscrollbar.c (init, class_init, the CSS node diagram)
|
|
53
|
+
// Reference: refs/gtk/gtk/gtkrange.c (compute_slider_position, coord_to_value,
|
|
54
|
+
// click_gesture_pressed, update_zoom_state, update_slider_position)
|
|
55
|
+
// Reference: refs/libadwaita/src/stylesheet/widgets/_scrolling.scss:1-138 (scrollbar, range,
|
|
56
|
+
// trough, slider and the .fine-tune variant)
|
|
57
|
+
// Copyright (c) The GTK Team. LGPLv2.1+.
|
|
58
|
+
// Modifications: Implemented as a Web Component for @gjsify/adwaita-web.
|
|
59
|
+
|
|
60
|
+
import {
|
|
61
|
+
clampAdjustmentValue,
|
|
62
|
+
normalizeAdjustment,
|
|
63
|
+
normalizeBoxOrientation,
|
|
64
|
+
parseAdjustment,
|
|
65
|
+
type AdwAdjustment,
|
|
66
|
+
type AdwAdjustmentInput,
|
|
67
|
+
type BoxOrientation,
|
|
68
|
+
} from '@gjsify/adwaita-core';
|
|
69
|
+
|
|
70
|
+
/** The two nodes below GTK's `range` level, spelled as GTK spells them. */
|
|
71
|
+
const TROUGH_CLASS = 'adw-scrollbar-trough';
|
|
72
|
+
const SLIDER_CLASS = 'adw-scrollbar-slider';
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The zoom factor `update_slider_position` falls back to when the measured one comes out
|
|
76
|
+
* at 1.0 — a scale's, where the trough is longer than the range it slides over.
|
|
77
|
+
*/
|
|
78
|
+
const ZOOM_FALLBACK = 0.25;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* One wheel detent, in CSS pixels.
|
|
82
|
+
*
|
|
83
|
+
* `GtkScrollbar`'s own doc answers the wheel question in units of the adjustment
|
|
84
|
+
* ("`page-increment` … when the user asks to move by a page"), and `scroll_delta_to_value`
|
|
85
|
+
* multiplies a WHEEL delta — which GDK reports PER DETENT — by that page increment
|
|
86
|
+
* (gtkrange.c:1889-1896). Firefox reports three LINES per detent and Chrome about a
|
|
87
|
+
* hundred pixels, so both are converted with the convention `src/scroll-shading.ts`
|
|
88
|
+
* already states.
|
|
89
|
+
*/
|
|
90
|
+
const LINES_PER_DETENT = 3;
|
|
91
|
+
const PIXELS_PER_LINE = 16;
|
|
92
|
+
|
|
93
|
+
/** `GtkScrollType`'s six kinds, which is what a `scroll-child` names. */
|
|
94
|
+
export type GtkScrollType = 'step-backward' | 'step-forward' | 'page-backward' | 'page-forward' | 'start' | 'end';
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* `gtk_range_set_adjustment`'s substitute for a NULL adjustment — `gtk_adjustment_new (0.0,
|
|
98
|
+
* 0.0, 0.0, 0.0, 0.0, 0.0)` (gtkrange.c:687-688), the six numbers in `gtk_adjustment_new`'s
|
|
99
|
+
* own order (value, lower, upper, step, page, page_size).
|
|
100
|
+
*
|
|
101
|
+
* `upper == lower` is the state every scrollbar starts in and the one `upper - lower == 0`
|
|
102
|
+
* in `gtk_range_compute_slider_position` answers with the slider's own size at position 0
|
|
103
|
+
* (gtkrange.c:2779-2793). Frozen: it is the same object for every bar that has no
|
|
104
|
+
* adjustment, and nothing writes to it.
|
|
105
|
+
*/
|
|
106
|
+
const ZERO_ADJUSTMENT: AdwAdjustment = Object.freeze({
|
|
107
|
+
value: 0,
|
|
108
|
+
lower: 0,
|
|
109
|
+
upper: 0,
|
|
110
|
+
stepIncrement: 0,
|
|
111
|
+
pageIncrement: 0,
|
|
112
|
+
pageSize: 0,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
export class GtkScrollbar extends HTMLElement {
|
|
116
|
+
private _trough!: HTMLElement;
|
|
117
|
+
private _slider!: HTMLElement;
|
|
118
|
+
private _observer: ResizeObserver | null = null;
|
|
119
|
+
private _built = false;
|
|
120
|
+
private _adjustment: AdwAdjustment | null = null;
|
|
121
|
+
/** `priv->slide_initial_slider_position` — the slider's position when the drag began. */
|
|
122
|
+
private _grabPosition = 0;
|
|
123
|
+
/** `priv->slide_initial_coordinate_delta` — how far into the slider the pointer was. */
|
|
124
|
+
private _grabDelta = 0;
|
|
125
|
+
/** `priv->zoom` — the fine adjustment, `.fine-tune` and all. */
|
|
126
|
+
private _zoom = false;
|
|
127
|
+
private _dragging = false;
|
|
128
|
+
|
|
129
|
+
static get observedAttributes() {
|
|
130
|
+
return ['orientation', 'adjustment'];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** `GtkOrientable:orientation` — HORIZONTAL in `gtk_scrollbar_init`; unknown is that. */
|
|
134
|
+
get orientation(): BoxOrientation {
|
|
135
|
+
return normalizeBoxOrientation(this.getAttribute('orientation'));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
set orientation(value: BoxOrientation) {
|
|
139
|
+
this.setAttribute('orientation', value);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* `GtkScrollbar:adjustment` — the range this bar moves, as the portable value.
|
|
144
|
+
*
|
|
145
|
+
* NEVER `null`, which is the half of this property that is easy to get wrong: GTK's
|
|
146
|
+
* pspec default is NULL, but `gtk_range_set_adjustment` answers a NULL with the ZERO
|
|
147
|
+
* adjustment (gtkrange.c:687-688) and `gtk_range_get_adjustment` creates it on demand
|
|
148
|
+
* (gtkrange.c:658-659), so a bare `GtkScrollbar` reads back a real adjustment whose
|
|
149
|
+
* `upper` is 0. A read that could return null would be a property GTK's own does not
|
|
150
|
+
* have, and the slider geometry would have to carry a second "nothing here" case.
|
|
151
|
+
*
|
|
152
|
+
* A string is read as the JSON the attribute carries, so the property and the
|
|
153
|
+
* attribute are one write; a partial object MERGES, which is
|
|
154
|
+
* `gtk_adjustment_configure`'s own contract (gtkadjustment.c). Assigning `null` is
|
|
155
|
+
* `gtk_scrollbar_set_adjustment (self, NULL)`: the zero adjustment again, and the
|
|
156
|
+
* property is assigned rather than merged.
|
|
157
|
+
*/
|
|
158
|
+
get adjustment(): AdwAdjustment {
|
|
159
|
+
return this._adjustment ?? ZERO_ADJUSTMENT;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
set adjustment(value: AdwAdjustmentInput | string | null) {
|
|
163
|
+
const input =
|
|
164
|
+
value === null || value === undefined ? null : typeof value === 'string' ? parseAdjustment(value) : value;
|
|
165
|
+
this._adjustment = input === null ? null : normalizeAdjustment(input, this._adjustment ?? undefined);
|
|
166
|
+
// A widget CONSTRUCTED writes properties without notifying (GObject has no observers
|
|
167
|
+
// yet), and this element is built inside `connectedCallback`, where a parent's own
|
|
168
|
+
// callback can reach a child whose callback has not run — the custom element reaction
|
|
169
|
+
// queue unwinds AFTER the parent's. So the value is taken and the render waits for the
|
|
170
|
+
// trough that `connectedCallback` is about to build.
|
|
171
|
+
if (!this._built) return;
|
|
172
|
+
this._render();
|
|
173
|
+
this._notify('adjustment', { adjustment: this.adjustment });
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** The position, which is the adjustment's own value (gtkrange.c:1168-1176). */
|
|
177
|
+
get value(): number {
|
|
178
|
+
return this.adjustment.value;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* `gtk_adjustment_set_value`: move the range, clamped, and announce it.
|
|
183
|
+
*
|
|
184
|
+
* A scrollbar is a VIEW of an adjustment it does not own, so the `value-changed`
|
|
185
|
+
* CustomEvent (bubbles, detail `{ adjustment }`) stands for `GtkAdjustment`'s signal —
|
|
186
|
+
* and `<gtk-scrolled-window>` is what listens, exactly as GTK reads the adjustment off
|
|
187
|
+
* the scrollbar it owns (`gtk_scrolled_window_scroll_child`, gtkscrolledwindow.c:3007).
|
|
188
|
+
*
|
|
189
|
+
* Over the zero adjustment `set_value` CLAMPS to 0 and reports no change, so a bar with
|
|
190
|
+
* no adjustment of its own is inert without being a special case anywhere.
|
|
191
|
+
*/
|
|
192
|
+
set value(value: number) {
|
|
193
|
+
const adjustment = this._adjustment;
|
|
194
|
+
if (adjustment === null) return;
|
|
195
|
+
const next = clampAdjustmentValue(adjustment, value);
|
|
196
|
+
if (next === adjustment.value) return;
|
|
197
|
+
this._adjustment = { ...adjustment, value: next };
|
|
198
|
+
this._render();
|
|
199
|
+
this.dispatchEvent(
|
|
200
|
+
new CustomEvent('value-changed', { bubbles: true, detail: { adjustment: this._adjustment } }),
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* The value one `GtkScrollType` moves by, which is `gtk_scrolled_window_scroll_child`'s
|
|
206
|
+
* switch.
|
|
207
|
+
*
|
|
208
|
+
* `scrollBy` is a platform method with a delta form, so both are here and the KIND of the
|
|
209
|
+
* argument decides — a `GtkScrollType` nick moves the adjustment, a number or a
|
|
210
|
+
* `ScrollToOptions` is the scrollport's own call, which a bar has none of (it is not a
|
|
211
|
+
* scrollport) and which therefore lands on no adjustment and does nothing.
|
|
212
|
+
*/
|
|
213
|
+
scrollBy(kind: GtkScrollType): void;
|
|
214
|
+
scrollBy(options?: ScrollToOptions): void;
|
|
215
|
+
scrollBy(x: number, y: number): void;
|
|
216
|
+
scrollBy(kind?: GtkScrollType | ScrollToOptions | number): void {
|
|
217
|
+
if (typeof kind !== 'string') return;
|
|
218
|
+
const adjustment = this.adjustment;
|
|
219
|
+
switch (kind) {
|
|
220
|
+
case 'step-forward':
|
|
221
|
+
this.value = adjustment.value + adjustment.stepIncrement;
|
|
222
|
+
break;
|
|
223
|
+
case 'step-backward':
|
|
224
|
+
this.value = adjustment.value - adjustment.stepIncrement;
|
|
225
|
+
break;
|
|
226
|
+
case 'page-forward':
|
|
227
|
+
this.value = adjustment.value + adjustment.pageIncrement;
|
|
228
|
+
break;
|
|
229
|
+
case 'page-backward':
|
|
230
|
+
this.value = adjustment.value - adjustment.pageIncrement;
|
|
231
|
+
break;
|
|
232
|
+
case 'start':
|
|
233
|
+
this.value = adjustment.lower;
|
|
234
|
+
break;
|
|
235
|
+
case 'end':
|
|
236
|
+
// `gtk_scrolled_window_scroll_child` sets `value = upper` and lets
|
|
237
|
+
// `gtk_adjustment_set_value` clamp it (gtkscrolledwindow.c:3029-3031,
|
|
238
|
+
// gtkadjustment.c:549-555) — which for a scrollbar's range is
|
|
239
|
+
// `upper - page_size`, the position the thumb can actually reach.
|
|
240
|
+
this.value = adjustment.upper;
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** How far a wheel detent moves the value: `scroll_delta_to_value` on a WHEEL unit. */
|
|
246
|
+
scrollByWheel(deltaY: number, deltaMode: number): void {
|
|
247
|
+
const perDetent = deltaMode === 1 ? PIXELS_PER_LINE * LINES_PER_DETENT : 100;
|
|
248
|
+
const detents = perDetent === 0 ? 0 : deltaY / perDetent;
|
|
249
|
+
this.scrollBy(detents >= 0 ? 'page-forward' : 'page-backward');
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* `gtk_range_get_range_area`-ish: the length of the trough, which is what the slider
|
|
254
|
+
* is a fraction of. Read on demand so a caller can scale with the same numbers.
|
|
255
|
+
*/
|
|
256
|
+
private get _troughLength(): number {
|
|
257
|
+
return this.orientation === 'vertical' ? this._trough.clientHeight : this._trough.clientWidth;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
connectedCallback() {
|
|
261
|
+
if (!this._built) {
|
|
262
|
+
this._built = true;
|
|
263
|
+
this._trough = document.createElement('div');
|
|
264
|
+
this._trough.className = TROUGH_CLASS;
|
|
265
|
+
this._slider = document.createElement('div');
|
|
266
|
+
this._slider.className = SLIDER_CLASS;
|
|
267
|
+
this._trough.appendChild(this._slider);
|
|
268
|
+
this.replaceChildren(this._trough);
|
|
269
|
+
// On the BAR, not the trough: `gtk_range_click_gesture_pressed` picks the widget
|
|
270
|
+
// under the pointer and folds everything that is not the slider into the trough
|
|
271
|
+
// (gtkrange.c:2052-2058), and libadwaita gives the trough a 9px margin — so the
|
|
272
|
+
// bar's own margin is trough as far as GTK is concerned and a click there warps
|
|
273
|
+
// the slider like any other.
|
|
274
|
+
this.addEventListener('pointerdown', this._onPointerDown);
|
|
275
|
+
this.addEventListener('keydown', this._onKeyDown);
|
|
276
|
+
this.addEventListener('wheel', this._onWheel, { passive: true });
|
|
277
|
+
// An ARIA scrollbar is operable, and `GtkRange` answers keys on the widget's
|
|
278
|
+
// own focus — so it takes a place in the tab order, as GTK's focus chain puts
|
|
279
|
+
// it there. No `disconnectedCallback`: the drag listeners live on this element
|
|
280
|
+
// and die with it, and a pointer capture is released by the platform when the
|
|
281
|
+
// captured node leaves the document.
|
|
282
|
+
this.tabIndex = 0;
|
|
283
|
+
// The slider is a FRACTION of the trough, so it needs the trough's length,
|
|
284
|
+
// which any resize of the trough or of the window changes. An observer on a
|
|
285
|
+
// node this element owns, so it dies with it.
|
|
286
|
+
this._observer = new ResizeObserver(() => this._render());
|
|
287
|
+
this._observer.observe(this._trough);
|
|
288
|
+
this.setAttribute('role', 'scrollbar');
|
|
289
|
+
}
|
|
290
|
+
if (this.hasAttribute('adjustment')) this.adjustment = this.getAttribute('adjustment');
|
|
291
|
+
this._render();
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null) {
|
|
295
|
+
if (!this._built || !this.isConnected) return;
|
|
296
|
+
if (name === 'adjustment') {
|
|
297
|
+
this.adjustment = value;
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
this._notify('orientation', { orientation: this.orientation });
|
|
301
|
+
this._render();
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
private _notify(property: string, detail: Record<string, unknown>): void {
|
|
305
|
+
this.dispatchEvent(new CustomEvent(`notify::${property}`, { bubbles: true, detail }));
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* The trough's three rules and the slider's drag, at the settings default
|
|
310
|
+
* (`gtk_range_click_gesture_pressed`, gtkrange.c:2018-2138).
|
|
311
|
+
*/
|
|
312
|
+
private _onPointerDown = (event: PointerEvent): void => {
|
|
313
|
+
if (!this.hasAttribute('tabindex')) return;
|
|
314
|
+
// `gtk_range_click_gesture_pressed` grabs the focus first and works on whatever
|
|
315
|
+
// adjustment the range holds (gtkrange.c:2036-2037), so a bar with none is still
|
|
316
|
+
// operable — every move it makes clamps back to 0.
|
|
317
|
+
this.focus();
|
|
318
|
+
const coord = this._coordinate(event);
|
|
319
|
+
// `gtk_range_click_gesture_pressed` treats anything outside the slider as the
|
|
320
|
+
// trough (gtkrange.c:2052-2058), and Shift inside the slider is the fine
|
|
321
|
+
// adjustment.
|
|
322
|
+
const onSlider = event.target === this._slider;
|
|
323
|
+
this._grabPosition = this._sliderPosition();
|
|
324
|
+
this._grabDelta = coord - this._grabPosition;
|
|
325
|
+
this._setZoom(onSlider && event.shiftKey);
|
|
326
|
+
this._dragging = onSlider;
|
|
327
|
+
this._capture(event.pointerId);
|
|
328
|
+
this.addEventListener('pointermove', this._onPointerMove);
|
|
329
|
+
this.addEventListener('pointerup', this._onPointerEnd);
|
|
330
|
+
this.addEventListener('pointercancel', this._onPointerEnd);
|
|
331
|
+
if (onSlider) return;
|
|
332
|
+
// Shift with the primary button, or the middle one, pages; a primary button on its
|
|
333
|
+
// own warps, because `gtk-primary-button-warps-slider` defaults TRUE.
|
|
334
|
+
if (event.button === 0 && !event.shiftKey) {
|
|
335
|
+
this.value = this._coordinateValue(coord + this._sliderSize() / 2);
|
|
336
|
+
} else if (event.button === 1 || (event.button === 0 && event.shiftKey)) {
|
|
337
|
+
this.scrollBy(this._coordinateValue(coord) > this.value ? 'page-forward' : 'page-backward');
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* `update_slider_position`: the pointer's travel since the grab, scaled by the zoom,
|
|
343
|
+
* added to where the slider WAS — so the slider keeps the offset it was grabbed at.
|
|
344
|
+
*/
|
|
345
|
+
private _onPointerMove = (event: PointerEvent): void => {
|
|
346
|
+
if (!this._dragging) return;
|
|
347
|
+
// Shift anywhere in a drag is the fine adjustment (gtkrange.c:1953-1970).
|
|
348
|
+
this._setZoom(event.shiftKey);
|
|
349
|
+
const coord = this._coordinate(event);
|
|
350
|
+
const zoom = this._zoom ? this._zoomFactor() : 1;
|
|
351
|
+
this.value = this._coordinateValue(
|
|
352
|
+
this._grabPosition + zoom * (coord - (this._grabDelta + this._grabPosition)),
|
|
353
|
+
);
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
private _onPointerEnd = (event: PointerEvent): void => {
|
|
357
|
+
this._endDrag(event.pointerId);
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
private _endDrag(pointerId?: number): void {
|
|
361
|
+
this._dragging = false;
|
|
362
|
+
this._setZoom(false);
|
|
363
|
+
if (pointerId !== undefined && this.hasPointerCapture(pointerId)) {
|
|
364
|
+
this.releasePointerCapture(pointerId);
|
|
365
|
+
}
|
|
366
|
+
this.removeEventListener('pointermove', this._onPointerMove);
|
|
367
|
+
this.removeEventListener('pointerup', this._onPointerEnd);
|
|
368
|
+
this.removeEventListener('pointercancel', this._onPointerEnd);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Keep the gesture alive past the bar's own edges, which is what `GtkGestureDrag` does
|
|
373
|
+
* upstream for as long as the button is held.
|
|
374
|
+
*
|
|
375
|
+
* `setPointerCapture` THROWS for a pointer id the platform is no longer tracking, and an
|
|
376
|
+
* exception here would abort the gesture before the warp or the page that follows it —
|
|
377
|
+
* which is not a state a scrollbar can be in. So a refused capture is a drag that ends at
|
|
378
|
+
* the bar's edge, and the synchronous move still happens.
|
|
379
|
+
*/
|
|
380
|
+
private _capture(pointerId: number): void {
|
|
381
|
+
try {
|
|
382
|
+
this.setPointerCapture(pointerId);
|
|
383
|
+
} catch {
|
|
384
|
+
// No capture: the pointermove listener below is on this element anyway, so a
|
|
385
|
+
// drag inside the bar is unaffected.
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/** The keys `GtkScrollbar`'s own doc names: the arrow keys step, Page Up/Down page. */
|
|
390
|
+
private _onKeyDown = (event: KeyboardEvent): void => {
|
|
391
|
+
const vertical = this.orientation === 'vertical';
|
|
392
|
+
const kind = resolveRangeKey(event, vertical);
|
|
393
|
+
if (kind === null) return;
|
|
394
|
+
event.preventDefault();
|
|
395
|
+
this.scrollBy(kind);
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
private _onWheel = (event: WheelEvent): void => {
|
|
399
|
+
// `GtkScrollbar` is inside a scrolled window that scrolls on the wheel already, so
|
|
400
|
+
// this only claims the event when the bar itself is the target — GTK's own
|
|
401
|
+
// GtkScrollbar is not a scroll event target either.
|
|
402
|
+
if (event.target !== this && event.target !== this._trough) return;
|
|
403
|
+
this.scrollByWheel(event.deltaY, event.deltaMode);
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
private _setZoom(enabled: boolean): void {
|
|
407
|
+
if (this._zoom === enabled) return;
|
|
408
|
+
this._zoom = enabled;
|
|
409
|
+
// `update_zoom_state` puts the class on the RANGE; here the scrollbar IS the node
|
|
410
|
+
// the class reaches, which is what libadwaita's `range.fine-tune` selector wants.
|
|
411
|
+
this.classList.toggle('fine-tune', enabled);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** `update_slider_position`'s zoom: the trough per unit of range, or the fallback. */
|
|
415
|
+
private _zoomFactor(): number {
|
|
416
|
+
const adjustment = this.adjustment;
|
|
417
|
+
const range = adjustment.upper - adjustment.lower - adjustment.pageSize;
|
|
418
|
+
const measured = range <= 0 ? 1 : Math.min(1, this._troughLength / range);
|
|
419
|
+
return measured === 1 ? ZOOM_FALLBACK : measured;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* `gtk_range_compute_slider_position`, in CSS pixels.
|
|
424
|
+
*
|
|
425
|
+
* The slider's length is a fraction of the WHOLE adjustment range and its position a
|
|
426
|
+
* fraction of the SCROLLABLE one, which is why the two denominators differ and why
|
|
427
|
+
* neither is a plain percentage of the trough. A range with nothing to scroll is the
|
|
428
|
+
* `trough_length == slider_length` case upstream and answers 1.0.
|
|
429
|
+
*/
|
|
430
|
+
private _render(): void {
|
|
431
|
+
if (!this._built) return;
|
|
432
|
+
const adjustment = this.adjustment;
|
|
433
|
+
const vertical = this.orientation === 'vertical';
|
|
434
|
+
this.classList.toggle('vertical', vertical);
|
|
435
|
+
this.classList.toggle('horizontal', !vertical);
|
|
436
|
+
this.setAttribute('aria-orientation', this.orientation);
|
|
437
|
+
// There is NO insensitivity to report: nothing in gtkscrollbar.c, gtkrange.c or
|
|
438
|
+
// gtkscrolledwindow.c calls `gtk_widget_set_sensitive` on a bar, so the `aria-disabled`
|
|
439
|
+
// and `disabled` this element used to set for a NULL adjustment were a state GTK never
|
|
440
|
+
// has. What the C publishes is the accessible RANGE, so that is all this writes.
|
|
441
|
+
this.removeAttribute('aria-disabled');
|
|
442
|
+
this.removeAttribute('disabled');
|
|
443
|
+
const trough = this._troughLength;
|
|
444
|
+
const total = adjustment.upper - adjustment.lower;
|
|
445
|
+
const scrollable = total - adjustment.pageSize;
|
|
446
|
+
// `upper - lower != 0` is the condition the C guards its fraction with
|
|
447
|
+
// (gtkrange.c:2779-2782, 2814-2817); without it the slider takes its OWN measured
|
|
448
|
+
// size, which for a libadwaita slider is the `$_slider_min_length` floor its own
|
|
449
|
+
// stylesheet sets. Writing no length at all is therefore the faithful answer — the
|
|
450
|
+
// stylesheet's `max (…, $_slider_min_length)` then IS that measured size.
|
|
451
|
+
if (total === 0) {
|
|
452
|
+
this._slider.style.removeProperty('--adw-scrollbar-size');
|
|
453
|
+
} else {
|
|
454
|
+
const size = Math.min(trough, trough * (adjustment.pageSize / total));
|
|
455
|
+
this._slider.style.setProperty('--adw-scrollbar-size', `${size}px`);
|
|
456
|
+
}
|
|
457
|
+
const size = this._sliderSize();
|
|
458
|
+
const free = Math.max(0, trough - size);
|
|
459
|
+
// `upper - lower - page_size != 0` is the C's own condition for the POSITION
|
|
460
|
+
// (gtkrange.c:2790-2793), so an unscrollable range puts the slider at the start.
|
|
461
|
+
const position = scrollable === 0 ? 0 : free * ((adjustment.value - adjustment.lower) / scrollable);
|
|
462
|
+
this.setAttribute('aria-valuemin', String(adjustment.lower));
|
|
463
|
+
this.setAttribute('aria-valuemax', String(adjustment.upper - adjustment.pageSize));
|
|
464
|
+
this.setAttribute('aria-valuenow', String(adjustment.value));
|
|
465
|
+
this._slider.style.setProperty('--adw-scrollbar-position', `${position}px`);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/** Where the slider's START is along the trough, in pixels. */
|
|
469
|
+
private _sliderPosition(): number {
|
|
470
|
+
return Number.parseFloat(this._slider.style.getPropertyValue('--adw-scrollbar-position')) || 0;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/** The slider's own length, in pixels, from the last layout. */
|
|
474
|
+
private _sliderSize(): number {
|
|
475
|
+
return Number.parseFloat(this._slider.style.getPropertyValue('--adw-scrollbar-size')) || 0;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* `coord_to_value` (gtkrange.c:1842-1886): a coordinate along the trough scaled by the
|
|
480
|
+
* FREE space — the trough less the slider — because the slider's centre has to reach
|
|
481
|
+
* both ends and not one of them twice over.
|
|
482
|
+
*/
|
|
483
|
+
private _coordinateValue(coord: number): number {
|
|
484
|
+
const adjustment = this.adjustment;
|
|
485
|
+
const free = Math.max(1, this._troughLength - this._sliderSize());
|
|
486
|
+
const frac = Math.min(1, Math.max(0, coord / free));
|
|
487
|
+
return adjustment.lower + frac * (adjustment.upper - adjustment.pageSize - adjustment.lower);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/** The pointer's coordinate along the trough, from the trough's own box. */
|
|
491
|
+
private _coordinate(event: PointerEvent): number {
|
|
492
|
+
const box = this._trough.getBoundingClientRect();
|
|
493
|
+
return this.orientation === 'vertical' ? event.clientY - box.top : event.clientX - box.left;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* The keys `GtkRange` answers, which are the ones `GtkScrollbar`'s own doc names: the
|
|
499
|
+
* arrows STEP, Page Up/Down PAGE, Home/End jump to the ends.
|
|
500
|
+
*
|
|
501
|
+
* An arrow on the OTHER axis is not a scrollbar key — GTK's GtkRange has no key bindings
|
|
502
|
+
* of its own beyond what `GtkScale` and `GtkScrollbar` document, and letting a vertical
|
|
503
|
+
* bar react to Left would answer a question nobody asked.
|
|
504
|
+
*/
|
|
505
|
+
function resolveRangeKey(event: KeyboardEvent, vertical: boolean): GtkScrollType | null {
|
|
506
|
+
switch (event.key) {
|
|
507
|
+
case 'ArrowRight':
|
|
508
|
+
return vertical ? null : 'step-forward';
|
|
509
|
+
case 'ArrowLeft':
|
|
510
|
+
return vertical ? null : 'step-backward';
|
|
511
|
+
case 'ArrowDown':
|
|
512
|
+
return vertical ? 'step-forward' : null;
|
|
513
|
+
case 'ArrowUp':
|
|
514
|
+
return vertical ? 'step-backward' : null;
|
|
515
|
+
case 'PageDown':
|
|
516
|
+
return 'page-forward';
|
|
517
|
+
case 'PageUp':
|
|
518
|
+
return 'page-backward';
|
|
519
|
+
case 'Home':
|
|
520
|
+
return 'start';
|
|
521
|
+
case 'End':
|
|
522
|
+
return 'end';
|
|
523
|
+
default:
|
|
524
|
+
return null;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
customElements.define('gtk-scrollbar', GtkScrollbar);
|