TachyonUI 1.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
gui_notification_types.h
Go to the documentation of this file.
1#pragma once
2
3#include <gui_core/style/gui_style_text.h> // IconID
4
5#include <cstdint>
6#include <functional>
7#include <optional>
8#include <string>
9#include <string_view>
10#include <vector>
11
12// Telling the user something without a dialog: toasts in a window's corner, banners at the
13// top of a panel.
14
15namespace tachyon
16{
19
21 enum class Severity : uint8_t { Info, Success, Warning, Error };
22
24 struct ToastAction {
25 std::string label;
26 std::function<void()> onClick;
27 };
28
30 struct ToastDesc {
32 std::string title;
33 std::string body;
34 bool monospaceBody = false;
35 std::optional<float> progress;
36 std::vector<ToastAction> actions;
37 float age = 0.0f;
39 };
40
42 using ToastID = uint32_t;
43
45 enum class BannerActionKind : uint8_t { Primary, Secondary, Link };
46
48 struct BannerAction {
49 std::string_view label;
50 std::function<void()> onClick;
52 };
53
55}
@ Primary
Definition gui_application.h:114
@ Secondary
Definition gui_application.h:114
Severity
How serious a notification is: its icon and color.
Definition gui_notification_types.h:21
uint32_t ToastID
A toast shown by ShowToast; 0 is none.
Definition gui_notification_types.h:42
BannerActionKind
How a banner's action is drawn.
Definition gui_notification_types.h:45
@ Info
Definition gui_notification_types.h:21
@ Secondary
Definition gui_notification_types.h:45
@ Link
Definition gui_notification_types.h:45
@ Success
Definition gui_element_storage.h:40
IconID
Handle for an icon registered with ITextSystem::RegisterIconFromSVG / RegisterIconFromSVGFile.
Definition gui_style_text.h:15
@ Invalid
Definition gui_style_text.h:15
Definition gui_logging.h:24
A banner's button or link, right-aligned after its message.
Definition gui_notification_types.h:48
std::function< void()> onClick
Definition gui_notification_types.h:50
std::string_view label
Definition gui_notification_types.h:49
BannerActionKind kind
Definition gui_notification_types.h:51
A failure: its category and a human-readable message.
Definition gui_result.h:26
A text button on a toast; the first is drawn in the link color.
Definition gui_notification_types.h:24
std::function< void()> onClick
then the toast goes
Definition gui_notification_types.h:26
std::string label
Definition gui_notification_types.h:25
What a toast says (ShowToast). Change it later through FindToast.
Definition gui_notification_types.h:30
std::vector< ToastAction > actions
Definition gui_notification_types.h:36
Severity severity
Definition gui_notification_types.h:31
float age
seconds since it happened, when it's shown: its time says so
Definition gui_notification_types.h:37
std::optional< float > progress
0..1: a progress bar under the body
Definition gui_notification_types.h:35
std::string body
Definition gui_notification_types.h:33
bool monospaceBody
code or file locations
Definition gui_notification_types.h:34
IconID icon
in place of its severity's ("Uploading": an up arrow); Invalid: the severity's
Definition gui_notification_types.h:38
std::string title
Definition gui_notification_types.h:32