From 4018a4b690646053bfea0ab41df78227e6274050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Tue, 25 Aug 2015 22:59:20 -0700 Subject: [PATCH] imgui: Added handling middle mouse button. --- examples/09-hdr/hdr.cpp | 5 +++-- examples/11-fontsdf/fontsdf.cpp | 5 +++-- examples/12-lod/lod.cpp | 5 +++-- examples/13-stencil/stencil.cpp | 5 +++-- examples/14-shadowvolumes/shadowvolumes.cpp | 5 +++-- examples/16-shadowmaps/shadowmaps.cpp | 5 +++-- examples/17-drawstress/drawstress.cpp | 5 +++-- examples/18-ibl/ibl.cpp | 5 +++-- examples/19-oit/oit.cpp | 5 +++-- examples/21-deferred/deferred.cpp | 5 +++-- examples/24-nbody/nbody.cpp | 5 +++-- examples/common/imgui/imgui.h | 5 +++-- examples/common/imgui/ocornut_imgui.cpp | 1 + 13 files changed, 37 insertions(+), 24 deletions(-) diff --git a/examples/09-hdr/hdr.cpp b/examples/09-hdr/hdr.cpp index c009da80..92fab4f2 100644 --- a/examples/09-hdr/hdr.cpp +++ b/examples/09-hdr/hdr.cpp @@ -298,8 +298,9 @@ class HDR : public entry::AppI imguiBeginFrame(m_mouseState.m_mx , m_mouseState.m_my - , (m_mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) - | (m_mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + , (m_mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) + | (m_mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + | (m_mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0) , m_mouseState.m_mz , m_width , m_height diff --git a/examples/11-fontsdf/fontsdf.cpp b/examples/11-fontsdf/fontsdf.cpp index c91d1a90..f74c3885 100644 --- a/examples/11-fontsdf/fontsdf.cpp +++ b/examples/11-fontsdf/fontsdf.cpp @@ -130,8 +130,9 @@ int _main_(int /*_argc*/, char** /*_argv*/) { imguiBeginFrame(mouseState.m_mx , mouseState.m_my - , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) - | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) + | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + | (mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0) , mouseState.m_mz , width , height diff --git a/examples/12-lod/lod.cpp b/examples/12-lod/lod.cpp index c2c7f0fe..c57d7bd8 100644 --- a/examples/12-lod/lod.cpp +++ b/examples/12-lod/lod.cpp @@ -117,8 +117,9 @@ int _main_(int /*_argc*/, char** /*_argv*/) { imguiBeginFrame(mouseState.m_mx , mouseState.m_my - , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) - | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) + | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + | (mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0) , mouseState.m_mz , width , height diff --git a/examples/13-stencil/stencil.cpp b/examples/13-stencil/stencil.cpp index 7ccd33e8..2551306e 100644 --- a/examples/13-stencil/stencil.cpp +++ b/examples/13-stencil/stencil.cpp @@ -942,8 +942,9 @@ int _main_(int /*_argc*/, char** /*_argv*/) { imguiBeginFrame(mouseState.m_mx , mouseState.m_my - , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) - | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) + | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + | (mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0) , mouseState.m_mz , viewState.m_width , viewState.m_height diff --git a/examples/14-shadowvolumes/shadowvolumes.cpp b/examples/14-shadowvolumes/shadowvolumes.cpp index 37a05bfb..1ab279cc 100644 --- a/examples/14-shadowvolumes/shadowvolumes.cpp +++ b/examples/14-shadowvolumes/shadowvolumes.cpp @@ -2129,8 +2129,9 @@ int _main_(int /*_argc*/, char** /*_argv*/) imguiBeginFrame(mouseState.m_mx , mouseState.m_my - , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) - | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) + | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + | (mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0) , mouseState.m_mz , viewState.m_width , viewState.m_height diff --git a/examples/16-shadowmaps/shadowmaps.cpp b/examples/16-shadowmaps/shadowmaps.cpp index 49240831..ad0dbc26 100644 --- a/examples/16-shadowmaps/shadowmaps.cpp +++ b/examples/16-shadowmaps/shadowmaps.cpp @@ -1971,8 +1971,9 @@ int _main_(int /*_argc*/, char** /*_argv*/) // Imgui. imguiBeginFrame(mouseState.m_mx , mouseState.m_my - , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) - | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) + | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + | (mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0) , mouseState.m_mz , viewState.m_width , viewState.m_height diff --git a/examples/17-drawstress/drawstress.cpp b/examples/17-drawstress/drawstress.cpp index 500337df..de08f68b 100644 --- a/examples/17-drawstress/drawstress.cpp +++ b/examples/17-drawstress/drawstress.cpp @@ -209,8 +209,9 @@ class DrawStress : public entry::AppI imguiBeginFrame(m_mouseState.m_mx , m_mouseState.m_my - , (m_mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) - | (m_mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + , (m_mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) + | (m_mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + | (m_mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0) , m_mouseState.m_mz , m_width , m_height diff --git a/examples/18-ibl/ibl.cpp b/examples/18-ibl/ibl.cpp index 429a7e7e..2d98aba5 100644 --- a/examples/18-ibl/ibl.cpp +++ b/examples/18-ibl/ibl.cpp @@ -309,8 +309,9 @@ int _main_(int /*_argc*/, char** /*_argv*/) { imguiBeginFrame(mouseState.m_mx , mouseState.m_my - , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) - | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) + | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + | (mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0) , mouseState.m_mz , width , height diff --git a/examples/19-oit/oit.cpp b/examples/19-oit/oit.cpp index 5fc58db7..f673a9ab 100644 --- a/examples/19-oit/oit.cpp +++ b/examples/19-oit/oit.cpp @@ -242,8 +242,9 @@ int _main_(int /*_argc*/, char** /*_argv*/) imguiBeginFrame(mouseState.m_mx , mouseState.m_my - , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) - | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) + | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + | (mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0) , mouseState.m_mz , width , height diff --git a/examples/21-deferred/deferred.cpp b/examples/21-deferred/deferred.cpp index 813c1f84..7aae64fe 100644 --- a/examples/21-deferred/deferred.cpp +++ b/examples/21-deferred/deferred.cpp @@ -452,8 +452,9 @@ class Deferred : public entry::AppI imguiBeginFrame(m_mouseState.m_mx , m_mouseState.m_my - , (m_mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) - | (m_mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + , (m_mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) + | (m_mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + | (m_mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0) , m_mouseState.m_mz , m_width , m_height diff --git a/examples/24-nbody/nbody.cpp b/examples/24-nbody/nbody.cpp index 26ccb343..da7e7a44 100644 --- a/examples/24-nbody/nbody.cpp +++ b/examples/24-nbody/nbody.cpp @@ -219,8 +219,9 @@ int _main_(int /*_argc*/, char** /*_argv*/) imguiBeginFrame(mouseState.m_mx , mouseState.m_my - , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) - | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) + | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + | (mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0) , mouseState.m_mz , width , height diff --git a/examples/common/imgui/imgui.h b/examples/common/imgui/imgui.h index 07e539bb..bbf9362f 100644 --- a/examples/common/imgui/imgui.h +++ b/examples/common/imgui/imgui.h @@ -29,8 +29,9 @@ #include #include -#define IMGUI_MBUT_LEFT 0x01 -#define IMGUI_MBUT_RIGHT 0x02 +#define IMGUI_MBUT_LEFT 0x01 +#define IMGUI_MBUT_RIGHT 0x02 +#define IMGUI_MBUT_MIDDLE 0x04 /// For custom values, define these macros before including imgui.h diff --git a/examples/common/imgui/ocornut_imgui.cpp b/examples/common/imgui/ocornut_imgui.cpp index 33ad44ae..aff41ac3 100644 --- a/examples/common/imgui/ocornut_imgui.cpp +++ b/examples/common/imgui/ocornut_imgui.cpp @@ -235,6 +235,7 @@ struct OcornutImguiContext io.MousePos = ImVec2( (float)_mx, (float)_my); io.MouseDown[0] = 0 != (_button & IMGUI_MBUT_LEFT); io.MouseDown[1] = 0 != (_button & IMGUI_MBUT_RIGHT); + io.MouseDown[2] = 0 != (_button & IMGUI_MBUT_MIDDLE); io.MouseWheel = (float)(_scroll - m_lastScroll); m_lastScroll = _scroll;