Skip to main content

App

Struct App 

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

A built application.

Implementations§

Source§

impl App

Source

pub fn builder() -> AppBuilder

Starts building an application.

Source

pub fn handle(&self) -> &AppHandle

The application handle.

Source

pub fn census(&self) -> BTreeMap<&'static str, usize>

How many things each registry holds: what removal tests compare.

Source

pub fn dispatcher(&self) -> &KeyDispatcher

The key dispatcher (its traces, a shortcut in progress).

Source

pub fn keymap(&self) -> Ref<'_, Keymap>

The keymap.

Source

pub fn debug_call( &mut self, collector: &str, action: &str, args: &Json, ) -> Feedback

Calls the debug bridge as the agent (AppHandle::debug_call); commands.run runs at once and its result is in the feedback.

Source

pub fn debug_call_as( &mut self, collector: &str, action: &str, args: &Json, origin: Origin, ) -> Feedback

Calls the debug bridge for origin (AppHandle::debug_call_as); commands.run runs at once and its result is in the feedback.

Source

pub fn disconnect(&mut self, plugin: &PluginId) -> Vec<PluginId>

Disconnects a plugin and those requiring it (dependents first); everything they registered is removed. Returns the plugins disconnected. Each leaves a plugin.disconnected event on the journal (ADR 0028).

Source

pub fn connect(&mut self, plugin: &PluginId) -> Result<(), PluginError>

Connects a plugin that is not (its requirements first).

Source

pub fn rebuild(&mut self)

Rebuilds the derived declarations: menus, palette and settings through their hooks, and the zones. Runs after plugins come or go, never per frame.

Source

pub fn save(&self) -> Result<(), PersistError>

Saves now the settings, the user’s keymap (when a directory was given), the layout (App::save_layout) and every document waiting in the debounced writer.

Source

pub fn layout_document(&self) -> Option<String>

The document the layout is kept in now, as the host says (Host::layout_document); None: the host keeps it.

Source

pub fn load_layout(&mut self) -> Option<Outcome>

Loads the layout from the host’s document, through the layout.load step (an application switching workspaces calls it once its host names the new one). None when the host keeps the layout; a document not written yet keeps the layout as it is.

Source

pub fn save_layout(&self) -> Option<Outcome>

Saves the layout to the host’s document, through the layout.save step. None when the host keeps the layout.

Source

pub fn declare( &mut self, owner: &OwnerId, spec: CommandSpec, ) -> Result<(), CtxError>

Declares a command now (see AppHandle::declare).

Source

pub fn undeclare(&mut self, id: &CommandId) -> bool

Removes a command, its owner’s keys and menu items for it; whether it was declared.

Source

pub fn load_keymap( &mut self, doc: &KeymapDoc, layer: Layer, ) -> Result<KeymapDiff, String>

Loads a keymap document into the user’s or the workspace’s layer now, through the keys.load step: what changed, what was skipped, the conflicts after it.

Source

pub fn exit(&mut self) -> Outcome

The application closes: the requests still asked for after the drawing heard (AppHandle::drain_asks), the on_exit functions, then the app.exit step, whose default writes what is still waiting (App::save). A vetoed exit writes nothing more: what changed was written already, a second after it changed.

Source

pub fn show_wrapped(&mut self, ui: &mut Ui)

Draws the application, through the wrap given to the builder when there is one.

Source

pub fn run(&mut self, command: &CommandId, args: Json, origin: Origin) -> Reply

Runs a command now, in the current context: its result, or a result to come (Reply::Later, kept until it arrives).

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

pub fn run_in( &mut self, command: &CommandId, args: Json, origin: Origin, cx: &WhenContext, ) -> Reply

Runs a command now, in a given context, through the host.

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

pub fn settle(&mut self) -> usize

Takes the results that arrived (each frame does it before drawing); returns how many.

Source

pub fn process_requests(&mut self)

Does what blocks and handlers asked for.

Source

pub fn logic(&mut self, ctx: &Context)

Between frames: the theme asked for, requests, declarations, and the On::Pass handlers.

The On::Pass handlers run once per pass: a second call inside the same egui pass (the same viewport and Context::cumulative_pass_nr) settles again (the theme asked for, requests, declarations) but does not run them. eframe calls it from its logic hook and App::show calls it again, so that an integration without that hook (plain egui, kittest’s build_ui) still runs it; a host may also call it a second time after changing something (a theme, a request) so the change is in place before the pass draws. Calls between passes always run the handlers: eframe ticks the logic alone while the window is hidden, and those ticks share one pass number.

Source

pub fn show(&mut self, ui: &mut Ui)

Draws the whole application in a Ui covering the window, after dispatching this frame’s keys.

Runs App::logic first, which does nothing when the host already ran it in this pass (eframe’s logic hook).

Trait Implementations§

Source§

impl App for App

Available on crate feature eframe only.
Source§

fn clear_color(&self, _visuals: &Visuals) -> [f32; 4]

Transparent where windows are built transparent for their rounded corners: what egui leaves unpainted outside a corner shows the desktop. An opaque window ignores the alpha.

Source§

fn logic(&mut self, ctx: &Context, _frame: &mut Frame)

Called once before each call to [Self::ui], and additionally also called when the UI is hidden, but [egui::Context::request_repaint] was called. Read more
Source§

fn ui(&mut self, ui: &mut Ui, _frame: &mut Frame)

Called each time the UI needs repainting, which may be many times per second. Read more
Source§

fn on_exit(&mut self)

Called once on shutdown, after [Self::save]. Read more
§

fn save(&mut self, _storage: &mut dyn Storage)

Called on shutdown, and perhaps at regular intervals. Allows you to save state. Read more
§

fn auto_save_interval(&self) -> Duration

Time between automatic calls to [Self::save]
§

fn persist_egui_memory(&self) -> bool

Controls whether or not the egui memory (window positions etc) will be persisted (only if the “persistence” feature is enabled).
§

fn raw_input_hook(&mut self, _ctx: &Context, _raw_input: &mut RawInput)

A hook for manipulating or filtering raw input before it is processed by [Self::ui]. Read more
Source§

impl Debug for App

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for App

§

impl !RefUnwindSafe for App

§

impl !Send for App

§

impl !Sync for App

§

impl Unpin for App

§

impl UnsafeUnpin for App

§

impl !UnwindSafe for App

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