Added basic sizes edition in the style editor

docking
ocornut 11 years ago
parent 05f0993616
commit 6062d18cf9

@ -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::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::RadioButton("HSV", &edit_mode, ImGuiColorEditMode_HSV); ImGui::SliderFloat2("WindowPadding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f");
ImGui::SameLine(); ImGui::SliderFloat("WindowRounding", &style.WindowRounding, 0.0f, 16.0f, "%.0f");
ImGui::RadioButton("HEX", &edit_mode, ImGuiColorEditMode_HEX); ImGui::SliderFloat2("FramePadding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f");
ImGui::SliderFloat2("ItemSpacing", (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f");
static ImGuiTextFilter filter; ImGui::SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f");
filter.Draw("Filter colors", 200); ImGui::SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 20.0f, "%.0f");
ImGui::SliderFloat("TreeNodeSpacing", &style.TreeNodeSpacing, 0.0f, 20.0f, "%.0f");
ImGui::SliderFloat("ScrollBarWidth", &style.ScrollBarWidth, 0.0f, 20.0f, "%.0f");
ImGui::TreePop();
}
ImGui::ColorEditMode(edit_mode); if (ImGui::TreeNode("Colors"))
for (int i = 0; i < ImGuiCol_COUNT; i++)
{ {
const char* name = GetStyleColorName(i); static ImGuiColorEditMode edit_mode = ImGuiColorEditMode_RGB;
if (!filter.PassFilter(name)) ImGui::RadioButton("RGB", &edit_mode, ImGuiColorEditMode_RGB);
continue; ImGui::SameLine();
ImGui::PushID(i); ImGui::RadioButton("HSV", &edit_mode, ImGuiColorEditMode_HSV);
ImGui::ColorEdit4(name, (float*)&style.Colors[i], true); ImGui::SameLine();
if (memcmp(&style.Colors[i], (ref ? &ref->Colors[i] : &def.Colors[i]), sizeof(ImVec4)) != 0) 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++)
{ {
ImGui::SameLine(); if (ImGui::Button("Revert")) style.Colors[i] = ref ? ref->Colors[i] : def.Colors[i]; const char* name = GetStyleColorName(i);
if (ref) { ImGui::SameLine(); if (ImGui::Button("Save")) ref->Colors[i] = style.Colors[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::PopID(); ImGui::TreePop();
} }
ImGui::PopItemWidth();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

Loading…
Cancel
Save