pub struct Window<'a> { /* private fields */ }Expand description
Builder for a floating window. Same API as egui::Window.
The only behavior change: Self::title_frame fill is honored even when
this window is the top layer. Stock egui replaces that fill from
widgets.open.
let frame = egui::Frame::window(&ctx.global_style());
Window::new("Demo")
.frame(frame)
.title_frame(frame.stroke(egui::Stroke::NONE))
.show(ctx, |ui| {
ui.label("hello");
});Implementations§
Source§impl<'a> Window<'a>
impl<'a> Window<'a>
Sourcepub fn new(title: impl IntoAtoms<'a>) -> Self
pub fn new(title: impl IntoAtoms<'a>) -> Self
The window title is used as a unique Id and must be unique, and
should not change. See egui::Window::new.
Sourcepub fn from_viewport(id: ViewportId, viewport: ViewportBuilder) -> Self
pub fn from_viewport(id: ViewportId, viewport: ViewportBuilder) -> Self
Construct a Window that follows the given viewport.
Sourcepub fn id(self, id: Id) -> Self
pub fn id(self, id: Id) -> Self
Assign a unique id. Required if the title changes or is shared.
Sourcepub fn open(self, open: &'a mut bool) -> Self
pub fn open(self, open: &'a mut bool) -> Self
Add a close button. See egui::Window::open.
Sourcepub fn enabled(self, enabled: bool) -> Self
pub fn enabled(self, enabled: bool) -> Self
If false the window is grayed out and non-interactive.
Sourcepub fn interactable(self, interactable: bool) -> Self
pub fn interactable(self, interactable: bool) -> Self
If false, clicks go through to what is behind us. Default: true.
Sourcepub fn drag_area(self, drag_area: WindowDrag) -> Self
pub fn drag_area(self, drag_area: WindowDrag) -> Self
Where the user can grab the window to move it.
Sourcepub fn order(self, order: Order) -> Self
pub fn order(self, order: Order) -> Self
order(Order::Foreground) for a window that should always be on top.
Sourcepub fn fade_in(self, fade_in: bool) -> Self
pub fn fade_in(self, fade_in: bool) -> Self
Fade in when the window first appears. Default: true.
Sourcepub fn fade_out(self, fade_out: bool) -> Self
pub fn fade_out(self, fade_out: bool) -> Self
Fade out when the window closes via Self::open. Default: true.
Sourcepub fn frame(self, frame: Frame) -> Self
pub fn frame(self, frame: Frame) -> Self
Change the background color, margins, etc. of the window body.
Sourcepub fn title_frame(self, frame: Frame) -> Self
pub fn title_frame(self, frame: Frame) -> Self
Change the background color, margins, etc. of the title bar.
Unlike egui::Window::title_frame, this fill is kept even when the
window is the top layer.
Sourcepub fn min_height(self, min_height: f32) -> Self
pub fn min_height(self, min_height: f32) -> Self
Set minimum height of the window.
Sourcepub fn max_height(self, max_height: f32) -> Self
pub fn max_height(self, max_height: f32) -> Self
Set maximum height of the window.
Sourcepub fn current_pos(self, current_pos: impl Into<Pos2>) -> Self
pub fn current_pos(self, current_pos: impl Into<Pos2>) -> Self
Set current position of the window.
Sourcepub fn default_pos(self, default_pos: impl Into<Pos2>) -> Self
pub fn default_pos(self, default_pos: impl Into<Pos2>) -> Self
Set initial position of the window.
Sourcepub fn fixed_pos(self, pos: impl Into<Pos2>) -> Self
pub fn fixed_pos(self, pos: impl Into<Pos2>) -> Self
Sets the window position and prevents it from being dragged.
Sourcepub fn constrain(self, constrain: bool) -> Self
pub fn constrain(self, constrain: bool) -> Self
Constrains this window to Context::content_rect. Default: true.
Sourcepub fn constrain_to(self, constrain_rect: Rect) -> Self
pub fn constrain_to(self, constrain_rect: Rect) -> Self
Constrain movement of the window to the given rectangle.
Sourcepub fn pivot(self, pivot: Align2) -> Self
pub fn pivot(self, pivot: Align2) -> Self
Where the “root” of the window is. Default: Align2::LEFT_TOP.
Sourcepub fn anchor(self, align: Align2, offset: impl Into<Vec2>) -> Self
pub fn anchor(self, align: Align2, offset: impl Into<Vec2>) -> Self
Set anchor and distance. Also makes the window immovable.
Sourcepub fn default_open(self, default_open: bool) -> Self
pub fn default_open(self, default_open: bool) -> Self
Set initial collapsed state of the window.
Sourcepub fn default_size(self, default_size: impl Into<Vec2>) -> Self
pub fn default_size(self, default_size: impl Into<Vec2>) -> Self
Set initial outer size of the window.
Sourcepub fn default_width(self, default_width: f32) -> Self
pub fn default_width(self, default_width: f32) -> Self
Set initial width of the window.
Sourcepub fn default_height(self, default_height: f32) -> Self
pub fn default_height(self, default_height: f32) -> Self
Set initial height of the window.
Sourcepub fn fixed_size(self, size: impl Into<Vec2>) -> Self
pub fn fixed_size(self, size: impl Into<Vec2>) -> Self
Sets the window size and prevents resizing by dragging edges.
Sourcepub fn default_rect(self, rect: Rect) -> Self
pub fn default_rect(self, rect: Rect) -> Self
Set initial position and size of the window.
Sourcepub fn fixed_rect(self, rect: Rect) -> Self
pub fn fixed_rect(self, rect: Rect) -> Self
Sets pos and size and prevents moving and resizing by dragging.
Sourcepub fn resizable(self, resizable: impl Into<Vec2b>) -> Self
pub fn resizable(self, resizable: impl Into<Vec2b>) -> Self
Can the user resize the window by dragging its edges? Default: true.
Sourcepub fn collapsible(self, collapsible: bool) -> Self
pub fn collapsible(self, collapsible: bool) -> Self
Can the window be collapsed by clicking on its title?
Sourcepub fn title_bar(self, title_bar: bool) -> Self
pub fn title_bar(self, title_bar: bool) -> Self
Show a title bar? If false, the window is not collapsible and has no
close button.
Sourcepub fn auto_sized(self) -> Self
pub fn auto_sized(self) -> Self
Not resizable, just takes the size of its contents. Also disables scrolling.
Sourcepub fn scroll(self, scroll: impl Into<Vec2b>) -> Self
pub fn scroll(self, scroll: impl Into<Vec2b>) -> Self
Enable/disable horizontal/vertical scrolling. false by default.
Sourcepub fn hscroll(self, hscroll: bool) -> Self
pub fn hscroll(self, hscroll: bool) -> Self
Enable/disable horizontal scrolling. false by default.
Sourcepub fn vscroll(self, vscroll: bool) -> Self
pub fn vscroll(self, vscroll: bool) -> Self
Enable/disable vertical scrolling. false by default.
Sourcepub fn drag_to_scroll(self, drag_to_scroll: DragScroll) -> Self
pub fn drag_to_scroll(self, drag_to_scroll: DragScroll) -> Self
Scroll by dragging the contents with the pointer.
Sourcepub fn scroll_bar_visibility(self, visibility: ScrollBarVisibility) -> Self
pub fn scroll_bar_visibility(self, visibility: ScrollBarVisibility) -> Self
Sets the ScrollBarVisibility of the window.
Sourcepub fn show<R>(
self,
ctx: &Context,
add_contents: impl FnOnce(&mut Ui) -> R,
) -> Option<InnerResponse<Option<R>>>
pub fn show<R>( self, ctx: &Context, add_contents: impl FnOnce(&mut Ui) -> R, ) -> Option<InnerResponse<Option<R>>>
Show the window.
Returns None if the window is not open (if Self::open was called
with &mut false). Returns Some(InnerResponse { inner: None }) if
the window is collapsed.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Window<'a>
impl<'a> !Send for Window<'a>
impl<'a> !Sync for Window<'a>
impl<'a> !UnwindSafe for Window<'a>
impl<'a> Freeze for Window<'a>
impl<'a> Unpin for Window<'a>
impl<'a> UnsafeUnpin for Window<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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