mirror of
https://github.com/Drezil/imgui.git
synced 2025-03-31 00:12:44 +00:00
Added basic sizes edition in the style editor
This commit is contained in:
parent
05f0993616
commit
6062d18cf9
71
imgui.cpp
71
imgui.cpp
@ -2344,7 +2344,7 @@ const char* GetStyleColorName(ImGuiCol idx)
|
|||||||
case ImGuiCol_PlotLines: return "PlotLines";
|
case ImGuiCol_PlotLines: return "PlotLines";
|
||||||
case ImGuiCol_PlotLinesHovered: return "PlotLinesHovered";
|
case ImGuiCol_PlotLinesHovered: return "PlotLinesHovered";
|
||||||
case ImGuiCol_PlotHistogram: return "PlotHistogram";
|
case ImGuiCol_PlotHistogram: return "PlotHistogram";
|
||||||
case ImGuiCol_PlotHistogramHovered: return "ImGuiCol_PlotHistogramHovered";
|
case ImGuiCol_PlotHistogramHovered: return "PlotHistogramHovered";
|
||||||
case ImGuiCol_TextSelectedBg: return "TextSelectedBg";
|
case ImGuiCol_TextSelectedBg: return "TextSelectedBg";
|
||||||
case ImGuiCol_TooltipBg: return "TooltipBg";
|
case ImGuiCol_TooltipBg: return "TooltipBg";
|
||||||
}
|
}
|
||||||
@ -5413,34 +5413,53 @@ void ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
*ref = g.Style;
|
*ref = g.Style;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SliderFloat("Alpha", &style.Alpha, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI. But application code could have a toggle to switch between zero and non-zero.
|
ImGui::PushItemWidth(ImGui::GetWindowWidth()*0.55f);
|
||||||
ImGui::SliderFloat("Rounding", &style.WindowRounding, 0.0f, 16.0f, "%.0f");
|
|
||||||
|
|
||||||
static ImGuiColorEditMode edit_mode = ImGuiColorEditMode_RGB;
|
if (ImGui::TreeNode("Sizes"))
|
||||||
ImGui::RadioButton("RGB", &edit_mode, ImGuiColorEditMode_RGB);
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::RadioButton("HSV", &edit_mode, ImGuiColorEditMode_HSV);
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::RadioButton("HEX", &edit_mode, ImGuiColorEditMode_HEX);
|
|
||||||
|
|
||||||
static ImGuiTextFilter filter;
|
|
||||||
filter.Draw("Filter colors", 200);
|
|
||||||
|
|
||||||
ImGui::ColorEditMode(edit_mode);
|
|
||||||
for (int i = 0; i < ImGuiCol_COUNT; i++)
|
|
||||||
{
|
{
|
||||||
const char* name = GetStyleColorName(i);
|
ImGui::SliderFloat("Alpha", &style.Alpha, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI. But application code could have a toggle to switch between zero and non-zero.
|
||||||
if (!filter.PassFilter(name))
|
ImGui::SliderFloat2("WindowPadding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f");
|
||||||
continue;
|
ImGui::SliderFloat("WindowRounding", &style.WindowRounding, 0.0f, 16.0f, "%.0f");
|
||||||
ImGui::PushID(i);
|
ImGui::SliderFloat2("FramePadding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f");
|
||||||
ImGui::ColorEdit4(name, (float*)&style.Colors[i], true);
|
ImGui::SliderFloat2("ItemSpacing", (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f");
|
||||||
if (memcmp(&style.Colors[i], (ref ? &ref->Colors[i] : &def.Colors[i]), sizeof(ImVec4)) != 0)
|
ImGui::SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f");
|
||||||
{
|
ImGui::SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 20.0f, "%.0f");
|
||||||
ImGui::SameLine(); if (ImGui::Button("Revert")) style.Colors[i] = ref ? ref->Colors[i] : def.Colors[i];
|
ImGui::SliderFloat("TreeNodeSpacing", &style.TreeNodeSpacing, 0.0f, 20.0f, "%.0f");
|
||||||
if (ref) { ImGui::SameLine(); if (ImGui::Button("Save")) ref->Colors[i] = style.Colors[i]; }
|
ImGui::SliderFloat("ScrollBarWidth", &style.ScrollBarWidth, 0.0f, 20.0f, "%.0f");
|
||||||
}
|
ImGui::TreePop();
|
||||||
ImGui::PopID();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGui::TreeNode("Colors"))
|
||||||
|
{
|
||||||
|
static ImGuiColorEditMode edit_mode = ImGuiColorEditMode_RGB;
|
||||||
|
ImGui::RadioButton("RGB", &edit_mode, ImGuiColorEditMode_RGB);
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::RadioButton("HSV", &edit_mode, ImGuiColorEditMode_HSV);
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::RadioButton("HEX", &edit_mode, ImGuiColorEditMode_HEX);
|
||||||
|
|
||||||
|
static ImGuiTextFilter filter;
|
||||||
|
filter.Draw("Filter colors", 200);
|
||||||
|
|
||||||
|
ImGui::ColorEditMode(edit_mode);
|
||||||
|
for (int i = 0; i < ImGuiCol_COUNT; i++)
|
||||||
|
{
|
||||||
|
const char* name = GetStyleColorName(i);
|
||||||
|
if (!filter.PassFilter(name))
|
||||||
|
continue;
|
||||||
|
ImGui::PushID(i);
|
||||||
|
ImGui::ColorEdit4(name, (float*)&style.Colors[i], true);
|
||||||
|
if (memcmp(&style.Colors[i], (ref ? &ref->Colors[i] : &def.Colors[i]), sizeof(ImVec4)) != 0)
|
||||||
|
{
|
||||||
|
ImGui::SameLine(); if (ImGui::Button("Revert")) style.Colors[i] = ref ? ref->Colors[i] : def.Colors[i];
|
||||||
|
if (ref) { ImGui::SameLine(); if (ImGui::Button("Save")) ref->Colors[i] = style.Colors[i]; }
|
||||||
|
}
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::PopItemWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user