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

[bug] Context.GetPlatform().GetContentScale() is missing in v0.8.0 #809

Closed
xEricL opened this issue Jun 30, 2024 · 5 comments
Closed

[bug] Context.GetPlatform().GetContentScale() is missing in v0.8.0 #809

xEricL opened this issue Jun 30, 2024 · 5 comments
Assignees
Labels
bug Something isn't working Likely fixed Discussion led to some point; everything seems to be fixed and issue is abandoned. Will close soon.
Milestone

Comments

@xEricL
Copy link

xEricL commented Jun 30, 2024

What happend?

In v0.7, I used Context.GetPlatform().GetContentScale() to scale a progress bar. However, it appears GetPlatform() has been removed in v0.8.0 in this commit.

What is the alternative?

Code example

main.go

I was using

giu.SingleWindow().Layout(
	giu.Align(giu.AlignCenter).To(
		giu.Dummy(0, scaleDivider(6)),
		giu.ImageWithRgba(logoI).Size(LogoSize, LogoSize),
		giu.Dummy(0, scaleDivider(6)),
		giu.ProgressBar(ReadProgress()).Size(scaleValue(WindowWidth)*0.75, scaleValue(5)),
	),
)

where scaleDivider and scaleValue were defined as

func scaleDivider(value float32) float32 {
	scale := giu.Context.GetPlatform().GetContentScale()
	if scale > 1.0 {
		value *= 2
	}
	return value * scale
}

func scaleValue(value int) float32 {
	scale := giu.Context.GetPlatform().GetContentScale()
	return float32(value) * scale
}

To Reproduce

  1. Update to v0.8.0
  2. Try to build project that was previously using giu.Context.GetPlatform().GetContentScale()

Version

(latest)

OS

Fedora

@xEricL xEricL added the bug Something isn't working label Jun 30, 2024
@gucio321
Copy link
Collaborator

gucio321 commented Jul 4, 2024

hi, GetScaleFactor was a part of imgui-go api.
Now, we check scale as follows:
(MasterWindow.go)

        // Scale DPI in windows
        if runtime.GOOS == "windows" {
                xScale, _ := Context.backend.ContentScale()
                imgui.CurrentStyle().ScaleAllSizes(xScale)
        }

go get access to Context.backend try using cimgui.CurrentBackend

@xEricL
Copy link
Author

xEricL commented Jul 6, 2024

go get access to Context.backend try using cimgui.CurrentBackend

Can you please give a code example? I'm having trouble finding cimgui.CurrentBackend.

@gucio321
Copy link
Collaborator

gucio321 commented Jul 6, 2024

Because, as i just realized, it doesn't exist hehe 😅
ill add giu.Context.Backend later

@gucio321 gucio321 self-assigned this Jul 6, 2024
@gucio321 gucio321 added this to the v0.8.1 milestone Jul 6, 2024
@gucio321
Copy link
Collaborator

gucio321 commented Jul 6, 2024

@gucio321 gucio321 added the Likely fixed Discussion led to some point; everything seems to be fixed and issue is abandoned. Will close soon. label Jul 7, 2024
@gucio321
Copy link
Collaborator

gucio321 commented Jul 7, 2024

I suppose this is fixed, lmk if you still need help.

⚠️ If you use ScaleAllSizes, this is IMPORTANT ⚠️

Take a look at the following things:

@gucio321 gucio321 closed this as completed Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Likely fixed Discussion led to some point; everything seems to be fixed and issue is abandoned. Will close soon.
Projects
None yet
Development

No branches or pull requests

2 participants