Struct rerun::external::eframe::egui::containers::collapsing_header::CollapsingState
pub struct CollapsingState {
id: Id,
state: InnerState,
}
Expand description
This is a a building block for building collapsing regions.
It is used by CollapsingHeader
and crate::Window
, but can also be used on its own.
See CollapsingState::show_header
for how to show a collapsing header with a custom header.
Fields§
§id: Id
§state: InnerState
Implementations§
§impl CollapsingState
impl CollapsingState
pub fn load(ctx: &Context, id: Id) -> Option<CollapsingState>
pub fn store(&self, ctx: &Context)
pub fn remove(&self, ctx: &Context)
pub fn id(&self) -> Id
pub fn load_with_default_open( ctx: &Context, id: Id, default_open: bool ) -> CollapsingState
pub fn is_open(&self) -> bool
pub fn set_open(&mut self, open: bool)
pub fn toggle(&mut self, ui: &Ui)
pub fn show_header<HeaderRet>(
self,
ui: &mut Ui,
add_header: impl FnOnce(&mut Ui) -> HeaderRet
) -> HeaderResponse<'_, HeaderRet>
pub fn show_header<HeaderRet>( self, ui: &mut Ui, add_header: impl FnOnce(&mut Ui) -> HeaderRet ) -> HeaderResponse<'_, HeaderRet>
Shows header and body (if expanded).
The header will start with the default button in a horizontal layout, followed by whatever you add.
Will also store the state.
Returns the response of the collapsing button, the custom header, and the custom body.
let id = ui.make_persistent_id("my_collapsing_header");
egui::collapsing_header::CollapsingState::load_with_default_open(ui.ctx(), id, false)
.show_header(ui, |ui| {
ui.label("Header"); // you can put checkboxes or whatever here
})
.body(|ui| ui.label("Body"));
pub fn show_body_indented<R>(
&mut self,
header_response: &Response,
ui: &mut Ui,
add_body: impl FnOnce(&mut Ui) -> R
) -> Option<InnerResponse<R>>
pub fn show_body_indented<R>( &mut self, header_response: &Response, ui: &mut Ui, add_body: impl FnOnce(&mut Ui) -> R ) -> Option<InnerResponse<R>>
Show body if we are open, with a nice animation between closed and open. Indent the body to show it belongs to the header.
Will also store the state.
pub fn show_body_unindented<R>(
&mut self,
ui: &mut Ui,
add_body: impl FnOnce(&mut Ui) -> R
) -> Option<InnerResponse<R>>
pub fn show_body_unindented<R>( &mut self, ui: &mut Ui, add_body: impl FnOnce(&mut Ui) -> R ) -> Option<InnerResponse<R>>
Show body if we are open, with a nice animation between closed and open. Will also store the state.
Paint this CollapsingState
’s toggle button. Takes an IconPainter
as the icon.
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);
}
let mut state = egui::collapsing_header::CollapsingState::load_with_default_open(
ui.ctx(),
ui.make_persistent_id("my_collapsing_state"),
false,
);
let header_res = ui.horizontal(|ui| {
ui.label("Header");
state.show_toggle_button(ui, circle_icon);
});
state.show_body_indented(&header_res.response, ui, |ui| ui.label("Body"));
Trait Implementations§
§impl Clone for CollapsingState
impl Clone for CollapsingState
§fn clone(&self) -> CollapsingState
fn clone(&self) -> CollapsingState
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for CollapsingState
impl RefUnwindSafe for CollapsingState
impl Send for CollapsingState
impl Sync for CollapsingState
impl Unpin for CollapsingState
impl UnwindSafe for CollapsingState
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
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request