Skip to main content

AppBuilder

Struct AppBuilder 

Source
pub struct AppBuilder { /* private fields */ }
Expand description

Builds an application.

Implementations§

Source§

impl AppBuilder

Source

pub fn new() -> Self

Source

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

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

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

Source

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.

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

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.

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

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.

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

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.

Source

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.

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

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.

Source

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.

Source

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.

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

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));
Experimental: may change in any release (docs/stability.md).
Source

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

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));
Experimental: may change in any release (docs/stability.md).
Source

pub fn menu_bar(self, on: bool) -> Self

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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();
Experimental: may change in any release (docs/stability.md).
Source

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.

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

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.

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

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

Source

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.

Source

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.

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

pub fn on_exit(self, f: impl FnMut(&AppHandle) + 'static) -> Self

Runs f when the application closes, before the app.exit step (which saves).

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

pub fn plugin(self, plugin: impl Plugin) -> Self

Adds a plugin; one a group added with the same id gives it its place.

Source

pub fn plugins(self, group: impl PluginGroup) -> Self

Adds a group of plugins (DefaultPlugins, MinimalPlugins), less those whose id is already added.

Source

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.

Source

pub fn theme(self, spec: ThemeSpec) -> Self

The theme at start-up.

Source

pub fn themes(self, themes: Themes) -> Self

The themes to pick from (the built-in ones by default).

Source

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.

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

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.

Source

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.

Source

pub fn persist(self, dir: impl Into<PathBuf>) -> Self

Where settings and the user’s keymap are saved.

Source

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.

Source

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

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

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

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

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

Source

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.

Source

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

Source

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.

Source

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.

Source

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

Source

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.

Source

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

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

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.

Source

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.

Source

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.

Source

pub fn build(self, ctx: &Context) -> Result<App, BuildError>

Sorts the plugins, connects them, installs the theme and resolves the declarations, on a context.

Source

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.

Source

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.

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

Trait Implementations§

Source§

impl Debug for AppBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AppBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,