Expand description
Icons by role: an Icon names what the icon means (Check,
Search, Warning), never a codepoint. With the phosphor feature
the Phosphor font (through
egui-phosphor, MIT) is added to the context as a family of its own
and icons are drawn from it; without it, or for the marks that are
always painted, the icon is painted with lines and fills. Either way
the icon is sized by its Size and coloured by its Tone from
the theme’s tokens.
A Source is what an IconWidget draws: an icon by role, a glyph
from any font, or an image.
Icons are declared by name wherever a declaration has no egui (a
command, a panel, a place): one vocabulary of egui-pop’s names, the
Phosphor glyphs’ (phosphor:<name>) and the registered ones
(<plugin-id>:<name>), resolved once and checked, the unknown ones
reported (registry). Widgets taking an icon accept a name too
(IconRef).
use egui_pop_core::icon::{Icon, Size, Tone};
fn toolbar(ui: &mut egui::Ui) {
let close = Icon::Close.size(Size::Toolbar).label("Close");
if ui.add(close.sense_click()).clicked() { /* ... */ }
ui.add(Icon::Warning.tone(Tone::Warning).label("Unsaved changes"));
}Re-exports§
pub use registry::IconRef;pub use registry::PLACEHOLDER;pub use registry::PhosphorIcon;
Modules§
- registry
- The icon vocabulary: every name an icon can be declared by, resolved once, and the names that did not resolve.
Structs§
- Icon
Widget - An icon as a widget.
Enums§
- Icon
- What an icon means. Each has a glyph in the icon font (with the
phosphorfeature) and a painted fallback. - Size
- Where an icon is used, which decides its size.
- Source
- What an icon widget draws.
- Tone
- Its colour, by meaning.
Constants§
- FAMILY
- The family the icon font is installed under (
phosphorfeature).
Functions§
- font_
ready - Whether the icon font is in use in this context.
- insert
- Puts the icon font, in its family, into font definitions being built
(
fonts::installreplaces egui’s definitions and keeps it this way). Does nothing without thephosphorfeature. - install
- Adds the icon font to a context, in a family of its own (the text
fonts are untouched). In use from the next pass; adding it again does
nothing. Called by
theme::install; does nothing without thephosphorfeature. - mark
- Allocates a square of
sidepoints and paints an icon in it, with no interaction: a mark inside another widget (a menu tick, a toast’s level). - paint_
fallback - Paints an icon’s fallback shape, whatever the fonts. Its strokes are whole physical pixels at the painter’s scale.
- paint_
mark - Paints one of the marks that fill their square (
Icon::Circle,Disc,Square,Triangle,Asterisk,Corner, and theIcon::Diamond) at the full size ofrect, a ringringpoints thick;falsefor any other icon, which is left unpainted. Dots, LEDs and flags draw their default shapes with it.