Skip to main content

Module bus

Module bus 

Source
Expand description

The bus: requests, events and the listeners of each, joined (ADR 0029).

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

A module knows the bus, not its neighbours. A state change another part may care about is a request, asked with who asks and why (a step, ADR 0011, named <noun>.<verb>), and an event said once it is done or refused (the journal, <noun>.<past>). Whoever cares listens, under a name and at a place it declares, on the bus the application holds (AppHandle::bus); nobody calls a neighbour to tell it.

The bus is a contract (ADR 0030, the bus-contract crate): the application supplies it (AppBuilder::bus), or egui-pop makes a hook kernel of its own. egui-pop declares its points from CONTRACT and registers its listeners on it; it never constructs a bus it is given.

The window lifecycle is the first family on it. Its points (WindowOpen, WindowClose, WindowReparent, PopupOpen, PopupClose) take a WindowRequest; the registry (REGISTRY) listens to them and is the one list of what is on screen (AppHandle::windows_list). Closing an application window (AppHandle::request_window_close) runs, in one call and in this order:

  1. CHILDREN: what belongs to the window goes with it (its dialogs);
  2. the owner’s listener (pop.admin.window for the Settings app): the state the window showed closes;
  3. FOCUS: the window worked in before becomes the active one;
  4. REGISTRY: the window is closed, no longer declared to the backend, hidden where the system allows;
  5. PLACE: its place is kept (written to disk later);
  6. INVARIANTS: last, checks the registry agrees.

window.closed is said after the last of them, so whoever reads it finds the owner’s state, the focus and the registry already agree. order_dump prints who runs when; the bus collector of the debug bridge shows it too.

The Settings app’s window is wholly on the bus: the app asks pop.window.open and pop.window.close for it as its owner, in the call that changed what it wants, and its listener (pop.admin.window) keeps the app’s state with the window on both points. A plugin disconnected has its windows closed (OWNER_GONE, reason owner-gone).

The shell’s windows are on the bus too: opening an application window is its pop.window.open (AppHandle::request_window_open, the application as owner for AppHandle::open_window); the main window’s close, whatever asked (the system, its title bar’s Close, AppHandle::close_window, AppHandle::quit with the reason quit), is its pop.window.close, which closes every other window by its own pop.window.close first; a window’s content moving into the main window when it closes, and back when the main window is asked to its front, is a pop.window.reparent (AppHandle::request_window_reparent). Detached panels’ windows are the workbench’s: detaching a panel is its window’s pop.window.open, docking it back its pop.window.reparent into the main window, closing its window its pop.window.close, the workbench’s listener (WORKBENCH_WINDOW) changing the layout whoever asked. Dialogs and file choices are on the bus too: a dialog coming up is its pop.popup.open (dialog:<n>, parent: its window), a file choice started its pop.popup.open (file:<n>), or pop.window.open of a native window for the system’s chooser (AppHandle::request_native_open); each ends by its pop.popup.close or pop.window.close. A window closing closes its popups and native windows first, each by its own request (reason parent-closed), and their owners’ listeners (pop.dialogs.popup, pop.files.choice) cancel what they showed in the same call. The overlay stack’s overlays (the palette, menus, flyouts, popovers) and the egui popups it follows (context menus, the menu bar’s menus, hover cards) are popups too: each opening and closing is its pop.popup.open or pop.popup.close, asked in that call with how it closed (how), and a close asked by anyone closes it in the stack (OVERLAY_STACK); tooltips and a field’s lists stay off, per-frame painting.

The active window, the one the person works in, is the registry’s too (WindowActivate, AppHandle::request_window_activate): a press or a key in a window asks it (user), a window gaining the system’s focus asks it (system), the application asking a window to the front asks it (command, raised by RAISE, the one place egui-pop sends ViewportCommand::Focus); window.activated is said when it changed, and a window closing while active hands it to the window worked in before it.

