|
Aurore
A Switch-like interface for your app, on every screen
|
Namespaces | |
| namespace | hooks |
Classes | |
| struct | CheckLine |
| A line of checklist_body(). More... | |
| struct | Choice |
| struct | Prefs |
Typedefs | |
| using | Alive = std::shared_ptr< bool > |
| using | Weak = std::weak_ptr< bool > |
| using | Swatch = CadranSwatch::Colors |
A row's colours in pick()'s swatches (CadranSwatch). | |
Enumerations | |
| enum class | Toast { Info , Done , Refused } |
| enum class | Check { Ok , Warn , Bad , Info , Header } |
Functions | |
| void | close_sheet (std::function< void()> then) |
Pops the sheet (a fade), then runs then (if any) on the next frame. | |
| aurore::Box * | sheet_outside (float width, bool grow) |
| std::string | fmt_minutes (uint32_t minutes) |
| "0 min", "45 min", "2 h", "2 h 30" | |
| std::string | fmt_duration_ns (uint64_t ns) |
| rounded to minutes, as fmt_minutes | |
| std::string | fmt_duration (uint64_t seconds) |
| "0 min", "< 1 min", "45 min", "52 h 30", "278 h" (no 24 h cap) | |
| std::string | day_name (int day) |
| 0 = Sunday, as a title ("Monday") | |
| std::string | day_name_in_text (int day) |
| inside a sentence (fr: "lundi") | |
| std::string | bool_text (bool ok, bool value, const std::string &yes, const std::string &no) |
| std::string | yes_no (bool value) |
| std::string | opens (const std::string &value="") |
| Alive | make_alive () |
| template<typename F > | |
| auto | guarded (Weak alive, F fn) |
| template<typename F > | |
| auto | guarded (const Alive &alive, F fn) |
| Prefs & | prefs () |
| The ones in use: the app's (use_prefs), else defaults of their own. | |
| void | use_prefs (Prefs &p) |
From now on, prefs() is p, which must outlive every screen. | |
| bool | env_flag (const char *name) |
| void | use_font_for (const std::string &locale) |
| void | notify (const std::string &text, Toast kind=Toast::Info) |
| void | refuse (const std::string &text) |
| void | error (const std::string &text) |
| void | error (const std::string &what, const std::string &why) |
what failed because of why (a path, a message from the network…). | |
| void | show_failure (const cadran_text::Failure &f) |
| void | replace_screen (aurore::Activity *next) |
| void | confirm (const std::string &body, const std::string &confirm_label, std::function< void()> on_yes, std::function< void()> on_no=nullptr, bool danger=false) |
| void | confirm_danger (const std::string &body, const std::string &confirm_label, std::function< void()> on_yes) |
| void | info (const std::string &body) |
| void | qr_dialog (const std::string &body, const std::string &url) |
| aurore::Box * | check_row (const CheckLine &line, float size=17) |
One of them: the mark, then the text (size px). | |
| aurore::Box * | checklist_body (const std::string &title, const std::vector< CheckLine > &lines, const std::string ¬e="", const std::string &subtitle="") |
| void | notice (const char *icon, Check tone, const std::string &title, const std::string &text) |
| void | hold_confirm (aurore::Box *body, const std::string &hold_label, std::function< void()> on_yes, std::function< void()> on_no=nullptr) |
| aurore::Dialog * | dialog (const std::string &text) |
| aurore::Dialog * | dialog (const std::string &text, aurore::View *below) |
| aurore::Dialog * | box_dialog (aurore::Box *body) |
| void | on_cancel (aurore::Dialog *dialog, std::function< void()> on_cancel) |
B closes dialog and runs on_cancel (Aurore's own B only closes it). | |
| void | add_cancel (aurore::Dialog *dialog, std::function< void()> cancel) |
| void | pick (const std::string &title, const std::vector< std::string > &values, int selected, std::function< void(int)> on_pick, bool checked=true, const std::vector< std::string > &details={}, const std::vector< std::string > &icons={}, const std::vector< Swatch > &swatches={}) |
| void | pick_grid (const std::string &title, const std::vector< std::string > &values, const std::vector< std::string > &icons, int selected, std::function< void(int)> on_pick, int columns=4) |
| void | pick_marked (const std::string &title, const std::vector< std::string > &values, const std::vector< bool > &marks, int focus, std::function< void(int)> on_pick, const std::vector< std::string > &details={}) |
| void | pick_actions (const std::string &title, const std::vector< Choice > &choices, const std::string &subtitle="", int image=0) |
The sheet of choices (see Choice) under title. | |
| bool | is_sheet (aurore::View *view) |
| The sheet those open: its view, on top of the activities' stack. | |
| void | prompt_text (const std::string &header, const std::string &initial, int max_len, std::function< void(std::string)> on_value) |
| The system keyboard for a text. The callback only on confirm. | |
| void | show_writable (aurore::DetailCell *cell, bool writable, const char *title_key="cadran/text", const char *detail_key="cadran/text2") |
| void | set_visible (aurore::View *view, bool visible) |
| void | set_visible_all (std::initializer_list< std::pair< aurore::View *, bool > > changes) |
| void | set_text (aurore::Label *label, const std::string &text) |
| void | set_detail (aurore::DetailCell *cell, const std::string &text) |
| void | batch_layout (aurore::Box *box, const std::function< void()> &fill) |
| void | keep_focus (aurore::Activity *activity, aurore::View *fallback=nullptr) |
| bool | has_focus (aurore::Activity *activity) |
| bool | on_top (aurore::Activity *activity) |
| aurore::Activity * | main_screen () |
| The main screen, wherever it is in the stack; nullptr before it opens. | |
| void | open_tab (int position, const std::string &row="") |
| void | refresh_shown_tab () |
| void | go_to_tab (aurore::View *from, int position) |
| void | open_screen (aurore::View *content, const std::string &title) |
| void | quick_settings (std::function< void()> after=nullptr) |
| bool | save_prefs () |
| void | pick_language (std::function< void()> after=nullptr) |
| void | pick_theme (std::function< void()> after=nullptr) |
| void | pick_palette (std::function< void()> after=nullptr) |
| std::string | palette_name () |
| void | pick_text_size (std::function< void()> after=nullptr) |
| std::string | text_size_name (bool tile=false) |
| void | pick_rail (std::function< void()> after=nullptr) |
| std::string | rail_name () |
| std::string | language_name (bool tile=false) |
| std::string | theme_name (bool tile=false) |
Variables | |
| constexpr const char * | LANGUAGES [] |
| constexpr const char * | THEMES [] = { "system", "light", "dark" } |
| constexpr const char * | TEXT_SIZES [] = { "auto", "normal", "large", "largest" } |
| constexpr const char * | EFFECTS [] = { "auto", "full", "reduced" } |
| constexpr const char * | RAILS [] = { "auto", "open", "icons" } |
| using ui::Alive = typedef std::shared_ptr<bool> |
The token a screen's late callbacks check: it goes with the screen (or is set to false, for a screen that closes before it is freed).
| using ui::Swatch = typedef CadranSwatch::Colors |
A row's colours in pick()'s swatches (CadranSwatch).
| using ui::Weak = typedef std::weak_ptr<bool> |
What a background task holds of it: the task never keeps the screen's token, it wraps with it the callback it hands to aurore::sync.
|
strong |
A list of checks in a dialog: each line with its mark (a teal check for what is ready, an amber or coral triangle for what is not, a grey dot for what is only said), under title, note small at the end (may be empty).
| Enumerator | |
|---|---|
| Ok | |
| Warn | |
| Bad | |
| Info | |
| Header | not a check: the name of the panel of lines after it |
|
strong |
| void ui::add_cancel | ( | aurore::Dialog * | dialog, |
| std::function< void()> | cancel | ||
| ) |
A Cancel button and B, both closing dialog and running cancel: a dialog that waits for something (a check, an answer from the network).
| void ui::batch_layout | ( | aurore::Box * | box, |
| const std::function< void()> & | fill | ||
| ) |
Runs fill, which adds many views to box (or changes them), with the box out of the screen's layout, then lays the screen out once. Aurore lays the whole screen out again on each addView and setText: a list of n rows built in place cost n layouts of the whole screen, n of them on screen.
| std::string ui::bool_text | ( | bool | ok, |
| bool | value, | ||
| const std::string & | yes, | ||
| const std::string & | no | ||
| ) |
| aurore::Dialog * ui::box_dialog | ( | aurore::Box * | body | ) |
The same for a body already laid out (a checklist, a sheet): as it is, or in a scrolling frame when taller than the dialog's room.
| aurore::Box * ui::check_row | ( | const CheckLine & | line, |
| float | size = 17 |
||
| ) |
One of them: the mark, then the text (size px).
| aurore::Box * ui::checklist_body | ( | const std::string & | title, |
| const std::vector< CheckLine > & | lines, | ||
| const std::string & | note = "", |
||
| const std::string & | subtitle = "" |
||
| ) |
Under title (and subtitle), the lines in rounded panels, one per Header line (its name small above it); note with an info icon last.
| void ui::close_sheet | ( | std::function< void()> | then | ) |
Pops the sheet (a fade), then runs then (if any) on the next frame.
| void ui::confirm | ( | const std::string & | body, |
| const std::string & | confirm_label, | ||
| std::function< void()> | on_yes, | ||
| std::function< void()> | on_no = nullptr, |
||
| bool | danger = false |
||
| ) |
Two-button dialog. Cancel (left) has the focus when it opens; confirm_label (right) runs on_yes, Cancel or B runs on_no. danger: the confirm button is drawn in the "bad" colour (see below).
| void ui::confirm_danger | ( | const std::string & | body, |
| const std::string & | confirm_label, | ||
| std::function< void()> | on_yes | ||
| ) |
Same, for actions that delete something: the confirm button is drawn in the "bad" colour so it never looks like an ordinary OK.
| std::string ui::day_name | ( | int | day | ) |
0 = Sunday, as a title ("Monday")
| std::string ui::day_name_in_text | ( | int | day | ) |
inside a sentence (fr: "lundi")
| aurore::Dialog * ui::dialog | ( | const std::string & | text | ) |
A dialog showing text, laid out by cadran::dialog_body (its question as the title, its tables, its notes), the caller adding its buttons; a text taller than the dialog's room scrolls.
| aurore::Dialog * ui::dialog | ( | const std::string & | text, |
| aurore::View * | below | ||
| ) |
The same with below under the text, the card's width unless it aligns itself: a QR code, a code to read out, the cards to support the app.
| bool ui::env_flag | ( | const char * | name | ) |
A flag of the environment, through ui::hooks::get().env_flag (its comment says which).
| void ui::error | ( | const std::string & | text | ) |
A failure the user asked for something and did not get: a dialog, not a toast (a toast is gone before "error 0x…" is read). Next frame, so it can be called from a dialog button. Logged as "error: " for the smoke test.
| void ui::error | ( | const std::string & | what, |
| const std::string & | why | ||
| ) |
what failed because of why (a path, a message from the network…).
| std::string ui::fmt_duration | ( | uint64_t | seconds | ) |
"0 min", "< 1 min", "45 min", "52 h 30", "278 h" (no 24 h cap)
| std::string ui::fmt_duration_ns | ( | uint64_t | ns | ) |
rounded to minutes, as fmt_minutes
| std::string ui::fmt_minutes | ( | uint32_t | minutes | ) |
"0 min", "45 min", "2 h", "2 h 30"
| void ui::go_to_tab | ( | aurore::View * | from, |
| int | position | ||
| ) |
Opens another tab of the main screen and focuses its first item. from is any view inside the current tab; the switch happens on the next frame because the current tab is deleted by it.
| auto ui::guarded | ( | const Alive & | alive, |
| F | fn | ||
| ) |
| auto ui::guarded | ( | Weak | alive, |
| F | fn | ||
| ) |
fn(args…), or nothing once alive is gone or false. Converts to the std::function a flow takes, whatever its arguments.
| bool ui::has_focus | ( | aurore::Activity * | activity | ) |
Whether activity has the focus: nothing (a dialog, another screen) is open over it. Unlike the top of Aurore's stack, true again as soon as a dialog over it starts closing.
| void ui::hold_confirm | ( | aurore::Box * | body, |
| const std::string & | hold_label, | ||
| std::function< void()> | on_yes, | ||
| std::function< void()> | on_no = nullptr |
||
| ) |
body with Cancel and hold_label: A (or a finger) held on it for 2 s, the button filling meanwhile, runs on_yes; let go sooner, it empties and nothing happens. For what is hard to undo from the console. The dialog says how itself (hold_hint, the A key for a controller): body need not.
| void ui::info | ( | const std::string & | body | ) |
| bool ui::is_sheet | ( | aurore::View * | view | ) |
The sheet those open: its view, on top of the activities' stack.
| void ui::keep_focus | ( | aurore::Activity * | activity, |
| aurore::View * | fallback = nullptr |
||
| ) |
For an activity's onResume(): Aurore then gives the focus back to the view that opened the dialog (or screen) just closed, and gives none when that view was hidden meanwhile; the focus would stay on the closed dialog's button, deleted after its animation, and no button answer any more. In that case only, fallback (else the activity's first focusable view) gets it first.
| std::string ui::language_name | ( | bool | tile = false | ) |
The language and the theme saved, as text (shorter on a tile).
| aurore::Activity * ui::main_screen | ( | ) |
The main screen, wherever it is in the stack; nullptr before it opens.
|
inline |
| void ui::notice | ( | const char * | icon, |
| Check | tone, | ||
| const std::string & | title, | ||
| const std::string & | text | ||
| ) |
A dialog that only says something: a badge (icon in tone's colour), title, text, OK.
| void ui::notify | ( | const std::string & | text, |
| Toast | kind = Toast::Info |
||
| ) |
A toast of kind. Deferred to the next frame (toasts fired right after a system applet returns were dropped on fw 22.1.0).
| void ui::on_cancel | ( | aurore::Dialog * | dialog, |
| std::function< void()> | on_cancel | ||
| ) |
B closes dialog and runs on_cancel (Aurore's own B only closes it).
| bool ui::on_top | ( | aurore::Activity * | activity | ) |
Whether activity is the top of Aurore's stack: no screen or dialog pushed over it, one closing included.
| void ui::open_screen | ( | aurore::View * | content, |
| const std::string & | title | ||
| ) |
content (a tab's view, such as the network clock) on a screen of its own, over the current one, titled title; B closes it.
| void ui::open_tab | ( | int | position, |
| const std::string & | row = "" |
||
| ) |
Shows its tab position (ui::tab) and focuses its content: the view with id row when given and shown, else its first one. Nothing before it opens.
| std::string ui::opens | ( | const std::string & | value = "" | ) |
The value of a line that opens a screen of its own (or another tab), with a chevron after it: "12 changes ›", or "›" alone. A line that asks first, in a dialog, ends its title with "…" instead; one that acts at once, neither.
| std::string ui::palette_name | ( | ) |
The language and theme pickers, shared by Preferences and the main screen's header: save the choice (ui::prefs, through hooks::get().save_prefs) and apply it at once (a language makes every screen again, live_prefs; a theme or the text size runs after, a refresh). language_name / theme_name: the choice saved, as text; text_size_name, language_name and theme_name their shorter words on a tile (Preferences). The theme picker ends with the palette's row, which opens pick_palette: the boards' colours, Aurore's presets (aurore::Theme:: builtinThemes) or the user's theme files (ui::hooks' themes_dir); palette_name, the one saved (ui::Prefs::theme_file), by its name.
| void ui::pick | ( | const std::string & | title, |
| const std::vector< std::string > & | values, | ||
| int | selected, | ||
| std::function< void(int)> | on_pick, | ||
| bool | checked = true, |
||
| const std::vector< std::string > & | details = {}, |
||
| const std::vector< std::string > & | icons = {}, |
||
| const std::vector< Swatch > & | swatches = {} |
||
| ) |
A list of values, as a sheet (ui/action_sheet.cpp); on_pick(index) runs after it has closed. The row selected has the focus and is checked as the current value, unless checked is false (a list of things to do, not of values). details, when given, says more about each row, after its label and quieter; icons, what goes before each row's label: a Cadran icon's name ("moon"), or a picture (a resource, "img/…png", drawn as it is); empty: none. swatches, when given, a sample of colours in the icon's place instead, for the rows it has (a palette's, as pick_palette() shows them): its background in a rounded square, its ring inside, its motif (a Cadran icon's name) in its ink, a hairline of the theme's cadran/line around it (CadranSwatch).
| void ui::pick_actions | ( | const std::string & | title, |
| const std::vector< Choice > & | choices, | ||
| const std::string & | subtitle = "", |
||
| int | image = 0 |
||
| ) |
The sheet of choices (see Choice) under title.
| void ui::pick_grid | ( | const std::string & | title, |
| const std::vector< std::string > & | values, | ||
| const std::vector< std::string > & | icons, | ||
| int | selected, | ||
| std::function< void(int)> | on_pick, | ||
| int | columns = 4 |
||
| ) |
The same as tiles, columns to a row, each its Cadran icon (icons, a name) large above its label: a few values that read better side by side (the tabs of Start on).
| void ui::pick_language | ( | std::function< void()> | after = nullptr | ) |
The language and theme pickers, shared by Preferences and the main screen's header: save the choice (ui::prefs, through hooks::get().save_prefs) and apply it at once (a language makes every screen again, live_prefs; a theme or the text size runs after, a refresh). language_name / theme_name: the choice saved, as text; text_size_name, language_name and theme_name their shorter words on a tile (Preferences). The theme picker ends with the palette's row, which opens pick_palette: the boards' colours, Aurore's presets (aurore::Theme:: builtinThemes) or the user's theme files (ui::hooks' themes_dir); palette_name, the one saved (ui::Prefs::theme_file), by its name.
| void ui::pick_marked | ( | const std::string & | title, |
| const std::vector< std::string > & | values, | ||
| const std::vector< bool > & | marks, | ||
| int | focus, | ||
| std::function< void(int)> | on_pick, | ||
| const std::vector< std::string > & | details = {} |
||
| ) |
The same with several rows checked: those marks sets (true). Choosing a row closes the list as pick() does: to toggle one, the caller opens it again with the row's mark changed and the focus on it (focus).
| void ui::pick_palette | ( | std::function< void()> | after = nullptr | ) |
The language and theme pickers, shared by Preferences and the main screen's header: save the choice (ui::prefs, through hooks::get().save_prefs) and apply it at once (a language makes every screen again, live_prefs; a theme or the text size runs after, a refresh). language_name / theme_name: the choice saved, as text; text_size_name, language_name and theme_name their shorter words on a tile (Preferences). The theme picker ends with the palette's row, which opens pick_palette: the boards' colours, Aurore's presets (aurore::Theme:: builtinThemes) or the user's theme files (ui::hooks' themes_dir); palette_name, the one saved (ui::Prefs::theme_file), by its name.
| void ui::pick_rail | ( | std::function< void()> | after = nullptr | ) |
The main screen's sidebar (ui::Prefs::rail): open, on its icons, or folding by itself; applied at once (cadran::apply_rail). rail_name: the choice saved, as text.
| void ui::pick_text_size | ( | std::function< void()> | after = nullptr | ) |
The language and theme pickers, shared by Preferences and the main screen's header: save the choice (ui::prefs, through hooks::get().save_prefs) and apply it at once (a language makes every screen again, live_prefs; a theme or the text size runs after, a refresh). language_name / theme_name: the choice saved, as text; text_size_name, language_name and theme_name their shorter words on a tile (Preferences). The theme picker ends with the palette's row, which opens pick_palette: the boards' colours, Aurore's presets (aurore::Theme:: builtinThemes) or the user's theme files (ui::hooks' themes_dir); palette_name, the one saved (ui::Prefs::theme_file), by its name.
| void ui::pick_theme | ( | std::function< void()> | after = nullptr | ) |
The language and theme pickers, shared by Preferences and the main screen's header: save the choice (ui::prefs, through hooks::get().save_prefs) and apply it at once (a language makes every screen again, live_prefs; a theme or the text size runs after, a refresh). language_name / theme_name: the choice saved, as text; text_size_name, language_name and theme_name their shorter words on a tile (Preferences). The theme picker ends with the palette's row, which opens pick_palette: the boards' colours, Aurore's presets (aurore::Theme:: builtinThemes) or the user's theme files (ui::hooks' themes_dir); palette_name, the one saved (ui::Prefs::theme_file), by its name.
| Prefs & ui::prefs | ( | ) |
The ones in use: the app's (use_prefs), else defaults of their own.
| void ui::prompt_text | ( | const std::string & | header, |
| const std::string & | initial, | ||
| int | max_len, | ||
| std::function< void(std::string)> | on_value | ||
| ) |
The system keyboard for a text. The callback only on confirm.
| void ui::qr_dialog | ( | const std::string & | body, |
| const std::string & | url | ||
| ) |
A web page to open on a phone: body, the QR code of url, then url itself, shortened (text::short_url), and OK.
| void ui::quick_settings | ( | std::function< void()> | after = nullptr | ) |
− on the main screen: a list of the two, each opening its picker.
| std::string ui::rail_name | ( | ) |
The main screen's sidebar (ui::Prefs::rail): open, on its icons, or folding by itself; applied at once (cadran::apply_rail). rail_name: the choice saved, as text.
| void ui::refresh_shown_tab | ( | ) |
Re-reads the tab on screen, if any (after the read-only or developer mode changed, the language or the text size).
| void ui::refuse | ( | const std::string & | text | ) |
Something asked that was not done, and why, as a Refused toast (its warning icon): a refusal is said and gone, a failure is a dialog (error).
| void ui::replace_screen | ( | aurore::Activity * | next | ) |
next in place of the current screen. Aurore never pops the first activity (the loading screen, under every start screen): a screen that cannot be popped gets next pushed over it instead.
| bool ui::save_prefs | ( | ) |
Saves ui::prefs() through hooks::get().save_prefs: false when it cannot be saved at all.
| void ui::set_detail | ( | aurore::DetailCell * | cell, |
| const std::string & | text | ||
| ) |
| void ui::set_text | ( | aurore::Label * | label, |
| const std::string & | text | ||
| ) |
A label's text, or a cell's detail, set only when it changes: Aurore lays the whole screen out again on every setText, and the tabs that refresh themselves every few seconds mostly write the same values back.
| void ui::set_visible | ( | aurore::View * | view, |
| bool | visible | ||
| ) |
Hides a view when visible is false (Visibility::GONE frees its space). When the hidden view had the focus, the focus moves to the nearest visible focusable sibling (the next one on a tie), so it never lands on the list container or jumps far away.
| void ui::set_visible_all | ( | std::initializer_list< std::pair< aurore::View *, bool > > | changes | ) |
Applies several visibility changes, showing views before hiding others, so a cell that replaces the focused one (Unlock -> Lock now) is there to take the focus.
| aurore::Box * ui::sheet_outside | ( | float | width, |
| bool | grow | ||
| ) |
Room around the panel, width wide or taking what is left (grow): a touch there closes the sheet.
| void ui::show_failure | ( | const cadran_text::Failure & | f | ) |
The dialog the three open, now: the title, the reason, the code small, and Send a report (OK focused) when f.report.
| void ui::show_writable | ( | aurore::DetailCell * | cell, |
| bool | writable, | ||
| const char * | title_key = "cadran/text", |
||
| const char * | detail_key = "cadran/text2" |
||
| ) |
An action that writes stays visible when the app cannot write (a read-only mode), greyed (title and value), so the user sees what exists. title_key / detail_key: the theme colours when writable. A BooleanCell gets its own colours back from its state.
| std::string ui::text_size_name | ( | bool | tile = false | ) |
The language and theme pickers, shared by Preferences and the main screen's header: save the choice (ui::prefs, through hooks::get().save_prefs) and apply it at once (a language makes every screen again, live_prefs; a theme or the text size runs after, a refresh). language_name / theme_name: the choice saved, as text; text_size_name, language_name and theme_name their shorter words on a tile (Preferences). The theme picker ends with the palette's row, which opens pick_palette: the boards' colours, Aurore's presets (aurore::Theme:: builtinThemes) or the user's theme files (ui::hooks' themes_dir); palette_name, the one saved (ui::Prefs::theme_file), by its name.
| std::string ui::theme_name | ( | bool | tile = false | ) |
The language and the theme saved, as text (shorter on a tile).
| void ui::use_font_for | ( | const std::string & | locale | ) |
On the console: the default font of the labels made from now on, for the strings' language locale: the system's Latin / Japanese font, the Chinese one only as a fallback; for Chinese, the Chinese one. Right after createWindow(), before the first label exists, then again when the language changes while the app runs (live_prefs, which builds the screens again).
| std::string ui::yes_no | ( | bool | value | ) |
"Yes" / "No"
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |