Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Paint bounds #401

Closed
raphlinus opened this issue Dec 19, 2019 · 0 comments · Fixed by #513
Closed

Paint bounds #401

raphlinus opened this issue Dec 19, 2019 · 0 comments · Fixed by #513
Labels
architecture changes the architecture, usually breaking

Comments

@raphlinus
Copy link
Contributor

At the moment, there's no enforcement of where widgets can paint, so there's nothing stopping them from painting outside their layout bounds. However, container widgets might skip painting a widget when the paint region doesn't overlap the widget's layout bounds, leading to potential visible artifacts (the most likely is a widget "popping" into visibility on scrolling).

A much more systematic approach would be to track the actual paint bounds of a widget. I propose a new set_paint_bounds method on LayoutCtx. If this function is not called during a layout, then the paint bounds are set to the layout bounds (thus, this function is opt-in). Further, during layout we should keep track of the union of the paint bounds of all the children, and make that available. A simple container (that does no painting of its own) will call set_paint_bounds to this value.

An interesting question is whether an update should also be able to update the paint bounds (without also changing the layout bounds). However, it is difficult to figure out the logic of how this should propagate up, so for simplicity it's probably best to request layout (#400), and then in the future we can be finer grained about minimizing the work when the layout bounds are not actually different.

@raphlinus raphlinus added the architecture changes the architecture, usually breaking label Dec 19, 2019
@cmyr cmyr mentioned this issue Dec 31, 2019
7 tasks
cmyr added a commit that referenced this issue Feb 6, 2020
This introduces the idea of a 'paint rect', which is the region
that a widget wishes to paint inside. In the general case this is
equivalent to the widget's layout rect; the exceptions are cases
where widgets explicitly wish to paint outside of their bounds.

the paint region is specified as Insets relative to the layout rect.
Widgets that need an explicit paint region specify that region when
handling the Widget::layout method.

closes #401
cmyr added a commit that referenced this issue Feb 6, 2020
This introduces the idea of a 'paint rect', which is the region
that a widget wishes to paint inside. In the general case this is
equivalent to the widget's layout rect; the exceptions are cases
where widgets explicitly wish to paint outside of their bounds.

the paint region is specified as Insets relative to the layout rect.
Widgets that need an explicit paint region specify that region when
handling the Widget::layout method.

closes #401
cmyr added a commit that referenced this issue Feb 7, 2020
This introduces the idea of a 'paint rect', which is the region
that a widget wishes to paint inside. In the general case this is
equivalent to the widget's layout rect; the exceptions are cases
where widgets explicitly wish to paint outside of their bounds.

the paint region is specified as Insets relative to the layout rect.
Widgets that need an explicit paint region specify that region when
handling the Widget::layout method.

closes #401
@cmyr cmyr closed this as completed in #513 Feb 7, 2020
cmyr added a commit that referenced this issue Feb 7, 2020
This introduces the idea of a 'paint rect', which is the region
that a widget wishes to paint inside. In the general case this is
equivalent to the widget's layout rect; the exceptions are cases
where widgets explicitly wish to paint outside of their bounds.

the paint region is specified as Insets relative to the layout rect.
Widgets that need an explicit paint region specify that region when
handling the Widget::layout method.

closes #401
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
architecture changes the architecture, usually breaking
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant