Skip to content

Commit

Permalink
Use a proper default size for ImGui and LVGL
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed May 6, 2024
1 parent 2ea7bdd commit 15b89db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions opengl/DearImGui.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Dear ImGui for DPF
* Copyright (C) 2021 Jean Pierre Cimalando <[email protected]>
* Copyright (C) 2021-2022 Filipe Coelho <[email protected]>
* Copyright (C) 2021-2024 Filipe Coelho <[email protected]>
*
* 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
Expand Down Expand Up @@ -98,8 +98,8 @@ struct ImGuiWidget<BaseWidget>::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;
Expand Down
7 changes: 4 additions & 3 deletions opengl/LVGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,16 @@ struct LVGLWidget<BaseWidget>::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);
Expand Down

0 comments on commit 15b89db

Please sign in to comment.