Expand description
Palettes: toolboxes, colour palettes, navigators floating over the
interface (not the command palette, crate::palette).
A palette is a panel (PanelSpec::palette) placed floating instead
of docked: one model, two placements. It opens floating, is dragged by
its header band (egui_pop_core::band, the movable dialogs’ band),
clamped inside the workbench, snapping to the workbench’s edges and to
the other palettes within the palette.magnet token. Dropped on an
edge of the workbench, it is anchored there (anchor_of) and keeps
its distance to it as the window is resized (anchored_pos); dragged
away, it no longer is. Dropped on a
side or bottom area (or a closed one’s edge, with the workbench’s drop
hint) with the dock keys held, it docks there; a docked floatable
panel floats again from its tab menu (Float).
Moving or docking (docs/design/drag-move-vs-dock.md). By
default a plain drag only moves a palette: the drop targets (an area,
another palette’s group) show and take it only while the dock keys
are held (gesture.workbench.dock, Ctrl and the drag, Cmd on
macOS, rebindable in the shortcuts editor), read every pass of the
drag, so pressing or releasing them mid-drag counts. The
input.dock_drag setting (crate::pointer::SETTING_DOCK_DRAG; its
default the application’s, AppBuilder::dock_drag, else the pointer
profile’s) picks the mode (DockDrag): modifier-docks (the
default), modifier-floats (a plain drag docks, the keys keep it
floating: Photoshop’s profile) or dwell (docking arms once the
pointer rests on a target for DWELL). Whether the targets are
armed shows in GroupHint::armed and the workbench’s
DropHint::armed; only armed targets are drawn. While a palette is
dragged over a target, a one-line hint says how to dock or not
(drag_hint): in the status bar, or under the pointer without one.
A floating panel’s menu docks it too (Dock in), for a pointer with no
keyboard. Its band carries Close, Roll up (down to the band)
and Pin (kept in place, in sight and opaque); a double click on the
band rolls it up or down. A right click on its title, or on a tab of
its group, opens the panel menu a docked tab opens
(crate::workbench::panel_menu): Detach into a window, Move to
group, Dock back (where it floated from), Close.
Never modal. A palette never blocks the interface: anything that
must be answered first is a dialog (crate::dialogs). It takes the
keyboard only when clicked into; Escape there gives it back to the
panel that had it.
Behaviour. The palettes.toggle command (Tab, rebindable) hides
and shows the unpinned palettes. Tab is the toggle only while some
panel floats, no widget has the keyboard and no overlay is open:
otherwise it moves the keyboard to the next widget, as always. While a stroke is in progress
(set_stroke) the palettes fade when the palettes.fade_on_stroke
setting is on; palettes.idle_opacity makes them translucent while
the pointer is elsewhere. palettes.reset puts them back where they
open first, rolled down and sized by their content.
Groups. Palettes float in groups (FloatingGroup), a palette
alone being a group of one. A palette dropped on another one’s top or
bottom quarter (join_at, with the drop hint the tabs use) stacks
above or below it, in a column where each keeps its own band and
roll-up. The group’s band (over its members’) drags, pins and anchors
the whole group, and docks every member over an area, as tabs
(floating one of them again gives the group back); a member’s own
band drags it out of the group. Dropped on the middle of another
palette, a palette joins its group as a tab: the group’s band then
holds the tabs, and the shown member its own band.
Docking conventions (as in Photoshop, Krita, GIMP, Qt docks and
VS Code). Close group is an entry of the menu on the group’s band,
not a button on it. A tab dragged out of its tabs comes out of them,
alone or into the palette it is dropped on. Closing the shown tab
shows its right neighbour, or its left one at the end. A palette
dropped on the top or bottom edge of a group of tabs stacks beside
them and the tabs stay tabs: a stack’s member may be a tab group
(Member::tabs), one level deep, whose band drags it out whole.
Sizes. A palette is sized by its content until the user resizes
it: each of its edges and corners drag its size (a left or top edge
keeping the opposite one where it is) (the palette.grip token’s width), kept between the
palette.min-width and palette.max-width tokens (and its panels’
own least width), palette.min-height and palette.max-height, and
inside the workbench. The size is the group’s
(FloatingGroup::size, saved in the layout): a group keeps it as
palettes join it, a palette coming out of it is sized by its content
again. Its content scrolls when it is taller than the room left; a
rolled-up palette keeps its width and only its band’s height. A
double click on an edge gives the content its size back. Resized
against an edge of the workbench, a palette is anchored there as when
it is dropped.
Steps (ADR 0011): palette.open ({panel}), palette.float
({panel, pos}), palette.dock ({panel, area}, group: true for
the whole group), palette.move ({panel, pos}, once a drag is
dropped), palette.resize ({panel, size}, size being
[width, height] or null for the content’s, once an edge is
dropped; with pos too when a left or top edge moved it), palette.roll ({panel, rolled}), palette.pin
({panel, pinned}), palette.group ({panels, into, at}),
palette.ungroup ({panel, pos}, tabs: true for a nested tab group
whole) and palette.close_group ({panel}); pos is the top-left
corner in points from the workbench’s top-left. Each done change is
published as palette.opened, palette.floated, palette.docked,
palette.moved, palette.resized, palette.rolled, palette.pinned,
palette.grouped, palette.ungrouped or palette.group_closed.
Not built yet: a palette outside the main window (a native utility window through egui’s viewports).
Structs§
- Group
Hint - Where dropping the dragged palettes would group them, while they are
dragged over another palette: what
group_hintreports.
Constants§
- CMD_
RESET - Puts the palettes back where they first open.
- CMD_
TOGGLE - Hides or shows the unpinned palettes (Tab).
- CONTEXT_
FLOATING - The context key saying some panel floats (shown or hidden): only then is Tab the palettes’ toggle.
- CONTEXT_
HIDDEN - The context key saying the palettes are hidden (
palettes.toggle). - CONTEXT_
STROKE - The context key saying a stroke is in progress (
set_stroke). - DWELL
- How long the pointer rests on a target before a drag in the
dwellmode (DockDrag::Dwell) docks there, in seconds. - SETTING_
FADE - The setting: palettes fade while a stroke is in progress.
- SETTING_
IDLE_ OPACITY - The setting: how opaque a palette is while the pointer is elsewhere.
- STEP_
CLOSE_ GROUP - Every palette of a floating panel’s group closes (
{panel}): the group band’s menu, Close group. - STEP_
DOCK - A floating panel docks in an area (
{panel, area}). - STEP_
FLOAT - A panel floats over the interface (
{panel, pos}). - STEP_
GROUP - Floating panels join another one’s group (
{panels, into, at},atbeingabove,belowortab). - STEP_
MOVE - A floating panel is moved: dropped after a drag, reset
(
{panel, pos}). - STEP_
OPEN - A palette opens (
{panel}). - STEP_
PIN - A floating panel is pinned or unpinned (
{panel, pinned}). - STEP_
RESIZE - A floating panel’s group is resized, once an edge is dropped, or
sized by its content again (
{panel, size},sizebeing[width, height]in points ornull; withpos, the place too, for a left or top edge dragged). - STEP_
ROLL - A floating panel rolls up or down (
{panel, rolled}). - STEP_
UNGROUP - A floating panel comes out of its group, alone (
{panel, pos}); withtabs: true, the tab group it is a tab of comes out of its stack whole.
Functions§
- anchor_
of - The workbench edges a palette’s
rectlies on, within half a point: its anchor. A side off the edges (dragged away, or snapped to another palette) is not anchored; on both edges of an axis (as large as the workbench), the start wins. - anchored_
pos - Where a palette’s top-left corner goes in
bounds: an anchored axis keeps its distance to its edge, the other keepspos(from the bounds’ top-left); kept inside either way. - area_id
- A palette’s area id.
- drag_
hint - The hint while a palette is dragged over a target, worded after the
drag mode and the keys bound to
gesture.workbench.dock(a rebind changes it): “Hold Ctrl to dock” or “Release Ctrl to move only” (modifier-docks), “Hold Ctrl to move without docking” (modifier-floats, the keys not held), “Rest here to dock” (dwell, while the delay runs).Nonewhile no palette is dragged over a target. - group_
hint - Where dropping the palettes dragged now would group them, if they are dragged over another palette.
- hidden
- Whether the unpinned palettes are hidden (
palettes.toggle). - join_at
- Where a palette dropped with the pointer at
at, over another palette drawn atrect, joins its group: on its top quarter above it, on its bottom quarter below it, in between as a tab; outside it, none. - reset
- Puts the floating palettes back where they first open, rolled down and sized by their content, each through its steps.
- resize_
by - A palette’s size once its right edge (
edges[0]) and bottom edge (edges[1]) are dragged bydeltafromstart, kept betweenleastandmost. - resize_
rect - A palette’s frame once the edges
sidessay are dragged bydeltafromstart: a start edge moves its side and keeps the opposite one where it is. Its size is kept betweenleastandmost, and insidebounds. - set_
hidden - Hides or shows the unpinned palettes.
- set_
stroke - Says a stroke (a brush, a drag on the canvas) starts or ends: the
palettes fade meanwhile when the
palettes.fade_on_strokesetting is on. - snap
- A rectangle snapped to the bounds’ edges and to the others’ edges
(side by side or aligned) when within
magnetof them; the nearest edge wins on each axis.
Type Aliases§
- Sides
- The edges a resize drags, on each axis (x, then y):
-1the start edge (left, top),1the end edge (right, bottom),0neither.