richardpl / lavfi-preview

GUI for libavfilter
MIT License
72 stars 8 forks source link

HiDPI support #5

Open dcnieho opened 1 year ago

dcnieho commented 1 year ago

I'm using a hidpi screen and lavfi-preview is not hidpi aware (I'm using Windows 10). That means everything is super small. In my own imgui+glfw c++ program, I handle this as follows, feel free to copy and adapt in case you'd like to fix this:

// 1. before opening the glfw window
float highDPIscaleFactor = 1.0;
float xscale, yscale;
glfwGetMonitorContentScale(glfwGetPrimaryMonitor(), &xscale, &yscale);
if (xscale > 1 || yscale > 1) {
    highDPIscaleFactor = xscale;
    glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);
}

// 2. after creating imgui context (and before setup Platform/Renderer bindings, but i'm not sure if that's important)
if (highDPIscaleFactor > 1.f) {
    ImGuiStyle& style = ImGui::GetStyle();
    style.ScaleAllSizes(highDPIscaleFactor);
}

This of course does not handle the case of dragging the gui between screens with different dpi, but its something at least.

dcnieho commented 1 year ago

See https://github.com/pthom/imgui_bundle/issues/7#issuecomment-1296977345 for python code for handling dragging between differen monitors. Same logic would apply in C++ (but be simpler to implement)

dcnieho commented 1 year ago

And last note: I'm happy to test anything you implement (I have a setup with two screens with different DPI), using the Windows build artefacts.

richardpl commented 1 year ago

Added some code to handle this. What about case if window is partially in one monitor and in another monitor?

dcnieho commented 1 year ago

There is no right solution to that case as far as i am aware. My example code (that i posted at the link above) determines with which monitor the window has most overlap and sets the window's scaling to that monitor's. This seems to be similar to what Microsoft programs here on Windows do.

Will test your new code today or tomorrow.

On Tue, Nov 1, 2022 at 12:25 PM Paul B Mahol @.***> wrote:

Added some code to handle this. What about case if window is partially in one monitor and in another monitor?

— Reply to this email directly, view it on GitHub https://github.com/richardpl/lavfi-preview/issues/5#issuecomment-1298380820, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANUOGMDY7BSN6YMBSTK5CTWGD437ANCNFSM6AAAAAARS7CKWQ . You are receiving this because you authored the thread.Message ID: @.***>

dcnieho commented 1 year ago

Works, stuff is nicely scaled now :)

On Tue, Nov 1, 2022 at 1:21 PM Diederick C. Niehorster @.***> wrote:

There is no right solution to that case as far as i am aware. My example code (that i posted at the link above) determines with which monitor the window has most overlap and sets the window's scaling to that monitor's. This seems to be similar to what Microsoft programs here on Windows do.

Will test your new code today or tomorrow.

On Tue, Nov 1, 2022 at 12:25 PM Paul B Mahol @.***> wrote:

Added some code to handle this. What about case if window is partially in one monitor and in another monitor?

— Reply to this email directly, view it on GitHub https://github.com/richardpl/lavfi-preview/issues/5#issuecomment-1298380820, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANUOGMDY7BSN6YMBSTK5CTWGD437ANCNFSM6AAAAAARS7CKWQ . You are receiving this because you authored the thread.Message ID: @.***>