Demo: omit ImGui:: prefix from ShowStyleEditor(), ShowUserGuide() code.
diff --git a/imgui_demo.cpp b/imgui_demo.cpp
index 82e7d48..14dcc32 100644
--- a/imgui_demo.cpp
+++ b/imgui_demo.cpp
@@ -8225,12 +8225,13 @@
return "";
}
+// We omit the ImGui:: prefix in this function, as we don't expect user to be copy and pasting this code.
void ImGui::ShowStyleEditor(ImGuiStyle* ref)
{
IMGUI_DEMO_MARKER("Tools/Style Editor");
// You can pass in a reference ImGuiStyle structure to compare to, revert to and save to
// (without a reference style pointer, we will use one compared locally as a reference)
- ImGuiStyle& style = ImGui::GetStyle();
+ ImGuiStyle& style = GetStyle();
static ImGuiStyle ref_saved_style;
// Default to using internal storage as reference
@@ -8241,206 +8242,206 @@
if (ref == NULL)
ref = &ref_saved_style;
- ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.50f);
+ PushItemWidth(GetWindowWidth() * 0.50f);
- if (ImGui::ShowStyleSelector("Colors##Selector"))
+ if (ShowStyleSelector("Colors##Selector"))
ref_saved_style = style;
- ImGui::ShowFontSelector("Fonts##Selector");
+ ShowFontSelector("Fonts##Selector");
// Simplified Settings (expose floating-pointer border sizes as boolean representing 0.0f or 1.0f)
- if (ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f"))
+ if (SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f"))
style.GrabRounding = style.FrameRounding; // Make GrabRounding always the same value as FrameRounding
- { bool border = (style.WindowBorderSize > 0.0f); if (ImGui::Checkbox("WindowBorder", &border)) { style.WindowBorderSize = border ? 1.0f : 0.0f; } }
- ImGui::SameLine();
- { bool border = (style.FrameBorderSize > 0.0f); if (ImGui::Checkbox("FrameBorder", &border)) { style.FrameBorderSize = border ? 1.0f : 0.0f; } }
- ImGui::SameLine();
- { bool border = (style.PopupBorderSize > 0.0f); if (ImGui::Checkbox("PopupBorder", &border)) { style.PopupBorderSize = border ? 1.0f : 0.0f; } }
+ { bool border = (style.WindowBorderSize > 0.0f); if (Checkbox("WindowBorder", &border)) { style.WindowBorderSize = border ? 1.0f : 0.0f; } }
+ SameLine();
+ { bool border = (style.FrameBorderSize > 0.0f); if (Checkbox("FrameBorder", &border)) { style.FrameBorderSize = border ? 1.0f : 0.0f; } }
+ SameLine();
+ { bool border = (style.PopupBorderSize > 0.0f); if (Checkbox("PopupBorder", &border)) { style.PopupBorderSize = border ? 1.0f : 0.0f; } }
// Save/Revert button
- if (ImGui::Button("Save Ref"))
+ if (Button("Save Ref"))
*ref = ref_saved_style = style;
- ImGui::SameLine();
- if (ImGui::Button("Revert Ref"))
+ SameLine();
+ if (Button("Revert Ref"))
style = *ref;
- ImGui::SameLine();
+ SameLine();
HelpMarker(
"Save/Revert in local non-persistent storage. Default Colors definition are not affected. "
"Use \"Export\" below to save them somewhere.");
- ImGui::Separator();
+ Separator();
- if (ImGui::BeginTabBar("##tabs", ImGuiTabBarFlags_None))
+ if (BeginTabBar("##tabs", ImGuiTabBarFlags_None))
{
- if (ImGui::BeginTabItem("Sizes"))
+ if (BeginTabItem("Sizes"))
{
- ImGui::SeparatorText("Main");
- ImGui::SliderFloat2("WindowPadding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f");
- ImGui::SliderFloat2("FramePadding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f");
- ImGui::SliderFloat2("ItemSpacing", (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f");
- ImGui::SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f");
- ImGui::SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f");
- ImGui::SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f");
- ImGui::SliderFloat("ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f");
- ImGui::SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f");
+ SeparatorText("Main");
+ SliderFloat2("WindowPadding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f");
+ SliderFloat2("FramePadding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f");
+ SliderFloat2("ItemSpacing", (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f");
+ SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f");
+ SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f");
+ SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f");
+ SliderFloat("ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f");
+ SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f");
- ImGui::SeparatorText("Borders");
- ImGui::SliderFloat("WindowBorderSize", &style.WindowBorderSize, 0.0f, 1.0f, "%.0f");
- ImGui::SliderFloat("ChildBorderSize", &style.ChildBorderSize, 0.0f, 1.0f, "%.0f");
- ImGui::SliderFloat("PopupBorderSize", &style.PopupBorderSize, 0.0f, 1.0f, "%.0f");
- ImGui::SliderFloat("FrameBorderSize", &style.FrameBorderSize, 0.0f, 1.0f, "%.0f");
+ SeparatorText("Borders");
+ SliderFloat("WindowBorderSize", &style.WindowBorderSize, 0.0f, 1.0f, "%.0f");
+ SliderFloat("ChildBorderSize", &style.ChildBorderSize, 0.0f, 1.0f, "%.0f");
+ SliderFloat("PopupBorderSize", &style.PopupBorderSize, 0.0f, 1.0f, "%.0f");
+ SliderFloat("FrameBorderSize", &style.FrameBorderSize, 0.0f, 1.0f, "%.0f");
- ImGui::SeparatorText("Rounding");
- ImGui::SliderFloat("WindowRounding", &style.WindowRounding, 0.0f, 12.0f, "%.0f");
- ImGui::SliderFloat("ChildRounding", &style.ChildRounding, 0.0f, 12.0f, "%.0f");
- ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f");
- ImGui::SliderFloat("PopupRounding", &style.PopupRounding, 0.0f, 12.0f, "%.0f");
- ImGui::SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f");
- ImGui::SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 12.0f, "%.0f");
+ SeparatorText("Rounding");
+ SliderFloat("WindowRounding", &style.WindowRounding, 0.0f, 12.0f, "%.0f");
+ SliderFloat("ChildRounding", &style.ChildRounding, 0.0f, 12.0f, "%.0f");
+ SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f");
+ SliderFloat("PopupRounding", &style.PopupRounding, 0.0f, 12.0f, "%.0f");
+ SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f");
+ SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 12.0f, "%.0f");
- ImGui::SeparatorText("Tabs");
- ImGui::SliderFloat("TabBorderSize", &style.TabBorderSize, 0.0f, 1.0f, "%.0f");
- ImGui::SliderFloat("TabBarBorderSize", &style.TabBarBorderSize, 0.0f, 2.0f, "%.0f");
- ImGui::SliderFloat("TabBarOverlineSize", &style.TabBarOverlineSize, 0.0f, 3.0f, "%.0f");
- ImGui::SameLine(); HelpMarker("Overline is only drawn over the selected tab when ImGuiTabBarFlags_DrawSelectedOverline is set.");
- ImGui::DragFloat("TabCloseButtonMinWidthSelected", &style.TabCloseButtonMinWidthSelected, 0.1f, -1.0f, 100.0f, (style.TabCloseButtonMinWidthSelected < 0.0f) ? "%.0f (Always)" : "%.0f");
- ImGui::DragFloat("TabCloseButtonMinWidthUnselected", &style.TabCloseButtonMinWidthUnselected, 0.1f, -1.0f, 100.0f, (style.TabCloseButtonMinWidthUnselected < 0.0f) ? "%.0f (Always)" : "%.0f");
- ImGui::SliderFloat("TabRounding", &style.TabRounding, 0.0f, 12.0f, "%.0f");
+ SeparatorText("Tabs");
+ SliderFloat("TabBorderSize", &style.TabBorderSize, 0.0f, 1.0f, "%.0f");
+ SliderFloat("TabBarBorderSize", &style.TabBarBorderSize, 0.0f, 2.0f, "%.0f");
+ SliderFloat("TabBarOverlineSize", &style.TabBarOverlineSize, 0.0f, 3.0f, "%.0f");
+ SameLine(); HelpMarker("Overline is only drawn over the selected tab when ImGuiTabBarFlags_DrawSelectedOverline is set.");
+ DragFloat("TabCloseButtonMinWidthSelected", &style.TabCloseButtonMinWidthSelected, 0.1f, -1.0f, 100.0f, (style.TabCloseButtonMinWidthSelected < 0.0f) ? "%.0f (Always)" : "%.0f");
+ DragFloat("TabCloseButtonMinWidthUnselected", &style.TabCloseButtonMinWidthUnselected, 0.1f, -1.0f, 100.0f, (style.TabCloseButtonMinWidthUnselected < 0.0f) ? "%.0f (Always)" : "%.0f");
+ SliderFloat("TabRounding", &style.TabRounding, 0.0f, 12.0f, "%.0f");
- ImGui::SeparatorText("Tables");
- ImGui::SliderFloat2("CellPadding", (float*)&style.CellPadding, 0.0f, 20.0f, "%.0f");
- ImGui::SliderAngle("TableAngledHeadersAngle", &style.TableAngledHeadersAngle, -50.0f, +50.0f);
- ImGui::SliderFloat2("TableAngledHeadersTextAlign", (float*)&style.TableAngledHeadersTextAlign, 0.0f, 1.0f, "%.2f");
+ SeparatorText("Tables");
+ SliderFloat2("CellPadding", (float*)&style.CellPadding, 0.0f, 20.0f, "%.0f");
+ SliderAngle("TableAngledHeadersAngle", &style.TableAngledHeadersAngle, -50.0f, +50.0f);
+ SliderFloat2("TableAngledHeadersTextAlign", (float*)&style.TableAngledHeadersTextAlign, 0.0f, 1.0f, "%.2f");
- ImGui::SeparatorText("Trees");
- bool combo_open = ImGui::BeginCombo("TreeLinesFlags", GetTreeLinesFlagsName(style.TreeLinesFlags));
- ImGui::SameLine();
+ SeparatorText("Trees");
+ bool combo_open = BeginCombo("TreeLinesFlags", GetTreeLinesFlagsName(style.TreeLinesFlags));
+ SameLine();
HelpMarker("[Experimental] Tree lines may not work in all situations (e.g. using a clipper) and may incurs slight traversal overhead.\n\nImGuiTreeNodeFlags_DrawLinesFull is faster than ImGuiTreeNodeFlags_DrawLinesToNode.");
if (combo_open)
{
const ImGuiTreeNodeFlags options[] = { ImGuiTreeNodeFlags_DrawLinesNone, ImGuiTreeNodeFlags_DrawLinesFull, ImGuiTreeNodeFlags_DrawLinesToNodes };
for (ImGuiTreeNodeFlags option : options)
- if (ImGui::Selectable(GetTreeLinesFlagsName(option), style.TreeLinesFlags == option))
+ if (Selectable(GetTreeLinesFlagsName(option), style.TreeLinesFlags == option))
style.TreeLinesFlags = option;
- ImGui::EndCombo();
+ EndCombo();
}
- ImGui::SliderFloat("TreeLinesSize", &style.TreeLinesSize, 0.0f, 2.0f, "%.0f");
- ImGui::SliderFloat("TreeLinesRounding", &style.TreeLinesRounding, 0.0f, 12.0f, "%.0f");
+ SliderFloat("TreeLinesSize", &style.TreeLinesSize, 0.0f, 2.0f, "%.0f");
+ SliderFloat("TreeLinesRounding", &style.TreeLinesRounding, 0.0f, 12.0f, "%.0f");
- ImGui::SeparatorText("Windows");
- ImGui::SliderFloat2("WindowTitleAlign", (float*)&style.WindowTitleAlign, 0.0f, 1.0f, "%.2f");
- ImGui::SliderFloat("WindowBorderHoverPadding", &style.WindowBorderHoverPadding, 1.0f, 20.0f, "%.0f");
+ SeparatorText("Windows");
+ SliderFloat2("WindowTitleAlign", (float*)&style.WindowTitleAlign, 0.0f, 1.0f, "%.2f");
+ SliderFloat("WindowBorderHoverPadding", &style.WindowBorderHoverPadding, 1.0f, 20.0f, "%.0f");
int window_menu_button_position = style.WindowMenuButtonPosition + 1;
- if (ImGui::Combo("WindowMenuButtonPosition", (int*)&window_menu_button_position, "None\0Left\0Right\0"))
+ if (Combo("WindowMenuButtonPosition", (int*)&window_menu_button_position, "None\0Left\0Right\0"))
style.WindowMenuButtonPosition = (ImGuiDir)(window_menu_button_position - 1);
- ImGui::SeparatorText("Widgets");
- ImGui::Combo("ColorButtonPosition", (int*)&style.ColorButtonPosition, "Left\0Right\0");
- ImGui::SliderFloat2("ButtonTextAlign", (float*)&style.ButtonTextAlign, 0.0f, 1.0f, "%.2f");
- ImGui::SameLine(); HelpMarker("Alignment applies when a button is larger than its text content.");
- ImGui::SliderFloat2("SelectableTextAlign", (float*)&style.SelectableTextAlign, 0.0f, 1.0f, "%.2f");
- ImGui::SameLine(); HelpMarker("Alignment applies when a selectable is larger than its text content.");
- ImGui::SliderFloat("SeparatorTextBorderSize", &style.SeparatorTextBorderSize, 0.0f, 10.0f, "%.0f");
- ImGui::SliderFloat2("SeparatorTextAlign", (float*)&style.SeparatorTextAlign, 0.0f, 1.0f, "%.2f");
- ImGui::SliderFloat2("SeparatorTextPadding", (float*)&style.SeparatorTextPadding, 0.0f, 40.0f, "%.0f");
- ImGui::SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f");
- ImGui::SliderFloat("ImageBorderSize", &style.ImageBorderSize, 0.0f, 1.0f, "%.0f");
+ SeparatorText("Widgets");
+ Combo("ColorButtonPosition", (int*)&style.ColorButtonPosition, "Left\0Right\0");
+ SliderFloat2("ButtonTextAlign", (float*)&style.ButtonTextAlign, 0.0f, 1.0f, "%.2f");
+ SameLine(); HelpMarker("Alignment applies when a button is larger than its text content.");
+ SliderFloat2("SelectableTextAlign", (float*)&style.SelectableTextAlign, 0.0f, 1.0f, "%.2f");
+ SameLine(); HelpMarker("Alignment applies when a selectable is larger than its text content.");
+ SliderFloat("SeparatorTextBorderSize", &style.SeparatorTextBorderSize, 0.0f, 10.0f, "%.0f");
+ SliderFloat2("SeparatorTextAlign", (float*)&style.SeparatorTextAlign, 0.0f, 1.0f, "%.2f");
+ SliderFloat2("SeparatorTextPadding", (float*)&style.SeparatorTextPadding, 0.0f, 40.0f, "%.0f");
+ SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f");
+ SliderFloat("ImageBorderSize", &style.ImageBorderSize, 0.0f, 1.0f, "%.0f");
- ImGui::SeparatorText("Tooltips");
+ SeparatorText("Tooltips");
for (int n = 0; n < 2; n++)
- if (ImGui::TreeNodeEx(n == 0 ? "HoverFlagsForTooltipMouse" : "HoverFlagsForTooltipNav"))
+ if (TreeNodeEx(n == 0 ? "HoverFlagsForTooltipMouse" : "HoverFlagsForTooltipNav"))
{
ImGuiHoveredFlags* p = (n == 0) ? &style.HoverFlagsForTooltipMouse : &style.HoverFlagsForTooltipNav;
- ImGui::CheckboxFlags("ImGuiHoveredFlags_DelayNone", p, ImGuiHoveredFlags_DelayNone);
- ImGui::CheckboxFlags("ImGuiHoveredFlags_DelayShort", p, ImGuiHoveredFlags_DelayShort);
- ImGui::CheckboxFlags("ImGuiHoveredFlags_DelayNormal", p, ImGuiHoveredFlags_DelayNormal);
- ImGui::CheckboxFlags("ImGuiHoveredFlags_Stationary", p, ImGuiHoveredFlags_Stationary);
- ImGui::CheckboxFlags("ImGuiHoveredFlags_NoSharedDelay", p, ImGuiHoveredFlags_NoSharedDelay);
- ImGui::TreePop();
+ CheckboxFlags("ImGuiHoveredFlags_DelayNone", p, ImGuiHoveredFlags_DelayNone);
+ CheckboxFlags("ImGuiHoveredFlags_DelayShort", p, ImGuiHoveredFlags_DelayShort);
+ CheckboxFlags("ImGuiHoveredFlags_DelayNormal", p, ImGuiHoveredFlags_DelayNormal);
+ CheckboxFlags("ImGuiHoveredFlags_Stationary", p, ImGuiHoveredFlags_Stationary);
+ CheckboxFlags("ImGuiHoveredFlags_NoSharedDelay", p, ImGuiHoveredFlags_NoSharedDelay);
+ TreePop();
}
- ImGui::SeparatorText("Misc");
- ImGui::SliderFloat2("DisplayWindowPadding", (float*)&style.DisplayWindowPadding, 0.0f, 30.0f, "%.0f"); ImGui::SameLine(); HelpMarker("Apply to regular windows: amount which we enforce to keep visible when moving near edges of your screen.");
- ImGui::SliderFloat2("DisplaySafeAreaPadding", (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f"); ImGui::SameLine(); HelpMarker("Apply to every windows, menus, popups, tooltips: amount where we avoid displaying contents. Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).");
+ SeparatorText("Misc");
+ SliderFloat2("DisplayWindowPadding", (float*)&style.DisplayWindowPadding, 0.0f, 30.0f, "%.0f"); SameLine(); HelpMarker("Apply to regular windows: amount which we enforce to keep visible when moving near edges of your screen.");
+ SliderFloat2("DisplaySafeAreaPadding", (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f"); SameLine(); HelpMarker("Apply to every windows, menus, popups, tooltips: amount where we avoid displaying contents. Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).");
- ImGui::EndTabItem();
+ EndTabItem();
}
- if (ImGui::BeginTabItem("Colors"))
+ if (BeginTabItem("Colors"))
{
static int output_dest = 0;
static bool output_only_modified = true;
- if (ImGui::Button("Export"))
+ if (Button("Export"))
{
if (output_dest == 0)
- ImGui::LogToClipboard();
+ LogToClipboard();
else
- ImGui::LogToTTY();
- ImGui::LogText("ImVec4* colors = ImGui::GetStyle().Colors;" IM_NEWLINE);
+ LogToTTY();
+ LogText("ImVec4* colors = GetStyle().Colors;" IM_NEWLINE);
for (int i = 0; i < ImGuiCol_COUNT; i++)
{
const ImVec4& col = style.Colors[i];
- const char* name = ImGui::GetStyleColorName(i);
+ const char* name = GetStyleColorName(i);
if (!output_only_modified || memcmp(&col, &ref->Colors[i], sizeof(ImVec4)) != 0)
- ImGui::LogText("colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE,
+ LogText("colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE,
name, 23 - (int)strlen(name), "", col.x, col.y, col.z, col.w);
}
- ImGui::LogFinish();
+ LogFinish();
}
- ImGui::SameLine(); ImGui::SetNextItemWidth(120); ImGui::Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0");
- ImGui::SameLine(); ImGui::Checkbox("Only Modified Colors", &output_only_modified);
+ SameLine(); SetNextItemWidth(120); Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0");
+ SameLine(); Checkbox("Only Modified Colors", &output_only_modified);
static ImGuiTextFilter filter;
- filter.Draw("Filter colors", ImGui::GetFontSize() * 16);
+ filter.Draw("Filter colors", GetFontSize() * 16);
static ImGuiColorEditFlags alpha_flags = 0;
- if (ImGui::RadioButton("Opaque", alpha_flags == ImGuiColorEditFlags_AlphaOpaque)) { alpha_flags = ImGuiColorEditFlags_AlphaOpaque; } ImGui::SameLine();
- if (ImGui::RadioButton("Alpha", alpha_flags == ImGuiColorEditFlags_None)) { alpha_flags = ImGuiColorEditFlags_None; } ImGui::SameLine();
- if (ImGui::RadioButton("Both", alpha_flags == ImGuiColorEditFlags_AlphaPreviewHalf)) { alpha_flags = ImGuiColorEditFlags_AlphaPreviewHalf; } ImGui::SameLine();
+ if (RadioButton("Opaque", alpha_flags == ImGuiColorEditFlags_AlphaOpaque)) { alpha_flags = ImGuiColorEditFlags_AlphaOpaque; } SameLine();
+ if (RadioButton("Alpha", alpha_flags == ImGuiColorEditFlags_None)) { alpha_flags = ImGuiColorEditFlags_None; } SameLine();
+ if (RadioButton("Both", alpha_flags == ImGuiColorEditFlags_AlphaPreviewHalf)) { alpha_flags = ImGuiColorEditFlags_AlphaPreviewHalf; } SameLine();
HelpMarker(
"In the color list:\n"
"Left-click on color square to open color picker,\n"
"Right-click to open edit options menu.");
- ImGui::SetNextWindowSizeConstraints(ImVec2(0.0f, ImGui::GetTextLineHeightWithSpacing() * 10), ImVec2(FLT_MAX, FLT_MAX));
- ImGui::BeginChild("##colors", ImVec2(0, 0), ImGuiChildFlags_Borders | ImGuiChildFlags_NavFlattened, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar);
- ImGui::PushItemWidth(ImGui::GetFontSize() * -12);
+ SetNextWindowSizeConstraints(ImVec2(0.0f, GetTextLineHeightWithSpacing() * 10), ImVec2(FLT_MAX, FLT_MAX));
+ BeginChild("##colors", ImVec2(0, 0), ImGuiChildFlags_Borders | ImGuiChildFlags_NavFlattened, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar);
+ PushItemWidth(GetFontSize() * -12);
for (int i = 0; i < ImGuiCol_COUNT; i++)
{
- const char* name = ImGui::GetStyleColorName(i);
+ const char* name = GetStyleColorName(i);
if (!filter.PassFilter(name))
continue;
- ImGui::PushID(i);
+ PushID(i);
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
- if (ImGui::Button("?"))
- ImGui::DebugFlashStyleColor((ImGuiCol)i);
- ImGui::SetItemTooltip("Flash given color to identify places where it is used.");
- ImGui::SameLine();
+ if (Button("?"))
+ DebugFlashStyleColor((ImGuiCol)i);
+ SetItemTooltip("Flash given color to identify places where it is used.");
+ SameLine();
#endif
- ImGui::ColorEdit4("##color", (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags);
+ ColorEdit4("##color", (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags);
if (memcmp(&style.Colors[i], &ref->Colors[i], sizeof(ImVec4)) != 0)
{
// Tips: in a real user application, you may want to merge and use an icon font into the main font,
// so instead of "Save"/"Revert" you'd use icons!
// Read the FAQ and docs/FONTS.md about using icon fonts. It's really easy and super convenient!
- ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Save")) { ref->Colors[i] = style.Colors[i]; }
- ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Revert")) { style.Colors[i] = ref->Colors[i]; }
+ SameLine(0.0f, style.ItemInnerSpacing.x); if (Button("Save")) { ref->Colors[i] = style.Colors[i]; }
+ SameLine(0.0f, style.ItemInnerSpacing.x); if (Button("Revert")) { style.Colors[i] = ref->Colors[i]; }
}
- ImGui::SameLine(0.0f, style.ItemInnerSpacing.x);
- ImGui::TextUnformatted(name);
- ImGui::PopID();
+ SameLine(0.0f, style.ItemInnerSpacing.x);
+ TextUnformatted(name);
+ PopID();
}
- ImGui::PopItemWidth();
- ImGui::EndChild();
+ PopItemWidth();
+ EndChild();
- ImGui::EndTabItem();
+ EndTabItem();
}
- if (ImGui::BeginTabItem("Fonts"))
+ if (BeginTabItem("Fonts"))
{
- ImGuiIO& io = ImGui::GetIO();
+ ImGuiIO& io = GetIO();
ImFontAtlas* atlas = io.Fonts;
HelpMarker("Read FAQ and docs/FONTS.md for details on font loading.");
- ImGui::ShowFontAtlas(atlas);
+ ShowFontAtlas(atlas);
// Post-baking font scaling. Note that this is NOT the nice way of scaling fonts, read below.
// (we enforce hard clamping manually as by default DragFloat/SliderFloat allows CTRL+Click text to get out of bounds).
@@ -8452,119 +8453,119 @@
"rebuild the font atlas, and call style.ScaleAllSizes() on a reference ImGuiStyle structure.\n"
"Using those settings here will give you poor quality results.");
static float window_scale = 1.0f;
- ImGui::PushItemWidth(ImGui::GetFontSize() * 8);
- if (ImGui::DragFloat("window scale", &window_scale, 0.005f, MIN_SCALE, MAX_SCALE, "%.2f", ImGuiSliderFlags_AlwaysClamp)) // Scale only this window
- ImGui::SetWindowFontScale(window_scale);
- ImGui::DragFloat("global scale", &io.FontGlobalScale, 0.005f, MIN_SCALE, MAX_SCALE, "%.2f", ImGuiSliderFlags_AlwaysClamp); // Scale everything
- ImGui::PopItemWidth();
+ PushItemWidth(GetFontSize() * 8);
+ if (DragFloat("window scale", &window_scale, 0.005f, MIN_SCALE, MAX_SCALE, "%.2f", ImGuiSliderFlags_AlwaysClamp)) // Scale only this window
+ SetWindowFontScale(window_scale);
+ DragFloat("global scale", &io.FontGlobalScale, 0.005f, MIN_SCALE, MAX_SCALE, "%.2f", ImGuiSliderFlags_AlwaysClamp); // Scale everything
+ PopItemWidth();
- ImGui::EndTabItem();
+ EndTabItem();
}
- if (ImGui::BeginTabItem("Rendering"))
+ if (BeginTabItem("Rendering"))
{
- ImGui::Checkbox("Anti-aliased lines", &style.AntiAliasedLines);
- ImGui::SameLine();
+ Checkbox("Anti-aliased lines", &style.AntiAliasedLines);
+ SameLine();
HelpMarker("When disabling anti-aliasing lines, you'll probably want to disable borders in your style as well.");
- ImGui::Checkbox("Anti-aliased lines use texture", &style.AntiAliasedLinesUseTex);
- ImGui::SameLine();
+ Checkbox("Anti-aliased lines use texture", &style.AntiAliasedLinesUseTex);
+ SameLine();
HelpMarker("Faster lines using texture data. Require backend to render with bilinear filtering (not point/nearest filtering).");
- ImGui::Checkbox("Anti-aliased fill", &style.AntiAliasedFill);
- ImGui::PushItemWidth(ImGui::GetFontSize() * 8);
- ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, 10.0f, "%.2f");
+ Checkbox("Anti-aliased fill", &style.AntiAliasedFill);
+ PushItemWidth(GetFontSize() * 8);
+ DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, 10.0f, "%.2f");
if (style.CurveTessellationTol < 0.10f) style.CurveTessellationTol = 0.10f;
// When editing the "Circle Segment Max Error" value, draw a preview of its effect on auto-tessellated circles.
- ImGui::DragFloat("Circle Tessellation Max Error", &style.CircleTessellationMaxError , 0.005f, 0.10f, 5.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp);
- const bool show_samples = ImGui::IsItemActive();
+ DragFloat("Circle Tessellation Max Error", &style.CircleTessellationMaxError , 0.005f, 0.10f, 5.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp);
+ const bool show_samples = IsItemActive();
if (show_samples)
- ImGui::SetNextWindowPos(ImGui::GetCursorScreenPos());
- if (show_samples && ImGui::BeginTooltip())
+ SetNextWindowPos(GetCursorScreenPos());
+ if (show_samples && BeginTooltip())
{
- ImGui::TextUnformatted("(R = radius, N = approx number of segments)");
- ImGui::Spacing();
- ImDrawList* draw_list = ImGui::GetWindowDrawList();
- const float min_widget_width = ImGui::CalcTextSize("R: MMM\nN: MMM").x;
+ TextUnformatted("(R = radius, N = approx number of segments)");
+ Spacing();
+ ImDrawList* draw_list = GetWindowDrawList();
+ const float min_widget_width = CalcTextSize("R: MMM\nN: MMM").x;
for (int n = 0; n < 8; n++)
{
const float RAD_MIN = 5.0f;
const float RAD_MAX = 70.0f;
const float rad = RAD_MIN + (RAD_MAX - RAD_MIN) * (float)n / (8.0f - 1.0f);
- ImGui::BeginGroup();
+ BeginGroup();
// N is not always exact here due to how PathArcTo() function work internally
- ImGui::Text("R: %.f\nN: %d", rad, draw_list->_CalcCircleAutoSegmentCount(rad));
+ Text("R: %.f\nN: %d", rad, draw_list->_CalcCircleAutoSegmentCount(rad));
const float canvas_width = IM_MAX(min_widget_width, rad * 2.0f);
const float offset_x = floorf(canvas_width * 0.5f);
const float offset_y = floorf(RAD_MAX);
- const ImVec2 p1 = ImGui::GetCursorScreenPos();
- draw_list->AddCircle(ImVec2(p1.x + offset_x, p1.y + offset_y), rad, ImGui::GetColorU32(ImGuiCol_Text));
- ImGui::Dummy(ImVec2(canvas_width, RAD_MAX * 2));
+ const ImVec2 p1 = GetCursorScreenPos();
+ draw_list->AddCircle(ImVec2(p1.x + offset_x, p1.y + offset_y), rad, GetColorU32(ImGuiCol_Text));
+ Dummy(ImVec2(canvas_width, RAD_MAX * 2));
/*
- const ImVec2 p2 = ImGui::GetCursorScreenPos();
- draw_list->AddCircleFilled(ImVec2(p2.x + offset_x, p2.y + offset_y), rad, ImGui::GetColorU32(ImGuiCol_Text));
- ImGui::Dummy(ImVec2(canvas_width, RAD_MAX * 2));
+ const ImVec2 p2 = GetCursorScreenPos();
+ draw_list->AddCircleFilled(ImVec2(p2.x + offset_x, p2.y + offset_y), rad, GetColorU32(ImGuiCol_Text));
+ Dummy(ImVec2(canvas_width, RAD_MAX * 2));
*/
- ImGui::EndGroup();
- ImGui::SameLine();
+ EndGroup();
+ SameLine();
}
- ImGui::EndTooltip();
+ EndTooltip();
}
- ImGui::SameLine();
+ SameLine();
HelpMarker("When drawing circle primitives with \"num_segments == 0\" tessellation will be calculated automatically.");
- ImGui::DragFloat("Global Alpha", &style.Alpha, 0.005f, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero.
- ImGui::DragFloat("Disabled Alpha", &style.DisabledAlpha, 0.005f, 0.0f, 1.0f, "%.2f"); ImGui::SameLine(); HelpMarker("Additional alpha multiplier for disabled items (multiply over current value of Alpha).");
- ImGui::PopItemWidth();
+ DragFloat("Global Alpha", &style.Alpha, 0.005f, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero.
+ DragFloat("Disabled Alpha", &style.DisabledAlpha, 0.005f, 0.0f, 1.0f, "%.2f"); SameLine(); HelpMarker("Additional alpha multiplier for disabled items (multiply over current value of Alpha).");
+ PopItemWidth();
- ImGui::EndTabItem();
+ EndTabItem();
}
- ImGui::EndTabBar();
+ EndTabBar();
}
-
- ImGui::PopItemWidth();
+ PopItemWidth();
}
//-----------------------------------------------------------------------------
// [SECTION] User Guide / ShowUserGuide()
//-----------------------------------------------------------------------------
+// We omit the ImGui:: prefix in this function, as we don't expect user to be copy and pasting this code.
void ImGui::ShowUserGuide()
{
- ImGuiIO& io = ImGui::GetIO();
- ImGui::BulletText("Double-click on title bar to collapse window.");
- ImGui::BulletText(
+ ImGuiIO& io = GetIO();
+ BulletText("Double-click on title bar to collapse window.");
+ BulletText(
"Click and drag on lower corner to resize window\n"
"(double-click to auto fit window to its contents).");
- ImGui::BulletText("CTRL+Click on a slider or drag box to input value as text.");
- ImGui::BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields.");
- ImGui::BulletText("CTRL+Tab to select a window.");
+ BulletText("CTRL+Click on a slider or drag box to input value as text.");
+ BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields.");
+ BulletText("CTRL+Tab to select a window.");
if (io.FontAllowUserScaling)
- ImGui::BulletText("CTRL+Mouse Wheel to zoom window contents.");
- ImGui::BulletText("While inputting text:\n");
- ImGui::Indent();
- ImGui::BulletText("CTRL+Left/Right to word jump.");
- ImGui::BulletText("CTRL+A or double-click to select all.");
- ImGui::BulletText("CTRL+X/C/V to use clipboard cut/copy/paste.");
- ImGui::BulletText("CTRL+Z to undo, CTRL+Y/CTRL+SHIFT+Z to redo.");
- ImGui::BulletText("ESCAPE to revert.");
- ImGui::Unindent();
- ImGui::BulletText("With keyboard navigation enabled:");
- ImGui::Indent();
- ImGui::BulletText("Arrow keys to navigate.");
- ImGui::BulletText("Space to activate a widget.");
- ImGui::BulletText("Return to input text into a widget.");
- ImGui::BulletText("Escape to deactivate a widget, close popup, exit child window.");
- ImGui::BulletText("Alt to jump to the menu layer of a window.");
- ImGui::Unindent();
+ BulletText("CTRL+Mouse Wheel to zoom window contents.");
+ BulletText("While inputting text:\n");
+ Indent();
+ BulletText("CTRL+Left/Right to word jump.");
+ BulletText("CTRL+A or double-click to select all.");
+ BulletText("CTRL+X/C/V to use clipboard cut/copy/paste.");
+ BulletText("CTRL+Z to undo, CTRL+Y/CTRL+SHIFT+Z to redo.");
+ BulletText("ESCAPE to revert.");
+ Unindent();
+ BulletText("With keyboard navigation enabled:");
+ Indent();
+ BulletText("Arrow keys to navigate.");
+ BulletText("Space to activate a widget.");
+ BulletText("Return to input text into a widget.");
+ BulletText("Escape to deactivate a widget, close popup, exit child window.");
+ BulletText("Alt to jump to the menu layer of a window.");
+ Unindent();
}
//-----------------------------------------------------------------------------