WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 7f78f52

Browse files
committed
Demo: removed some hardcoded widths.
1 parent 60f8b07 commit 7f78f52

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

imgui.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15224,7 +15224,7 @@ void ImGui::LogButtons()
1522415224
const bool log_to_file = Button("Log To File"); SameLine();
1522515225
const bool log_to_clipboard = Button("Log To Clipboard"); SameLine();
1522615226
PushItemFlag(ImGuiItemFlags_NoTabStop, true);
15227-
SetNextItemWidth(80.0f);
15227+
SetNextItemWidth(CalcTextSize("999").x);
1522815228
SliderInt("Default Depth", &g.LogDepthToExpandDefault, 0, 9, NULL);
1522915229
PopItemFlag();
1523015230
PopID();

imgui_demo.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4582,16 +4582,14 @@ static void DemoWindowLayout()
45824582

45834583
// Various
45844584
static float f0 = 1.0f, f1 = 2.0f, f2 = 3.0f;
4585-
ImGui::PushItemWidth(80);
4585+
ImGui::PushItemWidth(ImGui::CalcTextSize("AAAAAAA").x);
45864586
const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD" };
45874587
static int item = -1;
45884588
ImGui::Combo("Combo", &item, items, IM_ARRAYSIZE(items)); ImGui::SameLine();
45894589
ImGui::SliderFloat("X", &f0, 0.0f, 5.0f); ImGui::SameLine();
45904590
ImGui::SliderFloat("Y", &f1, 0.0f, 5.0f); ImGui::SameLine();
45914591
ImGui::SliderFloat("Z", &f2, 0.0f, 5.0f);
4592-
ImGui::PopItemWidth();
45934592

4594-
ImGui::PushItemWidth(80);
45954593
ImGui::Text("Lists:");
45964594
static int selection[4] = { 0, 1, 2, 3 };
45974595
for (int i = 0; i < 4; i++)
@@ -5026,7 +5024,7 @@ static void DemoWindowLayout()
50265024
if (explicit_content_size)
50275025
{
50285026
ImGui::SameLine();
5029-
ImGui::SetNextItemWidth(100);
5027+
ImGui::SetNextItemWidth(ImGui::CalcTextSize("123456").x);
50305028
ImGui::DragFloat("##csx", &contents_size_x);
50315029
ImVec2 p = ImGui::GetCursorScreenPos();
50325030
ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x + 10, p.y + 10), IM_COL32_WHITE);
@@ -8504,7 +8502,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
85048502
}
85058503
LogFinish();
85068504
}
8507-
SameLine(); SetNextItemWidth(120); Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0");
8505+
SameLine(); SetNextItemWidth(GetFontSize() * 10); Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0");
85088506
SameLine(); Checkbox("Only Modified Colors", &output_only_modified);
85098507

85108508
static ImGuiTextFilter filter;

0 commit comments

Comments
 (0)