pub struct DockPanel { /* private fields */ }Expand description
The center element takes most of the space, but at least 50% in width and height, depending how big the other elements are. The outer elements are technically computed within the layout first and the center is the last one. Each outer element should occupy at most 25% of the width/height - their relative size is relative to the maximum 25%. In case their size is fixed, the heuristic will choose MIN(<fixed window size>, <25% of the dockpanels size>). This control by default has no keybindings.
┌───────────────────────┐
│ Top │
├──────┬────────┬───────┤
│ Left │ Center │ Right │
├──────┴────────┴───────┤
│ Bottom │
└───────────────────────┘Implementations§
Source§impl DockPanel
impl DockPanel
Sourcepub const MAX_CHILD_SIZE: Size
pub const MAX_CHILD_SIZE: Size
The maximum size of an outer (non-center) child element
pub fn new(inner_border: bool) -> Self
pub fn default_callback(_: &mut Self)
pub fn default_key_handler(&mut self, _: &mut WindowEvent)
pub fn set_selection_changed_callback<F: Fn(&mut Self) + 'static>( &mut self, callback: F, )
pub fn set_key_handler(&mut self, f: DockPanelKeyHandler)
Sourcepub fn set_inner_border(&mut self, inner_border: bool)
pub fn set_inner_border(&mut self, inner_border: bool)
Examples found in repository?
examples/dockpanel.rs (line 50)
30 fn default() -> Self {
31 let label = WindowFactory::create::<Label>();
32 label.borrow_mut().set_text("Lorem ipsum");
33 let label2 = WindowFactory::create::<Label>();
34 label2.borrow_mut().set_text("Bibsum loram");
35 let label3 = WindowFactory::create::<Label>();
36 label3.borrow_mut().set_text("Epsum larel");
37 let label4 = WindowFactory::create::<Label>();
38 label4.borrow_mut().set_text("Ipsel Aarel");
39 let input = WindowFactory::create::<Textbox>();
40
41 let dockpanel = WindowFactory::create::<DockPanel>();
42 {
43 let mut brw = dockpanel.borrow_mut();
44 brw.set_child(DockAlignment::Center, Some(input));
45 brw.set_child(DockAlignment::Top, Some(label));
46 brw.set_child(DockAlignment::Right, Some(label2));
47 brw.set_child(DockAlignment::Left, Some(label3));
48 brw.set_child(DockAlignment::Bottom, Some(label4));
49 brw.set_border(BorderStyle::new(BorderKind::Dashed, None, None));
50 brw.set_inner_border(true);
51 }
52
53 Self {
54 uid: WindowUID::new(),
55 dockpanel,
56 running: true,
57 }
58 }Sourcepub fn set_child(&mut self, dock: DockAlignment, child: Option<WindowRef>)
pub fn set_child(&mut self, dock: DockAlignment, child: Option<WindowRef>)
Examples found in repository?
examples/dockpanel.rs (line 44)
30 fn default() -> Self {
31 let label = WindowFactory::create::<Label>();
32 label.borrow_mut().set_text("Lorem ipsum");
33 let label2 = WindowFactory::create::<Label>();
34 label2.borrow_mut().set_text("Bibsum loram");
35 let label3 = WindowFactory::create::<Label>();
36 label3.borrow_mut().set_text("Epsum larel");
37 let label4 = WindowFactory::create::<Label>();
38 label4.borrow_mut().set_text("Ipsel Aarel");
39 let input = WindowFactory::create::<Textbox>();
40
41 let dockpanel = WindowFactory::create::<DockPanel>();
42 {
43 let mut brw = dockpanel.borrow_mut();
44 brw.set_child(DockAlignment::Center, Some(input));
45 brw.set_child(DockAlignment::Top, Some(label));
46 brw.set_child(DockAlignment::Right, Some(label2));
47 brw.set_child(DockAlignment::Left, Some(label3));
48 brw.set_child(DockAlignment::Bottom, Some(label4));
49 brw.set_border(BorderStyle::new(BorderKind::Dashed, None, None));
50 brw.set_inner_border(true);
51 }
52
53 Self {
54 uid: WindowUID::new(),
55 dockpanel,
56 running: true,
57 }
58 }pub fn set_focus(&mut self, dock: DockAlignment)
Trait Implementations§
Source§impl HasWindowUID for DockPanel
impl HasWindowUID for DockPanel
Source§impl Widget for DockPanel
impl Widget for DockPanel
fn set_alignment( &mut self, horizontal: HorizontalAlignment, vertical: VerticalAlignment, )
fn set_visibility(&mut self, visibility: bool)
fn set_width(&mut self, width: Size)
fn set_height(&mut self, height: Size)
fn set_margin(&mut self, margin: Thickness)
fn set_border(&mut self, border: BorderStyle)
Source§fn set_enabled_state(&mut self, is_enabled: bool)
fn set_enabled_state(&mut self, is_enabled: bool)
Changing the IsEnabled state usually changes the highlight color
fn set_width_constraint(&mut self, width: SizeConstraint)
fn set_height_constraint(&mut self, height: SizeConstraint)
Source§impl WidgetColors for DockPanel
impl WidgetColors for DockPanel
fn set_disabled_color(&mut self, color: Option<Color>)
fn set_base_fg_color(&mut self, color: Option<Color>)
fn set_base_bg_color(&mut self, color: Option<Color>)
Source§impl Window for DockPanel
impl Window for DockPanel
Source§fn handle_event(&mut self, event: &mut WindowEvent)
fn handle_event(&mut self, event: &mut WindowEvent)
Source§fn children(&mut self, builder: SubWindowBuilder) -> SubWindows
fn children(&mut self, builder: SubWindowBuilder) -> SubWindows
Returns all children windows (and layouting Rects)
Note: When changing the children make sure to also adjust the focus
Source§impl WindowLayout for DockPanel
impl WindowLayout for DockPanel
Source§fn desired_size(&self, available_size: TPoint) -> TPoint
fn desired_size(&self, available_size: TPoint) -> TPoint
Parents call this to get the desired size of the child
This must not exceed
available_size on any axis
When the result’s product is equal to 0, this window wont be drawnSource§fn alignment(&self) -> (HorizontalAlignment, VerticalAlignment)
fn alignment(&self) -> (HorizontalAlignment, VerticalAlignment)
fn margin(&self) -> Thickness
fn border(&self) -> BorderStyle
fn is_visible(&self) -> bool
Source§fn desired_size_pre_hook(&mut self, available_size: TPoint)
fn desired_size_pre_hook(&mut self, available_size: TPoint)
This is similar to desired_size but will not return anything and can mutably change self
This is executed before WindowLayout::desired_size
Only implement if actually necessary
Auto Trait Implementations§
impl !RefUnwindSafe for DockPanel
impl !Send for DockPanel
impl !Sync for DockPanel
impl !UnwindSafe for DockPanel
impl Freeze for DockPanel
impl Unpin for DockPanel
impl UnsafeUnpin for DockPanel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for T
impl<T> Downcast for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> WindowHelper for Twhere
T: Window,
impl<T> WindowHelper for Twhere
T: Window,
Source§fn provoke_changed_property(&self, property: WindowProperty)
fn provoke_changed_property(&self, property: WindowProperty)
Helper method for WindowEventQueue::provoke_changed_property