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 not updating as expected #988

Closed
covercash2 opened this issue May 26, 2020 · 1 comment · Fixed by #991
Closed

Painter not updating as expected #988

covercash2 opened this issue May 26, 2020 · 1 comment · Fixed by #991
Labels
bug does not behave the way it is supposed to widget concerns a particular widget

Comments

@covercash2
Copy link
Contributor

Description

given some state:

pub struct State {
    string: String,
}

creating a druid::widget::Painter to indicate the state should dynamically change the style of the widget. we can also add a druid::widget::Label to represent the state.

with the Label added, the app acts as intended (a "good" state is when string.len() is even):

draw working as expected with label

however, when the Label is absent, the Painter no longer updates as expected, when the text in the TextBox is updated:

draw not repainting border when label is absent

however, unfocusing the window will trigger the Painter to draw correctly:

draw repaints border on window focus

what we have so far

my env is... esoteric. Arch Linux 5.6.11, i3 + Xorg, GTK3 3.24.20, but i also reproduced this on my macbook, macOS Mojave 10.14.6.

gdb and ole fashioned print debugging show that the closure passed to Painter is being run -- color is updated, values are calculated, etc. --, but i haven't dug into the ctx.stroke or ctx.fill enough to know exactly what is happening, and i'm still learning the draw system in general (i'm pretty new to druid).

i worked up this minimal example, but my original widget was a simple file viewer, using a more complicated state including things like PathBuf and some homebrewed druid::Data types. the basic behavior is the same, though. anyway, i pressed on thinking that something else in the hierarchy might trigger the redraw, and i was right! but this seems like a bug, so i went ahead and opened an issue.

code: https://gist.github.com/covercash2/0ef3185cf25635900363da5b71e4e268
gifs: https://imgur.com/a/ausXF2u

@ForLoveOfCats ForLoveOfCats added bug does not behave the way it is supposed to widget concerns a particular widget labels May 26, 2020
@jneem
Copy link
Collaborator

jneem commented May 26, 2020

This sounds like a partial invalidation issue, particularly since it fixes itself when you change focus. I'll take a look.

cmyr added a commit that referenced this issue May 26, 2020
This would cause painter to not invalidate as expected.

- fixes #988
@cmyr cmyr closed this as completed in #991 May 26, 2020
cmyr added a commit that referenced this issue May 26, 2020
This would cause painter to not invalidate as expected.

- fixes #988
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug does not behave the way it is supposed to widget concerns a particular widget
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants