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

Tooltip broken in Windows #1986

Closed
sjoshid opened this issue Sep 23, 2021 · 9 comments
Closed

Tooltip broken in Windows #1986

sjoshid opened this issue Sep 23, 2021 · 9 comments

Comments

@sjoshid
Copy link
Contributor

sjoshid commented Sep 23, 2021

Tooltips were introduced in #1919. But they aren't working correctly in Windows specifically when you set scaling to something other than 100%. Some issues (seen in sub_window.rs example) are:

  • Tooltips open up in a different location.
  • The closable/drag-able window is broken as well.
@giannissc
Copy link
Contributor

I am not sure if all the problems have been fixed or more changes are planned but I update the nursery to the latest druid version and these are the results when trying the tooltip example

Before update:
before-update-1
before-update-2
before-update-3
before-update-4

After update:
after-update-1
after-update-2
after-update-3
after-update-4

@giannissc
Copy link
Contributor

giannissc commented Oct 6, 2021

In case you can't tell the mouse pointer is over the label widget. After the update the full screen hovering works great and the tooltip is right under the mouse pointer however for the unmaximised windows, the tooltip more the further away the further you more from the screen's left corner

Edit: I have created a pr in the druid-widget-nursery to see the changes that I have made and run the code for yourself

@sjoshid
Copy link
Contributor Author

sjoshid commented Oct 6, 2021

Yup. The problem is set_position call on sub windows. I highly recommend reading updated docs on WindowBuilder::set_position()

@giannissc
Copy link
Contributor

But weren't these issues supposed to be solved with #1982?

@sjoshid
Copy link
Contributor Author

sjoshid commented Oct 6, 2021

Not really. There was no set definition of what set_position took: you could pass any type of Point.

With the PR, definition of set_position is clear: if creating a tooltip or dropdown that have a parent window you must pass a point in parent window coord.

@sjoshid
Copy link
Contributor Author

sjoshid commented Oct 6, 2021

Here it how it looks with the change I talked about.
image

You dont see the mouse pointer but it is right there in bottom left of tooltip.

This of course works with 100% scaling.

@giannissc
Copy link
Contributor

Does it work out of the box with tooltip code or did you have to make some changes? Cause it doesn't work right for me..

@sjoshid
Copy link
Contributor Author

sjoshid commented Oct 6, 2021

Not out of the box. I did following changes

let tooltip_position_in_window_coordinates = (last_mouse_pos.to_vec2() + TOOLTIP_OFFSET).to_point();
                        let win_id = ctx.new_sub_window(
                            WindowConfig::default()
                                .show_titlebar(false)
                                .window_size_policy(WindowSizePolicy::Content)
                                .set_level(WindowLevel::Tooltip(ctx.window().clone()))
                                .set_position(tooltip_position_in_window_coordinates),
                            // FIXME: we'd like to use the actual label text instead of
                            // resolving, but LabelText isn't Clone
                            Label::new(self.text.display_text())
                                .border(TOOLTIP_BORDER_COLOR, TOOLTIP_BORDER_WIDTH)
                                .on_monitor(ctx.window()),
                            data.clone(),
                            env.clone(),
                        );

and

const TOOLTIP_OFFSET: Vec2 = Vec2::new(15.0, 15.0);

@giannissc
Copy link
Contributor

Thank your that :) Pushing the change now in the nursery!

@sjoshid sjoshid closed this as completed Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants