Skip to main content

NativeMenuBackend

Trait NativeMenuBackend 

Source
pub trait NativeMenuBackend {
    // Required methods
    fn set_window_menu(
        &mut self,
        window_id: TeksiloWindowId,
        menu: NativeMenuSnapshot,
        poster: Arc<dyn AppEventPoster>,
    );
    fn activate_window(&mut self, window_id: TeksiloWindowId);
    fn clear_window(&mut self, window_id: TeksiloWindowId);
    fn update_item(&mut self, id: MenuItemId, delta: MenuItemDelta);

    // Provided method
    fn set_app_menu(
        &mut self,
        menu: NativeMenuSnapshot,
        poster: Arc<dyn AppEventPoster>,
        declared: bool,
    ) { ... }
}
Expand description

Swappable native-menu backend. One instance serves the whole app.

Required Methods§

Source

fn set_window_menu( &mut self, window_id: TeksiloWindowId, menu: NativeMenuSnapshot, poster: Arc<dyn AppEventPoster>, )

Build (or replace) the native menu of window_id, a window with a menu of its own, from menu. For every item the user later chooses, the backend MUST post a NativeMenuEventPayload, with window_id_owner == window_id, through poster. If window_id is the key window (the last one activate_window named), or no window has been activated yet, the backend shows this menu.

Source

fn activate_window(&mut self, window_id: TeksiloWindowId)

window_id became the key window (focus follows window): show the bar [key_window_bar] picks, its own menu if it set one, else the menu of the window it belongs to (see set_window_owner), else the application menu, or, when the application declared none, the bar shown before.

Source

fn clear_window(&mut self, window_id: TeksiloWindowId)

Forget window_id’s menu (the window closed, or no longer has a menu of its own). If it was showing, show the application menu until another window becomes key.

Source

fn update_item(&mut self, id: MenuItemId, delta: MenuItemDelta)

Apply a reactive delta to a single already-installed item, in every menu that carries it, the application menu included.

Provided Methods§

Source

fn set_app_menu( &mut self, menu: NativeMenuSnapshot, poster: Arc<dyn AppEventPoster>, declared: bool, )

Set the application menu: the menu shown whenever the key window has no menu of its own nor an owner with one, and while no window is open. teksilo-app sets it from the application tree at startup and again whenever it changes; it replaces any earlier one, and the bar is chosen again for the key window, as activate_window chooses it: an application menu declared while a window with no menu of its own is key shows at once. declared says whether the application declared it: false for the default App menu teksilo-app supplies when it declared none, which a key window without a menu does not bring up (see [key_window_bar]). For every item the user later chooses in it, the backend MUST post a NativeAppMenuEventPayload through poster. The default does nothing, for a backend whose menus belong to windows alone.

Trait Implementations§

Source§

impl NativeMenuBackend for Box<dyn NativeMenuBackend>

Forward through a boxed backend so NativeMenuHandle::new(default_backend()) type-checks.

Source§

fn set_window_menu( &mut self, window_id: TeksiloWindowId, menu: NativeMenuSnapshot, poster: Arc<dyn AppEventPoster>, )

Build (or replace) the native menu of window_id, a window with a menu of its own, from menu. For every item the user later chooses, the backend MUST post a NativeMenuEventPayload, with window_id_owner == window_id, through poster. If window_id is the key window (the last one activate_window named), or no window has been activated yet, the backend shows this menu.
Source§

fn activate_window(&mut self, window_id: TeksiloWindowId)

window_id became the key window (focus follows window): show the bar [key_window_bar] picks, its own menu if it set one, else the menu of the window it belongs to (see set_window_owner), else the application menu, or, when the application declared none, the bar shown before.
Source§

fn clear_window(&mut self, window_id: TeksiloWindowId)

Forget window_id’s menu (the window closed, or no longer has a menu of its own). If it was showing, show the application menu until another window becomes key.
Source§

fn update_item(&mut self, id: MenuItemId, delta: MenuItemDelta)

Apply a reactive delta to a single already-installed item, in every menu that carries it, the application menu included.
Source§

fn set_app_menu( &mut self, menu: NativeMenuSnapshot, poster: Arc<dyn AppEventPoster>, declared: bool, )

Set the application menu: the menu shown whenever the key window has no menu of its own nor an owner with one, and while no window is open. teksilo-app sets it from the application tree at startup and again whenever it changes; it replaces any earlier one, and the bar is chosen again for the key window, as activate_window chooses it: an application menu declared while a window with no menu of its own is key shows at once. declared says whether the application declared it: false for the default App menu teksilo-app supplies when it declared none, which a key window without a menu does not bring up (see [key_window_bar]). For every item the user later chooses in it, the backend MUST post a NativeAppMenuEventPayload through poster. The default does nothing, for a backend whose menus belong to windows alone.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl NativeMenuBackend for Box<dyn NativeMenuBackend>

Forward through a boxed backend so NativeMenuHandle::new(default_backend()) type-checks.

Source§

fn set_window_menu( &mut self, window_id: TeksiloWindowId, menu: NativeMenuSnapshot, poster: Arc<dyn AppEventPoster>, )

Source§

fn activate_window(&mut self, window_id: TeksiloWindowId)

Source§

fn clear_window(&mut self, window_id: TeksiloWindowId)

Source§

fn update_item(&mut self, id: MenuItemId, delta: MenuItemDelta)

Source§

fn set_app_menu( &mut self, menu: NativeMenuSnapshot, poster: Arc<dyn AppEventPoster>, declared: bool, )

Implementors§