pub struct Window<Msg> { /* private fields */ }Expand description
A window: a title strip one row tall above a body, with no border lines, for applications
that put surfaces where the user drags them, such as a desktop or a tool box. Place it with
View::place inside a stack; the body is built with
View::add_with.
The title strip shows the icon and the name, then a faint subtitle (a program’s own title, a
folder). A window that is focused is one tone raised, its name bright, and
the pillar ▌ runs down its whole left edge; others sit one tone lower with a quieter name.
On a narrow window the subtitle shortens first, then the name, each with …. The body keeps
the pillar column and one cell after it on the left, and the right column and the bottom row
free for the handles.
With no options the window is only a surface. on_event makes it one the
pointer moves: the three marks at the right end of the title (minimize, maximize or restore,
close) light up together under the pointer like every close mark; dragging the title moves
the window and double-clicking it maximizes; the body’s right column, bottom row and their
corner are handles that brighten under the pointer and take the accent while dragged, like a
splitter’s boundary; alt with the left button drags the window from anywhere, alt with the
right button resizes it from the nearest edge or corner (the left and top edges too). A drag
belongs to the window until the button comes up, which arrives as WindowEvent::Dropped,
wherever the pointer goes. The title, the
marks, the handles and alt drags are the window’s even when the body holds a
Terminal whose program reads the mouse; other presses in the body reach
the body. The window reports all of it through WindowEvents and changes nothing itself:
stacking order, focus, size limits and snapping are the application’s.
shadow darkens one column right of the window and one row below it. It is
not drawn with reduced motion or in 16 colours.
Style keys: window (bg, pillar), window-title (bg, fg, bold),
window-subtitle (fg), all with focus for a focused window; close-mark for the marks
(active while focused, hover); split-handle for the handles (hover, active while
dragged); window-shadow (scrim, strength in percent).
Implementations§
Source§impl<Msg: 'static> Window<Msg>
impl<Msg: 'static> Window<Msg>
Sourcepub fn new(title: impl Into<String>) -> Self
pub fn new(title: impl Into<String>) -> Self
A window named title, unfocused, with an empty body.
Sourcepub fn subtitle(self, subtitle: impl Into<String>) -> Self
pub fn subtitle(self, subtitle: impl Into<String>) -> Self
A faint second title after the name, such as the title a program set or its folder.
Sourcepub fn icon(self, glyph: impl Into<Glyph>) -> Self
pub fn icon(self, glyph: impl Into<Glyph>) -> Self
The glyph before the name: an icon key such as "folder", or a Glyph::literal.
Sourcepub fn focused(self, focused: bool) -> Self
pub fn focused(self, focused: bool) -> Self
Whether this is the window the user works in: raised one tone, bright name and the pillar
down its left edge. A press on a window that is not focused sends WindowEvent::Focus.
Sourcepub fn maximized(self, maximized: bool) -> Self
pub fn maximized(self, maximized: bool) -> Self
Whether the window fills its desktop; the maximize mark then offers to restore it.
Sourcepub fn shadow(self, shadow: bool) -> Self
pub fn shadow(self, shadow: bool) -> Self
Darkens one column right of the window and one row below it, as if it floated; drawn in the cell a placed child may reach past its rectangle. Not drawn with reduced motion or in 16 colours.
Sourcepub fn on_event(self, message: impl Fn(WindowEvent) -> Msg + 'static) -> Self
pub fn on_event(self, message: impl Fn(WindowEvent) -> Msg + 'static) -> Self
Makes the window one the pointer moves, resizes and closes, and shows its marks; message
turns each WindowEvent into the application’s message.
Trait Implementations§
Source§impl<Msg: 'static> Container<Msg> for Window<Msg>
impl<Msg: 'static> Container<Msg> for Window<Msg>
Source§fn set_children(&mut self, children: Vec<Node<Msg>>)
fn set_children(&mut self, children: Vec<Node<Msg>>)
Source§impl<Msg: 'static> Widget<Msg> for Window<Msg>
impl<Msg: 'static> Widget<Msg> for Window<Msg>
Source§fn measure(&self, _cx: &mut MeasureCx<'_>, available: Size) -> Size
fn measure(&self, _cx: &mut MeasureCx<'_>, available: Size) -> Size
available.Source§fn event(&self, cx: &mut EventCx<'_, Msg>, event: &Event) -> bool
fn event(&self, cx: &mut EventCx<'_, Msg>, event: &Event) -> bool
true when the event was used; unused key and scroll events
bubble to the parent widget.Source§fn children_mut(&mut self) -> &mut [Node<Msg>]
fn children_mut(&mut self) -> &mut [Node<Msg>]
Source§fn paint_overlay(&self, _cx: &mut PaintCx<'_>, _anchor: Rect)
fn paint_overlay(&self, _cx: &mut PaintCx<'_>, _anchor: Rect)
PaintCx::request_overlay. anchor is the area the widget was painted in.Auto Trait Implementations§
impl<Msg> !RefUnwindSafe for Window<Msg>
impl<Msg> !Send for Window<Msg>
impl<Msg> !Sync for Window<Msg>
impl<Msg> !UnwindSafe for Window<Msg>
impl<Msg> Freeze for Window<Msg>
impl<Msg> Unpin for Window<Msg>
impl<Msg> UnsafeUnpin for Window<Msg>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more