-
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
Add ability to override collapsing icons #1147
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, simple idea. I love it!
Only some minor nits and a clippy error to fix.
@@ -141,6 +141,7 @@ pub struct CollapsingHeader { | |||
selectable: bool, | |||
selected: bool, | |||
show_background: bool, | |||
icon: Option<Box<dyn FnOnce(&mut Ui, f32, &Response)>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub type IconPainter = Box<dyn FnOnce(&mut Ui, f32, &Response)>;
with a nice docstring would make this type simpler, and silence clippy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the type alias and used it here.
I didn't use it in the icon
function to keep the API simple (that way caller doesn't have to use Box::new
). If trait aliases ever get stabilized we could use that, but who knows if that will ever happen.
I wanted custom icons for my tree so I added the ability to override's
CollapsingHeader
's icon by passing a function that gets called instead ofpaint_icon
.I personally like the pointy triangles but not the fact that they get thicker on hover.
Let's discuss if this is the best approach or if there's something better (e.g. implementing an
Icon
trait or something). I can add a demo if we decide to move forward.2022-01-21.17-54-29.mp4