MCPcopy Create free account
hub / github.com/Aegel5/SimpleSwitcher / DemoWindowWidgetsText

Function DemoWindowWidgetsText

imgui_tiny_app/imgui/imgui_demo.cpp:3680–3793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3678//-----------------------------------------------------------------------------
3679
3680static void DemoWindowWidgetsText()
3681{
3682 if (ImGui::TreeNode("Text"))
3683 {
3684 IMGUI_DEMO_MARKER("Widgets/Text");
3685 if (ImGui::TreeNode("Colorful Text"))
3686 {
3687 IMGUI_DEMO_MARKER("Widgets/Text/Colored Text");
3688 // Using shortcut. You can use PushStyleColor()/PopStyleColor() for more flexibility.
3689 ImGui::TextColored(ImVec4(1.0f, 0.0f, 1.0f, 1.0f), "Pink");
3690 ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Yellow");
3691 ImGui::TextDisabled("Disabled");
3692 ImGui::SameLine(); HelpMarker("The TextDisabled color is stored in ImGuiStyle.");
3693 ImGui::TreePop();
3694 }
3695
3696 if (ImGui::TreeNode("Font Size"))
3697 {
3698 IMGUI_DEMO_MARKER("Widgets/Text/Font Size");
3699 ImGuiStyle& style = ImGui::GetStyle();
3700 const float global_scale = style.FontScaleMain * style.FontScaleDpi;
3701 ImGui::Text("style.FontScaleMain = %0.2f", style.FontScaleMain);
3702 ImGui::Text("style.FontScaleDpi = %0.2f", style.FontScaleDpi);
3703 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.
3704 ImGui::Text("FontSize = %0.2f", ImGui::GetFontSize());
3705
3706 ImGui::SeparatorText("");
3707 static float custom_size = 16.0f;
3708 ImGui::SliderFloat("custom_size", &custom_size, 10.0f, 100.0f, "%.0f");
3709 ImGui::Text("ImGui::PushFont(nullptr, custom_size);");
3710 ImGui::PushFont(NULL, custom_size);
3711 ImGui::Text("FontSize = %.2f (== %.2f * global_scale)", ImGui::GetFontSize(), custom_size);
3712 ImGui::PopFont();
3713
3714 ImGui::SeparatorText("");
3715 static float custom_scale = 1.0f;
3716 ImGui::SliderFloat("custom_scale", &custom_scale, 0.5f, 4.0f, "%.2f");
3717 ImGui::Text("ImGui::PushFont(nullptr, style.FontSizeBase * custom_scale);");
3718 ImGui::PushFont(NULL, style.FontSizeBase * custom_scale);
3719 ImGui::Text("FontSize = %.2f (== style.FontSizeBase * %.2f * global_scale)", ImGui::GetFontSize(), custom_scale);
3720 ImGui::PopFont();
3721
3722 ImGui::SeparatorText("");
3723 for (float scaling = 0.5f; scaling <= 4.0f; scaling += 0.5f)
3724 {
3725 ImGui::PushFont(NULL, style.FontSizeBase * scaling);
3726 ImGui::Text("FontSize = %.2f (== style.FontSizeBase * %.2f * global_scale)", ImGui::GetFontSize(), scaling);
3727 ImGui::PopFont();
3728 }
3729
3730 ImGui::TreePop();
3731 }
3732
3733 if (ImGui::TreeNode("Word Wrapping"))
3734 {
3735 IMGUI_DEMO_MARKER("Widgets/Text/Word Wrapping");
3736 // Using shortcut. You can use PushTextWrapPos()/PopTextWrapPos() for more flexibility.
3737 ImGui::TextWrapped(

Callers 1

DemoWindowWidgetsFunction · 0.85

Calls 6

ImVec4Class · 0.85
HelpMarkerFunction · 0.85
PushFontFunction · 0.85
ImVec2Function · 0.85
AddRectMethod · 0.80
AddRectFilledMethod · 0.80

Tested by

no test coverage detected