Cumulia Illustrator Rendering Engine v1.1.0
A Rendering engine for industrial CAD/CAE model and optimized for greatest performance
 
Loading...
Searching...
No Matches
manipulator.h
1//##################################################################################################
2//
3// Copyright (c) 2024 Beijing Qiongqi Tech Co.,Ltd. All rights reserved.
4
5// This source code is confidential and proprietary to Beijing Qiongqi Tech Co.,Ltd(The Holder).
6// Any unauthorized use, copying, modification, or distribution of the code is strictly prohibited.
7// Any user shall obtain authorizaition from the Holder before modifying the source code. And the user shall not
8// sublicense, sell, distribute, or transfer the source code, whether in original or modified form, to any third party
9// without the prior written consent of the Holder.
10
11// This copyright notice and permission grant shall be included in all copies or substantial portions of the source code.
12
13// Author Cumulia Illustrator
14// Date 2024-10-31
15// Version V1.1.0
16//##################################################################################################
17
18#pragma once
19
20#include "action.h"
21
22#include <cilcore.h>
23
24#include <memory>
25#include <map>
26#include <functional>
27#include <string>
28
29namespace cil
30{
32 {
33 private:
34 static const int ManhattanDist;
35 static const int ClickInterval;
36 static const int ClickHoldTime;
37
38 public:
39 enum class Button {
40 None = 0x0000,
41 Left = 0x0001,
42 Right = 0x0002,
43 Middle = 0x0004,
44 X1 = 0x0008,
45 X2 = 0x0010
46 };
47
48 enum class Modifier {
49 None = 0x0000,
50 Shift = 0x0200,
51 Ctrl = 0x0400,
52 Alt = 0x0800,
53 Meta = 0x1000
54 };
55
58
59 virtual void mouseDown(const ivec2& coord, Button button, Modifier modifier);
60 virtual void mouseMove(const ivec2& coord, Button button, Modifier modifier);
61 virtual void mouseUp(const ivec2& coord, Button button, Modifier modifier);
62 virtual void mouseWheel(const ivec2& coord, Modifier modifier, bool up);
63 void connect(int gesture, std::shared_ptr<MouseAction> action);
64 void disconnect(int gesture, MouseAction::Type type);
65 void push(int gesture, std::shared_ptr<MouseAction> action);
66 void pop(int gesture, MouseAction::Type type);
67 bool enabled() const;
68 void setEnabled(bool enabled);
69
70 void bind(const std::string& name, std::function<void(MouseAction*)> callback);
71 void unbind(const std::string& name);
72 void send(const std::string& name, MouseAction* action);
73
74 private:
75 void cancel();
76
77 private:
78 std::map<int, std::shared_ptr<MouseHoveredAction>> m_hoveredActionMap;
79 std::map<int, std::shared_ptr<MouseClickedAction>> m_clickedActionMap;
80 std::map<int, std::shared_ptr<MouseDraggedAction>> m_draggedActionMap;
81 std::map<int, std::shared_ptr<MouseHeldAction>> m_heldActionMap;
82 std::map<int, std::shared_ptr<MouseWheeledAction>> m_wheeledActionMap;
83 int m_gesture;
84 Vector2i m_coord;
85 MouseAction* m_actived;
86 bool m_mousedown;
87 bool m_canceled;
88 bool m_enabled;
89 std::shared_ptr<Timer> m_timer;
90 std::function<void(MouseAction*)> m_onTriggered;
91 };
92
93 std::shared_ptr<MouseManipulator> _manipulator();
94}
Definition action.h:27
Type
Definition action.h:29
Definition manipulator.h:32
virtual ~MouseManipulator()
void send(const std::string &name, MouseAction *action)
void pop(int gesture, MouseAction::Type type)
void setEnabled(bool enabled)
void connect(int gesture, std::shared_ptr< MouseAction > action)
void disconnect(int gesture, MouseAction::Type type)
bool enabled() const
virtual void mouseWheel(const ivec2 &coord, Modifier modifier, bool up)
void unbind(const std::string &name)
void push(int gesture, std::shared_ptr< MouseAction > action)
virtual void mouseDown(const ivec2 &coord, Button button, Modifier modifier)
virtual void mouseUp(const ivec2 &coord, Button button, Modifier modifier)
Button
Definition manipulator.h:39
virtual void mouseMove(const ivec2 &coord, Button button, Modifier modifier)
Modifier
Definition manipulator.h:48
void bind(const std::string &name, std::function< void(MouseAction *)> callback)
The class Vector2i inherits from the templated class of Vector2, and the template parameters are spec...
Definition vector.h:255
Definition decal.h:23
std::shared_ptr< MouseManipulator > _manipulator()