Skip to content

Conversation

@almarklein
Copy link
Member

@almarklein almarklein commented Oct 25, 2025

Fixes #56

Instead of backends needing to implement _rc_get_physical_size, _rc_get_logical_size and _rc_get_pixel_ratio, they must now call _set_size_info() whenever their size changes. Backends should also not submit a resize event, the base canvas now handles that.

The base class will now emit a resize event right before processing other events, but also right before doing the draw, if the size has changed since events were processed. This fixes #56.

Another benefit is that the backends become simpler, and the getters like get_physical_size() may be faster because values are read from the base class's cache, instead of calculated from the backend.

@kushalkolar
Copy link
Contributor

@FlynnOConnell is excited to stop whatever he's doing and try this right now 😂

@FlynnOConnell
Copy link

🙇‍♂️ thank you!

@FlynnOConnell
Copy link

Confirmed no more resizing errors! Unless you reduce the size to nothing, which is normally not an issue

rendercanvas.mp4

@kushalkolar
Copy link
Contributor

Unless you reduce the size to nothing, which is normally not an issue

Ah this is because the canvas has an actual size but portion of the canvas pygfx draws to has become negative. I wonder if there's a min window dims we can set.

@almarklein
Copy link
Member Author

Unless you reduce the size to nothing

In this case it's FPL that does not apply bounds to the viewport :)

But a zero size to the canvas can in theory also happen. I added a note regarding that.

@almarklein almarklein requested a review from Korijn October 26, 2025 21:21
@almarklein
Copy link
Member Author

@Vipitis I'll take care of adjusting #115

@almarklein almarklein merged commit 737d9fe into main Oct 29, 2025
12 checks passed
@almarklein almarklein deleted the resize-event branch October 29, 2025 11:55
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.

Qt render canvas resizes before viewport rect is updated

4 participants