mirror of
https://github.com/gwm17/implot.git
synced 2024-11-22 18:28:53 -05:00
add legend ctx menu, rev up to 0.9
This commit is contained in:
parent
ad29c9a046
commit
48c0d6fe38
44
implot.cpp
44
implot.cpp
|
@ -20,7 +20,7 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// ImPlot v0.8 WIP
|
||||
// ImPlot v0.9 WIP
|
||||
|
||||
/*
|
||||
|
||||
|
@ -2010,21 +2010,39 @@ void ShowPlotContextMenu(ImPlotPlot& plot) {
|
|||
|
||||
ImGui::Separator();
|
||||
if ((ImGui::BeginMenu("Settings"))) {
|
||||
if (ImGui::MenuItem("Box Select",NULL,!ImHasFlag(plot.Flags, ImPlotFlags_NoBoxSelect))) {
|
||||
ImFlipFlag(plot.Flags, ImPlotFlags_NoBoxSelect);
|
||||
if (ImGui::MenuItem("Title",NULL,!ImHasFlag(plot.Flags, ImPlotFlags_NoTitle)))
|
||||
ImFlipFlag(plot.Flags, ImPlotFlags_NoTitle);
|
||||
if ((ImGui::BeginMenu("Legend"))) {
|
||||
const float s = ImGui::GetFrameHeight();
|
||||
if (ImGui::RadioButton("H", plot.LegendOrientation == ImPlotOrientation_Horizontal))
|
||||
plot.LegendOrientation = ImPlotOrientation_Horizontal;
|
||||
ImGui::SameLine();
|
||||
if (ImGui::RadioButton("V", plot.LegendOrientation == ImPlotOrientation_Vertical))
|
||||
plot.LegendOrientation = ImPlotOrientation_Vertical;
|
||||
ImGui::Checkbox("Outside", &plot.LegendOutside);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(1,1));
|
||||
if (ImGui::Button("##NW",ImVec2(1.5f*s,s))) plot.LegendLocation = ImPlotLocation_NorthWest; ImGui::SameLine();
|
||||
if (ImGui::Button("##N", ImVec2(1.5f*s,s))) plot.LegendLocation = ImPlotLocation_North; ImGui::SameLine();
|
||||
if (ImGui::Button("##NE",ImVec2(1.5f*s,s))) plot.LegendLocation = ImPlotLocation_NorthEast;
|
||||
if (ImGui::Button("##W", ImVec2(1.5f*s,s))) plot.LegendLocation = ImPlotLocation_West; ImGui::SameLine();
|
||||
if (ImGui::Button("##C", ImVec2(1.5f*s,s))) plot.LegendLocation = ImPlotLocation_Center; ImGui::SameLine();
|
||||
if (ImGui::Button("##E", ImVec2(1.5f*s,s))) plot.LegendLocation = ImPlotLocation_East;
|
||||
if (ImGui::Button("##SW",ImVec2(1.5f*s,s))) plot.LegendLocation = ImPlotLocation_SouthWest; ImGui::SameLine();
|
||||
if (ImGui::Button("##S", ImVec2(1.5f*s,s))) plot.LegendLocation = ImPlotLocation_South; ImGui::SameLine();
|
||||
if (ImGui::Button("##SE",ImVec2(1.5f*s,s))) plot.LegendLocation = ImPlotLocation_SouthEast;
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::MenuItem("Query",NULL,ImHasFlag(plot.Flags, ImPlotFlags_Query))) {
|
||||
ImFlipFlag(plot.Flags, ImPlotFlags_Query);
|
||||
}
|
||||
if (ImGui::MenuItem("Crosshairs",NULL,ImHasFlag(plot.Flags, ImPlotFlags_Crosshairs))) {
|
||||
ImFlipFlag(plot.Flags, ImPlotFlags_Crosshairs);
|
||||
}
|
||||
if (ImGui::MenuItem("Mouse Position",NULL,!ImHasFlag(plot.Flags, ImPlotFlags_NoMousePos))) {
|
||||
if (ImGui::MenuItem("Mouse Position",NULL,!ImHasFlag(plot.Flags, ImPlotFlags_NoMousePos)))
|
||||
ImFlipFlag(plot.Flags, ImPlotFlags_NoMousePos);
|
||||
}
|
||||
if (ImGui::MenuItem("Anti-Aliased Lines",NULL,ImHasFlag(plot.Flags, ImPlotFlags_AntiAliased))) {
|
||||
if (ImGui::MenuItem("Crosshairs",NULL,ImHasFlag(plot.Flags, ImPlotFlags_Crosshairs)))
|
||||
ImFlipFlag(plot.Flags, ImPlotFlags_Crosshairs);
|
||||
if (ImGui::MenuItem("Box Select",NULL,!ImHasFlag(plot.Flags, ImPlotFlags_NoBoxSelect)))
|
||||
ImFlipFlag(plot.Flags, ImPlotFlags_NoBoxSelect);
|
||||
if (ImGui::MenuItem("Query",NULL,ImHasFlag(plot.Flags, ImPlotFlags_Query)))
|
||||
ImFlipFlag(plot.Flags, ImPlotFlags_Query);
|
||||
if (ImGui::MenuItem("Anti-Aliased Lines",NULL,ImHasFlag(plot.Flags, ImPlotFlags_AntiAliased)))
|
||||
ImFlipFlag(plot.Flags, ImPlotFlags_AntiAliased);
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::MenuItem("Legend",NULL,!ImHasFlag(plot.Flags, ImPlotFlags_NoLegend))) {
|
||||
|
|
30
implot.h
30
implot.h
|
@ -20,7 +20,7 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// ImPlot v0.8 WIP
|
||||
// ImPlot v0.9 WIP
|
||||
|
||||
#pragma once
|
||||
#include "imgui.h"
|
||||
|
@ -38,7 +38,7 @@
|
|||
#endif
|
||||
|
||||
// ImPlot version string
|
||||
#define IMPLOT_VERSION "0.8 WIP"
|
||||
#define IMPLOT_VERSION "0.9 WIP"
|
||||
// Indicates variable should deduced automatically.
|
||||
#define IMPLOT_AUTO -1
|
||||
// Special color used to indicate that a color should be deduced automatically.
|
||||
|
@ -65,19 +65,19 @@ typedef int ImPlotYAxis; // -> enum ImPlotYAxis_;
|
|||
// Options for plots.
|
||||
enum ImPlotFlags_ {
|
||||
ImPlotFlags_None = 0, // default
|
||||
ImPlotFlags_NoLegend = 1 << 0, // the top-left legend will not be displayed
|
||||
ImPlotFlags_NoMenus = 1 << 1, // the user will not be able to open context menus with double-right click
|
||||
ImPlotFlags_NoBoxSelect = 1 << 2, // the user will not be able to box-select with right-mouse
|
||||
ImPlotFlags_NoMousePos = 1 << 3, // the mouse position, in plot coordinates, will not be displayed inside of the plot
|
||||
ImPlotFlags_NoHighlight = 1 << 4, // plot items will not be highlighted when their legend entry is hovered
|
||||
ImPlotFlags_NoChild = 1 << 5, // a child window region will not be used to capture mouse scroll (can boost performance for single ImGui window applications)
|
||||
ImPlotFlags_YAxis2 = 1 << 6, // enable a 2nd y-axis on the right side
|
||||
ImPlotFlags_YAxis3 = 1 << 7, // enable a 3rd y-axis on the right side
|
||||
ImPlotFlags_Query = 1 << 8, // the user will be able to draw query rects with middle-mouse
|
||||
ImPlotFlags_Crosshairs = 1 << 9, // the default mouse cursor will be replaced with a crosshair when hovered
|
||||
ImPlotFlags_AntiAliased = 1 << 10, // plot lines will be software anti-aliased (not recommended for density plots, prefer MSAA)
|
||||
ImPlotFlags_NoTitle = 1 << 11, // Removes the title from the plot
|
||||
ImPlotFlags_CanvasOnly = ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect | ImPlotFlags_NoMousePos
|
||||
ImPlotFlags_NoTitle = 1 << 0, // the plot title will not be displayed (titles are also hidden if preceeded by double hashes, e.g. "##MyPlot")
|
||||
ImPlotFlags_NoLegend = 1 << 1, // the legend will not be displayed
|
||||
ImPlotFlags_NoMenus = 1 << 2, // the user will not be able to open context menus with double-right click
|
||||
ImPlotFlags_NoBoxSelect = 1 << 3, // the user will not be able to box-select with right-mouse
|
||||
ImPlotFlags_NoMousePos = 1 << 4, // the mouse position, in plot coordinates, will not be displayed inside of the plot
|
||||
ImPlotFlags_NoHighlight = 1 << 5, // plot items will not be highlighted when their legend entry is hovered
|
||||
ImPlotFlags_NoChild = 1 << 6, // a child window region will not be used to capture mouse scroll (can boost performance for single ImGui window applications)
|
||||
ImPlotFlags_YAxis2 = 1 << 7, // enable a 2nd y-axis on the right side
|
||||
ImPlotFlags_YAxis3 = 1 << 8, // enable a 3rd y-axis on the right side
|
||||
ImPlotFlags_Query = 1 << 9, // the user will be able to draw query rects with middle-mouse
|
||||
ImPlotFlags_Crosshairs = 1 << 10, // the default mouse cursor will be replaced with a crosshair when hovered
|
||||
ImPlotFlags_AntiAliased = 1 << 11, // plot lines will be software anti-aliased (not recommended for density plots, prefer MSAA)
|
||||
ImPlotFlags_CanvasOnly = ImPlotFlags_NoTitle | ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect | ImPlotFlags_NoMousePos
|
||||
};
|
||||
|
||||
// Options for plot axes (X and Y).
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// ImPlot v0.8 WIP
|
||||
// ImPlot v0.9 WIP
|
||||
|
||||
#include "implot.h"
|
||||
#include <math.h>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// ImPlot v0.8 WIP
|
||||
// ImPlot v0.9 WIP
|
||||
|
||||
// You may use this file to debug, understand or extend ImPlot features but we
|
||||
// don't provide any guarantee of forward compatibility!
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// ImPlot v0.8 WIP
|
||||
// ImPlot v0.9 WIP
|
||||
|
||||
#include "implot.h"
|
||||
#include "implot_internal.h"
|
||||
|
|
Loading…
Reference in New Issue
Block a user