-
Notifications
You must be signed in to change notification settings - Fork 568
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 debug option to display widget ids #876
Conversation
yea, I was just working on that. It's kind of tricky; the easiest thing I can do is use z-order painting, so at least we prioritize the topmost widget. I'm also experimenting with only painting if we're currently |
Okay, I've changed the behaviour to paint using z-order, so children overwrite parents; this should also fix the issue of smaller labels being written over larger labels, because children should always have larger ids than parents. ( In addition, we now only paint the label if the widget is hot. |
f4d005e
to
f392919
Compare
The invalidation (I guess) also causes problems with the |
right, we're stroking the boundary so it may spill. can adjust that. about the view_switcher example.... that's weird. My spidey sense says this is an existing bug that we're just seeing for the first time, but I'll dig in a bit more tomorrow. |
Okay fixed this, was an issue with how I was handling hot changes. |
druid/src/core.rs
Outdated
if debug_layout { | ||
self.debug_paint_layout_bounds(&mut inner_ctx, env); | ||
} | ||
if debug_ids { | ||
self.debug_paint_widget_ids(&mut inner_ctx, env); | ||
} |
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.
The debug_paint_widget_ids
method might call debug_paint_layout_bounds
, so I think we can optimize it into something like this:
// Check the bool first, because most widgets aren't hot and we won't need to do the map lookup
let debug_ids = inner_ctx.is_hot() && env.get(Env::DEBUG_WIDGET_ID);
let debug_layout = if debug_ids {
// Change debug_paint_widget_ids to return true if it called debug_paint_layout_bounds.
// Then we won't need to call it again or even do the env map lookup.
!self.debug_paint_widget_ids(&mut inner_ctx, env) && env.get(Env::DEBUG_PAINT)
} else {
env.get(Env::DEBUG_PAINT)
};
if debug_layout {
self.debug_paint_layout_bounds(&mut inner_ctx, env);
}
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.
okay, I think we can assume that debug_paint_widget_ids always paints the layout so I can simplify this a bit further, overall looks reasonable though.
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.
Looks good and useful.
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.
This breaks GTK invalidation. Only some parts get invalidated, buttons for example do not indicate hover, or do so only in one corner. Text field selection does not show up, but while typing text it does work.
This only happens when debug_widget_id
is active.
It happens even without debug_widget_id
.
After merging master (which gave me a conflict, wtf?), I tried X11 and it works fine. So this really seems to be GTK specific.
So, after that merge conflict irritated me, I forcefully reset my local git repo and now the rendering bug is gone 🙈 . But it still does not seem to work entirely, some widgets do not show their id, or have it offset (which could cause some ids to be offscreen) |
After comparing the behavior with X11 (where it works correctly) in the calc example, it seems like ids are drawn to far below and right of the widget they belong to. Also they sometimes do not show up at all, probably because the place where they draw is not being invalidated. |
I tested this on my Ubuntu 20.04 just now and both X11 and GTK work just fine. There are no rendering bugs and the ids are drawn in the correct location. Maybe there's something wrong with your setup @Finnerale? Give |
Neither |
I can even reproduce this on my Ubuntu 20.04 laptop. |
hm, so something like this was happening, but I think I've addressed it in an update? is it possible you're on a commit other than 3396138? |
Nope, it is 3396138 . Like I said, I've deleted my local copy of druid and cloned it again, compiled it fresh and the issue still is there, on my Arch desktop and on my Ubuntu 20.04 laptop, both with up to date system and Rust. |
that's really strange, because I had an issue similar to what you'd described, but it's now fixed. Can you share a screencap? |
This will paint the id of each widget of some subtree in the bottom right of that widget's bounds; useful for debugging various bits of event flow and widget behaviour.
This ensures that the ids of children will not be obscured by the ids of their parents. This also adds caching of the textlayout object.
So, I've found the reason why only I got it: It happens on Wayland, not on X11. I've added two videos, the first is on Wayland, the second (same computer) on X11. |
I managed to reproduce the issue with Wayland. This problem has nothing to do with this PR though, the same problem already exists with the |
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.
Interesting, I thought it would have been introduced in this PR because when I tested this PR the last time, it did work. In that case I'm happy to get this merged.
ah that makes sense, I had a similar issue on the coregraphics background where I couldn't trust the current transform returned by the platform, and have to track it separately myself. |
This will paint the id of each widget of some subtree in the bottom
right of that widget's bounds; useful for debugging various bits
of event flow and widget behaviour.