pub struct AppBuilder { /* private fields */ }Expand description
Builds an application.
Implementations§
Source§impl AppBuilder
impl AppBuilder
pub fn new() -> Self
Sourcepub fn panel_alignment(self, alignment: PanelAlignment) -> Self
pub fn panel_alignment(self, alignment: PanelAlignment) -> Self
The bottom panel’s alignment by default (the
workbench.panel_alignment setting’s default; Center, under
the editors between the side bars as VS Code has it, unless
given).
Sourcepub fn toast_corner(self, corner: Corner) -> Self
pub fn toast_corner(self, corner: Corner) -> Self
Where the toasts show by default (the appearance.toast_corner
setting’s default; the bottom-right corner unless given).
Sourcepub fn group_handles(self, allowed: GroupHandles) -> Self
pub fn group_handles(self, allowed: GroupHandles) -> Self
The handles that may move a whole tab group, and a floating
window’s move handle (MOVE_WINDOW): the user turns off any of
them in the settings, never on one left out here. By default
DEFAULT_GROUP_HANDLES,
every handle.
Sourcepub fn dock_controls(self, controls: DockControls) -> Self
pub fn dock_controls(self, controls: DockControls) -> Self
The controls the workbench’s docks show beyond their tabs: an
“Eject group” button on the tab bars, the groups’ menus, what
drags a floating window
(DockControls). By default
egui_stack’s: no eject button, the group menus on, a floating
window moved by its bar.
Sourcepub fn arrangement_strings(self, words: ArrangementStrings) -> Self
pub fn arrangement_strings(self, words: ArrangementStrings) -> Self
The application’s own texts naming an arrangement of the panels
(ArrangementStrings):
the layout menu’s “Save the current arrangement as…”, the save
dialog’s title and button, the name it suggests. Whole strings
under the application’s keys, translated by its catalogues; by
default egui-pop’s.
Sourcepub fn pointer_profile(self, id: &str) -> Self
pub fn pointer_profile(self, id: &str) -> Self
The pointer profile by default (the input.pointer_profile
setting’s default: document unless given; darktable,
photoshop, lightroom, blender, trackpad; the retired
adobe gives lightroom). An id no profile has is reported and
the default kept.
Sourcepub fn dock_drag(self, mode: DockDrag) -> Self
pub fn dock_drag(self, mode: DockDrag) -> Self
What a plain drag of a floating palette does by default (the
input.dock_drag setting’s default; the pointer profile’s unless
given, which is DockDrag::ModifierDocks but for Photoshop’s):
a Visual Studio-like application picks
DockDrag::ModifierFloats, a touch-first one DockDrag::Dwell.
The user changes it in the settings.
Sourcepub fn name(self, name: &str) -> Self
pub fn name(self, name: &str) -> Self
The application’s name (“Helios”), apart from its window’s title
(“photo.raw — Helios”): a detached panel’s window says it
({ $application }), and the frame shows it when FramePlugin
has no name of its own. run_native takes its app_name when
none is given.
Sourcepub fn app_id(self, id: &str) -> Self
pub fn app_id(self, id: &str) -> Self
The application’s id, reverse-DNS (org.example.App): the one its
desktop file, its store listing and its window (eframe’s
ViewportBuilder::with_app_id) carry. What identifies the
application to others reads it (AppHandle::app_id): the viewer’s
YouTube player sends it. run_native takes the window’s when none
is given.
Sourcepub fn main_edge_to_edge(self, on: bool) -> Self
pub fn main_edge_to_edge(self, on: bool) -> Self
Draws the main area edge to edge: no margin around the centre’s
panels (an image viewer, a canvas). Their bodies keep their own
frame; AppBuilder::frameless takes that away too.
Sourcepub fn frameless(self, areas: &[Area]) -> Self
pub fn frameless(self, areas: &[Area]) -> Self
Areas drawn without a frame: no margin around the area, and its
panels’ bodies without margin, border or rounded corners, so that
they run to the window’s edges and are set apart by the splitter’s
line only (a viewer whose views draw to their edges). A panel then
gives itself the margin it wants. Any area: the side areas, the
bottom one, the centre (which main_edge_to_edge leaves framed
inside).
use egui_pop_api::App;
use egui_pop_model::panels::Area;
let app = App::builder()
.frameless(&[Area::StartSide, Area::Bottom])
.build(&egui::Context::default())
.unwrap();
assert!(app.handle().frameless(Area::Bottom));
assert!(!app.handle().frameless(Area::EndSide));Sourcepub fn bare_strips(self, areas: &[Area]) -> Self
pub fn bare_strips(self, areas: &[Area]) -> Self
Side areas whose folded strip stays bare: its grip glyph alone,
area-strip.width wide, without an icon (or a title’s first
letter) per panel; a click on it unfolds the area, and no panel
opens as a flyout from it. For an application whose folded area is
a plain handle. The centre and the bottom area have no strip and
are ignored.
use egui_pop_api::App;
use egui_pop_model::panels::Area;
let app = App::builder()
.bare_strips(&[Area::StartSide])
.build(&egui::Context::default())
.unwrap();
assert!(app.handle().bare_strip(Area::StartSide));
assert!(!app.handle().bare_strip(Area::EndSide));Sourcepub fn layout(self, layout: Layout) -> Self
pub fn layout(self, layout: Layout) -> Self
The layout the application starts with when none was saved, and
the one the Default arrangement resets to: its panels in their
areas, its closed panels (Layout::hidden), its folded and lying
areas. Not given, every panel starts in its default area. The
shell’s zone panels (workbench::PANEL_SIDE_BAR, PANEL_MAIN,
PANEL_INSPECTOR) show as soon as their zones have blocks, a
default plugin’s included: listing them in hidden leaves them
out. A panel the layout does
not place goes to its default area; one it places where its rules
forbid, or that no plugin declares, is repaired as a saved layout
is (the repair is logged). folded and over, given too, add
their areas.
use egui_pop_api::App;
use egui_pop_api::workbench::{PANEL_INSPECTOR, PANEL_SIDE_BAR};
use egui_pop_model::layout::Layout;
let app = App::builder()
.layout(Layout {
hidden: vec![PANEL_SIDE_BAR, PANEL_INSPECTOR],
..Layout::default()
})
.build(&egui::Context::default())
.unwrap();
assert!(!app.handle().panel_visible(&PANEL_SIDE_BAR));Draws the main menu as a bar under the title (the default), or
not at all: its commands stay in the palette, under their keys and
in any menu the application opens itself (menus::popup_at). The
top bar’s zone is then drawn only when it has blocks.
Sourcepub fn system_file_chooser(self, on: bool) -> Self
pub fn system_file_chooser(self, on: bool) -> Self
Allows the system’s file chooser (files, feature native-dialogs):
a fallback, off by default, for an application that cannot do with
egui-pop’s in-app picker. On, the files plugin uses the system’s
chooser when the feature is compiled in, a portal answers and the
person’s files.native setting is on; never under tests
(files::system_chooser_refused). Off, or without the feature, the
in-app picker always answers.
Sourcepub fn transparent_panel_windows(self, on: bool) -> Self
pub fn transparent_panel_windows(self, on: bool) -> Self
Builds detached panels’ windows transparent where the platform
gives a surface below a window (Wayland, where the image viewport’s
image surface is a subsurface), so that surface shows through; off
by default. Elsewhere, and off, they stay opaque. Either way each
window says how it was built and why
(egui_pop_core::window_surface::transparency, windows.list). The
panel’s content fills the window: eframe clears an immediate
window to transparent, so a panel that leaves part of it unpainted
shows the desktop there.
Sourcepub fn rounded_windows(self, on: bool) -> Self
pub fn rounded_windows(self, on: bool) -> Self
Whether the windows the application decorates (its own frame:
the main window, detached panels’ and application windows) get
rounded corners while they float free (the kit’s window.radius;
square when maximized, in full screen or against a screen’s
edge). A rounded corner needs a transparent window, so they are
built transparent: by default on Wayland only; true allows X11
too (a compositing window manager is needed there), false keeps
them square and opaque. Windows and macOS round their windows
themselves (window.corners), the web has no window: never there.
Sourcepub fn shell_panel_size(self, panel: PanelId, size: f32) -> Self
pub fn shell_panel_size(self, panel: PanelId, size: f32) -> Self
The size a shell panel starts at (workbench::PANEL_SIDE_BAR,
PANEL_INSPECTOR: their width), instead of egui-pop’s; its
smallest size follows when it is larger. The user’s resizing and a
saved layout still win.
Sourcepub fn shell_panel_min_size(
self,
panel: PanelId,
size: impl Into<ShellSize>,
) -> Self
pub fn shell_panel_min_size( self, panel: PanelId, size: impl Into<ShellSize>, ) -> Self
The least size of a panel across its area (workbench::PANEL_SIDE_BAR,
PANEL_INSPECTOR: their width), in points or as a share of the
window (ShellSize), instead of
egui-pop’s (120 points for the side bar, 160 for the inspector) or
the panel’s own PanelSpec::min_size. Dragging stops there, in
the main window and in an application window’s side areas alike. A
least size measured from the panel’s content, while running:
AppHandle::set_shell_panel_min_size.
use egui_pop_api::App;
use egui_pop_api::workbench::{PANEL_SIDE_BAR, ShellSize};
let app = App::builder()
.shell_panel_min_size(PANEL_SIDE_BAR, 230.0)
.shell_panel_max_size(PANEL_SIDE_BAR, ShellSize::Share(0.6))
.build(&egui::Context::default())
.unwrap();Sourcepub fn shell_panel_max_size(
self,
panel: PanelId,
size: impl Into<ShellSize>,
) -> Self
pub fn shell_panel_max_size( self, panel: PanelId, size: impl Into<ShellSize>, ) -> Self
The largest size of a panel across its area, in points or as a share of the window; none by default. Dragging stops there; a least size larger wins.
Sourcepub fn centre_min_size(self, size: impl Into<ShellSize>) -> Self
pub fn centre_min_size(self, size: impl Into<ShellSize>) -> Self
The centre’s least width, in points or as a share of the window: the side areas give way to it, each down to its own least width (a window too narrow for all of them squeezes the centre). None by default.
Sourcepub fn folded(self, areas: &[Area]) -> Self
pub fn folded(self, areas: &[Area]) -> Self
Areas folded to their strip when the application starts with no saved layout (a saved one, the user’s choice, wins).
Sourcepub fn over(self, areas: &[Area]) -> Self
pub fn over(self, areas: &[Area]) -> Self
Side areas lying over the centre when the application starts with
no saved layout (workbench.place; a saved one wins): their
folded strip keeps the room, the centre its width. The centre and
the bottom area always lie beside.
Sourcepub fn wrap(
self,
f: impl FnMut(&mut Ui, &AppHandle, &mut dyn FnMut(&mut Ui)) + 'static,
) -> Self
pub fn wrap( self, f: impl FnMut(&mut Ui, &AppHandle, &mut dyn FnMut(&mut Ui)) + 'static, ) -> Self
Draws around the whole application every frame (a custom frame,
a backdrop): f gets the Ui, the handle and the application’s
drawing, to call where it likes.
Sourcepub fn on_exit(self, f: impl FnMut(&AppHandle) + 'static) -> Self
pub fn on_exit(self, f: impl FnMut(&AppHandle) + 'static) -> Self
Runs f when the application closes, before the app.exit step
(which saves).
Sourcepub fn plugin(self, plugin: impl Plugin) -> Self
pub fn plugin(self, plugin: impl Plugin) -> Self
Adds a plugin; one a group added with the same id gives it its place.
Sourcepub fn plugins(self, group: impl PluginGroup) -> Self
pub fn plugins(self, group: impl PluginGroup) -> Self
Adds a group of plugins (DefaultPlugins, MinimalPlugins),
less those whose id is already added.
Sourcepub fn boxed(self, plugin: Box<dyn Plugin>) -> Self
pub fn boxed(self, plugin: Box<dyn Plugin>) -> Self
Adds a boxed plugin; one a group added with the same id gives it its place.
Sourcepub fn themes(self, themes: Themes) -> Self
pub fn themes(self, themes: Themes) -> Self
The themes to pick from (the built-in ones by default).
Sourcepub fn kit(self, kit: impl Into<KitSource>) -> Self
pub fn kit(self, kit: impl Into<KitSource>) -> Self
Adds a kit (docs/kit-packages.md): its theme joins the themes to
pick from, under the kit’s name, and its faces and handlers are
registered when the application is built. A folder read at run
time, a kit! or a kit crate’s kit():
use egui_pop_api::App;
use egui_pop_core::kit::Kit;
use egui_pop_core::theme::ThemeSpec;
use egui_pop_core::tokens::kit::KitData;
let kit = KitData::from_text(
"underline",
r#"
tab:
shape: {$type: "string", $value: "underline"}
"#,
);
let ctx = egui::Context::default();
let app = App::builder()
.kit(kit)
.theme(ThemeSpec::new("underline"))
.build(&ctx)
.unwrap();
assert_eq!(Kit::of(&ctx).tab.shape, "underline");
assert_eq!(app.handle().theme().kits()[0].name, "underline");What is wrong with a kit is logged and in the diagnostics
(kit-problem); the kit is added anyway, with fallbacks.
Sourcepub fn user_kits(self, on: bool) -> Self
pub fn user_kits(self, on: bool) -> Self
Adds the user’s kits too: the data-only kit folders under
<persist directory>/kits (egui_pop_tokens::kit::discover), read
when the application is built, after the application’s own (a
user kit of the same name replaces it), their YAML through the
cache (AppBuilder::cache). Without a persistence directory there
are none.
Sourcepub fn cache(self, cache: Cache) -> Self
pub fn cache(self, cache: Cache) -> Self
Where the files read at run time (the user’s kits) are kept
compiled (egui_pop_tokens::cache): Cache::for_app(id) for the
platform’s cache directory under the application’s id,
Cache::at(dir) elsewhere, Cache::off() for none. Not given,
it is the process’s default (cache::set_default), off until the
application sets one.
Sourcepub fn persist(self, dir: impl Into<PathBuf>) -> Self
pub fn persist(self, dir: impl Into<PathBuf>) -> Self
Where settings and the user’s keymap are saved.
Sourcepub fn persist_in_config(self, app: &str) -> Self
pub fn persist_in_config(self, app: &str) -> Self
Saves the settings, the layout and the window’s place in the
user’s configuration folder, in a folder named app
(crate::dirs::config_dir: ~/.config/<app> on Linux), or in
the temporary folder when the environment names no configuration
folder. persist_in_config(env!("CARGO_PKG_NAME")) names it after
the crate.
Sourcepub fn host(self, host: impl Host + 'static) -> Self
pub fn host(self, host: impl Host + 'static) -> Self
The application’s kernel: runs the commands, keeps the journal
and the store (LocalHost by default, see host).
Sourcepub fn bus(self, bus: Arc<dyn Bus>) -> Self
pub fn bus(self, bus: Arc<dyn Bus>) -> Self
The bus egui-pop publishes on and listens to (ADR 0030): the
application’s, shared with its other libraries if it chooses one
bus, or one of several. egui-pop declares its points on it
(crate::bus::CONTRACT) and registers its listeners; it never
constructs a bus when one is given. Without it, the default: an
bus_kernel::Kernel of its own.
One egui-pop application per bus: its listeners hold that application’s window registry, and a second application on the same bus finds its points declared (logged as an error).
Sourcepub fn store(self, store: SharedStore) -> Self
pub fn store(self, store: SharedStore) -> Self
Shares an existing store instead of a new one (with the default
host; a host given to host brings its own).
Sourcepub fn writer_check(self, check: WriterCheck) -> Self
pub fn writer_check(self, check: WriterCheck) -> Self
What a write from a plugin that is not one of a path’s writers
gets: refused (the default) or applied with a warning, to migrate
plugins written before the check
(egui_pop_model::values::WriterCheck). Either way it is in the
diagnostics.
Sourcepub fn offer_to_agents(self, action: &str) -> Self
pub fn offer_to_agents(self, action: &str) -> Self
Offers a debug collector’s action to agents (dialogs.answer):
the bridge’s agent (AppHandle::debug_call) may then call it,
whatever the action declares. An action that writes is for the
user only by default; offer one only to agents the application
trusts with it (a test harness, its own automation). A name that
matches no action once the plugins are connected is reported
(agent-offer-unknown).
Sourcepub fn debug_bridge(self, mode: BridgeMode) -> Self
pub fn debug_bridge(self, mode: BridgeMode) -> Self
What the debug bridge lets anyone but the user do: On (the
default: every action and command offered to agents), ReadOnly
(only calls that change nothing: actions with mutates: false and
commands.run of a command declared read_only), or Off (no
call). The user’s calls (the devtools panel, debug_call_as with
Origin::User) are never refused by it; snapshots stay readable
by code in the process.
Sourcepub fn chosen_debug_bridge(&self) -> Option<BridgeMode>
pub fn chosen_debug_bridge(&self) -> Option<BridgeMode>
The debug bridge’s mode the application chose
(AppBuilder::debug_bridge), None when it chose none (the
bridge is then On). A transport the application turns on
(egui-pop-agent) reads it to default to ReadOnly.
Sourcepub fn offer_command_to_agents(self, command: CommandId) -> Self
pub fn offer_command_to_agents(self, command: CommandId) -> Self
Offers a command to agents whatever it declares
(CommandSpec::no_agent): terminal.send, for an agent the
application trusts to type into its terminals. The agent then runs
it through the bridge (commands.run) and the commands a handler
starts for it, as the user would. A command kept from agents
usually reaches the system or acts for the person: offer one only
knowing what it does. A command that is not declared once the
plugins are connected is reported (agent-offer-unknown).
Sourcepub fn multi_window(self, on: bool) -> Self
pub fn multi_window(self, on: bool) -> Self
The application opens windows of its own
(AppHandle::open_window): run_native then sets wgpu’s present
mode for several windows (windows::present_mode: AutoNoVsync
on Wayland, where a FIFO present can stall every window), unless
the options chose a mode other than eframe’s default.
Sourcepub fn system_focus(self, system: SystemFocus) -> Self
pub fn system_focus(self, system: SystemFocus) -> Self
The window manager’s focus mode (focus_mode::read_system()
reads it). Not given, it is read by run_native and taken as
click elsewhere (tests stay the same on every desktop).
Sourcepub fn system_text_scale(self, system: SystemTextScale) -> Self
pub fn system_text_scale(self, system: SystemTextScale) -> Self
The system’s text scaling (egui_pop_platform::text_scale::read
reads it in-process): the default of the text size setting, rounded
to a step, until the user chooses one. Not given, the default is
100 %; egui-pop reads nothing itself.
Sourcepub fn system_always_shows_scroll_bars(self, always: bool) -> Self
pub fn system_always_shows_scroll_bars(self, always: bool) -> Self
Whether the system was asked always to show its scroll bars: true
makes the auto of the appearance.scroll_bars setting show full
bars. One way only, so there is no value for a system that hides them:
that is most systems’ default, and nobody chose it. Not given, false;
egui-pop reads nothing itself.
Sourcepub fn system_wheel_lines(self, lines: u32) -> Self
pub fn system_wheel_lines(self, lines: u32) -> Self
The lines a notch of the wheel moves on the system
(egui_pop_platform::wheel_lines::read reads it): the default of the
input.wheel_speed setting, 3 lines being 1, until the user chooses one.
Not given, 3; egui-pop reads nothing itself.
Sourcepub fn build(self, ctx: &Context) -> Result<App, BuildError>
pub fn build(self, ctx: &Context) -> Result<App, BuildError>
Sorts the plugins, connects them, installs the theme and resolves the declarations, on a context.
Sourcepub fn run_native(self, title: &str, options: NativeOptions) -> Result
pub fn run_native(self, title: &str, options: NativeOptions) -> Result
Builds and runs the application in a native window. With the
create-native feature (default), eframe runs on an event loop
egui-pop owns (crate::runner): the screens are known before the
main window is placed, and every window’s handles once painted.
Sourcepub fn run_native_with(
self,
title: &str,
options: NativeOptions,
make: impl FnOnce(App, &CreationContext<'_>) -> Result<Box<dyn App>, MakeError> + 'static,
) -> Result
pub fn run_native_with( self, title: &str, options: NativeOptions, make: impl FnOnce(App, &CreationContext<'_>) -> Result<Box<dyn App>, MakeError> + 'static, ) -> Result
As AppBuilder::run_native, the built application handed to
make, which gives eframe the eframe::App to run: one of the
application’s own around egui-pop’s (it calls App::logic,
App::show_wrapped and App::exit from its own). make may fail
(its kernel does not start, a file is missing): the error is
logged, published on the journal as app.make_failed and returned
as eframe’s Error::AppCreation.
Trait Implementations§
Source§impl Debug for AppBuilder
impl Debug for AppBuilder
Auto Trait Implementations§
impl Freeze for AppBuilder
impl !RefUnwindSafe for AppBuilder
impl !Send for AppBuilder
impl !Sync for AppBuilder
impl Unpin for AppBuilder
impl UnsafeUnpin for AppBuilder
impl !UnwindSafe for AppBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more