Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gtk/tk: Ensure no flicker when hovering over images. #17989

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

Merged
merged 1 commit into from
Aug 2, 2020

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Jul 21, 2020

PR Summary

When the mouse is over an image, the status message is two lines long. This causes the toolbar to increase size slightly. On Qt, this is ignored by a sizing policy, but there is no such thing in other toolkits. On GTK this steals space from the canvas, so it re-draws a little bit smaller, until the mouse moves off the image. On Tk, the space is added to the window, unless the window is maximized, and then it's stolen from the canvas as well.

As a simple workaround, we add an additional label with invisible text (spaces) on two lines. This forces the toolbar to always be two lines high and thus not flicker. If the message were 3 or more lines long, then the same thing would happen, but we don't have any of those by default. The advantage of using a label is that it saves us having to measure text in some toolkit-specific way, and thus works regardless of theme.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • [N/A] New features are documented, with examples if plot related
  • [N/A] Documentation is sphinx and numpydoc compliant
  • [N/A] Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • [N/A] Documented in doc/api/next_api_changes/* if API changed in a backward-incompatible way

When the mouse is over an image, the status message is two lines long.
This causes the toolbar to increase size slightly. On Qt, this is
ignored by a sizing policy, but there is no such thing in other
toolkits. On GTK this steals space from the canvas, so it re-draws a
little bit smaller, until the mouse moves off the image. On Tk, the
space is added to the window, _unless_ the window is maximized, and then
it's stolen from the canvas as well.

As a simple workaround, we add an additional label with invisible text
(spaces) on two lines. This forces the toolbar to always be two lines
high and thus not flicker. If the message were 3 or more lines long,
then the same thing would happen, but we don't have any of those by
default. The advantage of using a label is that it saves us having to
measure text in some toolkit-specific way, and thus works regardless of
theme.
@QuLogic
Copy link
Member Author

QuLogic commented Jul 21, 2020

Note, I also made the message in the GTK toolbar small; this is closer to the text size in Qt and means the toolbar is not actually any taller for two-line text, in the default theme. Other themes may not be so consistent and thus we still need the filler item like in Tk.

I think this multi-line status message is new in 3.3.

@QuLogic QuLogic added this to the v3.3.1 milestone Jul 21, 2020
@jkseppan jkseppan merged commit 1c55901 into matplotlib:master Aug 2, 2020
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Aug 2, 2020
@QuLogic QuLogic deleted the toolbar-flicker branch August 2, 2020 08:39
jklymak added a commit that referenced this pull request Aug 2, 2020
…989-on-v3.3.x

Backport PR #17989 on branch v3.3.x (gtk/tk: Ensure no flicker when hovering over images.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants