aboutsummaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/ui_layer.cpp14
-rw-r--r--src/ui/ui_layer.h3
2 files changed, 13 insertions, 4 deletions
diff --git a/src/ui/ui_layer.cpp b/src/ui/ui_layer.cpp
index 90ddb7c..a65000e 100644
--- a/src/ui/ui_layer.cpp
+++ b/src/ui/ui_layer.cpp
@@ -140,7 +140,7 @@ namespace Donut
// the theme: soft-rounded cards on a near-black ground, 1px borders for edges,
// and the accent reserved for "this is live / selected" — slider grabs, checks,
// the active tab's underline, the one primary button per panel.
- static auto apply_donut_style() -> void
+ static auto apply_donut_style(float dpi_scale) -> void
{
ImGuiStyle& s = ImGui::GetStyle();
s.WindowRounding = 8.0f; s.ChildRounding = 6.0f; s.FrameRounding = 6.0f;
@@ -216,6 +216,9 @@ namespace Donut
c[ImGuiCol_TableRowBgAlt] = ImVec4(1.0f, 1.0f, 1.0f, 0.025f);
c[ImGuiCol_TextSelectedBg] = amber_dim;
c[ImGuiCol_DragDropTarget] = kAmberHi;
+
+ // everything above is in 1x pixels; a 200% desktop wants it all doubled.
+ if (dpi_scale != 1.0f) { s.ScaleAllSizes(dpi_scale); s.FontScaleDpi = dpi_scale; }
}
// inspector row: label in a fixed left column, the control fills the rest.
@@ -262,8 +265,9 @@ namespace Donut
}
}
- auto UILayer::init() -> void
+ auto UILayer::init(float dpi_scale) -> void
{
+ m_dpi_scale = dpi_scale;
ImGuiIO& io = ImGui::GetIO();
m_font_body = io.Fonts->AddFontFromFileTTF("assets/fonts/inter/static/Inter_18pt-Regular.ttf", kBodySize);
m_font_heading = io.Fonts->AddFontFromFileTTF("assets/fonts/inter/static/Inter_18pt-SemiBold.ttf", kHeadSize);
@@ -329,7 +333,7 @@ namespace Donut
auto UILayer::draw(const UIContext& ctx) -> View
{
static bool styled = false;
- if (!styled) { apply_donut_style(); styled = true; }
+ if (!styled) { apply_donut_style(m_dpi_scale); styled = true; }
ImGuizmo::BeginFrame(); // the Properties panel draws the scene gizmo
@@ -991,7 +995,11 @@ namespace Donut
};
char buf[64];
row("Device", ctx.device_name.empty() ? "GPU" : ctx.device_name.c_str());
+#ifdef __APPLE__
row("API", RendererAPI::get_api() == RendererAPI::API::Vulkan ? "Vulkan (MoltenVK)" : "OpenGL 4.1");
+#else
+ row("API", RendererAPI::get_api() == RendererAPI::API::Vulkan ? "Vulkan" : "OpenGL");
+#endif
row("Workspace", tab.label);
std::snprintf(buf, sizeof(buf), "%.0f x %.0f", io.DisplaySize.x * io.DisplayFramebufferScale.x,
io.DisplaySize.y * io.DisplayFramebufferScale.y);
diff --git a/src/ui/ui_layer.h b/src/ui/ui_layer.h
index 4479844..bcfff23 100644
--- a/src/ui/ui_layer.h
+++ b/src/ui/ui_layer.h
@@ -30,7 +30,7 @@ namespace Donut
// loads the Inter faces and registers the workspace ini section on the
// live ImGui context. call once after the device's init_imgui() and before
// the first draw(): ImGui reads imgui.ini on its first NewFrame.
- auto init() -> void;
+ auto init(float dpi_scale = 1.0f) -> void;
auto draw(const UIContext& ctx) -> View;
private:
@@ -76,6 +76,7 @@ namespace Donut
int m_active_tab = 0; // index into m_tabs; the source of truth
int m_tab_request = -1; // one-frame programmatic strip selection
bool m_first_frame = true;
+ float m_dpi_scale = 1.0f; // monitor content scale (windows/linux); 1 on macos
// properties-panel gizmo op (0 = translate, 1 = scale); cast in the .cpp.
int m_gizmo_op = 0;