libs/imgui/src/eu/imgui/init.cc
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "eu/imgui/init.h" | ||
| 2 | |||
| 3 | #include <SDL_video.h> | ||
| 4 | #include "imgui.h" | ||
| 5 | |||
| 6 | namespace eu::imgui | ||
| 7 | { | ||
| 8 | |||
| 9 | ✗ | float calculate_app_scale() | |
| 10 | { | ||
| 11 | ✗ | return SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay()); | |
| 12 | } | ||
| 13 | |||
| 14 | ✗ | std::pair<int, int> rescale_window(int width, int height, float app_scale) | |
| 15 | { | ||
| 16 | ✗ | const auto new_width = static_cast<int>(static_cast<float>(width) * app_scale); | |
| 17 | ✗ | const auto new_height = static_cast<int>(static_cast<float>(height) * app_scale); | |
| 18 | ✗ | return { new_width, new_height }; | |
| 19 | } | ||
| 20 | |||
| 21 | ✗ | void setup_scale(float app_scale) | |
| 22 | { | ||
| 23 | // scale dear imgui: https://wiki.libsdl.org/SDL3/README-highdpi | ||
| 24 | ✗ | auto& style = ImGui::GetStyle(); | |
| 25 | ✗ | style.ScaleAllSizes(app_scale); | |
| 26 | ✗ | style.FontScaleDpi *= app_scale; | |
| 27 | ✗ | } | |
| 28 | |||
| 29 | |||
| 30 | } | ||
| 31 |