Struct CustomFrame

Source
pub struct CustomFrame {
    pub sizebox: Margin,
    pub caption: Rect,
    pub inner_margin: Margin,
    pub rounding: Rounding,
    pub shadow: Shadow,
}
Expand description

A frame that allows you to custom its appearance and behavior

§Example

egui_custom_frame::CustomFrame::default().show(ctx, |ui| {
   ui.label("Hello World!");
});

Fields§

§sizebox: Margin

The size of the resizing frame

§caption: Rect

The caption area

§inner_margin: Margin

The inner margin

§rounding: Rounding

The rounding radius

§shadow: Shadow

The shadow attributes

Implementations§

Source§

impl CustomFrame

Source

pub fn sizebox(self, sizebox: Margin) -> Self

Change the resizing frame area

Source

pub fn caption(self, caption: Rect) -> Self

Change the draggable caption area

Examples found in repository?
examples/custom_frame.rs (lines 13-18)
10  fn new(_cc: &eframe::CreationContext<'_>) -> Self {
11    Self {
12      tip: "This window is for testing a custom frame window.".to_string(),
13      frame: CustomFrame::default().caption(
14        Rect::from_min_max(
15          Pos2::new(0.0, 0.0),
16          Pos2::new(f32::MAX, f32::MAX) // Make the whole window draggable
17        )
18      ),
19    }
20  }
Source

pub fn rounding(self, rounding: Rounding) -> Self

Change the rounding radius

Source

pub fn shadow(self, shadow: Shadow) -> Self

Change the shadow attributes

Source

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

Show the custom frame

Examples found in repository?
examples/custom_frame.rs (lines 30-35)
28  fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
29    // Display contents in the custom frame
30    self.frame.show(ctx, |ui| {
31      ui.heading(&self.tip);
32      if ui.button("Close").clicked() {
33          ui.ctx().send_viewport_cmd(egui::ViewportCommand::Close);
34      }
35    });
36  }

Trait Implementations§

Source§

impl Default for CustomFrame

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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<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, 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.