Skip to main content

Module ui

Module ui 

Source
Expand description

Layout helpers named by role, for an application’s own layout code: text by role, spacing by intent, a card and a button in a tone, drawn from the theme’s tokens and kit.

use egui_pop_core::theme::{self, ThemeSpec};
use egui_pop_core::ui::{Space, Tone, UiPop};

let ctx = egui::Context::default();
theme::install(&ctx, &ThemeSpec::new("pop-dark"));
let mut out = ctx.run_ui(Default::default(), |ui| {
    ui.section_title("Export");
    ui.muted("Writes a copy next to the original.");
    ui.space_role(Space::Group);
    ui.card(Tone::Neutral, |ui| {
        ui.label("IMG_0001.raw");
        ui.meta("24 MB, 12 October");
    });
    if ui.button_tone(Tone::Danger, "Delete").clicked() {
        // ...
    }
});
out.textures_delta.clear();

The helpers are few on purpose, so Ui’s completion list stays short; role_text and Space::points serve the rest.

Re-exports§

pub use crate::kit::Stock;
pub use crate::kit::Tone;
pub use crate::theme::TextRole;
pub use layout::Align;
pub use layout::Cells;
pub use layout::Flow;
pub use layout::FlowCells;
pub use layout::Grid;
pub use layout::Length;
pub use layout::Row;
pub use layout::Track;

Modules§

layout
Rows, grids and flows: UiPop::row and UiPop::grid place cells on tracks, align them on their text’s baseline, and leave gaps of Space only; UiPop::flow places whole cells left to right and wraps them.

Enums§

Space
Spacing by intent (space.inline, group, section, page): what the space is for, each an alias of a step of the spacing scale, so densities scale it.

Traits§

UiPop
Layout helpers named by role, on egui’s [Ui]. Each is a few lines over the theme’s tokens and kit; see the module.

Functions§

contain_wheel
Keeps the wheel over a scroll area just drawn from what scrolls around it, for a view that shows its own ScrollArea (show_viewport, show_rows); UiPop::scroll_area_contained does it for the others. Call it right after the area, in the Ui it was shown in.
contain_wheel_in
contain_wheel for what scrolls in a way a [ScrollAreaOutput] does not tell: over rect, the wheel stops on the ways of ways ([x, y]) that are set. Taken as egui’s own scroll area takes it, and only by the axis it would take.
role_text
text in a role’s size, colour and weight (text-role.*), for a widget that takes a [RichText]. A weight other than regular is drawn with the theme’s interface font at that weight once the theme has installed it (fonts::family), at the regular weight before.
set_scroll_offset
Moves the scroll area of id id (its [ScrollAreaOutput::id]) to offset, in points from its start, as from the next time it is drawn; false when no such area has been drawn. Kinetic scrolling in progress stops there.
strong_text
text as inline emphasis (text-role.strong): the body’s size, a heavier weight and the strong text colour, for a word or a value that must stand out in running text. Not a heading: a title over a group is UiPop::section_title.
tone_color
The colour of text in tone (UiPop::text_tone): danger, warning, success and info the status colours (status.*), accent accent.default, muted text-role.muted.color, record status.danger, neutral text-role.body.color.