Skip to content
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 improvements #754

Closed
wants to merge 5 commits into from
Closed

Collapsing header improvements #754

wants to merge 5 commits into from

Conversation

DrOptix
Copy link
Contributor

@DrOptix DrOptix commented Sep 29, 2021

This is a PR without a backing issue.

This PR changes CollapsingHeader container like this:

  • CollapsingHeader is now opening or closing only when clicking the arrow icon
  • CollapsingHeader is now filling all the available horizontal space
  • Emit clicks on CollapsingHeader's header only when NOT clicking the icon

Visual display:
collapsing_header_improvement

Because `CollapsingHeader` can also be selected and/or used to display
a tree, then it is a pain to have it collapse when you just want to
select it.

The behavior described here, before and after this improvement, can be
observed in "Misc Demos" -> Tree demo
@emilk
Copy link
Owner

emilk commented Sep 29, 2021

I think being able to click the entire header should be the default behavior, just as it is the default behavior to be able to click the label of a checkbox or a radiobutton to toggle it. This new behavior is only useful for selectable collapsing headers, so I suggest we restrict it to those.

@coderedart
Copy link
Contributor

just a random suggestion: single click could select and double click (or long press/click) could be expand. kinda like reddit comment threads or some tree ui in android apps.

@DrOptix
Copy link
Contributor Author

DrOptix commented Sep 30, 2021

I think being able to click the entire header should be the default behavior, just as it is the default behavior to be able to click the label of a checkbox or a radiobutton to toggle it. This new behavior is only useful for selectable collapsing headers, so I suggest we restrict it to those.

Now that you mention it my target is to be able to create something like this for my project.
image

Now I'm not quite sure how to make it API wise so we can add custom controls to the header. In my case I would like to add a checkbox in front of the title and a button on the right side of the label as it can be seen in the screenshot above.

I'm thinking of adding something like this, but the drawback is that you need to paint the title yourself:

CollapsingHeader::new("title").show_custom_header(|title, ui| {
    // Show checkbox

    // Show title

    // On the right side of the header, show button for actions popup menu
});

@emilk
Copy link
Owner

emilk commented Oct 9, 2021

@DrOptix I think the best solution for that screenshot is to refactor CollapsingHeader so one can have a CollapsingSection without a header, controlled by a button. This is sort of how Window implements collapsing.

@emilk
Copy link
Owner

emilk commented Oct 25, 2021

This change produces some weirdness:

collapsing-weirdness

I wonder if it is is better to try to make the CollapsingHeader more composable instead, so that it is easier to create separate functions for the old-style collapsing header, and your "separate arrow and header". As I mentioned before, Window already has a collapsing arrow as a separate widget, and I suspect we could make that even more reusable and composable.

But then again, composability is difficult in immediate mode.

@DrOptix
Copy link
Contributor Author

DrOptix commented Oct 25, 2021

I need to get back on this as I put it on the backlog for quite some time.

@emilk
Copy link
Owner

emilk commented Apr 27, 2022

I found a nicer approach in #1538

@emilk emilk closed this Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants