diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2022-12-01 23:58:00 +0100 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-12-01 23:58:00 +0100 |
| commit | dee84335974f43f4d3661c5c7df481310357c24c (patch) | |
| tree | 0ec8900c6d4768a7ba4af851e010c495c0b74585 /editor | |
| parent | c9ed7f5a14037a87f74650e4426056cbdec59116 (diff) | |
main, imgui: use magnum's virtual dpi scale
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/imgui-scenery.cpp | 2 | ||||
| -rw-r--r-- | editor/imgui-tiles.cpp | 8 | ||||
| -rw-r--r-- | editor/imgui.cpp | 14 |
3 files changed, 12 insertions, 12 deletions
diff --git a/editor/imgui-scenery.cpp b/editor/imgui-scenery.cpp index f7577a04..85e7516f 100644 --- a/editor/imgui-scenery.cpp +++ b/editor/imgui-scenery.cpp @@ -19,7 +19,7 @@ void app::draw_editor_scenery_pane(scenery_editor& ed) constexpr int ncolumns = 4; const auto size = ImGui::GetWindowSize(); auto b2 = imgui::begin_table("scenery-table", ncolumns, flags, size); - const auto row_height = ImGui::GetCurrentContext()->FontSize + 10*dpi; + const auto row_height = ImGui::GetCurrentContext()->FontSize + 10*dpi[1]; constexpr auto thumbnail_width = 50; const auto colwidth_type = ImGui::CalcTextSize("generic").x; const auto colwidth_group = ImGui::CalcTextSize("MMMMMMMMMMMMMMM").x; diff --git a/editor/imgui-tiles.cpp b/editor/imgui-tiles.cpp index 79bf2166..9d84027f 100644 --- a/editor/imgui-tiles.cpp +++ b/editor/imgui-tiles.cpp @@ -17,7 +17,7 @@ void app::draw_editor_tile_pane_atlas(tile_editor& ed, StringView name, const st constexpr Color4 color_perm_selected{1, 1, 1, .7f}, color_selected{1, 0.843f, 0, .8f}, color_hover{0, .8f, 1, .7f}; - const float window_width = ImGui::GetWindowWidth() - 32 * dpi; + const float window_width = ImGui::GetWindowWidth() - 32 * dpi[0]; char buf[128]; const auto& style = ImGui::GetStyle(); const auto N = atlas->num_tiles(); @@ -36,7 +36,7 @@ void app::draw_editor_tile_pane_atlas(tile_editor& ed, StringView name, const st text(" (selected)"); } const auto len = snformat(buf, "{:d}"_cf, N); - ImGui::SameLine(window_width - ImGui::CalcTextSize(buf).x - style.FramePadding.x - 4*dpi); + ImGui::SameLine(window_width - ImGui::CalcTextSize(buf).x - style.FramePadding.x - 4*dpi[0]); text({buf, len}); }; if (const auto flags = ImGuiTreeNodeFlags_(ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_Framed); @@ -44,7 +44,7 @@ void app::draw_editor_tile_pane_atlas(tile_editor& ed, StringView name, const st { do_caption(); [[maybe_unused]] const raii_wrapper vars[] = { - push_style_var(ImGuiStyleVar_FramePadding, {2*dpi, 2*dpi}), + push_style_var(ImGuiStyleVar_FramePadding, {2*dpi[0], 2*dpi[1]}), push_style_color(ImGuiCol_ButtonHovered, color_hover), }; const bool perm_selected = ed.is_permutation_selected(atlas); @@ -65,7 +65,7 @@ void app::draw_editor_tile_pane_atlas(tile_editor& ed, StringView name, const st snformat(buf, "##item_{}"_cf, i); const auto uv = atlas->texcoords_for_id(i); constexpr ImVec2 size_2 = { TILE_SIZE[0]*.5f, TILE_SIZE[1]*.5f }; - ImGui::ImageButton(buf, (void*)&atlas->texture(), ImVec2(size_2.x * dpi, size_2.y * dpi), + ImGui::ImageButton(buf, (void*)&atlas->texture(), ImVec2(size_2.x * dpi[0], size_2.y * dpi[1]), { uv[3][0], uv[3][1] }, { uv[0][0], uv[0][1] }); if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) ed.select_tile(atlas, i); diff --git a/editor/imgui.cpp b/editor/imgui.cpp index e1b39d07..59196e6f 100644 --- a/editor/imgui.cpp +++ b/editor/imgui.cpp @@ -26,7 +26,7 @@ float app::draw_main_menu() float main_menu_height = 0; if (auto b = begin_main_menu()) { - ImGui::SetWindowFontScale(M->dpi_scale()); + ImGui::SetWindowFontScale(M->dpi_scale().min()); if (auto b = begin_menu("File")) { #if 0 @@ -77,7 +77,7 @@ float app::draw_main_menu() void app::draw_ui() { - const auto dpi = M->dpi_scale(); + const auto dpi = M->dpi_scale().min(); [[maybe_unused]] const auto style_ = style_saver{}; auto& style = ImGui::GetStyle(); auto& ctx = *ImGui::GetCurrentContext(); @@ -107,7 +107,7 @@ void app::draw_fps() const ImVec2 size = ImGui::CalcTextSize(buf); ImDrawList& draw = *ImGui::GetForegroundDrawList(); draw.AddText(nullptr, ImGui::GetCurrentContext()->FontSize, - {M->window_size()[0] - size.x - 3.5f*dpi, 3*dpi}, ImGui::ColorConvertFloat4ToU32({0, 1, 0, 1}), buf); + {M->window_size()[0] - size.x - 3.5f*dpi[0], 3*dpi[1]}, ImGui::ColorConvertFloat4ToU32({0, 1, 0, 1}), buf); } void app::draw_tile_under_cursor() @@ -126,7 +126,7 @@ void app::draw_tile_under_cursor() ImDrawList& draw = *ImGui::GetForegroundDrawList(); draw.AddText(nullptr, ImGui::GetCurrentContext()->FontSize, - {window_size[0]*.5f - size.x/2, 3*dpi}, (unsigned)-1, buf); + {window_size[0]*.5f - size.x/2, 3*dpi[1]}, (unsigned)-1, buf); } void app::draw_editor_pane(float main_menu_height) @@ -143,9 +143,9 @@ void app::draw_editor_pane(float main_menu_height) active ? M->start_text_input() : M->stop_text_input(); [[maybe_unused]] const raii_wrapper vars[] = { - push_style_var(ImGuiStyleVar_WindowPadding, {8*dpi, 8*dpi}), + push_style_var(ImGuiStyleVar_WindowPadding, {8*dpi[0], 8*dpi[1]}), push_style_var(ImGuiStyleVar_WindowBorderSize, 0), - push_style_var(ImGuiStyleVar_FramePadding, {4*dpi, 4*dpi}), + push_style_var(ImGuiStyleVar_FramePadding, {4*dpi[0], 4*dpi[1]}), push_style_color(ImGuiCol_WindowBg, {0, 0, 0, .5}), push_style_color(ImGuiCol_FrameBg, {0, 0, 0, 0}), }; @@ -158,7 +158,7 @@ void app::draw_editor_pane(float main_menu_height) ImGui::SetNextWindowPos({0, main_menu_height+style.WindowPadding.y}); ImGui::SetNextFrameWantCaptureKeyboard(false); - ImGui::SetNextWindowSize({425 * dpi, window_size[1] - main_menu_height - style.WindowPadding.y}); + ImGui::SetNextWindowSize({425 * dpi[0], window_size[1] - main_menu_height - style.WindowPadding.y}); if (const auto flags = ImGuiWindowFlags_(ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings); auto b = begin_window({}, flags)) { |
