ImPlotFlags_Crosshairs enables legend after disabling it
- Dominant language
- C++
- Stars
- 6.2k
- Forks
- 693
- PR merge metrics
- No merged PRs in 30d
Description
In the below code, if you right click the plot and disable the Legend, adding the `ImPlotFlags_Crosshairs` flag re-enables the Legend icon. I am just wondering if this is a bug or is there a work-around so that I can simply right click to disable the legend and it re-enable in the same way.
```
#include
#ifndef GLFW_INCLUDE_NONE
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
#endif // GLFW_INCLUDE_NONE
#include
#include "ImGui/imgui.h"
#include "ImGui/implot.h"
#include "ImGui/implot_internal.h"
#include "ImGui/imgui_impl_glfw.h"
#include "ImGui/imgui_impl_opengl3.h"
int main(int argc, char* argv[])
{
glfwInit();
GLFWwindow* window = glfwCreateWindow(1280, 720, "Program", NULL, NULL);
glfwMakeContextCurrent(window);
glfwSwapInterval(0); // vsync
glewInit();
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImPlot::CreateContext();
ImGui::StyleColorsDark();
ImPlotStyle& ImPlot_Style = ImPlot::GetStyle();
ImPlot_Style.UseLocalTime = true;
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init("#version 460");
ImPlotFlags flags = ImPlotFlags_None;
double xs[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
double ys[] = { 1, 4, 9, 16, 25, 36, 49, 64, 81, 100 };
while (!glfwWindowShouldClose(window))
{
glfwPollEvents();
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
if (ImPlot::BeginPlot("Plot", nullptr, nullptr, { -1, 0 }, flags)) {
ImPlot::PlotLine("Line", xs, ys, 10);
ImPlot::EndPlot();
}
if (ImGui::Button("Add crosshair")) {
flags |= ImPlotFlags_Crosshairs;
}
if (ImGui::Button("Remove crosshair")) {
flags &= ~ImPlotFlags_Crosshairs;
}
ImGui::Render();
glClearColor(0.45f, 0.55f, 0.60f, 1.00f);
glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
glfwSwapBuffers(window);
}
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImPlot::DestroyContext();
ImGui::DestroyContext();
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.