pub struct CollapsibleSection<'a> { /* private fields */ }Expand description
A reusable collapsible section component for detail panels.
The section has a clickable header that toggles between expanded and collapsed states. When expanded, the content area is visible. When collapsed, only the header is shown with an indicator showing the collapsed state.
§Example
let mut collapsed_sections = HashMap::new();
CollapsibleSection::new("work_summaries", "Work Summaries")
.default_expanded(false)
.show(ui, &mut collapsed_sections, |ui| {
// Section content here
ui.label("Content goes here");
});Implementations§
Source§impl<'a> CollapsibleSection<'a>
impl<'a> CollapsibleSection<'a>
Sourcepub fn new(id: &'a str, title: &'a str) -> Self
pub fn new(id: &'a str, title: &'a str) -> Self
Create a new collapsible section with the given ID and title.
The ID should be unique within the context where the section is used, as it’s used to track the collapsed state in the state map.
Sourcepub fn default_expanded(self, expanded: bool) -> Self
pub fn default_expanded(self, expanded: bool) -> Self
Set whether this section should be expanded by default.
When the section is first rendered (or when its state is not in the map), this determines whether it starts expanded or collapsed.
Sourcepub fn show<R>(
self,
ui: &mut Ui,
collapsed_state: &mut HashMap<String, bool>,
add_contents: impl FnOnce(&mut Ui) -> R,
) -> Response
pub fn show<R>( self, ui: &mut Ui, collapsed_state: &mut HashMap<String, bool>, add_contents: impl FnOnce(&mut Ui) -> R, ) -> Response
Render the collapsible section and execute the content callback if expanded.
§Arguments
ui- The egui UI contextcollapsed_state- Map of section IDs to their collapsed state (true = collapsed)add_contents- Callback to render the section content when expanded
§Returns
The response from the header click interaction.
Auto Trait Implementations§
impl<'a> Freeze for CollapsibleSection<'a>
impl<'a> RefUnwindSafe for CollapsibleSection<'a>
impl<'a> Send for CollapsibleSection<'a>
impl<'a> Sync for CollapsibleSection<'a>
impl<'a> Unpin for CollapsibleSection<'a>
impl<'a> UnwindSafe for CollapsibleSection<'a>
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 more