Expand description
Tips, as a plugin (TipsPlugin): a tip of the day and contextual
hints, which plugins register (Tips::add), each dismissible and
remembered in the settings (tips.dismissed, the ids of the tips not
to show again; tips.show turns them all off).
A tip’s title and text are translated by keys derived from its id,
tip-<id>.title and tip-<id>.text (the id’s dots become dashes), in
the application’s catalogues; the English given is the fallback.
tip_of_the_daydraws a card with the next tip not dismissed: the previous and next ones, “Don’t show again”, close (for this session);hintdraws one contextual tip where it is called, beside what it is about, with “Got it”.
| Step | Arguments | Default |
|---|---|---|
tips.dismiss | tip, cause (user, agent) | adds it to tips.dismissed |
Commands: tips.reset (every tip shown again, in the Help menu’s
category) and, for agents, tips.list and tips.dismiss (tip).
Tips also come by themselves (Tips::set_auto), chosen by rules
(pick: not dismissed, their command never used, their surface
holding, not shown in the last day, the one shown longest ago), as a
card that never takes the focus, beside the element a tip is about
(its target, named with mark or target) with a halo around
it. Commands tips.show, tips.next, tips.gotIt, tips.notNow
(Escape), tips.off and, for agents, tips.current.
Tips are also declared in files, tips/<id>.md (file): a header
(id, surface, command, target, contextual), a # Title and
the text, read with Tips::add_files (the files’ text, built into
the binary with include_str!) or Tips::add_dir. A text shows
**bold** and `code`; {key} is the key bound to the tip’s
command in the keymap in force, {key:<command>} another command’s
(markup), so a rebound key shows rebound.
Owned: egui has tooltips (on_hover_text), which stay as they are;
no crate offers remembered, translated tips (see docs/tips.md).
use egui_pop_api::tips::{TIPS, Tip, TipsPlugin};
use egui_pop_api::App;
let app = App::builder()
.plugin(TipsPlugin)
.build(&egui::Context::default())
.unwrap();
let tips = app.handle().service(&TIPS).unwrap();
tips.add(Tip::new("photos.rate", "Rate quickly", "Press 1 to 5 to rate the selected photos."));
assert_eq!(tips.of_the_day(app.handle()).map(|t| t.id), Some("photos.rate".into()));
tips.dismiss(app.handle(), "photos.rate").unwrap();
assert!(tips.of_the_day(app.handle()).is_none());Re-exports§
pub use file::TipError;
Modules§
- file
- Tips declared in files:
tips/<id>.md, a header between---lines, then a# Titleheading and the text. - lint
- The tips’ lint: every tip checked against the application, so a renamed command or target cannot leave a dead tip behind.
- markup
- A tip’s text:
{key}placeholders resolved to the key bindings in force, then**bold**and`code`drawn. - pick
- Which tip to show by itself: the rules, without egui.
Structs§
- Tip
- A tip: a title and a text, in English (translated by its id’s keys).
- Tips
- The tips registered, and the tip of the day’s place.
- Tips
Plugin - Declares the tips’ service, settings, step and commands.
Constants§
- CMD_
TIPS_ BROWSE - CMD_
TIPS_ CURRENT - CMD_
TIPS_ DISMISS - CMD_
TIPS_ GOT_ IT - CMD_
TIPS_ LIST - CMD_
TIPS_ NEXT - CMD_
TIPS_ NOT_ NOW - CMD_
TIPS_ OFF - CMD_
TIPS_ ORIGIN - CMD_
TIPS_ RESET - CMD_
TIPS_ SHOW - CONTEXT_
TIP_ SHOWN - The context key set while a tip’s card is shown.
- FIRST_
AFTER - How long after the start the first tip shows by itself, in seconds.
- SETTING_
TIPS_ DISMISSED - The tips not to show again: their ids, separated by commas.
- SETTING_
TIPS_ OFF - The origins (plugins) whose tips are off, separated by commas.
- SETTING_
TIPS_ SEEN - When each tip was shown last:
id@seconds(since 1970), separated by commas. - SETTING_
TIPS_ SHOW - Whether tips are shown at all.
- SETTING_
TIPS_ USED - The commands a person used: their ids, separated by commas.
- STEP_
TIPS_ DISMISS - A tip is dismissed.
- TIPS
- The tips registered, as a service.
- TIPS_
PLUGIN - The plugin’s id.
- TIP_
KIND - The kind of declaration a tip’s keys are derived from (
tip-<id>).
Functions§
- browser
- Draws the browser (it needs
super::TipsPlugin). - groups
- The tips grouped by origin, in the order their first tip was registered.
- halo_
color - The halo’s colour: the theme’s
tip-card.halo-colorwhen it has one, else the information status colour (the card’s icon’s). - hint
- Draws a contextual tip where it is called (it needs
TipsPlugin), unless tips are off or it was dismissed. Returns whether it was drawn. - mark
- Names a widget a tip may point at; returns the response.
- target
- Names a rectangle a tip may point at (a tip’s
target): call it each pass the element is drawn. Names are stable ids (photos.rating,param:exposure). - target_
rect - Where a target is, when it was drawn in this pass or the last.
- targets_
seen - Every target named so far in this session (for the lint).
- tip_
of_ the_ day - Draws the tip of the day, when there is one to show (it needs
TipsPlugin). Returns whether a card was drawn.