Skip to main content

perspective_viewer/components/main_panel/
msg.rs

1// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2// ┃ ██████ ██████ ██████       █      █      █      █      █ █▄  ▀███ █       ┃
3// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█  ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄  ▀█ █ ▀▀▀▀▀ ┃
4// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄   █ ▄▄▄▄▄ ┃
5// ┃ █      ██████ █  ▀█▄       █ ██████      █      ███▌▐███ ███████▄ █       ┃
6// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7// ┃ Copyright (c) 2017, the Perspective Authors.                              ┃
8// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9// ┃ This file is part of the Perspective library, distributed under the terms ┃
10// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
13use crate::components::panel_menu::PanelCommand;
14
15#[derive(Debug)]
16pub enum MainPanelMsg {
17    PointerEvent(web_sys::PointerEvent),
18
19    /// The `Workspace` staged-panel set changed (`staged_changed` PubSub —
20    /// see `Workspace::stage_panel`): re-render so cells/tabs/wrappers
21    /// reflect it and `reconcile` inserts a promoted panel. Subscribed on
22    /// MainPanel's OWN scope — the root's `LayoutChanged` delivery proved
23    /// unreliable from element-API task contexts (promoted panels stranded
24    /// in their hidden wrappers), while this component's own messages
25    /// deliver in every observed context.
26    StagedChanged,
27
28    /// The `<regular-layout>` tree changed (fired by its
29    /// `regular-layout-update` event). Used to detect panels removed from
30    /// the layout (e.g. a frame's close button) so they can be disposed.
31    LayoutUpdated,
32
33    /// A tab was selected (fired by `regular-layout-select`, `detail.name`);
34    /// the selected panel becomes the active panel. This is
35    /// regular-layout's own selection signal, so it resolves the correct
36    /// panel within a stack.
37    TabSelected(String),
38
39    /// The layout is about to resize its cells (fired by the cancelable
40    /// `regular-layout-before-resize`). Carries the event so its
41    /// `PresizeDetail` can pre-size each panel's plugin to its target box
42    /// before the layout commits — avoiding the post-commit resize
43    /// shear/clip. The handler (`onbeforeresize` closure) has already
44    /// `preventDefault()`-ed it.
45    BeforeResize(web_sys::Event),
46
47    /// A right-click opened the panel context menu (target panel id, client
48    /// x, y). Fired by the imperative `contextmenu` listener on the panel
49    /// container — see `_contextmenu_listener` — and by each `PanelTab`.
50    /// `Some(id)` activates that panel and opens its
51    /// [`PanelMenu`](crate::components::panel_menu::PanelMenu) at the
52    /// cursor; `None` is the EMPTY stage (zero panels) — a target-less menu
53    /// offering only "New", whose items create the first panel.
54    ContextMenu(Option<String>, f64, f64),
55
56    /// Dismiss the panel context menu (the menu session ended).
57    CloseContextMenu,
58
59    /// The open context menu selected a command. Maximize/Restore act on the
60    /// layout here; the rest forward to `on_panel_command`.
61    Command(PanelCommand),
62}