Scale UI style sizes by DPI.
PiperOrigin-RevId: 907630627 Change-Id: Ia6dc35ce00e9764a454f4021250089b0d9a94073
This commit is contained in:
committed by
Copybara-Service
parent
4e7b2f2124
commit
cae70086da
@@ -187,27 +187,29 @@ void SetupTheme(GuiTheme theme) {
|
|||||||
c[ImGuiCol_TabDimmedSelected] = check;
|
c[ImGuiCol_TabDimmedSelected] = check;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float scale = s.FontScaleDpi;
|
||||||
|
|
||||||
int hspacing = 4;
|
int hspacing = 4;
|
||||||
int vspacing = 6;
|
int vspacing = 6;
|
||||||
float rounding = 4.0f;
|
float rounding = 4.0f;
|
||||||
s.DisplaySafeAreaPadding = ImVec2(0, 0);
|
s.DisplaySafeAreaPadding = ImVec2(0, 0);
|
||||||
s.WindowPadding = ImVec2(hspacing, vspacing);
|
s.WindowPadding = ImTrunc(ImVec2(hspacing * scale, vspacing * scale));
|
||||||
s.FramePadding = ImVec2(hspacing, 2);
|
s.FramePadding = ImTrunc(ImVec2(hspacing * scale, 2.0f * scale));
|
||||||
s.ItemSpacing = ImVec2(hspacing, vspacing);
|
s.ItemSpacing = ImTrunc(ImVec2(hspacing * scale, vspacing * scale));
|
||||||
s.ItemInnerSpacing = ImVec2(hspacing, vspacing);
|
s.ItemInnerSpacing = ImTrunc(ImVec2(hspacing * scale, vspacing * scale));
|
||||||
s.WindowRounding = rounding;
|
s.WindowRounding = ImTrunc(rounding * scale);
|
||||||
s.FrameRounding = rounding;
|
s.FrameRounding = ImTrunc(rounding * scale);
|
||||||
s.TabRounding = rounding;
|
s.TabRounding = ImTrunc(rounding * scale);
|
||||||
s.ScrollbarRounding = rounding;
|
s.ScrollbarRounding = ImTrunc(rounding * scale);
|
||||||
s.ChildRounding = rounding;
|
s.ChildRounding = ImTrunc(rounding * scale);
|
||||||
s.GrabRounding = rounding;
|
s.GrabRounding = ImTrunc(rounding * scale);
|
||||||
s.PopupRounding = rounding;
|
s.PopupRounding = ImTrunc(rounding * scale);
|
||||||
s.WindowBorderSize = 0.0f;
|
s.WindowBorderSize = 0.0f;
|
||||||
s.FrameBorderSize = 1.0f;
|
s.FrameBorderSize = 1.0f;
|
||||||
s.PopupBorderSize = 1.0f;
|
s.PopupBorderSize = 1.0f;
|
||||||
s.IndentSpacing = 6.0f;
|
s.IndentSpacing = ImTrunc(6.0f * scale);
|
||||||
s.ScrollbarSize = 12.0f;
|
s.ScrollbarSize = ImTrunc(12.0f * scale);
|
||||||
s.GrabMinSize = 5.0f;
|
s.GrabMinSize = ImTrunc(5.0f * scale);
|
||||||
s.WindowMenuButtonPosition = ImGuiDir_None;
|
s.WindowMenuButtonPosition = ImGuiDir_None;
|
||||||
s.TabCloseButtonMinWidthSelected = 0.0f;
|
s.TabCloseButtonMinWidthSelected = 0.0f;
|
||||||
s.DockingNodeHasCloseButton = false;
|
s.DockingNodeHasCloseButton = false;
|
||||||
@@ -323,7 +325,7 @@ ImVec4 ConfigureDockingLayout() {
|
|||||||
style.Var(ImGuiStyleVar_WindowMinSize, ImVec2(1, 1));
|
style.Var(ImGuiStyleVar_WindowMinSize, ImVec2(1, 1));
|
||||||
const float toolbar_vpad =
|
const float toolbar_vpad =
|
||||||
std::max(0.f, (kToolsBarHeight - ImGui::GetFrameHeight()) * 0.5f);
|
std::max(0.f, (kToolsBarHeight - ImGui::GetFrameHeight()) * 0.5f);
|
||||||
style.Var(ImGuiStyleVar_WindowPadding, ImVec2(4, toolbar_vpad));
|
style.Var(ImGuiStyleVar_WindowPadding, ImVec2(4 * scale, toolbar_vpad));
|
||||||
ImGui::SetNextWindowPos(viewport->WorkPos, ImGuiCond_Always);
|
ImGui::SetNextWindowPos(viewport->WorkPos, ImGuiCond_Always);
|
||||||
ImGui::SetNextWindowSize(ImVec2(viewport->Size.x, kToolsBarHeight),
|
ImGui::SetNextWindowSize(ImVec2(viewport->Size.x, kToolsBarHeight),
|
||||||
ImGuiCond_Always);
|
ImGuiCond_Always);
|
||||||
@@ -357,7 +359,7 @@ ImVec4 ConfigureDockingLayout() {
|
|||||||
void StepControlGui(const mjModel* model, StepControl* step_control,
|
void StepControlGui(const mjModel* model, StepControl* step_control,
|
||||||
int& speed_index) {
|
int& speed_index) {
|
||||||
platform::ScopedStyle style;
|
platform::ScopedStyle style;
|
||||||
style.Var(ImGuiStyleVar_FrameRounding, 8.f);
|
style.Var(ImGuiStyleVar_FrameRounding, 8.f * ImGui::GetStyle().FontScaleDpi);
|
||||||
|
|
||||||
const ImColor yellow(255, 215, 0, 255);
|
const ImColor yellow(255, 215, 0, 255);
|
||||||
const ImColor green(40, 180, 40, 255);
|
const ImColor green(40, 180, 40, 255);
|
||||||
@@ -394,7 +396,8 @@ void StepControlGui(const mjModel* model, StepControl* step_control,
|
|||||||
style.Reset();
|
style.Reset();
|
||||||
ImGui::SameLine(0, ImGui::GetFrameHeight() * .6f);
|
ImGui::SameLine(0, ImGui::GetFrameHeight() * .6f);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,
|
||||||
ImVec2(ImGui::GetStyle().FramePadding.x + 5.f,
|
ImVec2(ImGui::GetStyle().FramePadding.x +
|
||||||
|
5.f * ImGui::GetStyle().FontScaleDpi,
|
||||||
ImGui::GetStyle().FramePadding.y));
|
ImGui::GetStyle().FramePadding.y));
|
||||||
|
|
||||||
const auto [misaligned, measured] = IsSpeedMisaligned(*step_control);
|
const auto [misaligned, measured] = IsSpeedMisaligned(*step_control);
|
||||||
|
|||||||
Reference in New Issue
Block a user