Skip to main content

Module property_grid

Module property_grid 

Source
Available on crate feature property-grid only.
Expand description

Named properties in a compact two-column inspector, such as the properties panel of a design tool: names on the left, editors on the right, grouped into categories that collapse.

State holds the properties by id with their values, which categories are collapsed, the highlight, the filter and the Sort. Its update returns Output::Changed whenever a value changes and Output::Reset when one goes back to its default.

Text, numbers and colours are edited as text. A valid edit changes the value as it is typed; an invalid one keeps its draft and shows the error until it is fixed or cancelled, without changing the value. Cancelling puts back the value from before the edit.

The grid resolves its keys through a Keymap of Actions while it has focus, which it takes when pressed; see default_keymap.

Structs§

Draft
Text being typed into a property, and why it is not valid yet.
Number
The limits and look of a number property.
Property
One named property.
PropertyGrid
A property grid builder. Convert it into an Element to render.
RowStyle
The colours of a row.
State
The properties, their values, and what is open, highlighted, filtered and being edited.
Status
How a row is shown.

Enums§

Action
What a property grid keyboard shortcut does.
Entry
One row of the grid.
Event
Everything that changes a property grid.
Kind
What a property holds and how it is edited.
MenuItem
An entry of the context menu from menu.
Output
What the app may need to act on after an Event.
Sort
How the properties are listed.
Toggle
How a true or false property is shown.
Value
A property’s value.

Constants§

DESCRIPTION_HEIGHT
The least height of the description area under the rows, which grows to fit a longer description.
EDITOR_ID
The widget id of the field being edited, to find it in tests.
HANDLE_WIDTH
Width of the draggable line between the columns.
MIN_NAME_WIDTH
The narrowest the name column gets.
MIN_VALUE_WIDTH
The room the value column keeps when the name column is dragged wide.
NAME_WIDTH
The widest the name column starts out, before the user drags it.
NOTHING_SELECTED
Shown in the description area while nothing is highlighted.
RESET_WIDTH
Width of the slot at the end of a row for the reset button.
ROW_HEIGHT
Height of every row, which fits a select.
SEARCH
The widget id of the filter box, which focus_search focuses.
VALUE_WIDTH
The room the value column keeps before the name column, at its default width, starts to shrink: enough for a colour swatch and its hex.

Functions§

choice
A property chosen from options with a select.
colour
A colour property, shown as a swatch and edited as hex.
custom
A property the app draws itself with PropertyGrid::custom. Without a renderer its value is shown as text.
default_keymap
The default property grid shortcuts:
divider_colour
The line between the name and value columns, brighter while dragged or hovered.
focus_search
Focuses the filter box of a grid, for an app that moves the keyboard there itself. Action::FocusSearch does the same from inside the grid.
frame_style
The border around the grid.
hex
A colour as #RRGGBB, or #RRGGBBAA when it is not opaque.
mark_colour
The dot before the name of a property that differs from its default.
match_label
The text beside the search box, as in the log and JSON viewers: “2 of 5” for the highlighted property of those shown, “5 found” while none of them is highlighted, “None” when nothing passes, and empty without a search.
menu
A context menu to pass to PropertyGrid::context_menu: copy the value, or reset it to its default. Turn the chosen entry into an event with MenuItem::event, and call sync_menu after each menu event so entries that would do nothing are disabled.
name_width
The name column’s width in a row width pixels wide. A dragged or set width is kept between MIN_NAME_WIDTH and what leaves the value column MIN_VALUE_WIDTH. Otherwise names take NAME_WIDTH, and in a narrow grid the value column gives up its room first, down to VALUE_WIDTH, so names stay readable.
number
A number property. Set its limits with min, max, step and its look with decimals and unit.
parse_hex
Reads a hex colour: #RGB, #RGBA, #RRGGBB or #RRGGBBAA, with or without the #.
property_grid
Renders state. Without on_event every editor renders disabled.
read_only
Text that cannot be edited, such as an id or a computed size.
row_style
Resolves a row’s colours. Headings sit on a muted band. The grid selects nothing, so the highlighted row only carries a ring, and only while the grid has focus.
swatch_ring
The ring around a colour swatch. Dark themes lift it towards the text colour, so a near-black swatch still shows its edge.
swatch_style
A colour swatch: the colour inside a thin ring.
sync_menu
Disables the entries of a menu that would do nothing for the property it is open on, such as “Reset to default” on a property that already holds its default.
text
A text property.
toggle
A true or false property, shown as a checkbox, or as a switch with switch.
value_colour
The colour of a value: muted when it cannot be edited.

Type Aliases§

Validate
Checks text typed into a text property, returning the error to show.