The job lifecycle is the second family. Asking about a job is a request (JobCancel, JobPause, JobResume, JobRetry, each a JobAsk, asked by AppHandle::request_job); whoever runs the job does the work and answers with its job events, published typed on JobEvents (pop.job.event, a JobEvent of a JobEventKind) with a JobPublisher. Those events, and the job commands’ dispatch and answer, are delivered to its listeners in journal order, once each (AppHandle::deliver_events): the jobs plugin’s model is one of them (pop.jobs.model), so no job state changes but on the bus. A plugin connecting or disconnecting is asked on PluginConnect and PluginDisconnect (a PluginChange), the disconnection before plugin.disconnected is said: the jobs a plugin leaves are cancelled or said orphaned by a listener of its disconnection, and taken back by one of its connection.

An application’s own rows in the jobs list are on it too (job_rows): a row source is declared, its rows replaced, by pop.jobs.rows (JobRowsSet) and taken away by pop.jobs.source.drop (JobSourceDrop), from any thread; the jobs plugin’s listener (JOB_SOURCES) keeps them for the list.

Files dropped from another program are on it too: every window’s pass reads the files dropped on it once, as its pop.files.drop (FilesDrop, a FileDrop naming the window); whoever takes them listens, and nobody taking them is said as files.refused.

Settings are on it too: every change of a setting’s value is said once by the value store, its one writer, as pop.settings.changed (SettingsChanged, a SettingChange: path, scope, by), whether it was made here or by another client of the host’s store; the theme, the pointer profile and the main window’s frame are its listeners (THEME_INSTALL, POINTER_PROFILE, FRAME_DECORATIONS), and an application’s part that follows a setting listens there too.

A drag across windows is on it too (drag): a drag begins as pop.drag.start (DragStart, its kind and window); let go over a drop target that takes it, in its window or another, it is pop.drag.drop (DragDrop) and drag.dropped; refused, let go over nothing or cancelled, drag.refused with the reason. Where it hovers each pass stays off the bus (per-frame painting).

The screens are on it too: a screen plugged in or unplugged, as told by whatever runs the event loop (crate::window::set_screens), is said as pop.screen.added (ScreenAdded) or pop.screen.removed (ScreenRemoved), by its name; on pop.screen.removed a detached panel’s window kept on it docks back (WORKBENCH_SCREENS) and every other window left off every screen moves onto one (PLACE).

The layout is on it too: every real change of the workbench’s layout is said once, when the gesture that made it ends, as pop.layout.changed (LayoutChanged, a LayoutChange naming its causes); the layout is saved by its listener (LAYOUT_SAVE), an application’s copy of it follows after.

A panel’s state is on it too: whoever knows a panel’s content is not current asks pop.panel.state (PanelStateSet, from any thread), and the workbench’s chrome shows it (PANEL_CHROME), never the panel. What a declared panel is, its kind (whether it edits) included, is pop.panel.describe (PanelDescribe, answered by PANEL_DESCRIBE). Opening a panel, wherever it is asked from (a menu, a tab bar’s “+”, a group’s menu, its toggle command, an agent), is pop.panel.open (PanelOpen, a PanelOpenAsk naming the panel and where it opens: where it was, here or an area; answered by PANEL_OPEN). Naming an open panel instance’s tab title, or giving it its generated title back, is pop.panel.retitle (PanelRetitle, a PanelRetitleAsk; answered by PANEL_RETITLE). The interactive areas each window’s last pass registered, what each writes (display, navigate, edit) and whether an edit area is inert, are pop.ui.areas (UiAreas, answered by AREA_REGISTRY). Which panel zen mode shows when none is named and the focused panel is not a view is the application’s, asked on pop.zen.panel (ZenPanel). A command’s live title and tooltip, for a command whose text follows the application’s state, are the application’s, asked on pop.command.label (CommandLabel, a CommandText). Notices are on it too (docs/notices.md): a message for the user (an error, a warning, a success, a question) is raised once as pop.notice.raised (NoticeRaised, AppHandle::report); a condition ending is pop.notice.resolved, notices read pop.notice.seen, notices put away pop.notice.dismissed; egui-pop’s store (NOTICE_STORE) keeps the last ones (AppHandle::notices).

