RigsofRods
Soft-body Physics Simulation
OgreImGui.h
Go to the documentation of this file.
1 
2 // -------------------------------------------
3 // OGRE-IMGUI bindings
4 // See file 'README-OgreImGui.txt' for details
5 // -------------------------------------------
6 
7 /*
8  This source file is part of Rigs of Rods
9  Copyright 2016-2020 Petr Ohlidal
10 
11  For more information, see http://www.rigsofrods.org/
12 
13  Rigs of Rods is free software: you can redistribute it and/or modify
14  it under the terms of the GNU General Public License version 3, as
15  published by the Free Software Foundation.
16 
17  Rigs of Rods is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
24 */
25 
26 #pragma once
27 
28 #include "OgreImGuiOverlay.h" // RoR's ported version
29 
30 #include <imgui.h>
31 #include <Ogre.h>
32 #include <OISMouse.h>
33 #include <OISKeyboard.h>
34 #include <memory>
35 
36 // DearIMGUI math functions, copypasted from <imgui_internal.h>
37 static inline ImVec2 operator*(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x*rhs, lhs.y*rhs); }
38 static inline ImVec2 operator/(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x/rhs, lhs.y/rhs); }
39 static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x+rhs.x, lhs.y+rhs.y); }
40 static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x-rhs.x, lhs.y-rhs.y); }
41 static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x*rhs.x, lhs.y*rhs.y); }
42 static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x/rhs.x, lhs.y/rhs.y); }
43 static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }
44 static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
45 static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
46 static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
47 
54 class OgreImGui: public Ogre::RenderQueueListener
55 {
56 public:
57  void Init();
58 
59  // Input-injecting functions
60  void InjectMouseMoved( const OIS::MouseEvent &arg );
61  void SetMouseButtonState(OIS::MouseButtonID id, bool down);
62  void ResetAllMouseButtons();
63  void InjectKeyPressed( const OIS::KeyEvent &arg );
64  void InjectKeyReleased( const OIS::KeyEvent &arg );
65 
66  // Ogre::RenderQueueListener
67  virtual void renderQueueStarted(Ogre::uint8 queueGroupId,
68  const Ogre::String& invocation, bool& skipThisInvocation) override;
69 
70 private:
71  std::unique_ptr<Ogre::ImGuiOverlay> m_imgui_overlay;
72 };
OgreImGui::SetMouseButtonState
void SetMouseButtonState(OIS::MouseButtonID id, bool down)
Definition: OgreImGui.cpp:99
operator-=
static ImVec2 & operator-=(ImVec2 &lhs, const ImVec2 &rhs)
Definition: OgreImGui.h:44
operator+=
static ImVec2 & operator+=(ImVec2 &lhs, const ImVec2 &rhs)
Definition: OgreImGui.h:43
operator/=
static ImVec2 & operator/=(ImVec2 &lhs, const float rhs)
Definition: OgreImGui.h:46
operator/
static ImVec2 operator/(const ImVec2 &lhs, const float rhs)
Definition: OgreImGui.h:38
OgreImGui::m_imgui_overlay
std::unique_ptr< Ogre::ImGuiOverlay > m_imgui_overlay
Definition: OgreImGui.h:71
operator-
static ImVec2 operator-(const ImVec2 &lhs, const ImVec2 &rhs)
Definition: OgreImGui.h:40
OgreImGui::InjectKeyReleased
void InjectKeyReleased(const OIS::KeyEvent &arg)
Definition: OgreImGui.cpp:129
OgreImGui
DearIMGUI integration.
Definition: OgreImGui.h:54
OgreImGui::Init
void Init()
Definition: OgreImGui.cpp:38
OgreImGui::ResetAllMouseButtons
void ResetAllMouseButtons()
Definition: OgreImGui.cpp:108
operator*
static ImVec2 operator*(const ImVec2 &lhs, const float rhs)
Definition: OgreImGui.h:37
OgreImGui::InjectMouseMoved
void InjectMouseMoved(const OIS::MouseEvent &arg)
Definition: OgreImGui.cpp:89
operator+
static ImVec2 operator+(const ImVec2 &lhs, const ImVec2 &rhs)
Definition: OgreImGui.h:39
OgreImGui::InjectKeyPressed
void InjectKeyPressed(const OIS::KeyEvent &arg)
Definition: OgreImGui.cpp:118
OgreImGuiOverlay.h
OgreImGui::renderQueueStarted
virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &skipThisInvocation) override
Definition: OgreImGui.cpp:135
operator*=
static ImVec2 & operator*=(ImVec2 &lhs, const float rhs)
Definition: OgreImGui.h:45