Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
UIEventListener.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef EventListener_INCLUDE_ONCE
33 #define EventListener_INCLUDE_ONCE
34 
36 #include <vlCore/String.hpp>
37 
38 namespace vl
39 {
40  class OpenGLContext;
41  //-----------------------------------------------------------------------------
42  // UIEventListener
43  //-----------------------------------------------------------------------------
56  {
58 
59  friend class OpenGLContext;
60 
61  public:
63  UIEventListener(): mOpenGLContext(NULL), mEnabled(true)
64  {
65  VL_DEBUG_SET_OBJECT_NAME()
66  }
67 
69  virtual void initEvent() = 0;
70 
72  virtual void destroyEvent() = 0;
73 
76  virtual void updateEvent() = 0;
77 
79  virtual void enableEvent(bool enabled) = 0;
80 
82  virtual void addedListenerEvent(OpenGLContext*) = 0;
83 
85  virtual void removedListenerEvent(OpenGLContext*) = 0;
86 
88  virtual void mouseMoveEvent(int x, int y) = 0;
89 
91  virtual void mouseUpEvent(EMouseButton button, int x, int y) = 0;
92 
94  virtual void mouseDownEvent(EMouseButton button, int x, int y) = 0;
95 
97  virtual void mouseWheelEvent(int n) = 0;
98 
100  virtual void keyPressEvent(unsigned short unicode_ch, EKey key) = 0;
101 
103  virtual void keyReleaseEvent(unsigned short unicode_ch, EKey key) = 0;
104 
106  virtual void resizeEvent(int x, int y) = 0;
107 
109  virtual void fileDroppedEvent(const std::vector<String>& files) = 0;
110 
112  virtual void visibilityEvent(bool visible) = 0;
113 
116  virtual void setEnabled(bool enabled) { if (mEnabled != enabled) { mEnabled = enabled; enableEvent(enabled); } }
117 
119  bool isEnabled() const { return mEnabled; }
120 
122  OpenGLContext* openglContext();
123 
125  const OpenGLContext* openglContext() const;
126 
127  private:
128  OpenGLContext* mOpenGLContext;
129  bool mEnabled;
130  };
131 }
132 
133 #endif
The UIEventListener class listens to the events emitted by an OpenGLContext.
Represents an OpenGL context, possibly a widget or a pbuffer, which can also respond to keyboard...
bool isEnabled() const
Returns whether the UIEventListener is currently enabled or not.
Visualization Library main namespace.
The base class for all the reference counted objects.
Definition: Object.hpp:158
EMouseButton
#define NULL
Definition: OpenGLDefs.hpp:81
#define VL_INSTRUMENT_ABSTRACT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:145
virtual void setEnabled(bool enabled)
Enables or disables a UIEventListener.