AllenDang / giu

Cross platform rapid GUI framework for golang based on Dear ImGui.
MIT License
2.11k stars 127 forks source link

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

Open xEricL opened 5 days ago

xEricL commented 5 days ago

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 ```golang 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 ```golang 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

gucio321 commented 1 day ago

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