pub struct Layout {
pub areas: Vec<(Area, Node)>,
pub auxiliary: Vec<Auxiliary>,
pub hidden: Vec<PanelId>,
pub folded: Vec<Area>,
pub over: Vec<Area>,
pub flyouts: BTreeMap<PanelId, f32>,
pub floating: Vec<FloatingGroup>,
pub docked_groups: Vec<FloatingGroup>,
pub closed: BTreeMap<PanelId, DormantPlace>,
pub instances: Vec<PanelInstance>,
pub windows: Vec<WindowAreas>,
}Fields§
§areas: Vec<(Area, Node)>§auxiliary: Vec<Auxiliary>Panels the user closed: not put back as new ones are.
folded: Vec<Area>Areas folded to their strip: their panels stay, unshown.
over: Vec<Area>Side areas lying over the centre (Placement::Over): their
folded strip keeps their room, the centre its width.
flyouts: BTreeMap<PanelId, f32>The width each panel was given as a flyout over the centre, out of its folded side area’s strip, in points.
floating: Vec<FloatingGroup>Panels floating over the interface (palettes), each group as one unit (a palette alone is a group of one).
docked_groups: Vec<FloatingGroup>Groups docked whole in an area (their members there as tabs), kept so that floating one of them out again gives the group back.
closed: BTreeMap<PanelId, DormantPlace>The place each closed panel had when it closed (Layout::hide),
where opening it puts it back (Layout::last_place); kept only
for panels in hidden.
instances: Vec<PanelInstance>The instances of panels declared with several
(PanelSpec::instances): each <kind>#<n> open, its title when
renamed and the application’s payload for it; the panel declared
(instance 1) only when it holds a payload. A layout saved without
them reads as one with none.
windows: Vec<WindowAreas>The areas of the application windows other than the main one, each
window’s own workbench (WindowAreas); areas are the main
window’s. A layout saved before them reads as one with none.
Implementations§
Source§impl Layout
impl Layout
Sourcepub fn default_for(panels: &Panels) -> Layout
pub fn default_for(panels: &Panels) -> Layout
Every declared panel in its default area, as tabs.
Sourcepub fn placement(&self, area: Area) -> Placement
pub fn placement(&self, area: Area) -> Placement
Where a side area lies (the centre and the bottom area always lie beside).
Sourcepub fn set_placement(&mut self, area: Area, placement: Placement)
pub fn set_placement(&mut self, area: Area, placement: Placement)
Lays a side area over the centre or beside it.
Sourcepub fn window_areas(&self, window: &str) -> Option<&WindowAreas>
pub fn window_areas(&self, window: &str) -> Option<&WindowAreas>
An application window’s areas, if it has any.
Sourcepub fn window_folded(&self, window: &str, area: Area) -> bool
pub fn window_folded(&self, window: &str, area: Area) -> bool
Whether an application window’s area is folded
(WindowAreas::folded).
Sourcepub fn fold_in_window(&mut self, window: &str, area: Area, folded: bool) -> bool
pub fn fold_in_window(&mut self, window: &str, area: Area, folded: bool) -> bool
Folds an application window’s area (true) or unfolds it; a
window without areas has nothing to fold. false when nothing
changed.
use egui_pop_model::ids::PanelId;
use egui_pop_model::layout::Layout;
use egui_pop_model::panels::Area;
let outline = PanelId::from_static("app.outline");
let mut layout = Layout::default();
layout.place_in_window(&outline, "library", Area::StartSide);
assert!(layout.fold_in_window("library", Area::StartSide, true));
assert!(layout.window_folded("library", Area::StartSide));
assert!(layout.shows(&outline));Sourcepub fn window_place(&self, panel: &PanelId) -> Option<(&str, Area)>
pub fn window_place(&self, panel: &PanelId) -> Option<(&str, Area)>
The application window (other than the main one) a panel is docked in, and its area there.
Sourcepub fn panels_in_window(&self, window: &str) -> Vec<&PanelId>
pub fn panels_in_window(&self, window: &str) -> Vec<&PanelId>
Every panel an application window holds: for MAIN_WINDOW those
in its areas, its detached windows and its floating groups; for
another, those docked in its own areas (Layout::windows).
use egui_pop_model::ids::PanelId;
use egui_pop_model::layout::{Layout, MAIN_WINDOW};
use egui_pop_model::panels::Area;
let [tree, log] = [PanelId::from_static("app.tree"), PanelId::from_static("app.log")];
let mut layout = Layout::default();
layout.place(&tree, Area::StartSide);
layout.place_in_window(&log, "activity", Area::Bottom);
assert_eq!(layout.panels_in_window(MAIN_WINDOW), [&tree]);
assert_eq!(layout.panels_in_window("activity"), [&log]);Sourcepub fn with_window_from(&self, from: &Layout, window: &str) -> Layout
pub fn with_window_from(&self, from: &Layout, window: &str) -> Layout
This layout with one application window’s part taken from from,
every other window left as it is here: what a change made to one
window (a place switched in it) puts in.
The part of MAIN_WINDOW is its areas, its detached windows,
its floating groups and what goes with them (folded and overlaid
areas, flyouts, docked groups); another window’s part is its own
areas. A panel this layout shows in another window stays there:
from cannot take it, show it or close it. Closed panels follow
the window they were closed in, and instances the window that
holds them.
use egui_pop_model::ids::PanelId;
use egui_pop_model::layout::{Layout, MAIN_WINDOW};
use egui_pop_model::panels::Area;
let [tree, log] = [PanelId::from_static("app.tree"), PanelId::from_static("app.log")];
// Shown: the log docked in a second window.
let mut shown = Layout::default();
shown.place(&tree, Area::StartSide);
shown.place_in_window(&log, "activity", Area::Bottom);
// A place's layout for the main window, which had the log there.
let mut place = Layout::default();
place.place(&tree, Area::EndSide);
place.place(&log, Area::Bottom);
let merged = shown.with_window_from(&place, MAIN_WINDOW);
assert_eq!(merged.area_of(&tree), Some(Area::EndSide));
assert_eq!(merged.window_place(&log), Some(("activity", Area::Bottom)));
assert_eq!(merged.area_of(&log), None);Sourcepub fn place_in_window(&mut self, panel: &PanelId, window: &str, area: Area)
pub fn place_in_window(&mut self, panel: &PanelId, window: &str, area: Area)
Docks a panel in an area of an application window other than the main one (taken out of where it was, opened if closed), as the shown tab of the area’s first tabs.
Sourcepub fn set_window_areas(&mut self, window: &str, areas: Vec<(Area, Node)>)
pub fn set_window_areas(&mut self, window: &str, areas: Vec<(Area, Node)>)
Sets an application window’s areas as drawn (its tabs reordered, split, moved between its areas); empty areas are dropped, and the window with them when it has none left.
Sourcepub fn window_of(&self, panel: &PanelId) -> Option<&Auxiliary>
pub fn window_of(&self, panel: &PanelId) -> Option<&Auxiliary>
The window a detached panel is in, if it is detached (alone or as one of its tabs).
Sourcepub fn join_window(
&mut self,
panel: &PanelId,
window: &PanelId,
) -> Result<(), String>
pub fn join_window( &mut self, panel: &PanelId, window: &PanelId, ) -> Result<(), String>
Moves a panel into the window holding window (a panel of it), as
its last tab, shown; taken out of where it was, opened if closed.
A panel in that window already is only shown.
Sourcepub fn group_of(&self, panel: &PanelId) -> Option<(Vec<PanelId>, usize)>
pub fn group_of(&self, panel: &PanelId) -> Option<(Vec<PanelId>, usize)>
The tab group holding a docked or detached panel: its panels in order and the index of the shown one (an area’s tabs holding it, or its window’s tabs).
use egui_pop_model::ids::PanelId;
use egui_pop_model::layout::{Layout, Node};
use egui_pop_model::panels::Area;
let [a, b] = [PanelId::from_static("app.a"), PanelId::from_static("app.b")];
let mut layout = Layout::default();
layout.areas.push((Area::Bottom, Node::Tabs { panels: vec![a.clone(), b.clone()], active: 1 }));
assert_eq!(layout.group_of(&a), Some((vec![a, b], 1)));Sourcepub fn join_window_group(
&mut self,
panel: &PanelId,
window: &PanelId,
) -> Result<(), String>
pub fn join_window_group( &mut self, panel: &PanelId, window: &PanelId, ) -> Result<(), String>
Moves the tab group holding panel (Layout::group_of) into
the window holding window, after its tabs, in order; the group’s
shown panel is shown there. A group already in that window stays.
Sourcepub fn detach_group(
&mut self,
panel: &PanelId,
screen: &str,
rect: [f32; 4],
) -> Result<(), String>
pub fn detach_group( &mut self, panel: &PanelId, screen: &str, rect: [f32; 4], ) -> Result<(), String>
Moves the tab group holding panel (Layout::group_of) into a
window of its own at rect on screen, in order, its shown panel
shown. A group that is a window already stays.
Sourcepub fn float_tabs(
&mut self,
panel: &PanelId,
pos: [f32; 2],
) -> Result<Vec<PanelId>, String>
pub fn float_tabs( &mut self, panel: &PanelId, pos: [f32; 2], ) -> Result<Vec<PanelId>, String>
Floats the docked tab group holding panel (Layout::group_of)
over the interface at pos, whole: one floating group of tabs, in
order, its shown tab shown. The panels floated.
use egui_pop_model::ids::PanelId;
use egui_pop_model::layout::{Arrangement, Layout, Node};
use egui_pop_model::panels::Area;
let [a, b] = [PanelId::from_static("app.a"), PanelId::from_static("app.b")];
let mut layout = Layout::default();
layout.areas.push((Area::Bottom, Node::Tabs { panels: vec![a.clone(), b.clone()], active: 1 }));
assert_eq!(layout.float_tabs(&a, [8.0, 8.0]).unwrap(), [a.clone(), b.clone()]);
let g = layout.floating_of(&a).unwrap();
assert_eq!(g.arrangement, Arrangement::Tabs);
assert_eq!(g.shown(), &b);
assert_eq!(layout.area_of(&a), None);Sourcepub fn floating_of(&self, panel: &PanelId) -> Option<&FloatingGroup>
pub fn floating_of(&self, panel: &PanelId) -> Option<&FloatingGroup>
The group a floating panel floats in, if it floats.
Sourcepub fn floating_mut(&mut self, panel: &PanelId) -> Option<&mut FloatingGroup>
pub fn floating_mut(&mut self, panel: &PanelId) -> Option<&mut FloatingGroup>
The group a floating panel floats in, to change it.
Sourcepub fn float(&mut self, panel: &PanelId, pos: [f32; 2])
pub fn float(&mut self, panel: &PanelId, pos: [f32; 2])
Floats a panel over the interface at pos (taken out of where it
was, opened if it was closed); a panel floating already moves
there with its group, keeping its state. A panel docked with the
group it was docked in whole (Layout::dock_group) floats with
the members still docked beside it: the group comes back.
Sourcepub fn group(
&mut self,
panels: &[PanelId],
into: &PanelId,
at: Join,
) -> Result<(), String>
pub fn group( &mut self, panels: &[PanelId], into: &PanelId, at: Join, ) -> Result<(), String>
Moves floating panels into the group of another floating panel,
into, and says where:
Join::AboveorJoin::Belowit: the group is then a stack. Beside a group of tabs, the tabs stay tabs, as one member of the stack (a nested tab group).Join::Tab: as tabs of it, the first of them shown. In a group of tabs or with a palette alone, the group turns to tabs; on a member of a stack, that member alone becomes a tab group.
A nested tab group whose tabs all move keeps them, unless it joins as tabs; each moved member keeps whether it is rolled up; groups left empty go.
Sourcepub fn ungroup(&mut self, panel: &PanelId, pos: [f32; 2]) -> Result<(), String>
pub fn ungroup(&mut self, panel: &PanelId, pos: [f32; 2]) -> Result<(), String>
Takes a floating panel out of its group, alone at pos (it keeps
whether it is rolled up); out of a nested tab group, the group’s
other tabs stay.
Sourcepub fn ungroup_tabs(
&mut self,
panel: &PanelId,
pos: [f32; 2],
) -> Result<(), String>
pub fn ungroup_tabs( &mut self, panel: &PanelId, pos: [f32; 2], ) -> Result<(), String>
Takes the tab group a floating panel is a tab of, nested in a
stack, out of the stack whole: a group of tabs at pos. A palette
that is not in a nested tab group comes out alone, as
Layout::ungroup takes it.
Sourcepub fn dock_group(&mut self, panel: &PanelId, area: Area) -> Vec<PanelId>
pub fn dock_group(&mut self, panel: &PanelId, area: Area) -> Vec<PanelId>
Docks every member of a floating panel’s group in an area, as
tabs, the group’s shown member shown; the group is kept
(Layout::docked_groups) so that floating one of them out
again gives it back. The panels docked.
Sourcepub fn area_of(&self, panel: &PanelId) -> Option<Area>
pub fn area_of(&self, panel: &PanelId) -> Option<Area>
The area a panel is docked in, if it is.
Sourcepub fn shows(&self, panel: &PanelId) -> bool
pub fn shows(&self, panel: &PanelId) -> bool
Whether a panel is docked or detached, and not closed.
Sourcepub fn remove(&mut self, panel: &PanelId) -> bool
pub fn remove(&mut self, panel: &PanelId) -> bool
Takes a panel out of its area, its window or its float (out of its group, the others staying together; it stays known: not closed). Whether it was placed.
Sourcepub fn place(&mut self, panel: &PanelId, area: Area)
pub fn place(&mut self, panel: &PanelId, area: Area)
Docks a panel in an area (taken out of where it was), as the shown tab of the area’s first tabs.
Sourcepub fn docked_place(&self, panel: &PanelId) -> Option<DormantPlace>
pub fn docked_place(&self, panel: &PanelId) -> Option<DormantPlace>
Where a docked panel is: its area, the other panels of its tabs
and its index among them (a DormantPlace::Docked); None when
it is not docked.
use egui_pop_model::ids::PanelId;
use egui_pop_model::layout::{DormantPlace, Layout, Node};
use egui_pop_model::panels::Area;
let [a, b] = [PanelId::from_static("app.a"), PanelId::from_static("app.b")];
let mut layout = Layout::default();
layout.areas.push((Area::Bottom, Node::Tabs { panels: vec![a.clone(), b.clone()], active: 0 }));
let place = layout.docked_place(&b).unwrap();
assert_eq!(place, DormantPlace::Docked { area: Area::Bottom, beside: vec![a.clone()], index: 1 });
layout.float(&b, [0.0, 0.0]);
layout.dock_at(&b, &place);
assert_eq!(layout.group_of(&b), Some((vec![a, b], 1)));Sourcepub fn in_window_place(&self, panel: &PanelId) -> Option<DormantPlace>
pub fn in_window_place(&self, panel: &PanelId) -> Option<DormantPlace>
Where a panel docked in an application window other than the main
one is (a DormantPlace::InWindow); None when it is not there.
Sourcepub fn dock_at(&mut self, panel: &PanelId, place: &DormantPlace) -> bool
pub fn dock_at(&mut self, panel: &PanelId, place: &DormantPlace) -> bool
Docks a panel at a place Layout::docked_place gave (taken out of
where it is, opened if closed), shown: at its index in the tabs
holding one of the panels it was beside, else in its area’s first
tabs. A place that is not DormantPlace::Docked changes nothing;
whether it was docked.
Sourcepub fn join_tabs(
&mut self,
panel: &PanelId,
into: &PanelId,
) -> Result<(), String>
pub fn join_tabs( &mut self, panel: &PanelId, into: &PanelId, ) -> Result<(), String>
Docks a panel in the tabs holding into, after them and shown
(taken out of where it is: floating, detached or docked, opened if
closed). into is docked; a panel already there is only shown.
use egui_pop_model::ids::PanelId;
use egui_pop_model::layout::{Layout, Node};
use egui_pop_model::panels::Area;
let [a, b] = [PanelId::from_static("app.a"), PanelId::from_static("app.b")];
let mut layout = Layout::default();
layout.areas.push((Area::Bottom, Node::tab(a.clone())));
layout.float(&b, [0.0, 0.0]);
layout.join_tabs(&b, &a).unwrap();
assert_eq!(layout.group_of(&b), Some((vec![a, b], 1)));Sourcepub fn place_of(&self, panel: &PanelId) -> Option<DormantPlace>
pub fn place_of(&self, panel: &PanelId) -> Option<DormantPlace>
Where a panel is: docked (its area, the tabs beside it and its
index, Layout::docked_place), detached (its window’s screen and
rectangle) or floating (its group’s corner); None when it is not
placed.
use egui_pop_model::ids::PanelId;
use egui_pop_model::layout::{DormantPlace, Layout};
let tools = PanelId::from_static("app.tools");
let mut layout = Layout::default();
layout.float(&tools, [16.0, 24.0]);
assert_eq!(layout.place_of(&tools), Some(DormantPlace::Floating { pos: [16.0, 24.0] }));Sourcepub fn last_place(&self, panel: &PanelId) -> Option<&DormantPlace>
pub fn last_place(&self, panel: &PanelId) -> Option<&DormantPlace>
The place a closed panel had when it closed (Layout::hide):
None when it is open, or closed with no place known.
use egui_pop_model::ids::PanelId;
use egui_pop_model::layout::{DormantPlace, Layout, Node};
use egui_pop_model::panels::Area;
let [a, b] = [PanelId::from_static("app.a"), PanelId::from_static("app.b")];
let mut layout = Layout::default();
layout.areas.push((Area::Bottom, Node::Tabs { panels: vec![a.clone(), b.clone()], active: 1 }));
layout.hide(&b);
let place = layout.last_place(&b).cloned().unwrap();
assert_eq!(place, DormantPlace::Docked { area: Area::Bottom, beside: vec![a.clone()], index: 1 });
layout.dock_at(&b, &place);
assert_eq!(layout.group_of(&b), Some((vec![a, b], 1)));Sourcepub fn instance(&self, id: &PanelId) -> Option<&PanelInstance>
pub fn instance(&self, id: &PanelId) -> Option<&PanelInstance>
An instance’s record (Layout::instances).
Sourcepub fn instance_mut(&mut self, id: &PanelId) -> &mut PanelInstance
pub fn instance_mut(&mut self, id: &PanelId) -> &mut PanelInstance
An instance’s record, made (without payload) when it has none.
Sourcepub fn instances_of(&self, kind: &PanelId) -> Vec<PanelId>
pub fn instances_of(&self, kind: &PanelId) -> Vec<PanelId>
The instances of kind this layout knows (open, closed or kept
for a panel no longer declared), the panel declared included when
placed or closed, in number order.
Sourcepub fn next_instance(&self, kind: &PanelId) -> PanelId
pub fn next_instance(&self, kind: &PanelId) -> PanelId
The id a new instance of kind takes: the number after the
highest this layout knows, from 2.
Sourcepub fn drop_instance(&mut self, id: &PanelId) -> bool
pub fn drop_instance(&mut self, id: &PanelId) -> bool
Drops an instance (<kind>#<n>): out of where it is, its record
and payload gone, not kept closed (closing the panel declared
keeps its place, Layout::hide). Whether it was known.
Sourcepub fn hide(&mut self, panel: &PanelId)
pub fn hide(&mut self, panel: &PanelId)
Closes a panel: out of its area or window, and kept closed, its
place kept for when it opens again (Layout::last_place).
Sourcepub fn activate(&mut self, panel: &PanelId) -> bool
pub fn activate(&mut self, panel: &PanelId) -> bool
Makes a docked panel the shown tab of its tabs; whether it is docked.
Sourcepub fn active_in(&self, area: Area) -> Vec<&PanelId>
pub fn active_in(&self, area: Area) -> Vec<&PanelId>
The shown panels of an area, in order (the shown tab of each tabs node).
Sourcepub fn repair(self, panels: &Panels, screens: &[&str]) -> (Layout, Vec<String>)
pub fn repair(self, panels: &Panels, screens: &[&str]) -> (Layout, Vec<String>)
Brings a saved layout in line with today’s panels and screens:
panels no longer declared leave it, new ones go to their default
area, so do panels in an area they may no longer be in, a window on
a screen that is gone comes back docked. Says what it changed.
Layout::repair_dormant also keeps the places of the panels
that leave.
Sourcepub fn repair_dormant(
self,
dormant: Vec<Dormant>,
panels: &Panels,
screens: &[&str],
) -> (SavedLayout, Vec<String>)
pub fn repair_dormant( self, dormant: Vec<Dormant>, panels: &Panels, screens: &[&str], ) -> (SavedLayout, Vec<String>)
Layout::repair, keeping the places of panels no longer declared
(ADR 0028): dormant, the places kept so far, comes back with
those of the panels leaving now; a panel declared again goes back
to its place (docked at its index beside the same tabs, detached,
floating, or closed) instead of to its default area.