From 15b89db33b7a1391d6310fbbf57f68133ef474a7 Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 6 May 2024 11:23:15 +0200 Subject: [PATCH] Use a proper default size for ImGui and LVGL Signed-off-by: falkTX --- opengl/DearImGui.cpp | 6 +++--- opengl/LVGL.cpp | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/opengl/DearImGui.cpp b/opengl/DearImGui.cpp index a398d7d..3b9ae89 100644 --- a/opengl/DearImGui.cpp +++ b/opengl/DearImGui.cpp @@ -1,7 +1,7 @@ /* * Dear ImGui for DPF * Copyright (C) 2021 Jean Pierre Cimalando - * Copyright (C) 2021-2022 Filipe Coelho + * Copyright (C) 2021-2024 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -98,8 +98,8 @@ struct ImGuiWidget::PrivateData { ImGuiIO& io(ImGui::GetIO()); io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; - io.DisplaySize.x = self->getWidth(); - io.DisplaySize.y = self->getHeight(); + io.DisplaySize.x = self->getWidth() ?: 640 * scaleFactor; + io.DisplaySize.y = self->getHeight() ?: 480 * scaleFactor; // not needed, we handle this ourselves // io.DisplayFramebufferScale = ImVec2(scaleFactor, scaleFactor); io.IniFilename = nullptr; diff --git a/opengl/LVGL.cpp b/opengl/LVGL.cpp index db12d51..11a02af 100644 --- a/opengl/LVGL.cpp +++ b/opengl/LVGL.cpp @@ -72,15 +72,16 @@ struct LVGLWidget::PrivateData { lv_delay_set_cb(msleep); lv_tick_set_cb(gettime_ms); - const uint width = self->getWidth() ?: 100; - const uint height = self->getHeight() ?: 100; + const double scaleFactor = self->getTopLevelWidget()->getScaleFactor(); + const uint width = self->getWidth() ?: 640 * scaleFactor; + const uint height = self->getHeight() ?: 480 * scaleFactor; lv_area_set(&updatedArea, 0, 0, width, height); display = lv_display_create(width, height); DISTRHO_SAFE_ASSERT_RETURN(display != nullptr,); - lv_display_set_dpi(display, LV_DPI_DEF * self->getTopLevelWidget()->getScaleFactor()); + lv_display_set_dpi(display, LV_DPI_DEF * scaleFactor); group = lv_group_create(); lv_group_set_default(group);