Skip to main content

Area

Struct Area 

Source
pub struct Area { /* private fields */ }
Expand description

An area on the screen that can be moved by dragging.

This forms the base of the crate::Window container.

egui::Area::new(egui::Id::new("my_area"))
    .fixed_pos(egui::pos2(32.0, 32.0))
    .show(ctx, |ui| {
        ui.label("Floating text!");
    });

The previous rectangle used by this area can be obtained through crate::Memory::area_rect().

Implementations§

Source§

impl Area

Source

pub fn new(id: Id) -> Area

The id must be globally unique.

Source

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

Let’s you change the id that you assigned in Self::new.

The id must be globally unique.

Source

pub fn kind(self, kind: UiKind) -> Area

Change the UiKind of the arena.

Default to UiKind::GenericArea.

Source

pub fn layer(&self) -> LayerId

Source

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

If false, no content responds to click and widgets will be shown grayed out. You won’t be able to move the window. Default: true.

Source

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

Moveable by dragging the area?

Source

pub fn is_enabled(&self) -> bool

Source

pub fn is_movable(&self) -> bool

Source

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

If false, clicks goes straight through to what is behind us.

Can be used for semi-invisible areas that the user should be able to click through.

Default: true.

Source

pub fn sense(self, sense: Sense) -> Area

Explicitly set a sense.

If not set, this will default to Sense::drag() if movable, Sense::click() if interactable, and Sense::hover() otherwise.

Source

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

order(Order::Foreground) for an Area that should always be on top

Source

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

Source

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

The size used for the Ui::max_rect the first frame.

Text will wrap at this width, and images that expand to fill the available space will expand to this size.

If the contents are smaller than this size, the area will shrink to fit the contents. If the contents overflow, the area will grow.

If not set, crate::style::Spacing::default_area_size will be used.

Source

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

Source

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

Source

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

Positions the window and prevents it from being moved

Source

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

Constrains this area to Context::screen_rect?

Default: true.

Source

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

Constrain the movement of the window to the given rectangle.

For instance: .constrain_to(ctx.screen_rect()).

Source

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

Where the “root” of the area is.

For instance, if you set this to Align2::RIGHT_TOP then Self::fixed_pos will set the position of the right-top corner of the area.

Default: Align2::LEFT_TOP.

Source

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

Positions the window but you can still move it.

Source

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

Set anchor and distance.

An anchor of Align2::RIGHT_TOP means “put the right-top corner of the window in the right-top corner of the screen”.

The offset is added to the position, so e.g. an offset of [-5.0, 5.0] would move the window left and down from the given anchor.

Anchoring also makes the window immovable.

It is an error to set both an anchor and a position.

Source

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

If true, quickly fade in the area.

Default: true.

Source§

impl Area

Source

pub fn show<R>( self, ctx: &Context, add_contents: impl FnOnce(&mut Ui) -> R, ) -> InnerResponse<R>

Trait Implementations§

Source§

impl Clone for Area

Source§

fn clone(&self) -> Area

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Area

Source§

impl Debug for Area

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl WidgetWithState for Area

Auto Trait Implementations§

§

impl Freeze for Area

§

impl RefUnwindSafe for Area

§

impl Send for Area

§

impl Sync for Area

§

impl Unpin for Area

§

impl UnsafeUnpin for Area

§

impl UnwindSafe for Area

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more