HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DM_MouseHook.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: DM_MouseHook.h ( DM Library, C++)
7  *
8  * COMMENTS:
9  * Base classes to hook into the viewport mouse event handling pipeline.
10  */
11 #ifndef __DM_MouseHook_H__
12 #define __DM_MouseHook_H__
13 
14 #include "DM_API.h"
15 #include "DM_ViewportType.h"
16 
17 #include <UT/UT_String.h>
18 
19 class DM_VPortAgent;
20 class UI_Event;
21 
22 /// Data structure for rendering scene hooks.
24 {
25 public:
26  // Currently this is an empty class.
27 };
28 
29 
30 
31 /// Mouse event hook instance, which does the actual handling for a viewport.
32 ///
33 /// Allocated by the DM_MouseHook factory object.
35 {
36 public:
37  /// A mouse event hook has a parent viewport and a view type mask which
38  /// determines which viewport types it will process mouse events within
39  /// (eg. perspective, ortho, UV, all).
41  virtual ~DM_MouseEventHook();
42 
43  /// @brief Method called to handle a mouse motion or button event.
44  ///
45  /// This method is called to handle a regular mouse event. It should
46  /// return true when it handles the event to prevent any further code
47  /// from processing it.
48  virtual bool handleMouseEvent(const DM_MouseHookData &hook_data,
49  UI_Event *event) = 0;
50 
51  /// @brief Method called to handle a mouse wheel scroll event.
52  ///
53  /// This method is called to handle a mouse wheel scroll event. It should
54  /// return true when it handles the event to prevent any further code from
55  /// processing it.
56  virtual bool handleMouseWheelEvent(
57  const DM_MouseHookData &hook_data,
58  UI_Event *event) = 0;
59 
60  /// @brief Method called to handle a mouse button double click event.
61  ///
62  /// This method is called to handle a mouse double click event. It should
63  /// return true when it handles the event to prevent any further code from
64  /// processing it.
65  virtual bool handleDoubleClickEvent(
66  const DM_MouseHookData &hook_data,
67  UI_Event *event) = 0;
68 
69  /// @brief Method called to determine whether to allow a RMB menu popup.
70  ///
71  /// This method is called to determine if Houdini is allowed to open a RMB
72  /// menu on a particular mouse event. It is called in descending order of
73  /// priority with the RMB menu event allowed only if all hooks allow it.
74  virtual bool allowRMBMenu(const DM_MouseHookData &, UI_Event *)
75  { return true; }
76 
77 
78  /// Viewport this scene render is attached to.
79  DM_VPortAgent &viewport() const { return myAgent; }
80  DM_ViewportType getViewportMask() const { return myViewportMask; }
81 
82 private:
83  DM_VPortAgent &myAgent;
84  DM_ViewportType myViewportMask;
85 };
86 
87 
88 
89 /// A DM_MouseHook creates new DM_MouseEventHook objects when new viewports are
90 /// created.
92 {
93 public:
94  /// Create a mouse hook which creates mouse event hook instances for
95  /// specific viewports. Only one mouse hook is ever created, and it is
96  /// responsible for managing the mouse event hooks for viewports.
97  /// Each hook requires a name (for error reporting) and a priority level
98  /// to resolve multiple mouse hook conflicts.
99  DM_MouseHook(const char *hook_name,
100  int priority);
101  virtual ~DM_MouseHook();
102 
103  const char *getName() const { return myHookName; }
104  int getPriority() const { return myPriority; }
105 
106  /// @brief Called when a viewport needs to create a new hook.
107  ///
108  /// Each viewport has its own event hook.
109  virtual DM_MouseEventHook *newEventHook(DM_VPortAgent &vport) = 0;
110 
111  /// @brief Called when a viewport no longer requires the hook.
112  ///
113  /// When a viewport is destroyed, it retires all its hooks. Because a hook
114  /// could be shared between all viewports, this method gives the mouse hook
115  /// the opportunity to delete it, dereference it, etc. The viewport doing
116  /// the retiring is passed in along with the hook it is retiring.
117  virtual void retireEventHook(DM_VPortAgent &vport,
118  DM_MouseEventHook *hook) = 0;
119 
120 private:
121  UT_String myHookName;
122  int myPriority;
123 };
124 #endif
const char * getName() const
Definition: DM_MouseHook.h:103
DM_VPortAgent & viewport() const
Viewport this scene render is attached to.
Definition: DM_MouseHook.h:79
DM_ViewportType getViewportMask() const
Definition: DM_MouseHook.h:80
Data structure for rendering scene hooks.
Definition: DM_MouseHook.h:23
struct _cl_event * event
Definition: glcorearb.h:2961
#define DM_API
Definition: DM_API.h:10
int getPriority() const
Definition: DM_MouseHook.h:104
virtual bool allowRMBMenu(const DM_MouseHookData &, UI_Event *)
Method called to determine whether to allow a RMB menu popup.
Definition: DM_MouseHook.h:74
int DM_ViewportType