Skip to main content

Module tips

Module tips 

Source
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).

Experimental: may change in any release (docs/stability.md).

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_day draws a card with the next tip not dismissed: the previous and next ones, “Don’t show again”, close (for this session);
  • hint draws one contextual tip where it is called, beside what it is about, with “Got it”.
StepArgumentsDefault
tips.dismisstip, 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 # Title heading 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.
TipsPlugin
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-color when 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.