1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-11-26 20:28:50 -05:00

simplify legend demo

This commit is contained in:
epezent 2020-10-19 18:11:38 -05:00
parent 42d93bcdbc
commit eb935d0b4f

View File

@ -814,22 +814,15 @@ void ShowDemoWindow(bool* p_open) {
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
if (ImGui::CollapsingHeader("Legend")) { if (ImGui::CollapsingHeader("Legend")) {
static bool n = false; static bool s = false; static bool w = false; static bool e = true; static ImPlotLocation loc = ImPlotLocation_East;
static bool h = false; static bool o = true; static bool h = false; static bool o = true;
ImGui::CheckboxFlags("North", (unsigned int*)&loc, ImPlotLocation_North); ImGui::SameLine();
ImGui::Checkbox("North", &n); ImGui::SameLine(); ImGui::CheckboxFlags("South", (unsigned int*)&loc, ImPlotLocation_South); ImGui::SameLine();
ImGui::Checkbox("South", &s); ImGui::SameLine(); ImGui::CheckboxFlags("West", (unsigned int*)&loc, ImPlotLocation_West); ImGui::SameLine();
ImGui::Checkbox("West", &w); ImGui::SameLine(); ImGui::CheckboxFlags("East", (unsigned int*)&loc, ImPlotLocation_East); ImGui::SameLine();
ImGui::Checkbox("East", &e); ImGui::SameLine();
ImGui::Checkbox("Horizontal", &h); ImGui::SameLine(); ImGui::Checkbox("Horizontal", &h); ImGui::SameLine();
ImGui::Checkbox("Outside", &o); ImGui::Checkbox("Outside", &o);
ImPlotLocation loc = 0;
loc = n ? loc | ImPlotLocation_North : loc;
loc = s ? loc | ImPlotLocation_South : loc;
loc = w ? loc | ImPlotLocation_West : loc;
loc = e ? loc | ImPlotLocation_East : loc;
ImGui::SliderFloat2("LegendPadding", (float*)&GetStyle().LegendPadding, 0.0f, 20.0f, "%.0f"); ImGui::SliderFloat2("LegendPadding", (float*)&GetStyle().LegendPadding, 0.0f, 20.0f, "%.0f");
ImGui::SliderFloat2("LegendInnerPadding", (float*)&GetStyle().LegendInnerPadding, 0.0f, 10.0f, "%.0f"); ImGui::SliderFloat2("LegendInnerPadding", (float*)&GetStyle().LegendInnerPadding, 0.0f, 10.0f, "%.0f");
ImGui::SliderFloat2("LegendSpacing", (float*)&GetStyle().LegendSpacing, 0.0f, 5.0f, "%.0f"); ImGui::SliderFloat2("LegendSpacing", (float*)&GetStyle().LegendSpacing, 0.0f, 5.0f, "%.0f");