Skip to main content

egui_pop_api/
lib.rs

1//! The application API of egui-pop (layer L3, see ADR 0001), with its
2//! own semver: what plugins are written against.
3//!
4//! - [`Plugin`]: a feature with an id, requirements, a priority, and
5//!   `connect`/`disconnect`; everything it registers is its own
6//!   (ADR 0004);
7//! - [`Ctx`]: what a plugin registers through: commands (declared once:
8//!   keys, menus, palette and agent surface derived), key bindings, menu
9//!   items, panels, zones, blocks, settings, services, lifecycle
10//!   handlers, alter hooks, stories;
11//! - [`zones`]: named places and blocks added, replaced, extended or
12//!   wrapped (ADR 0005);
13//! - [`hooks`]: alter hooks over menus, the palette and settings, run at
14//!   build time; lifecycle events;
15//! - [`host`]: the application's kernel behind the interface: commands
16//!   run, an event journal, the store, a waker ([`host::LocalHost`] by
17//!   default);
18//! - [`steps`]: the moments of a feature's life plugins may watch,
19//!   veto, replace or extend (ADR 0011);
20//! - [`contexts`]: the context stack (places and modes, ADR 0012): its
21//!   owner behind the host, the projection, the breadcrumb and mode
22//!   chips, the `nav.*` and `context.*` commands, a plugin;
23//! - [`clipboard`]: the clipboard (ADR 0015): its owner behind the
24//!   host, components' sources and targets, types, transforms and
25//!   sanitisers declared by plugins, the `clipboard.copy` and
26//!   `clipboard.paste` steps, the Edit commands and the agents'
27//!   `clipboard.*`, a plugin;
28//! - [`links`]: links (ADR 0017): one service opens them through one
29//!   policy and the `link.open` step, with a replaceable opener; egui's
30//!   own `OpenUrl` routed through it; the link widget, the
31//!   confirmation, the agents' `links.open` and `links.check`, the
32//!   `links` collector and the lint, a plugin;
33//! - [`selection`]: the application-wide selection (opt-in):
34//!   the items selected and the one hovered, shared by every panel,
35//!   their history (`selection.back`, `selection.forward`), context keys,
36//!   the agents' commands and the `selection` collector, a plugin;
37//! - [`services`]: typed service tokens;
38//! - [`stories`]: gallery stories as a contribution;
39//! - [`busy`]: a button bound to a command, showing its busy state (a
40//!   delayed spinner while the host has not answered);
41//! - [`palette`]: the command palette, a plugin;
42//! - [`palettes`]: toolboxes and palettes floating over the interface,
43//!   never modal, docking in the workbench's areas;
44//! - [`devtools`]: the debug bridge's collectors in the application, a
45//!   panel behind a setting, a plugin;
46//! - [`dialogs`]: confirmations, forms, choices and notices, a plugin;
47//! - [`toasts`]: notices in a corner, with actions, a plugin;
48//! - [`notices`]: notice sites (a page's notes), routing policies,
49//!   command errors;
50//! - [`jobs`]: the host's background jobs followed from its journal
51//!   (each with an estimated overall fraction), their commands and the
52//!   `jobs` collector, a plugin; [`jobs_centre`]: the jobs as a panel
53//!   and a popover, each with its log console;
54//! - [`frame`]: the window's own title bar and edges, a plugin;
55//! - [`strips`]: the activity bar and status bar indicators fed by the
56//!   host's events, a plugin;
57//! - [`arrangements`]: named layouts saved, switched and reset through
58//!   the host's store, a plugin;
59//! - [`workbench`]: panels in areas over egui_stack, with placement
60//!   rules, changed by named steps;
61//! - [`window`]: the window's place kept and repaired, full screen with
62//!   a way out, a plugin;
63//! - [`zoom`]: the interface zoom in steps, its commands and keys;
64//! - [`sliders`]: the `slider.change` step, and the hook that runs it
65//!   from egui-pop's sliders;
66//! - [`admin`]: the administration app, settings as full pages generated
67//!   from declarations (scope tabs, sections, value scopes);
68//! - [`settings_window`]: the settings window (search, sections, form)
69//!   and the shortcuts editor, a plugin;
70//! - [`settings_pages`]: custom pages a plugin draws in the settings
71//!   window, placed in its tree, searched, with their reset;
72//! - [`system_keys`]: how the shortcuts bound in the system scope (also
73//!   outside the window) are registered, as the shortcuts editor shows
74//!   it;
75//! - [`theme_editor`]: a theme's tokens edited live, by role, with
76//!   colour pickers, contrast readouts, undo, export and import, a
77//!   plugin;
78//! - [`about`]: Help > About *application*, the application's name,
79//!   version, licences, authors and links, and its version info to
80//!   copy, a plugin;
81//! - [`tips`]: a tip of the day and contextual hints, dismissed for good
82//!   through the settings, a plugin;
83//! - [`strings`]: the interface's own text, by key with English
84//!   fallbacks, translated by the installed `egui_pop_core::strings`
85//!   provider;
86//! - [`mounts`]: the mount contract (ADR 0013): the hosts and their
87//!   offers, the components and their needs, `AppHandle::where_can`,
88//!   `AppHandle::mount` and the `mounts` collector;
89//! - [`DefaultPlugins`] and [`MinimalPlugins`]: plugin groups for
90//!   [`AppBuilder::plugins`];
91//! - [`AppBuilder`] and [`App`]: sorting, connecting, the shell (menu
92//!   bar, zones, panels, the command palette), key dispatch; over eframe
93//!   or headless.
94//!
95//! ```
96//! use egui_pop_api::{App, Ctx, Plugin, PluginError, zones};
97//! use egui_pop_api::zones::Block;
98//! use egui_pop_model::commands::CommandSpec;
99//! use egui_pop_model::ids::{BlockId, CommandId, PluginId};
100//!
101//! struct Hello;
102//!
103//! impl Plugin for Hello {
104//!     fn id(&self) -> PluginId {
105//!         PluginId::from_static("hello")
106//!     }
107//!
108//!     fn connect(&mut self, ctx: &mut Ctx<'_>) -> Result<(), PluginError> {
109//!         ctx.command(
110//!             CommandSpec::new(CommandId::from_static("hello.greet"), "Greet", "Hello").key("Ctrl+G"),
111//!             |_| Ok(serde_json::json!("hello")),
112//!         )?;
113//!         ctx.block(zones::MAIN, Block::add(BlockId::from_static("hello.text"), 0, |ui, _| {
114//!             ui.label("Hello");
115//!         }));
116//!         Ok(())
117//!     }
118//! }
119//!
120//! let ctx = egui::Context::default();
121//! let mut app = App::builder().plugin(Hello).build(&ctx).unwrap();
122//! assert!(app.handle().diagnostics().is_empty());
123//! let out = app.run(&CommandId::from_static("hello.greet"), serde_json::Value::Null,
124//!     egui_pop_model::commands::Origin::User);
125//! assert_eq!(out.now(), Some(Ok(serde_json::json!("hello"))));
126//! ```
127
128pub mod about;
129pub mod admin;
130pub mod app;
131pub mod arrangements;
132pub mod bus;
133pub mod busy;
134pub mod clipboard;
135pub mod contexts;
136pub mod ctx;
137pub mod devtools;
138pub mod dialogs;
139pub mod dirs;
140pub mod files;
141pub mod frame;
142pub mod group;
143mod groups;
144pub mod history;
145pub mod history_view;
146pub mod hooks;
147pub mod host;
148pub mod jobs;
149pub mod jobs_centre;
150pub mod layout_controls;
151pub mod links;
152pub mod main_wake;
153pub mod menus;
154pub mod mounts;
155pub mod notices;
156pub mod paint_guard;
157pub mod palette;
158pub mod palettes;
159pub mod plugin;
160pub mod pointer;
161pub mod reads;
162#[cfg(all(feature = "eframe", not(target_arch = "wasm32")))]
163pub mod runner;
164pub mod scroll_bars;
165pub mod selection;
166pub mod services;
167pub mod settings;
168pub mod settings_pages;
169pub mod settings_window;
170pub mod sliders;
171pub mod steps;
172pub mod stories;
173pub mod strings;
174pub mod strips;
175pub mod system_keys;
176pub mod text;
177pub mod theme_editor;
178pub mod tips;
179pub mod toasts;
180pub mod toolbars;
181pub mod wait;
182pub mod window;
183pub mod window_invariants;
184pub mod windows;
185pub mod workbench;
186mod zen;
187pub mod zones;
188pub mod zoom;
189
190pub use app::{
191    App, AppBuilder, AppHandle, CMD_THEME_TOGGLE, Call, DormantKey, FOCUS_MODE, MakeError, Request,
192    SETTING_ACCENT_COLOR, SETTING_FOCUS, SETTING_THEME_PREFERENCE, THEME, ThemeService,
193};
194pub use ctx::{Ctx, CtxError, ValueWriter};
195pub use group::Group;
196pub use groups::{DefaultPlugins, MinimalPlugins, PluginGroup};
197pub use plugin::{BuildError, Plugin, PluginError, PluginInfo};
198
199/// eframe, with the `eframe` feature: the version `run_native` uses.
200#[cfg(feature = "eframe")]
201pub use eframe;
202pub use egui_pop_core as core;
203pub use egui_pop_model as model;