Struct CollapsingHeader

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

A header which can be collapsed/expanded, revealing a contained Ui region.

egui::CollapsingHeader::new("Heading")
    .show(ui, |ui| {
        ui.label("Body");
    });

// Short version:
ui.collapsing("Heading", |ui| { ui.label("Body"); });

If you want to customize the header contents, see CollapsingState::show_header.

Implementations§

Source§

impl CollapsingHeader

Source

pub fn new(text: impl Into<WidgetText>) -> CollapsingHeader

The CollapsingHeader starts out collapsed unless you call default_open.

The label is used as an Id source. If the label is unique and static this is fine, but if it changes or there are several CollapsingHeader with the same title you need to provide a unique id source with Self::id_source.

Source

pub fn default_open(self, open: bool) -> CollapsingHeader

By default, the CollapsingHeader is collapsed. Call .default_open(true) to change this.

Source

pub fn open(self, open: Option<bool>) -> CollapsingHeader

Calling .open(Some(true)) will make the collapsing header open this frame (or stay open).

Calling .open(Some(false)) will make the collapsing header close this frame (or stay closed).

Calling .open(None) has no effect (default).

Source

pub fn id_source(self, id_source: impl Hash) -> CollapsingHeader

Explicitly set the source of the Id of this widget, instead of using title label. This is useful if the title label is dynamic or not unique.

Source

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

If you set this to false, the CollapsingHeader will be grayed out and un-clickable.

This is a convenience for Ui::set_enabled.

Source

pub fn selectable(self, selectable: bool) -> CollapsingHeader

👎Deprecated: Use the more powerful egui::collapsing_header::CollapsingState::show_header

Can the CollapsingHeader be selected by clicking it? Default: false.

Source

pub fn selected(self, selected: bool) -> CollapsingHeader

👎Deprecated: Use the more powerful egui::collapsing_header::CollapsingState::show_header

If you set this to ‘true’, the CollapsingHeader will be shown as selected.

Example:

let mut selected = false;
let response = egui::CollapsingHeader::new("Select and open me")
    .selectable(true)
    .selected(selected)
    .show(ui, |ui| ui.label("Body"));
if response.header_response.clicked() {
    selected = true;
}
Source

pub fn show_background(self, show_background: bool) -> CollapsingHeader

Should the CollapsingHeader show a background behind it? Default: false.

To show it behind all CollapsingHeader you can just use:

ui.visuals_mut().collapsing_header_frame = true;
Source

pub fn icon( self, icon_fn: impl FnOnce(&mut Ui, f32, &Response) + 'static, ) -> CollapsingHeader

Use the provided function to render a different CollapsingHeader icon. Defaults to a triangle that animates as the CollapsingHeader opens and closes.

For example:

fn circle_icon(ui: &mut egui::Ui, openness: f32, response: &egui::Response) {
    let stroke = ui.style().interact(&response).fg_stroke;
    let radius = egui::lerp(2.0..=3.0, openness);
    ui.painter().circle_filled(response.rect.center(), radius, stroke.color);
}

egui::CollapsingHeader::new("Circles")
  .icon(circle_icon)
  .show(ui, |ui| { ui.label("Hi!"); });
Source§

impl CollapsingHeader

Source

pub fn show<R>( self, ui: &mut Ui, add_body: impl FnOnce(&mut Ui) -> R, ) -> CollapsingResponse<R>

Source

pub fn show_unindented<R>( self, ui: &mut Ui, add_body: impl FnOnce(&mut Ui) -> R, ) -> CollapsingResponse<R>

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<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,