mirror of
https://github.com/gwm17/implot.git
synced 2024-11-26 20:28:50 -05:00
Compare commits
3 Commits
d34204b5a7
...
8250340f04
Author | SHA1 | Date | |
---|---|---|---|
8250340f04 | |||
2fcf81af78 | |||
6d3e3bb418 |
29
implot.cpp
29
implot.cpp
|
@ -619,6 +619,7 @@ bool ShowLegendEntries(ImPlotItemGroup& items, const ImRect& legend_bb, bool hov
|
||||||
|
|
||||||
ImRect button_bb(icon_bb.Min, label_bb.Max);
|
ImRect button_bb(icon_bb.Min, label_bb.Max);
|
||||||
|
|
||||||
|
ImGui::KeepAliveID(item->ID);
|
||||||
|
|
||||||
bool item_hov = false;
|
bool item_hov = false;
|
||||||
bool item_hld = false;
|
bool item_hld = false;
|
||||||
|
@ -3684,6 +3685,7 @@ bool DragPoint(int n_id, double* x, double* y, const ImVec4& col, float radius,
|
||||||
ImRect rect(pos.x-grab_half_size,pos.y-grab_half_size,pos.x+grab_half_size,pos.y+grab_half_size);
|
ImRect rect(pos.x-grab_half_size,pos.y-grab_half_size,pos.x+grab_half_size,pos.y+grab_half_size);
|
||||||
bool hovered = false, held = false;
|
bool hovered = false, held = false;
|
||||||
|
|
||||||
|
ImGui::KeepAliveID(id);
|
||||||
if (input)
|
if (input)
|
||||||
ImGui::ButtonBehavior(rect,id,&hovered,&held);
|
ImGui::ButtonBehavior(rect,id,&hovered,&held);
|
||||||
|
|
||||||
|
@ -3728,6 +3730,7 @@ bool DragLineX(int n_id, double* value, const ImVec4& col, float thickness, ImPl
|
||||||
ImRect rect(x-grab_half_size,yt,x+grab_half_size,yb);
|
ImRect rect(x-grab_half_size,yt,x+grab_half_size,yb);
|
||||||
bool hovered = false, held = false;
|
bool hovered = false, held = false;
|
||||||
|
|
||||||
|
ImGui::KeepAliveID(id);
|
||||||
if (input)
|
if (input)
|
||||||
ImGui::ButtonBehavior(rect,id,&hovered,&held);
|
ImGui::ButtonBehavior(rect,id,&hovered,&held);
|
||||||
|
|
||||||
|
@ -3779,6 +3782,7 @@ bool DragLineY(int n_id, double* value, const ImVec4& col, float thickness, ImPl
|
||||||
ImRect rect(xl,y-grab_half_size,xr,y+grab_half_size);
|
ImRect rect(xl,y-grab_half_size,xr,y+grab_half_size);
|
||||||
bool hovered = false, held = false;
|
bool hovered = false, held = false;
|
||||||
|
|
||||||
|
ImGui::KeepAliveID(id);
|
||||||
if (input)
|
if (input)
|
||||||
ImGui::ButtonBehavior(rect,id,&hovered,&held);
|
ImGui::ButtonBehavior(rect,id,&hovered,&held);
|
||||||
|
|
||||||
|
@ -3849,6 +3853,7 @@ bool DragRect(int n_id, double* x_min, double* y_min, double* x_max, double* y_m
|
||||||
bool hovered = false, held = false;
|
bool hovered = false, held = false;
|
||||||
ImRect b_rect(pc.x-DRAG_GRAB_HALF_SIZE,pc.y-DRAG_GRAB_HALF_SIZE,pc.x+DRAG_GRAB_HALF_SIZE,pc.y+DRAG_GRAB_HALF_SIZE);
|
ImRect b_rect(pc.x-DRAG_GRAB_HALF_SIZE,pc.y-DRAG_GRAB_HALF_SIZE,pc.x+DRAG_GRAB_HALF_SIZE,pc.y+DRAG_GRAB_HALF_SIZE);
|
||||||
|
|
||||||
|
ImGui::KeepAliveID(id);
|
||||||
if (input)
|
if (input)
|
||||||
ImGui::ButtonBehavior(b_rect,id,&hovered,&held);
|
ImGui::ButtonBehavior(b_rect,id,&hovered,&held);
|
||||||
|
|
||||||
|
@ -4490,32 +4495,32 @@ ImPlotInputMap& GetInputMap() {
|
||||||
void MapInputDefault(ImPlotInputMap* dst) {
|
void MapInputDefault(ImPlotInputMap* dst) {
|
||||||
ImPlotInputMap& map = dst ? *dst : GetInputMap();
|
ImPlotInputMap& map = dst ? *dst : GetInputMap();
|
||||||
map.Pan = ImGuiMouseButton_Left;
|
map.Pan = ImGuiMouseButton_Left;
|
||||||
map.PanMod = ImGuiKeyModFlags_None;
|
map.PanMod = ImGuiModFlags_None;
|
||||||
map.Fit = ImGuiMouseButton_Left;
|
map.Fit = ImGuiMouseButton_Left;
|
||||||
map.Menu = ImGuiMouseButton_Right;
|
map.Menu = ImGuiMouseButton_Right;
|
||||||
map.Select = ImGuiMouseButton_Right;
|
map.Select = ImGuiMouseButton_Right;
|
||||||
map.SelectMod = ImGuiKeyModFlags_None;
|
map.SelectMod = ImGuiModFlags_None;
|
||||||
map.SelectCancel = ImGuiMouseButton_Left;
|
map.SelectCancel = ImGuiMouseButton_Left;
|
||||||
map.SelectHorzMod = ImGuiKeyModFlags_Alt;
|
map.SelectHorzMod = ImGuiModFlags_Alt;
|
||||||
map.SelectVertMod = ImGuiKeyModFlags_Shift;
|
map.SelectVertMod = ImGuiModFlags_Shift;
|
||||||
map.OverrideMod = ImGuiKeyModFlags_Ctrl;
|
map.OverrideMod = ImGuiModFlags_Ctrl;
|
||||||
map.ZoomMod = ImGuiKeyModFlags_None;
|
map.ZoomMod = ImGuiModFlags_None;
|
||||||
map.ZoomRate = 0.1f;
|
map.ZoomRate = 0.1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapInputReverse(ImPlotInputMap* dst) {
|
void MapInputReverse(ImPlotInputMap* dst) {
|
||||||
ImPlotInputMap& map = dst ? *dst : GetInputMap();
|
ImPlotInputMap& map = dst ? *dst : GetInputMap();
|
||||||
map.Pan = ImGuiMouseButton_Right;
|
map.Pan = ImGuiMouseButton_Right;
|
||||||
map.PanMod = ImGuiKeyModFlags_None;
|
map.PanMod = ImGuiModFlags_None;
|
||||||
map.Fit = ImGuiMouseButton_Left;
|
map.Fit = ImGuiMouseButton_Left;
|
||||||
map.Menu = ImGuiMouseButton_Right;
|
map.Menu = ImGuiMouseButton_Right;
|
||||||
map.Select = ImGuiMouseButton_Left;
|
map.Select = ImGuiMouseButton_Left;
|
||||||
map.SelectMod = ImGuiKeyModFlags_None;
|
map.SelectMod = ImGuiModFlags_None;
|
||||||
map.SelectCancel = ImGuiMouseButton_Right;
|
map.SelectCancel = ImGuiMouseButton_Right;
|
||||||
map.SelectHorzMod = ImGuiKeyModFlags_Alt;
|
map.SelectHorzMod = ImGuiModFlags_Alt;
|
||||||
map.SelectVertMod = ImGuiKeyModFlags_Shift;
|
map.SelectVertMod = ImGuiModFlags_Shift;
|
||||||
map.OverrideMod = ImGuiKeyModFlags_Ctrl;
|
map.OverrideMod = ImGuiModFlags_Ctrl;
|
||||||
map.ZoomMod = ImGuiKeyModFlags_None;
|
map.ZoomMod = ImGuiModFlags_None;
|
||||||
map.ZoomRate = 0.1f;
|
map.ZoomRate = 0.1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
implot.h
14
implot.h
|
@ -397,16 +397,16 @@ struct ImPlotStyle {
|
||||||
// Input mapping structure. Default values listed. See also MapInputDefault, MapInputReverse.
|
// Input mapping structure. Default values listed. See also MapInputDefault, MapInputReverse.
|
||||||
struct ImPlotInputMap {
|
struct ImPlotInputMap {
|
||||||
ImGuiMouseButton Pan; // LMB enables panning when held,
|
ImGuiMouseButton Pan; // LMB enables panning when held,
|
||||||
ImGuiKeyModFlags PanMod; // none optional modifier that must be held for panning/fitting
|
ImGuiModFlags PanMod; // none optional modifier that must be held for panning/fitting
|
||||||
ImGuiMouseButton Fit; // LMB initiates fit when double clicked
|
ImGuiMouseButton Fit; // LMB initiates fit when double clicked
|
||||||
ImGuiMouseButton Select; // RMB begins box selection when pressed and confirms selection when released
|
ImGuiMouseButton Select; // RMB begins box selection when pressed and confirms selection when released
|
||||||
ImGuiMouseButton SelectCancel; // LMB cancels active box selection when pressed; cannot be same as Select
|
ImGuiMouseButton SelectCancel; // LMB cancels active box selection when pressed; cannot be same as Select
|
||||||
ImGuiKeyModFlags SelectMod; // none optional modifier that must be held for box selection
|
ImGuiModFlags SelectMod; // none optional modifier that must be held for box selection
|
||||||
ImGuiKeyModFlags SelectHorzMod; // Alt expands active box selection horizontally to plot edge when held
|
ImGuiModFlags SelectHorzMod; // Alt expands active box selection horizontally to plot edge when held
|
||||||
ImGuiKeyModFlags SelectVertMod; // Shift expands active box selection vertically to plot edge when held
|
ImGuiModFlags SelectVertMod; // Shift expands active box selection vertically to plot edge when held
|
||||||
ImGuiMouseButton Menu; // RMB opens context menus (if enabled) when clicked
|
ImGuiMouseButton Menu; // RMB opens context menus (if enabled) when clicked
|
||||||
ImGuiKeyModFlags OverrideMod; // Ctrl when held, all input is ignored; used to enable axis/plots as DND sources
|
ImGuiModFlags OverrideMod; // Ctrl when held, all input is ignored; used to enable axis/plots as DND sources
|
||||||
ImGuiKeyModFlags ZoomMod; // none optional modifier that must be held for scroll wheel zooming
|
ImGuiModFlags ZoomMod; // none optional modifier that must be held for scroll wheel zooming
|
||||||
float ZoomRate; // 0.1f zoom rate for scroll (e.g. 0.1f = 10% plot range every scroll click); make negative to invert
|
float ZoomRate; // 0.1f zoom rate for scroll (e.g. 0.1f = 10% plot range every scroll click); make negative to invert
|
||||||
IMPLOT_API ImPlotInputMap();
|
IMPLOT_API ImPlotInputMap();
|
||||||
};
|
};
|
||||||
|
@ -863,7 +863,7 @@ IMPLOT_API bool BeginDragDropTargetLegend();
|
||||||
IMPLOT_API void EndDragDropTarget();
|
IMPLOT_API void EndDragDropTarget();
|
||||||
|
|
||||||
// NB: By default, plot and axes drag and drop *sources* require holding the Ctrl modifier to initiate the drag.
|
// NB: By default, plot and axes drag and drop *sources* require holding the Ctrl modifier to initiate the drag.
|
||||||
// You can change the modifier if desired. If ImGuiKeyModFlags_None is provided, the axes will be locked from panning.
|
// You can change the modifier if desired. If ImGuiModFlags_None is provided, the axes will be locked from panning.
|
||||||
|
|
||||||
// Turns the current plot's plotting area into a drag and drop source. You must hold Ctrl. Don't forget to call EndDragDropSource!
|
// Turns the current plot's plotting area into a drag and drop source. You must hold Ctrl. Don't forget to call EndDragDropSource!
|
||||||
IMPLOT_API bool BeginDragDropSourcePlot(ImGuiDragDropFlags flags = 0);
|
IMPLOT_API bool BeginDragDropSourcePlot(ImGuiDragDropFlags flags = 0);
|
||||||
|
|
|
@ -226,16 +226,16 @@ void ButtonSelector(const char* label, ImGuiMouseButton* b) {
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModSelector(const char* label, ImGuiKeyModFlags* k) {
|
void ModSelector(const char* label, ImGuiModFlags* k) {
|
||||||
ImGui::PushID(label);
|
ImGui::PushID(label);
|
||||||
ImGui::CheckboxFlags("Ctrl", (unsigned int*)k, ImGuiKeyModFlags_Ctrl); ImGui::SameLine();
|
ImGui::CheckboxFlags("Ctrl", (unsigned int*)k, ImGuiModFlags_Ctrl); ImGui::SameLine();
|
||||||
ImGui::CheckboxFlags("Shift", (unsigned int*)k, ImGuiKeyModFlags_Shift); ImGui::SameLine();
|
ImGui::CheckboxFlags("Shift", (unsigned int*)k, ImGuiModFlags_Shift); ImGui::SameLine();
|
||||||
ImGui::CheckboxFlags("Alt", (unsigned int*)k, ImGuiKeyModFlags_Alt); ImGui::SameLine();
|
ImGui::CheckboxFlags("Alt", (unsigned int*)k, ImGuiModFlags_Alt); ImGui::SameLine();
|
||||||
ImGui::CheckboxFlags("Super", (unsigned int*)k, ImGuiKeyModFlags_Super);
|
ImGui::CheckboxFlags("Super", (unsigned int*)k, ImGuiModFlags_Super);
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputMapping(const char* label, ImGuiMouseButton* b, ImGuiKeyModFlags* k) {
|
void InputMapping(const char* label, ImGuiMouseButton* b, ImGuiModFlags* k) {
|
||||||
ImGui::LabelText("##","%s",label);
|
ImGui::LabelText("##","%s",label);
|
||||||
if (b != NULL) {
|
if (b != NULL) {
|
||||||
ImGui::SameLine(100);
|
ImGui::SameLine(100);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user