-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collapsing header with custom header #1538
Conversation
I think, this will help with #1036 as well? |
I really like the idea of having header separate from the body itself and It looks nicer. |
@gents83 yeah, that's the point. Instead of having "selectable" as part of let id = ui.make_persistent_id("my_collapsing_header");
egui::collapsing_header::CollapsingState::load_with_default_open(ui.ctx(), id, true)
.show_header(ui, |ui| {
ui.toggle_value(&mut self.selected, "Click to select/unselect header");
}).body(|ui| {
ui.label("Body");
}); |
I think I can improve the UI of this feature a bit though |
Is it possible to maintain "click header to expand tree" behavior with these semantics? I would like to use this to make a normal tree but with a context menu on each header, for example. |
@lumlune you should be able to do that like so: let response = CollapsingHeader::new("header").show(ui, |ui| ui.label("body"));
response.header_response.context_menu(|ui| ui.label("Shown on right-clicks")); it should work already on egui 0.17.0 IIRC |
For now I have removed the selectable method call from the collapsing entity ui. This can be re-added in the future, once the engine is more complete. (see emilk/egui#1538).
This makes it possible to construct collapsing headers with custom header contents.
Closes #754
Closes #1036
I think this is a better approach for making header selectable, which means we could/should deprecate
CollapsingHeader::selectable
, which is buggy anyway (i.e. clicking both selects and toggles, which is very annoying).This introduces a separate
CollapsingState
which is perhaps a bit confusing, butCollapsingHeader
is a bit overloaded with features and I didn't want to pile onto it.CollapsingState
can also be used as a more low-level building block (and is indeed used byCollapsingHeader
and byWindow
).TODO
show_custom_header
into two calls