Re-exports§

pub use drawing::DrawingPanel;
pub use drawing::TopologyOf;
pub use drawing::drawing_panel;
pub use drag::DRAG_POINTS;
pub use drag::DragBegin;
pub use drag::DragDelivery;
pub use drag::DragDrop;
pub use drag::DragStart;
pub use drag::TARGET as DRAG_TARGET;
pub use bus_contract;
pub use bus_contract_crossing;
pub use bus_contract_defer;
pub use bus_contract_journal;
pub use bus_contract_timings;
pub use egui_pop_hooks;

Modules§

drag
A drag across windows, on the bus (ADR 0029).
drawing
The panel being drawn: a scope egui-pop holds around each panel’s draw, so what runs inside it (an emit, a listener, an ask, a sink of the bus’s trace tap) knows which panel, window and topology it runs for.
trace
The kernel’s trace tap (bus-kernel’s Trace capability): a sink observing the bus hears each emit, listener heard, ask and drain, on the emitting thread, where drawing_panel names the panel drawing. The trace tap: each emit, each listener heard, each ask and its drain, reported as it happens to the sinks that observe the kernel.

Structs§

CommandAsk
A command about to run: which, with what, for whom, and in which window.
CommandLabel
A command’s live title and tooltip (pop.command.label): the input is the command, the value what the application says of it, empty while no listener answers.
CommandRun
A command is about to run (pop.command.run): its listeners run in their declared order before the handler; one may refuse the run with a reason. Fail-closed: a listener’s failure refuses it too. The value is what the listeners noted, one line each.
CommandText
A command’s text as an application says it now; None keeps the declared one.
FileDrop
Files dropped on a window: which window, the files, where the pointer was.
FilesDrop
Files are dropped on a window (pop.files.drop): each listener that takes them says what it did, one line, in the value. Nobody taking them is a refusal.
HostEvent
An event egui-pop publishes, as the bus’s journal keeps it: who did it, its name and its data (its number and cause are the entry’s).
HostEvents
egui-pop’s events on the bus’s journal (pop.journal): each one the host journal records when it is the bus’s, delivered to this point’s listeners by the journal’s pump, after the publisher moved on.
JobAsk
A request about a job, asked of whoever runs it (the host, or the application’s own runner): which job, what, and why when it is not the person asking.
JobCancel
A job is asked to stop (pop.job.cancel); its listeners say what they did, one line each, in the value.
JobEvent
A job event, as JobEvents carries it: what happened, typed (JobEventKind), its data (see egui_pop_model::jobs), who said it, and its number and cause in the journal it is recorded in.
JobEvents
A job event was said (pop.job.event): each event the host published with a JobPublisher (AppHandle::publish_job), and each event of a job command (dispatched, done, failed), delivered once, in journal order (AppHandle::deliver_events). The point’s kind is typed: no listener reads a journal entry’s name, and an entry named job.* that was not published on this point is not a job event.
JobPause
A job is asked to pause (pop.job.pause).
JobPublisher
Publishes job events on pop.job.event, from any thread: the host’s side of the jobs contract. The application hands one to its host (Host::set_job_publisher); AppHandle::job_publisher gives one too. Each event is recorded in the journal (under its kind’s label, JobEventKind::name, for the journal’s readers) and delivered to the point’s listeners at the next delivery, in the order said; the interface is woken.
JobResume
A paused job is asked to go on (pop.job.resume).
JobRetry
A failed or cancelled job is asked to run again (pop.job.retry).
JobRowsAsk
A source’s rows, asked: the source, its title (the filter’s label), who asks, and every row it has now (the set replaces the last one).
JobRowsSet
A source’s rows are asked (pop.jobs.rows); its listeners say what they did, one line each, in the value.
JobSourceAsk
A source taken away: which, and who asks.
JobSourceDrop
A source is taken away (pop.jobs.source.drop).
LayoutChange
What changed the layout: the workbench step’s id (workbench.move, workbench.detach, …), layout.set (a layout put in), layout.repair (repaired against the panels declared), pop.window.place (a detached window moved or resized), palette.place (a palette following the window’s edges), input (a button let go or a key pressed: what a dock changed).
LayoutChanged
The layout changed (pop.layout.changed), said once per real change, once the gesture that made it ended.
NoticeBadge
What the status bar’s badge counts: the notices routed to it (Surface::StatusBadge) not seen yet, and for a condition not resolved yet.
NoticeDismissed
Notices were put away by the user (pop.notice.dismissed).
NoticeRaised
A notice is raised (pop.notice.raised).
NoticeResolved
A condition ended (pop.notice.resolved).
NoticeSeen
Notices were read (pop.notice.seen).
PanelDescribe
A panel is described (pop.panel.describe): the input is its id, the value its description, None while nobody knows it.
PanelDescription
A declared panel, as the bus describes it.
PanelHome
The window a panel opening goes to (pop.panel.home), the application’s choice over rule A: the value is a window’s id (main for the main window), None while no listener picks one. A window that is not shown is passed over. egui-pop has no listener of its own.
PanelHomeArea
The area a panel opening docks in (pop.panel.home_area), the application’s choice over the panel’s declared area: asked after PanelHome, so an application answering a window there may answer its area here. None while no listener picks one: the declared area. Used where the declared area would be (a panel back to its last place stays there; an area named by the ask wins); an area the panel’s rules refuse is passed over. egui-pop has no listener of its own.
PanelHomeAreaAsk
Which area a panel opening goes to, asked of the application (PanelHomeArea): the panel and the window it opens in.
PanelHomeAsk
Where a panel opening goes, asked of the application (PanelHome): the panel and the window it is asked from.
PanelOpen
A panel is asked open (pop.panel.open); its listeners say what they did, one line each, in the value.
PanelOpenAsk
A panel asked open: which panel, where, and who asks.
PanelRetitle
A panel instance is asked retitled (pop.panel.retitle); its listeners say what they did, one line each, in the value.
PanelRetitleAsk
A panel instance asked retitled: which instance, its title (None: the generated one again).
PanelStateAsk
A panel’s state asked: which panel, its state, who asks, and the event that caused it.
PanelStateSet
A panel’s state is asked (pop.panel.state); its listeners say what they did, one line each, in the value.
PluginChange
A plugin connecting or disconnecting: which, its owner id, why, and the commands it registered (gone with it on a disconnection).
PluginConnect
A plugin is connected (pop.plugin.connect), what it registers in place; its listeners take back what it had left.
PluginDisconnect
A plugin is disconnected (pop.plugin.disconnect), what it registered removed, before plugin.disconnected is said: each listener adds what it did to the value (jobs_cancelled…), which the event’s removed carries.
PopupClose
A popup closes (pop.popup.close).
PopupOpen
A popup opens in a window (pop.popup.open).
ScreenAdded
A screen was plugged in (pop.screen.added).
ScreenChange
A screen come or gone: its name as the system gives it (winit’s MonitorHandle::name; none when it gives none), its rectangle in points ([x, y, width, height]) and its scale factor.
ScreenRemoved
A screen was unplugged (pop.screen.removed): the windows on it move onto a screen left, or dock back.
SettingChange
A setting changed: its store path (settings/<id>), the value scope it changed in (app, a host’s scope such as library, run), who wrote it (user, agent:<session>, store for another client of the host’s store) and the value store’s sequence number of the write.
SettingsChanged
A setting changed (pop.settings.changed), said once per change of its value by the value store, its one writer.
UiAreas
The interactive areas are listed (pop.ui.areas): the value is the list, each window’s last pass, the main window’s first.
WindowActivate
A window becomes the active one, the window worked in (pop.window.activate): the person pressed or typed in it (user), the system gave it the focus (system), or the application asks it to the front (command, raised by RAISE).
WindowClose
A window closes (pop.window.close).
WindowOpen
A window opens (pop.window.open); its listeners say what they did, one line each, in the value.
WindowRecord
A window or popup as the registry holds it.
WindowReparent
A window’s content moves to another window (pop.window.reparent).
WindowRequest
A window or popup request: which, of what kind, who asks, why, and the event that caused it.
ZenPanel
Which panel zen mode shows (pop.zen.panel): the value is the panel’s id, None while no listener picks one.

