AllenDang / giu

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

[bug] Broken app scaling with Windows' display scaling above 100% #745

Open mikigal opened 6 months ago

mikigal commented 6 months ago

What happend?

When I set display scale in Windows above 100% my app does not scale corretly - window is bigger, but it's content (widgets, fonts, SplitLayouts) does not scale with window size.

scaling_100 scaling_125

Code example

Ful code of GUI: https://github.com/mikigal/Anime4K-GUI/blob/master/gui.go

main.go ```golang g.SingleWindow().Layout( g.SplitLayout(g.DirectionVertical, 580, g.SplitLayout(g.DirectionHorizontal, 1200, g.Layout{ g.Table().Flags(g.TableFlagsResizable).Rows(buildTableRows()...).Columns(buildTableColumns()...), g.Custom(func() { if len(animeList) == 0 { g.Label("\n\n\n\n\n\n\n Drag n' Drop your anime here").Font(g.AddFont("Arial", 35)).Build() } }), }, g.Layout{ g.Label("Settings"), g.Label(""), g.Label("Target resolution"), g.Combo("", resolutionsNames[settings.Resolution], resolutionsNames, &settings.Resolution).Size(400), g.Label(""), g.Label("Shaders mode"), g.Tooltip("Check the project's GitHub page if you're not sure what to choose"), g.Combo("", shaders[settings.Shaders].Name, shadersNames, &settings.Shaders).Size(400), g.Tooltip("Check the project's GitHub page if you're not sure what to choose"), g.Label(""), g.Label("Encoder"), g.Tooltip("Codec for encoding output file. In most cases GPU based are faster, use CPU mainly if you have slow GPU\n" + "AV1 is compatible only with RTX 4000+ and RX 6500XT+"), g.Combo("", availableEncoders[settings.Encoder].Name, availableEncodersNames, &settings.Encoder).Size(400), g.Tooltip("Codec for encoding output file. In most cases GPU based are faster, use CPU mainly if you have slow GPU\n" + "GPU based AV1 is compatible only with RTX 4000+ and RX 6500XT+"), g.Label(""), g.Label("Output format"), g.Combo("", outputFormats[settings.OutputFormat], outputFormats, &settings.OutputFormat).Size(400), g.Label(""), g.Checkbox("Compatibility mode", &settings.CompatibilityMode), g.Tooltip("Should be used only for compatibility troubleshooting, disables most of features"), g.Checkbox("Debug mode", &settings.DebugMode), g.Tooltip("Show more detailed logs, useful for troubleshooting and debugging"), g.Label(""), g.Button(buttonLabel).OnClick(handleButton).Size(360, 30), }, ), g.Layout{ g.Label("Logs"), g.InputTextMultiline(&logs).Flags(g.InputTextFlagsReadOnly).Size(1600, 270), g.SplitLayout(g.DirectionHorizontal, 1310, g.SplitLayout(g.DirectionHorizontal, 120, g.Label("Progress: "+totalProgress), g.ProgressBar(progress).Overlay(progressLabel).Size(1170, 20), ), g.SplitLayout(g.DirectionHorizontal, 110, g.Label(currentSpeed), g.Label(eta), ), ), }, ), ) ```

To Reproduce

  1. Set Windows display scale to 125%
  2. Run above code or my app (https://github.com/mikigal/Anime4K-GUI/releases)

Version

master

OS

Windows 11 23H2

0xkalle commented 5 months ago

@mikigal did you try it on 150% yet? The behaviour is not the same. I also read, that on 125% windows API may return a faulty scale, so maybe that is influencing it in the background. See: https://stackoverflow.com/questions/70340316/how-to-get-monitor-resolution-independent-of-scaling (that somment: https://stackoverflow.com/questions/70340316/how-to-get-monitor-resolution-independent-of-scaling#comment124345342_70340316 )

mikigal commented 3 months ago

@0xkalle Maybe this can help? https://stackoverflow.com/questions/70794284/how-to-get-current-monitor-scale