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

Painter widget handling events #1492

Open
arthmis opened this issue Dec 30, 2020 · 1 comment
Open

Painter widget handling events #1492

arthmis opened this issue Dec 30, 2020 · 1 comment
Labels
enhancement adds or requests a new feature widget concerns a particular widget

Comments

@arthmis
Copy link
Collaborator

arthmis commented Dec 30, 2020

@cmyr proposed the idea of the painter widget handling events, in one of the zulip threads. Essentially he said

What i would do is add a new builder method to painter, with a name like... hm. paint_on_mouse_change? And that sets a bool in the painter that indicates it should invalidate itself during these events. A more robust way might be a builder fn, invalidate(mut self, fn: impl Fn(&Event) -> bool) -> Self? Basically you can pass it a closure that will receive an event and you can return a flag indicating whether you need to repaint. 🤔

I'm bringing this up in case it's still something up for consideration.

@cmyr
Copy link
Member

cmyr commented Dec 31, 2020

To summarize: there's currently a limitation with the painter widget where it doesn't repaint when things like hot or active change, which make it not very useful if you're trying to paint the background for a custom button.

(The button example isn't the best because buttons request paint on hot/active change themselves, and so the painter does get repainted; but other widgets might not).

The rationale for this choice was that having it do this by default would cause a bunch of unnecessary paint calls if you didn't actually need it.

The current solution is to make sure some other widget in your hierarchy is handling this invalidation; if nothing is, you can use a custom controller or something.

My proposed solution is be to allow Painter to be optionally configured to do this itself; you can specify in some way that it should repaint on certain events (either by setting a repaint_on_mouse_change flag, or else by passing some closure Fn(&Event) -> bool that lets you specify exactly when you want to repaint).

This might be useful?

Would we also want this for focus change events?

@cmyr cmyr added enhancement adds or requests a new feature widget concerns a particular widget labels Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement adds or requests a new feature widget concerns a particular widget
Projects
None yet
Development

No branches or pull requests

2 participants