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

edit custom popups demo

This commit is contained in:
epezent 2020-09-01 01:35:36 -05:00
parent 9e82be5bff
commit b74accfb59

View File

@ -1051,9 +1051,11 @@ void ShowDemoWindow(bool* p_open) {
static float frequency = 0.1; static float frequency = 0.1;
static float amplitude = 0.5f; static float amplitude = 0.5f;
static ImVec4 color = ImVec4(1,1,0,1); static ImVec4 color = ImVec4(1,1,0,1);
static float alpha = 1.0f;
static bool line = false; static bool line = false;
static float thickness = 1; static float thickness = 1;
static bool markers = false; static bool markers = false;
static bool shaded = false;
static t_float vals[101]; static t_float vals[101];
for (int i = 0; i < 101; ++i) for (int i = 0; i < 101; ++i)
@ -1061,6 +1063,8 @@ void ShowDemoWindow(bool* p_open) {
ImPlot::SetNextPlotLimits(0,100,-1,1); ImPlot::SetNextPlotLimits(0,100,-1,1);
if (ImPlot::BeginPlot("Right Click the Legend")) { if (ImPlot::BeginPlot("Right Click the Legend")) {
// rendering logic
ImPlot::PushStyleVar(ImPlotStyleVar_FillAlpha, alpha);
if (!line) { if (!line) {
ImPlot::SetNextFillStyle(color); ImPlot::SetNextFillStyle(color);
ImPlot::PlotBars("Right Click Me", vals, 101); ImPlot::PlotBars("Right Click Me", vals, 101);
@ -1069,17 +1073,21 @@ void ShowDemoWindow(bool* p_open) {
if (markers) ImPlot::SetNextMarkerStyle(ImPlotMarker_Circle); if (markers) ImPlot::SetNextMarkerStyle(ImPlotMarker_Circle);
ImPlot::SetNextLineStyle(color, thickness); ImPlot::SetNextLineStyle(color, thickness);
ImPlot::PlotLine("Right Click Me", vals, 101); ImPlot::PlotLine("Right Click Me", vals, 101);
if (shaded) ImPlot::PlotShaded("Right Click Me",vals,101);
} }
ImPlot::PopStyleVar();
// custom legend context menu // custom legend context menu
if (ImPlot::BeginLegendPopup("Right Click Me")) { if (ImPlot::BeginLegendPopup("Right Click Me")) {
ImGui::DragFloat("Frequency",&frequency,0.01f,0,1); ImGui::SliderFloat("Frequency",&frequency,0,1,"%0.2f");
ImGui::DragFloat("Amplitude",&amplitude,0.01f,0,1); ImGui::SliderFloat("Amplitude",&amplitude,0,1,"%0.2f");
ImGui::Separator(); ImGui::Separator();
ImGui::ColorEdit4("Color",&color.x); ImGui::ColorEdit3("Color",&color.x);
ImGui::Checkbox("Line Graph", &line); ImGui::SliderFloat("Transparency",&alpha,0,1,"%.2f");
ImGui::Checkbox("Line Plot", &line);
if (line) { if (line) {
ImGui::DragFloat("Thickness", &thickness, 0.1f, 0, 5); ImGui::SliderFloat("Thickness", &thickness, 0, 5);
ImGui::Checkbox("Markers", &markers); ImGui::Checkbox("Markers", &markers);
ImGui::Checkbox("Shaded",&shaded);
} }
ImPlot::EndLegendPopup(); ImPlot::EndLegendPopup();
} }