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

MacOS with Retina: UI clickable area is calculated incorrectly #281

Open
dant3 opened this issue Aug 9, 2022 · 6 comments
Open

MacOS with Retina: UI clickable area is calculated incorrectly #281

dant3 opened this issue Aug 9, 2022 · 6 comments

Comments

@dant3
Copy link

dant3 commented Aug 9, 2022

Most likely bug is caused by incorrect calculation of UI element position due to Retina. See video for a reproduction. I used an example code from the readme.md

Screen.Recording.2022-08-09.at.19.41.23.mov
@danaugrs
Copy link
Member

danaugrs commented Aug 10, 2022

Hi and thanks for the video! Unfortunately I don't have a MacOS device and can't reproduce/debug/fix. The relevant code is probably in gui/panel.go in the SetModelMatrix function if you (or anyone else with a MacOS device) would like to have a stab at fixing it. You might also want to add the window hint mentioned in #161 (comment) and it might be helpful to look through that PR and the ones linked there.

@berkeleynerd
Copy link

I am able to reproduce this issue on a MacBook Pro M1.

@TheRealDigitalMaster
Copy link

How to put this in html?

@danaugrs
Copy link
Member

danaugrs commented Sep 2, 2022

@TheRealDigitalMaster please see #282 (comment).

@tomekc
Copy link

tomekc commented Apr 7, 2023

Hi, I come late to the party and took a moment to apply #161 tu current master, and it brings some improvement: the button is now clickable, but apparently incorrectly scaled (2x) with regards to size and position I guess.

I also am experiencing a strange glitch where initially the 3D scene takes only lower left quadrant of the window. It gets right after simply moving a window (!).

Screenshot 2023-04-07 at 02 25 37

And after moving a window button is clickable:

Screenshot 2023-04-07 at 02 25 55

EDIT

Glitch resolved by fixing onResize handler:

		scaleX, scaleY := a.GetScale()
		width, height := a.GetSize()
		a.Gls().Viewport(0, 0, int32(float32(width)*scaleX), int32(float32(height)*scaleY))

Now the UI is rendered properly, but mouse coordinates read improperly (need to move to coordinates 2x position of the button to click). Probably resolved by simple fix of the mouse coordinate reading?

Screenshot 2023-04-07 at 02 40 49

@zyxkad
Copy link
Contributor

zyxkad commented Dec 2, 2023

Hi @tomekc , your solution works for me. The cursor position does not have the 2x error but have 2 pixels offset on my computer.
Also, the actual code fixed for me is:

r.Gls().Viewport(0, 0, (int32)((float64)(w)*scaleX), (int32)((float64)(h)*scaleY))

which scaleX/Y is float64

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

6 participants