Skip to main content

Module widgets

Module widgets 

Source
Expand description

Small pieces both apps use: an accent picker, a titled section, a labelled row, a slider, a dropdown of fixed options, a stepper and a dragged number, a colour swatch, a centred empty state, an icon button. Plain data in, no store; colours from the current look (crate::theme::color).

Structs§

AccentChanged
What the picker reports: the accent picked (None: the app’s own).
AccentPicker
A row to choose the accent: “App” (the app’s palette), the suggested colours (Rgb::SUGGESTED) as swatches, and gpui-kit’s colour picker for any other colour (hex, hue, saturation, lightness). The current choice is ringed, not only coloured (WCAG 1.4.1). Each swatch is a 24 px target (designparser touch-target). It emits AccentChanged; the owner stores the value and applies it (theme::use_look(look.with_accent(…))).
EmptyState
Centred icon, title and a line of explanation, with actions under it (added as children).
MenuSelect
A button showing the current option; pressing it lists the options, the current one checked. It fills its place, so a long option ends in “…” instead of being cut or pushing the panel wider.
Section
A titled block of a panel: a short caps title (with something at its right, if given), then its rows (added as children), theme::SM apart. Boxed (Section::boxed), the rows sit in a bordered box.

Constants§

SCRUB_PX
Pointer px per step of a dragged number.

Functions§

icon_button
A small ghost icon button with a tooltip (the tooltip names what it does, since the icon alone may not). gpui-kit’s small size: about 24 px square at the default text size (designparser touch-target).
row
label control on one line when both fit: the label theme::LABEL_W wide, the control the rest (at least theme::CONTROL_MIN_W). In a narrow panel the control drops under its label, full width. Nothing is clipped (a cut label names nothing): a long label wraps, a long value in a control ends in “…”.
scrub_label
A number that changes as it is dragged (Affinity, Blender): press it and move left or right; every SCRUB_PX px is one step down or up. The pointer may leave it while dragging. The caller holds the value and formats it; id (owned, unique in the window) names the drag.
slider
A horizontal slider over min..=max with the value printed beside it (fmt). A click sets the value; a drag follows the pointer (even off the track) and ends on release, when on_change gets true. It keeps no state: the caller holds the value, and id (owned, unique in the window) names the drag in progress. The track’s element id is {id}-track.
stepper
− value +: a number changed in steps, by its buttons or by dragging the number (see scrub_label). The caller holds the value and formats it. Element ids: {id}-minus, {id}-value, {id}-plus. The buttons are gpui-kit’s small size, theme::XS apart (designparser touch-target: about 24 px each).
swatch
A colour chip size px square, outlined so a colour close to the panel’s still shows its edge. For 0–255 RGB use crate::theme::rgb8.

Type Aliases§

OnSlide
What a slider calls: the new value and whether the drag ended (to commit one undo step).
OnStep
What a stepped number calls with its step (−1 or +1; a fast drag calls it once per step).