SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLUiInterface.h
Go to the documentation of this file.
1 /**
2  * \file SLUiInterface.h
3  * \date January 2018
4  * \authors Michael Göttlicher, Marcus Hudritsch
5  * \copyright http://opensource.org/licenses/GPL-3.0
6  * \remarks Please use clangformat to format the code. See more code style on
7  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
8 */
9 
10 #ifndef SL_UIINTERFACE_H
11 #define SL_UIINTERFACE_H
12 
13 #include <SL.h>
14 #include <SLEnums.h>
15 #include <math/SLRect.h>
16 
17 class SLScene;
18 class SLSceneView;
19 
20 //! Interface for ui integration in SLSceneView
21 /*! (all functions are called by SLSceneView so basically it is a SLSceneViewUiInterface)
22  */
24 {
25 public:
26  virtual ~SLUiInterface() {}
27 
28  //! initialization (called by SLSceneView init)
29  virtual void init(const string& configPath) {}
30  //! inform the ui about scene view size change
31  virtual void onResize(const SLRecti& viewportRect) {}
32  //! shutdown ui
33  virtual void onClose() {}
34 
35  //! prepare the ui for a new rendering, e.g. update visual ui representation (called by SLSceneView onPaint)
36  virtual void onInitNewFrame(SLScene* s, SLSceneView* sv) {}
37 
38  //! ui render call (called by SLSceneView draw2DGL)
39  virtual void onPaint(const SLRecti& viewport) {}
41 
42  //! forward user input to ui
43  virtual void onMouseDown(SLMouseButton button, SLint x, SLint y) {}
44  //! forward user input to ui
45  virtual void onMouseUp(SLMouseButton button, SLint x, SLint y) {}
46  //! forward user input to ui
47  virtual void onMouseMove(SLint xPos, SLint yPos) {}
48  //! forward user input to ui
49  virtual void onMouseWheel(SLfloat yoffset) {}
50  //! forward user input to ui
51  virtual void onKeyPress(SLKey key, SLKey mod) {}
52  //! forward user input to ui
53  virtual void onKeyRelease(SLKey key, SLKey mod) {}
54  //! forward user input to ui
55  virtual void onCharInput(SLuint c) {}
56 
57  //! inform if user keyboard input was consumed by the ui
58  virtual bool doNotDispatchKeyboard() { return false; }
59 
60  //! inform if user mouse input was consumed by the ui
61  /*! (e.g. the ui was hit by a mouse click.
62  * In this case the user input would not be forwarded to 3D scene graph)
63  */
64  virtual bool doNotDispatchMouse() { return false; }
65 
66  //! Turns on or off the mouse cursor drawing
67  virtual void drawMouseCursor(bool doDraw) {}
68 };
69 
70 #endif
static SLint mouseX
Last mouse position x in pixels.
static SLint mouseY
Last mouse position y in pixels.
float SLfloat
Definition: SL.h:173
unsigned int SLuint
Definition: SL.h:171
int SLint
Definition: SL.h:170
SLMouseButton
Mouse button codes.
Definition: SLEnums.h:98
SLKey
Keyboard key codes enumeration.
Definition: SLEnums.h:16
The SLScene class represents the top level instance holding the scene structure.
Definition: SLScene.h:47
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69
Interface for ui integration in SLSceneView.
Definition: SLUiInterface.h:24
virtual void onMouseDown(SLMouseButton button, SLint x, SLint y)
forward user input to ui
Definition: SLUiInterface.h:43
virtual void onPaint(const SLRecti &viewport)
ui render call (called by SLSceneView draw2DGL)
Definition: SLUiInterface.h:39
virtual void onMouseMove(SLint xPos, SLint yPos)
forward user input to ui
Definition: SLUiInterface.h:47
virtual void init(const string &configPath)
initialization (called by SLSceneView init)
Definition: SLUiInterface.h:29
virtual void onKeyPress(SLKey key, SLKey mod)
forward user input to ui
Definition: SLUiInterface.h:51
virtual void renderExtraFrame(SLScene *s, SLSceneView *sv, SLint mouseX, SLint mouseY)
Definition: SLUiInterface.h:40
virtual bool doNotDispatchKeyboard()
inform if user keyboard input was consumed by the ui
Definition: SLUiInterface.h:58
virtual void onResize(const SLRecti &viewportRect)
inform the ui about scene view size change
Definition: SLUiInterface.h:31
virtual void onMouseWheel(SLfloat yoffset)
forward user input to ui
Definition: SLUiInterface.h:49
virtual void onClose()
shutdown ui
Definition: SLUiInterface.h:33
virtual void onKeyRelease(SLKey key, SLKey mod)
forward user input to ui
Definition: SLUiInterface.h:53
virtual bool doNotDispatchMouse()
inform if user mouse input was consumed by the ui
Definition: SLUiInterface.h:64
virtual void onMouseUp(SLMouseButton button, SLint x, SLint y)
forward user input to ui
Definition: SLUiInterface.h:45
virtual ~SLUiInterface()
Definition: SLUiInterface.h:26
virtual void onInitNewFrame(SLScene *s, SLSceneView *sv)
prepare the ui for a new rendering, e.g. update visual ui representation (called by SLSceneView onPai...
Definition: SLUiInterface.h:36
virtual void onCharInput(SLuint c)
forward user input to ui
Definition: SLUiInterface.h:55
virtual void drawMouseCursor(bool doDraw)
Turns on or off the mouse cursor drawing.
Definition: SLUiInterface.h:67
T mod(T a, T b)
Definition: Utils.h:250