[−][src]Struct thyme::WindowBuilder
A WidgetBuilder
specifically for creating windows.
Windows can have a titlebar, close button, move, and resizing capabilities. Each window
is automatically part of its own render group
and will automatically come on top of other widgets when clicked on. You can create a WindowBuilder
from a WidgetBuilder
by calling window
after any calls to general purpose widget layout.
There is also a window method on Frame
as a convenience for simple cases.
Once you are finished setting up the window, you call children
to add children and add the widget
to the frame.
Example
fn create_window(ui: &mut Frame, unique_id: &str) { ui.start("window") .window(unique_id) .title("My Window") .resizable(false) .children(|ui| { // window content here }); }
Theme definition
An example of a theme definition for a window:
window:
background: gui/window_bg
wants_mouse: true
layout: Vertical
layout_spacing: [5, 5]
border: { left: 5, right: 5, top: 35, bot: 5 }
size: [300, 400]
child_align: Top
children:
titlebar:
wants_mouse: true
background: gui/small_button
size: [10, 30]
pos: [-6, -36]
border: { all: 5 }
width_from: Parent
child_align: Center
align: TopLeft
children:
title:
from: label
text: "Main Window"
font: medium
width_from: Parent
close:
wants_mouse: true
background: gui/small_button
foreground: gui/close_icon
size: [20, 20]
border: { all: 4 }
align: TopRight
handle:
wants_mouse: true
background: gui/window_handle
size: [12, 12]
align: BotRight
pos: [-1, -1]
Implementations
impl<'a> WindowBuilder<'a>
[src]
#[must_use]pub fn cancel_render_group(self) -> WindowBuilder<'a>
[src]
Specifies that this window will not use a new render group. This can
be useful in some cases where you want to handle grouping yourself.
See WidgetBuilder.new_render_group
#[must_use]pub fn with_titlebar(self, with_titlebar: bool) -> WindowBuilder<'a>
[src]
Specifies whether the created window should show a titlebar.
#[must_use]pub fn title<T: Into<String>>(self, title: T) -> WindowBuilder<'a>
[src]
Specify a title to show in the window's titlebar, if it is present. If the titlebar is not present, does nothing. This will override any text set in the theme.
#[must_use]pub fn with_close_button(self, with_close_button: bool) -> WindowBuilder<'a>
[src]
Specifies whether the created window should have a close button.
#[must_use]pub fn moveable(self, moveable: bool) -> WindowBuilder<'a>
[src]
Specifies whether the user should be able to move the created window
by dragging the mouse. Note that if the titlebar
is not shown, there
will be no way to move the window regardless of this setting.
#[must_use]pub fn resizable(self, resizable: bool) -> WindowBuilder<'a>
[src]
Specifies whether the user should be able to resize the created window. If false, the resize handle will not be shown.
pub fn children<F: FnOnce(&mut Frame)>(self, children: F) -> WidgetState
[src]
Consumes the builder and adds a widget to the current frame. The returned data includes information about the animation state and mouse interactions of the created element. The provided closure is called to enable adding children to this window.
Auto Trait Implementations
impl<'a> !RefUnwindSafe for WindowBuilder<'a>
impl<'a> !Send for WindowBuilder<'a>
impl<'a> !Sync for WindowBuilder<'a>
impl<'a> Unpin for WindowBuilder<'a>
impl<'a> !UnwindSafe for WindowBuilder<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,