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

Scroll bar blinks when scrolling #1202

Open
EdoardoLaGreca opened this issue Sep 8, 2018 · 3 comments
Open

Scroll bar blinks when scrolling #1202

EdoardoLaGreca opened this issue Sep 8, 2018 · 3 comments

Comments

@EdoardoLaGreca
Copy link

When running the example all_winit_glium (on Linux) from the examples page, the window opens normally and the scroll bar is not visible (which may be done on purpose) but when I scroll down with my mouse, it blinks fast.

I've also noticed that the scroll bar's blinking frequency is equal to the mouse one when scrolling, so in other words: one mouse scrolling "unit" is equal to one fast blink (appearing and disappearing instantly).

Is it happening to someone else here? May it be a problem about my Linux distro? Please help.

@nicmr
Copy link

nicmr commented Sep 25, 2018

Edit: I'm encountering the same issue.

@mitchmindtree
Copy link
Contributor

Thanks for opening this @EdoardoLaGreca!

You're correct about this issue - when the scrollbar autohide field is set it will only show "during" motion and thus flickers if the application only receives scroll events even every second frame for example. It really needs a delay of some sort before disappearing or fading out quickly to reduce the stutter, though I'm not sure how to do this nicely as conrod doesn't drive it's own event loop (a side-effect of trying to support a bunch of different backends which makes animation tricky in general). Perhaps the scrollbar could generate an event which indicates the maximum amount of time until the GUI should be updated and redrawn in order to let the scrollbar disappear or fade out. Will have to keep thinking on this, there might be a nicer way to solve animated/timing based events in conrod in general.

@emdash
Copy link

emdash commented Nov 21, 2018

I saw this too, good to know it is a known issue.

I'm still new to this, but I have a suggestion for how to handle it: just add some notion of time to the state that the widget consumes, and then calculate the visibility of the scroll bar based on that time.

I.e. you can stash time at which the last relevant mouse event occurred in your global state, and this allows you to calculate how long it has been since that event. At this point you have let is_visible = ((current_time - last_mouse_event_time) <= auto_hide_duration)

If you want to get fancy with animations, then you can have: let opacity = fade_out((current_time - last_mouse_event_time)

Where fade_out(t) can be some clamped function: min(1.0, max(0.0, -(t -fade_out_delay) * fade_out_rate))

Hopefully that makes some sense... it's possible to express behavior in terms of pure functions over the current state. And since rust has Option, it's even easier to handle edge cases where some of these time-dependent values become invalid. In other languages, you'd have a mess of boolean flags or sentinel values, or checks against NULL / None that can go wrong.

The issue of not driving your event loop isn't all that relevant, as long as there's a way to update the current time before each frame is drawn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants