API Documentation
Loading...
Searching...
No Matches
MouseController.h
Go to the documentation of this file.
1/**--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Design
28File: MouseController
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/Camera.h>
34#if NDEVR_VIEWPORT
35#include <NDEVR/Resource.h>
36#include <NDEVR/Event.h>
37#include <NDEVR/INIInterface.h>
38namespace NDEVR
39{
40 class NDEVR_DESIGN_API MouseControllerBase
41 {
42 public:
43 virtual bool processMouseEvent(const MouseEvent& event, DesignObjectLookup* lookup, Camera* camera) = 0;
44 };
45 class SnapController;
46
47 class DesignObjectLookup;
48 class MouseController final : public INIInterface, public MouseControllerBase
49 {
50 public:
51 enum ReferencePoint : uint01
52 {
53 e_map_center
54 , e_mouse_center
55 , e_screen_center
56 };
57 enum MouseAction : uint01
58 {
59 e_ignore
60 , e_select
61 , e_inv_select
62 , e_orbit
63 , e_pan
64 , e_look_around
65 , e_zoom
66 , e_inv_zoom
67 , e_context_menu
68
69 , e_command
70 };
71 enum MuuseSelectionMode
72 {
73 e_select_model
74 , e_select_model_base
75 , e_select_material
76 , e_select_geometry
77 , e_select_bone
78 };
79 class MouseActions
80 {
81 public:
82 Resource<MouseAction> drag_action;
83 Resource<MouseAction> click_action;
84 Resource<MouseAction> double_click_action;
85 Resource<MuuseSelectionMode> selection_mode;
86 Resource<ReferencePoint> prefered_reference;
87 Resource<fltp04> sensitivity;
88 Resource<Vector<2, bool>> inverted;
89
90 Resource<ReferencePoint> double_click_reference;
91 public:
92 MouseActions();
93 MouseActions(const MouseActions& actions);
94 };
95 public:
96 NDEVR_DESIGN_API MouseController();
97 NDEVR_DESIGN_API virtual ~MouseController();
98 MouseActions center_mouse_action;
99 MouseActions left_mouse_action;
100 MouseActions right_mouse_action;
101 MouseActions wheel_mouse_action;
102
103 public:
104 NDEVR_DESIGN_API void setParkeDefaults();
105 NDEVR_DESIGN_API MouseAction getAction(const MouseEvent& event) const;
106 NDEVR_DESIGN_API MouseActions& getDefaultAction(MouseEvent::MouseClickType type);
107 NDEVR_DESIGN_API const MouseActions& getDefaultAction(MouseEvent::MouseClickType type) const;
108
109 NDEVR_DESIGN_API bool processMouseEvent(const MouseEvent& event, DesignObjectLookup* lookup, Camera* camera) override;
110
111 NDEVR_DESIGN_API void addController(UUID id, MouseControllerBase* controller);
112 NDEVR_DESIGN_API void removeController(UUID id);
113 bool contextMenuRequested() const { return m_request_context_menu; }
114 void resetContextMenuRequested() { m_request_context_menu = false; }
115 bool selectionRequested() const { return m_request_selection; }
116 void resetSelectionRequested() { m_request_selection = false; }
117 const MouseEvent& lastMouseEvent() const { return m_last_mouse_event; }
118 Resource<Buffer<UUID>> selected;
119 Resource<UUID> selected_layer;
120 Resource<UUID> focus;
121 Resource<String> cursor;
122 Resource<String> information;
123 Resource<uint04> number_of_mouse_events;
124 Resource<uint04> number_of_mouse_clicks;
125 private:
126 Matrix<fltp08> m_parent_transform;
127 CameraAnimation m_original_camera;
128 Vector<2, fltp08> m_screen_percent_0;
129 fltp08 m_last_valid_distance;
130 bool m_is_dragging;
131 bool m_is_mouse_scrolling;
132 bool m_is_touch_scrolling;
133
134 MouseEvent m_last_mouse_event;
135 private:
136
137
138 void getINI(INIFactory& factory) override;
139 void setReferencePoint(ReferencePoint ref, Camera* camera);
140 bool processGrips(const MouseEvent& event, DesignObjectLookup* lookup, Camera* camera);
141 //void updateCenterOfScreen(DesignObjectLookup* lookup);
142 void updateCenterOfMouse(DesignObjectLookup* lookup, Camera* camera, bool update_distance);
143 void setView(MouseAction act, ReferencePoint ref, const Vector<2, fltp08>& screen_percent, Camera* camera);
144 void mouseScrolled(fltp04 scroll_distance, Camera* camera);
145 void touchScrolled(fltp04 scroll_distance, Camera* camera);
146 void mouseClicked(const MouseEvent& e, DesignObjectLookup* lookup, Camera* camera);
147 void mouseChangeView(const MouseEvent& e, Camera* camera);
148 protected:
149 bool m_request_context_menu;
150 bool m_request_selection;
151 bool m_ignore_next_event_if_click;//If the next event is a click, ignore it
152 Dictionary<UUID, MouseControllerBase*> m_controller_lookup;
153 Buffer<MouseControllerBase*> m_controllers;
154 DynamicPointer<SnapController> m_snap_controller;
155 };
156};
157#endif
158
159
#define NDEVR_DESIGN_API
Definition DLLInfo.h:77
Definition ACIColor.h:37
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:98
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181