mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 20:07:01 +00:00
Demo: Text baseline demo tweaks.
This commit is contained in:
parent
a6c3be4bda
commit
1425bec7a4
@ -2047,8 +2047,44 @@ static void ShowDemoWindowLayout()
|
||||
|
||||
if (ImGui::TreeNode("Text Baseline Alignment"))
|
||||
{
|
||||
{
|
||||
ImGui::BulletText("Text baseline:");
|
||||
ImGui::SameLine();
|
||||
HelpMarker("This is testing the vertical alignment that gets applied on text to keep it aligned with widgets. Lines only composed of text or \"small\" widgets fit in less vertical spaces than lines with normal widgets.");
|
||||
ImGui::Indent();
|
||||
|
||||
ImGui::Text("KO Blahblah"); ImGui::SameLine();
|
||||
ImGui::Button("Some framed item"); ImGui::SameLine();
|
||||
HelpMarker("Baseline of button will look misaligned with text..");
|
||||
|
||||
// If your line starts with text, call AlignTextToFramePadding() to align text to upcoming widgets.
|
||||
// Because we don't know what's coming after the Text() statement, we need to move the text baseline down by FramePadding.y
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text("OK Blahblah"); ImGui::SameLine();
|
||||
ImGui::Button("Some framed item"); ImGui::SameLine();
|
||||
HelpMarker("We call AlignTextToFramePadding() to vertically align the text baseline by +FramePadding.y");
|
||||
|
||||
// SmallButton() uses the same vertical padding as Text
|
||||
ImGui::Button("TEST##1"); ImGui::SameLine();
|
||||
ImGui::Text("TEST"); ImGui::SameLine();
|
||||
ImGui::SmallButton("TEST##2");
|
||||
|
||||
// If your line starts with text, call AlignTextToFramePadding() to align text to upcoming widgets.
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text("Text aligned to framed item"); ImGui::SameLine();
|
||||
ImGui::Button("Item##1"); ImGui::SameLine();
|
||||
ImGui::Text("Item"); ImGui::SameLine();
|
||||
ImGui::SmallButton("Item##2"); ImGui::SameLine();
|
||||
ImGui::Button("Item##3");
|
||||
|
||||
ImGui::Unindent();
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
{
|
||||
ImGui::BulletText("Multi-line text:");
|
||||
ImGui::Indent();
|
||||
ImGui::Text("One\nTwo\nThree"); ImGui::SameLine();
|
||||
ImGui::Text("Hello\nWorld"); ImGui::SameLine();
|
||||
ImGui::Text("Banana");
|
||||
@ -2065,17 +2101,23 @@ static void ShowDemoWindowLayout()
|
||||
ImGui::Button("HOP##2"); ImGui::SameLine();
|
||||
ImGui::Text("Hello\nWorld"); ImGui::SameLine();
|
||||
ImGui::Text("Banana");
|
||||
ImGui::Unindent();
|
||||
}
|
||||
|
||||
ImGui::Button("TEST##1"); ImGui::SameLine();
|
||||
ImGui::Text("TEST"); ImGui::SameLine();
|
||||
ImGui::SmallButton("TEST##2");
|
||||
ImGui::Spacing();
|
||||
|
||||
ImGui::AlignTextToFramePadding(); // If your line starts with text, call this to align it to upcoming widgets.
|
||||
ImGui::Text("Text aligned to Widget"); ImGui::SameLine();
|
||||
ImGui::Button("Widget##1"); ImGui::SameLine();
|
||||
ImGui::Text("Widget"); ImGui::SameLine();
|
||||
ImGui::SmallButton("Widget##2"); ImGui::SameLine();
|
||||
ImGui::Button("Widget##3");
|
||||
{
|
||||
ImGui::BulletText("Misc items:");
|
||||
ImGui::Indent();
|
||||
|
||||
// SmallButton() sets FramePadding to zero. Text baseline is aligned to match baseline of previous Button
|
||||
ImGui::Button("80x80", ImVec2(80, 80));
|
||||
ImGui::SameLine();
|
||||
ImGui::Button("50x50", ImVec2(50, 50));
|
||||
ImGui::SameLine();
|
||||
ImGui::Button("Button()");
|
||||
ImGui::SameLine();
|
||||
ImGui::SmallButton("SmallButton()");
|
||||
|
||||
// Tree
|
||||
const float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
|
||||
@ -2096,6 +2138,8 @@ static void ShowDemoWindowLayout()
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::BulletText("Node");
|
||||
ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##4");
|
||||
ImGui::Unindent();
|
||||
}
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user