Skip to content

Commit 626e391

Browse files
authored
Fixes for ImGuiModFlags_XXX -> ImGuiMod_XXX (v1.89) (#347) (#407)
Sorry!
1 parent 8879c99 commit 626e391

File tree

3 files changed

+37
-31
lines changed

3 files changed

+37
-31
lines changed

implot.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4635,32 +4635,32 @@ ImPlotInputMap& GetInputMap() {
46354635
void MapInputDefault(ImPlotInputMap* dst) {
46364636
ImPlotInputMap& map = dst ? *dst : GetInputMap();
46374637
map.Pan = ImGuiMouseButton_Left;
4638-
map.PanMod = ImGuiModFlags_None;
4638+
map.PanMod = ImGuiMod_None;
46394639
map.Fit = ImGuiMouseButton_Left;
46404640
map.Menu = ImGuiMouseButton_Right;
46414641
map.Select = ImGuiMouseButton_Right;
4642-
map.SelectMod = ImGuiModFlags_None;
4642+
map.SelectMod = ImGuiMod_None;
46434643
map.SelectCancel = ImGuiMouseButton_Left;
4644-
map.SelectHorzMod = ImGuiModFlags_Alt;
4645-
map.SelectVertMod = ImGuiModFlags_Shift;
4646-
map.OverrideMod = ImGuiModFlags_Ctrl;
4647-
map.ZoomMod = ImGuiModFlags_None;
4644+
map.SelectHorzMod = ImGuiMod_Alt;
4645+
map.SelectVertMod = ImGuiMod_Shift;
4646+
map.OverrideMod = ImGuiMod_Ctrl;
4647+
map.ZoomMod = ImGuiMod_None;
46484648
map.ZoomRate = 0.1f;
46494649
}
46504650

46514651
void MapInputReverse(ImPlotInputMap* dst) {
46524652
ImPlotInputMap& map = dst ? *dst : GetInputMap();
46534653
map.Pan = ImGuiMouseButton_Right;
4654-
map.PanMod = ImGuiModFlags_None;
4654+
map.PanMod = ImGuiMod_None;
46554655
map.Fit = ImGuiMouseButton_Left;
46564656
map.Menu = ImGuiMouseButton_Right;
46574657
map.Select = ImGuiMouseButton_Left;
4658-
map.SelectMod = ImGuiModFlags_None;
4658+
map.SelectMod = ImGuiMod_None;
46594659
map.SelectCancel = ImGuiMouseButton_Right;
4660-
map.SelectHorzMod = ImGuiModFlags_Alt;
4661-
map.SelectVertMod = ImGuiModFlags_Shift;
4662-
map.OverrideMod = ImGuiModFlags_Ctrl;
4663-
map.ZoomMod = ImGuiModFlags_None;
4660+
map.SelectHorzMod = ImGuiMod_Alt;
4661+
map.SelectVertMod = ImGuiMod_Shift;
4662+
map.OverrideMod = ImGuiMod_Ctrl;
4663+
map.ZoomMod = ImGuiMod_None;
46644664
map.ZoomRate = 0.1f;
46654665
}
46664666

implot.h

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -543,28 +543,34 @@ struct ImPlotStyle {
543543
IMPLOT_API ImPlotStyle();
544544
};
545545

546+
// Support for legacy versions
546547
#if (IMGUI_VERSION_NUM < 18716) // Renamed in 1.88
547-
#define ImGuiModFlags ImGuiKeyModFlags
548-
#define ImGuiModFlags_None ImGuiKeyModFlags_None
549-
#define ImGuiModFlags_Ctrl ImGuiKeyModFlags_Ctrl
550-
#define ImGuiModFlags_Shift ImGuiKeyModFlags_Shift
551-
#define ImGuiModFlags_Alt ImGuiKeyModFlags_Alt
552-
#define ImGuiModFlags_Super ImGuiKeyModFlags_Super
548+
#define ImGuiMod_None 0
549+
#define ImGuiMod_Ctrl ImGuiKeyModFlags_Ctrl
550+
#define ImGuiMod_Shift ImGuiKeyModFlags_Shift
551+
#define ImGuiMod_Alt ImGuiKeyModFlags_Alt
552+
#define ImGuiMod_Super ImGuiKeyModFlags_Super
553+
#elif (IMGUI_VERSION_NUM < 18823) // Renamed in 1.89, sorry
554+
#define ImGuiMod_None 0
555+
#define ImGuiMod_Ctrl ImGuiModFlags_Ctrl
556+
#define ImGuiMod_Shift ImGuiModFlags_Shift
557+
#define ImGuiMod_Alt ImGuiModFlags_Alt
558+
#define ImGuiMod_Super ImGuiModFlags_Super
553559
#endif
554560

555561
// Input mapping structure. Default values listed. See also MapInputDefault, MapInputReverse.
556562
struct ImPlotInputMap {
557563
ImGuiMouseButton Pan; // LMB enables panning when held,
558-
ImGuiModFlags PanMod; // none optional modifier that must be held for panning/fitting
564+
int PanMod; // none optional modifier that must be held for panning/fitting
559565
ImGuiMouseButton Fit; // LMB initiates fit when double clicked
560566
ImGuiMouseButton Select; // RMB begins box selection when pressed and confirms selection when released
561567
ImGuiMouseButton SelectCancel; // LMB cancels active box selection when pressed; cannot be same as Select
562-
ImGuiModFlags SelectMod; // none optional modifier that must be held for box selection
563-
ImGuiModFlags SelectHorzMod; // Alt expands active box selection horizontally to plot edge when held
564-
ImGuiModFlags SelectVertMod; // Shift expands active box selection vertically to plot edge when held
568+
int SelectMod; // none optional modifier that must be held for box selection
569+
int SelectHorzMod; // Alt expands active box selection horizontally to plot edge when held
570+
int SelectVertMod; // Shift expands active box selection vertically to plot edge when held
565571
ImGuiMouseButton Menu; // RMB opens context menus (if enabled) when clicked
566-
ImGuiModFlags OverrideMod; // Ctrl when held, all input is ignored; used to enable axis/plots as DND sources
567-
ImGuiModFlags ZoomMod; // none optional modifier that must be held for scroll wheel zooming
572+
int OverrideMod; // Ctrl when held, all input is ignored; used to enable axis/plots as DND sources
573+
int ZoomMod; // none optional modifier that must be held for scroll wheel zooming
568574
float ZoomRate; // 0.1f zoom rate for scroll (e.g. 0.1f = 10% plot range every scroll click); make negative to invert
569575
IMPLOT_API ImPlotInputMap();
570576
};
@@ -1023,7 +1029,7 @@ IMPLOT_API bool BeginDragDropTargetLegend();
10231029
IMPLOT_API void EndDragDropTarget();
10241030

10251031
// NB: By default, plot and axes drag and drop *sources* require holding the Ctrl modifier to initiate the drag.
1026-
// You can change the modifier if desired. If ImGuiModFlags_None is provided, the axes will be locked from panning.
1032+
// You can change the modifier if desired. If ImGuiMod_None is provided, the axes will be locked from panning.
10271033

10281034
// Turns the current plot's plotting area into a drag and drop source. You must hold Ctrl. Don't forget to call EndDragDropSource!
10291035
IMPLOT_API bool BeginDragDropSourcePlot(ImGuiDragDropFlags flags=0);

implot_demo.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,16 @@ void ButtonSelector(const char* label, ImGuiMouseButton* b) {
221221
ImGui::PopID();
222222
}
223223

224-
void ModSelector(const char* label, ImGuiModFlags* k) {
224+
void ModSelector(const char* label, int* k) {
225225
ImGui::PushID(label);
226-
ImGui::CheckboxFlags("Ctrl", (unsigned int*)k, ImGuiModFlags_Ctrl); ImGui::SameLine();
227-
ImGui::CheckboxFlags("Shift", (unsigned int*)k, ImGuiModFlags_Shift); ImGui::SameLine();
228-
ImGui::CheckboxFlags("Alt", (unsigned int*)k, ImGuiModFlags_Alt); ImGui::SameLine();
229-
ImGui::CheckboxFlags("Super", (unsigned int*)k, ImGuiModFlags_Super);
226+
ImGui::CheckboxFlags("Ctrl", (unsigned int*)k, ImGuiMod_Ctrl); ImGui::SameLine();
227+
ImGui::CheckboxFlags("Shift", (unsigned int*)k, ImGuiMod_Shift); ImGui::SameLine();
228+
ImGui::CheckboxFlags("Alt", (unsigned int*)k, ImGuiMod_Alt); ImGui::SameLine();
229+
ImGui::CheckboxFlags("Super", (unsigned int*)k, ImGuiMod_Super);
230230
ImGui::PopID();
231231
}
232232

233-
void InputMapping(const char* label, ImGuiMouseButton* b, ImGuiModFlags* k) {
233+
void InputMapping(const char* label, ImGuiMouseButton* b, int* k) {
234234
ImGui::LabelText("##","%s",label);
235235
if (b != NULL) {
236236
ImGui::SameLine(100);

0 commit comments

Comments
 (0)