Enums§

JobEventKind
What a job event says: the kind the host gives when it publishes the event on pop.job.event (egui-pop-api’s JobEvents). The model folds events by this kind, never by a journal entry’s name; name (job.started…) is only the label the event is journaled under.
OpenPlace
Where a panel opens (PanelOpenAsk::place). Written "last", "here" or an area’s name ("start_side", "end_side", "bottom", "center").
PanelState
Whether what a panel shows is current.
Reason
Why a window or a popup opens or closes.
TabMark
The mark a panel’s tab holds, one at a time: the highest rank wins (TabMark::rank).
WindowKind
What a window of the registry is.

Constants§

AREA_POINTS
The area points, in the order super::order_dump prints them.
AREA_REGISTRY
The registry’s listener of pop.ui.areas: lists the areas registered.
ARGS_VALIDATOR
Who refuses a run whose arguments do not match its command’s JSON Schema (CommandSpec::schema): the by of its command.refused. The check is not a listener: it runs before pop.command.run is asked, for every origin.
CHILDREN
What belongs to a closing window goes with it: its dialogs.
COMMAND_LABEL_POINTS
The command text points, in the order super::order_dump prints them.
COMMAND_POINTS
The command points, in the order super::order_dump prints them.
CONTRACT
egui-pop’s contract table (ADR 0030): every point it declares on the bus it is given, with its kind and description, readable before an application is built.
FILES_BROWSER
egui-pop’s listener of pop.files.drop, first: what the widgets of the window’s pass took (the file browser over one of its targets).
FILES_POINTS
The files points, in the order super::order_dump prints them.
FOCUS
The window worked in before a closing one becomes the active one.
FRAME_DECORATIONS
egui-pop’s listener giving the main window the decorations window.frame asks for.
HOST_JOURNAL
The declaration of HostEvents: journaled, so declared only on a bus offering the journal capability (it is not in CONTRACT, which every bus takes).
INVARIANTS
Checks, last, the window invariants (crate::window_invariants).
JOB_POINTS
The job points, in the order order_dump prints them.
JOB_ROW_POINTS
The row source points, in the order super::order_dump prints them.
JOB_SOURCES
The jobs plugin’s listener of the row source points: keeps each source’s rows for the list.
KEYS
Another window becoming the active one drops every window’s shortcut in progress: a chord begun in one window is never finished in another (a local listener: the windows’ key dispatchers are the interface’s).
LAYOUT_POINTS
The layout points, in the order super::order_dump prints them.
LAYOUT_SAVE
egui-pop’s listener saving the layout to the host’s document (the layout.save step). An application’s copy of the layout runs after it.
LAYOUT_SETTLE
How long a place followed from the system (a window, a palette) stays still before its change is said, in seconds.
NOTICE_POINTS
The notice points, in the order super::order_dump prints them.
NOTICE_ROUTE
egui-pop’s listener of pop.notice.raised after the store: routes each notice to its views (AppHandle::route_notices).
NOTICE_STORE
egui-pop’s listener of the notice points: keeps the last notices raised (AppHandle::notices).
OVERLAY_OWNER
The owner of an overlay its owner did not name.
OVERLAY_POPUP_PREFIX
The start of an unnamed overlay’s popup id.
OVERLAY_STACK
Closes in the stack a popup closed by a request (pop.popup.close).
OWNER
What owns egui-pop’s own listeners.
OWNER_GONE
Closes the application windows a disconnected plugin owned, before plugin.disconnected is said: each a pop.window.close (owner-gone), counted as windows_closed.
PANEL_CHROME
The workbench’s listener of pop.panel.state: keeps each panel’s state for its chrome.
PANEL_DESCRIBE
The workbench’s listener of pop.panel.describe: describes a declared panel from its declaration.
PANEL_DESCRIBE_POINTS
The panel description points, in the order super::order_dump prints them.
PANEL_OPEN
The workbench’s listener of pop.panel.open: opens the panel through the workbench.show step.
PANEL_OPEN_POINTS
The panel opening points, in the order super::order_dump prints them.
PANEL_RETITLE
The workbench’s listener of pop.panel.retitle: keeps the title in the layout’s instance entry.
PANEL_RETITLE_POINTS
The panel retitling points, in the order super::order_dump prints them.
PANEL_STATE_POINTS
The panel state points, in the order super::order_dump prints them.
PLACE
A window’s place, kept when it closes, and moved onto a screen left when its screen is unplugged (pop.screen.removed).
PLUGIN_POINTS
The plugin points, in the order order_dump prints them.
POINTER_PROFILE
egui-pop’s listener loading the pointer profile the setting names.
POINTS
Every point egui-pop declares: the window, job, plugin, files, settings, drag, screen, panel state, layout, panel description and command, area, panel opening, panel retitling, zen and command label, notice and job row source points.
RAISE
A window asked to the front by a command (pop.window.activate, reason command) is shown, restored and given the system’s focus: the one place egui-pop sends ViewportCommand::Focus.
REGISTRY
The one list of windows and popups (AppHandle::windows_list).
SCREEN_POINTS
The screen points, in the order super::order_dump prints them.
SETTINGS_POINTS
The settings points, in the order super::order_dump prints them.
STEP_WINDOW_CLOSE
The window.close step: the request as steps trace it (before-hooks may veto or redirect it).
STEP_WINDOW_REPARENT
The window.reparent step: the request as steps trace it (before-hooks may veto it).
THEME_INSTALL
egui-pop’s listener installing the theme a setting changes.
WINDOW_POINTS
The window and popup points, in the order order_dump prints them.
WORKBENCH_OWNER
What owns the detached panels’ windows.
WORKBENCH_SCREENS
The workbench’s listener of pop.screen.removed: a detached panel’s window kept on the screen gone docks back.
WORKBENCH_WINDOW
The workbench’s listener on the window points: the layout follows the request, whoever asked.
ZEN_POINTS
The zen points, in the order super::order_dump prints them.

Traits§

BusTrace
The kernel’s trace tap (bus-kernel’s Trace capability): a sink observing the bus hears each emit, listener heard, ask and drain, on the emitting thread, where drawing_panel names the panel drawing. The trace of a bus, found through its capability lookup.

Functions§

asking
The application whose request runs now, for a listener (listeners are Send + Sync and keep no handle): an application’s listener of pop.files.drop runs its import command on it. None outside a request.
mark_id
The indicator id of a panel’s mark on its content (panel-state:<id>) and on its tab or palette band (panel-state-tab:<id>, its one mark slot: the busy, failed or edits mark), for tests and agents.
missing_targets
The ordering constraints of points that name a listener not there: point: listener -> target. A test ends with none.
order_dump
The order the listeners of points run in, one point after the other, each listener with its owner and what it declares: “who runs when”, read rather than remembered.
raise_main_window
The main window shown, restored and focused, for a program without an egui-pop application (the platform readers used standalone): what RAISE does for a pop.window.activate of the main window. An application asks pop.window.activate instead (AppHandle::request_window_activate).