Skip to main content

Window

Struct Window 

Source
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>

Source

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.

Source

pub fn from_viewport(id: ViewportId, viewport: ViewportBuilder) -> Self

Construct a Window that follows the given viewport.

Source

pub fn id(self, id: Id) -> Self

Assign a unique id. Required if the title changes or is shared.

Source

pub fn open(self, open: &'a mut bool) -> Self

Add a close button. See egui::Window::open.

Source

pub fn enabled(self, enabled: bool) -> Self

If false the window is grayed out and non-interactive.

Source

pub fn interactable(self, interactable: bool) -> Self

If false, clicks go through to what is behind us. Default: true.

Source

pub fn movable(self, movable: bool) -> Self

If false the window cannot be moved by dragging.

Source

pub fn drag_area(self, drag_area: WindowDrag) -> Self

Where the user can grab the window to move it.

Source

pub fn order(self, order: Order) -> Self

order(Order::Foreground) for a window that should always be on top.

Source

pub fn fade_in(self, fade_in: bool) -> Self

Fade in when the window first appears. Default: true.

Source

pub fn fade_out(self, fade_out: bool) -> Self

Fade out when the window closes via Self::open. Default: true.

Source

pub fn mutate(self, mutate: impl Fn(&mut Self)) -> Self

Mutate the builder in place.

Source

pub fn resize(self, mutate: impl Fn(Resize) -> Resize) -> Self

Mutate the inner Resize.

Source

pub fn frame(self, frame: Frame) -> Self

Change the background color, margins, etc. of the window body.

Source

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.

Source

pub fn min_width(self, min_width: f32) -> Self

Set minimum width of the window.

Source

pub fn min_height(self, min_height: f32) -> Self

Set minimum height of the window.

Source

pub fn min_size(self, min_size: impl Into<Vec2>) -> Self

Set minimum outer size of the window.

Source

pub fn max_width(self, max_width: f32) -> Self

Set maximum width of the window.

Source

pub fn max_height(self, max_height: f32) -> Self

Set maximum height of the window.

Source

pub fn max_size(self, max_size: impl Into<Vec2>) -> Self

Set maximum outer size of the window.

Source

pub fn current_pos(self, current_pos: impl Into<Pos2>) -> Self

Set current position of the window.

Source

pub fn default_pos(self, default_pos: impl Into<Pos2>) -> Self

Set initial position of the window.

Source

pub fn fixed_pos(self, pos: impl Into<Pos2>) -> Self

Sets the window position and prevents it from being dragged.

Source

pub fn constrain(self, constrain: bool) -> Self

Constrains this window to Context::content_rect. Default: true.

Source

pub fn constrain_to(self, constrain_rect: Rect) -> Self

Constrain movement of the window to the given rectangle.

Source

pub fn pivot(self, pivot: Align2) -> Self

Where the “root” of the window is. Default: Align2::LEFT_TOP.

Source

pub fn anchor(self, align: Align2, offset: impl Into<Vec2>) -> Self

Set anchor and distance. Also makes the window immovable.

Source

pub fn default_open(self, default_open: bool) -> Self

Set initial collapsed state of the window.

Source

pub fn default_size(self, default_size: impl Into<Vec2>) -> Self

Set initial outer size of the window.

Source

pub fn default_width(self, default_width: f32) -> Self

Set initial width of the window.

Source

pub fn default_height(self, default_height: f32) -> Self

Set initial height of the window.

Source

pub fn fixed_size(self, size: impl Into<Vec2>) -> Self

Sets the window size and prevents resizing by dragging edges.

Source

pub fn default_rect(self, rect: Rect) -> Self

Set initial position and size of the window.

Source

pub fn fixed_rect(self, rect: Rect) -> Self

Sets pos and size and prevents moving and resizing by dragging.

Source

pub fn resizable(self, resizable: impl Into<Vec2b>) -> Self

Can the user resize the window by dragging its edges? Default: true.

Source

pub fn collapsible(self, collapsible: bool) -> Self

Can the window be collapsed by clicking on its title?

Source

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.

Source

pub fn auto_sized(self) -> Self

Not resizable, just takes the size of its contents. Also disables scrolling.

Source

pub fn scroll(self, scroll: impl Into<Vec2b>) -> Self

Enable/disable horizontal/vertical scrolling. false by default.

Source

pub fn hscroll(self, hscroll: bool) -> Self

Enable/disable horizontal scrolling. false by default.

Source

pub fn vscroll(self, vscroll: bool) -> Self

Enable/disable vertical scrolling. false by default.

Source

pub fn drag_to_scroll(self, drag_to_scroll: DragScroll) -> Self

Scroll by dragging the contents with the pointer.

Source

pub fn scroll_bar_visibility(self, visibility: ScrollBarVisibility) -> Self

Sets the ScrollBarVisibility of the window.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.