MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / DemoWindowWidgetsText

Function DemoWindowWidgetsText

Source/3rdParty/imgui/imgui_demo.cpp:3594–3707  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3592//-----------------------------------------------------------------------------
3593
3594static void DemoWindowWidgetsText()
3595{
3596 if (ImGui::TreeNode("Text"))
3597 {
3598 IMGUI_DEMO_MARKER("Widgets/Text");
3599 if (ImGui::TreeNode("Colorful Text"))
3600 {
3601 IMGUI_DEMO_MARKER("Widgets/Text/Colored Text");
3602 // Using shortcut. You can use PushStyleColor()/PopStyleColor() for more flexibility.
3603 ImGui::TextColored(ImVec4(1.0f, 0.0f, 1.0f, 1.0f), "Pink");
3604 ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Yellow");
3605 ImGui::TextDisabled("Disabled");
3606 ImGui::SameLine(); HelpMarker("The TextDisabled color is stored in ImGuiStyle.");
3607 ImGui::TreePop();
3608 }
3609
3610 if (ImGui::TreeNode("Font Size"))
3611 {
3612 IMGUI_DEMO_MARKER("Widgets/Text/Font Size");
3613 ImGuiStyle& style = ImGui::GetStyle();
3614 const float global_scale = style.FontScaleMain * style.FontScaleDpi;
3615 ImGui::Text("style.FontScaleMain = %0.2f", style.FontScaleMain);
3616 ImGui::Text("style.FontScaleDpi = %0.2f", style.FontScaleDpi);
3617 ImGui::Text("global_scale = ~%0.2f", global_scale); // This is not technically accurate as internal scales may apply, but conceptually let's pretend it is.
3618 ImGui::Text("FontSize = %0.2f", ImGui::GetFontSize());
3619
3620 ImGui::SeparatorText("");
3621 static float custom_size = 16.0f;
3622 ImGui::SliderFloat("custom_size", &custom_size, 10.0f, 100.0f, "%.0f");
3623 ImGui::Text("ImGui::PushFont(nullptr, custom_size);");
3624 ImGui::PushFont(NULL, custom_size);
3625 ImGui::Text("FontSize = %.2f (== %.2f * global_scale)", ImGui::GetFontSize(), custom_size);
3626 ImGui::PopFont();
3627
3628 ImGui::SeparatorText("");
3629 static float custom_scale = 1.0f;
3630 ImGui::SliderFloat("custom_scale", &custom_scale, 0.5f, 4.0f, "%.2f");
3631 ImGui::Text("ImGui::PushFont(nullptr, style.FontSizeBase * custom_scale);");
3632 ImGui::PushFont(NULL, style.FontSizeBase * custom_scale);
3633 ImGui::Text("FontSize = %.2f (== style.FontSizeBase * %.2f * global_scale)", ImGui::GetFontSize(), custom_scale);
3634 ImGui::PopFont();
3635
3636 ImGui::SeparatorText("");
3637 for (float scaling = 0.5f; scaling <= 4.0f; scaling += 0.5f)
3638 {
3639 ImGui::PushFont(NULL, style.FontSizeBase * scaling);
3640 ImGui::Text("FontSize = %.2f (== style.FontSizeBase * %.2f * global_scale)", ImGui::GetFontSize(), scaling);
3641 ImGui::PopFont();
3642 }
3643
3644 ImGui::TreePop();
3645 }
3646
3647 if (ImGui::TreeNode("Word Wrapping"))
3648 {
3649 IMGUI_DEMO_MARKER("Widgets/Text/Word Wrapping");
3650 // Using shortcut. You can use PushTextWrapPos()/PopTextWrapPos() for more flexibility.
3651 ImGui::TextWrapped(

Callers 1

DemoWindowWidgetsFunction · 0.85

Calls 14

TextColoredFunction · 0.85
ImVec4Class · 0.85
TextDisabledFunction · 0.85
SeparatorTextFunction · 0.85
SliderFloatFunction · 0.85
PushFontFunction · 0.85
TextWrappedFunction · 0.85
ImVec2Function · 0.85
InputTextFunction · 0.85
AddRectMethod · 0.80
AddRectFilledMethod · 0.80
HelpMarkerFunction · 0.70

Tested by

no test coverage detected