CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
UIGizmo.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2023 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "UIControl.hpp"
11#include "UIView.hpp"
12
14
17
18namespace CeresEngine {
19
20 class UIViewport;
21
22 class UIGizmo;
23 class UIGizmoArrowManipulator;
24 class UIGizmoCircleManipulator;
25
27 class UIGizmo : public UIView {
28 using super = UIView;
29
30 public:
33
36
38
39 public:
42
43 public:
45
46 public: // Transforms
49
52
55
58
59 public: // UIView
60 // \copydoc UIView::mouseEntered
61 void mouseEntered(const CeresEngine::UIMouseEvent &event) override;
62 };
63
65 class UITranslationGizmo : public UIGizmo {
66 private:
69
72
75
76 // UIGizmoPlaneManipulator* mXYManipulator;
77 // UIGizmoPlaneManipulator* mXZManipulator;
78 // UIGizmoPlaneManipulator* mYZManipulator;
79
80 public:
83 };
84
101
103 class UIScalingGizmo : public UIGizmo {
104 public:
106 ~UIScalingGizmo() override;
107 };
108
109 // ---------------------------------------------------------------------------------------------
110
114
115 protected:
118
119 public:
120 using super::super;
121
122 public: // UIView
125
126 // \copydoc UIView::mouseEntered
127 void mouseEntered(const UIMouseEvent& event) override;
128
129 protected:
130 [[nodiscard]] AffineTransform getSceneToLocalTransform() const;
131 };
132
136
137 private:
140
143
146
147 public:
149
150 public:
152 void draw(UIGraphicsContext& context, const UIRect& dirtyRect) override;
153
155 bool isPointInside(const UIPoint& point, const Optional<const UIEvent&>& event) override;
156
158 void mouseDown(const UIMouseEvent& event) override;
159
161 void mouseDragged(const UIMouseEvent& event) override;
162 };
163
167
168 private:
171
174
178
179 public:
181
182 public:
184 void draw(UIGraphicsContext& context, const UIRect& dirtyRect) override;
185
187 bool isPointInside(const UIPoint& point, const Optional<const UIEvent&>& event) override;
188
190 void mouseDown(const UIMouseEvent& event) override;
191
193 void mouseDragged(const UIMouseEvent& event) override;
194 };
195
196} // namespace CeresEngine
A path that consists of straight and curved line segments that you can render.
Definition BezierPath.hpp:46
An object that represents a graphics context.
Definition GraphicsContext.hpp:45
Definition Optional.hpp:17
Base template for the event class.
Definition Event.hpp:27
A definition of the fundamental behavior for controls, which are specialized views that notify your a...
Definition UIControl.hpp:30
UIControl()
Definition UIControl.hpp:219
An arrow that allows moving an axis on the scene.
Definition UIGizmo.hpp:134
void mouseDown(const UIMouseEvent &event) override
Informs the receiver that the user has pressed the left mouse button.
Vector3 mAxis
Definition UIGizmo.hpp:144
BezierPath mPath
The path that draws the gizmo manipulator.
Definition UIGizmo.hpp:139
Vector3 mOriginalPosition
Definition UIGizmo.hpp:145
bool isPointInside(const UIPoint &point, const Optional< const UIEvent & > &event) override
Returns a Boolean value indicating whether the receiver contains the specified point.
UIColor mColor
The gizmo manipulator color.
Definition UIGizmo.hpp:142
UIGizmoArrowManipulator(const UIColor &color, const Vector3 &axis)
void mouseDragged(const UIMouseEvent &event) override
Informs the receiver that the user has moved the mouse with the left button pressed.
void draw(UIGraphicsContext &context, const UIRect &dirtyRect) override
Overridden by subclasses to draw the view's texture within the specified rectangle.
An circle that allows rotating on an axis on the scene.
Definition UIGizmo.hpp:165
UIColor mColor
The gizmo manipulator color.
Definition UIGizmo.hpp:173
void mouseDown(const UIMouseEvent &event) override
Informs the receiver that the user has pressed the left mouse button.
Vector3 mAxis
Definition UIGizmo.hpp:175
Vector3 mOriginalDirection
Definition UIGizmo.hpp:177
bool isPointInside(const UIPoint &point, const Optional< const UIEvent & > &event) override
Returns a Boolean value indicating whether the receiver contains the specified point.
void draw(UIGraphicsContext &context, const UIRect &dirtyRect) override
Overridden by subclasses to draw the view's texture within the specified rectangle.
BezierPath mPath
The path that draws the gizmo manipulator.
Definition UIGizmo.hpp:170
Quaternion mOriginalRotation
Definition UIGizmo.hpp:176
void mouseDragged(const UIMouseEvent &event) override
Informs the receiver that the user has moved the mouse with the left button pressed.
UIGizmoCircleManipulator(const UIColor &color, const Vector3 &axis)
Represents a gizmo that can be used to move 3D objects on a 2D viewport.
Definition UIGizmo.hpp:27
void setTransform(const Transform &transform)
The 3D transform to be represented by the gizmo.
void setViewTransform(const Transform &viewTransform)
A transform of the gizmo view. Usually set by the owner of the gizmo.
Event< void(const Transform &)> didChangeTransform
An event fired whenever the gizmo has changed the transform.
Definition UIGizmo.hpp:41
void mouseEntered(const CeresEngine::UIMouseEvent &event) override
Informs the receiver that the cursor has entered a tracking rectangle.
Transform mViewTransform
A transform of the gizmo view. Usually set by the owner of the gizmo.
Definition UIGizmo.hpp:35
const Transform & getViewTransform() const noexcept
A transform of the gizmo view. Usually set by the owner of the gizmo.
Definition UIGizmo.hpp:54
const Transform & getTransform() const noexcept
The 3D transform to be represented by the gizmo.
Definition UIGizmo.hpp:48
UIViewport * mViewport
Definition UIGizmo.hpp:37
Transform mTransform
The 3D transform to be represented by the gizmo.
Definition UIGizmo.hpp:32
A gizmo manipulator that allows performing some transformation on the scene.
Definition UIGizmo.hpp:112
AffineTransform getSceneToLocalTransform() const
void didMoveToSuperView(UIView *superView) override
Informs the view that its superview has changed (possibly to nil).
UIGizmo * mGizmo
The parent gizmo.
Definition UIGizmo.hpp:117
void mouseEntered(const UIMouseEvent &event) override
Informs the receiver that the cursor has entered a tracking rectangle.
A gizmo that allows manipulating the rotation of a 3D transform.
Definition UIGizmo.hpp:86
UIGizmoCircleManipulator * mXManipulator
The manipulator that corresponds to the circle at the X axis.
Definition UIGizmo.hpp:89
UIGizmoCircleManipulator * mZManipulator
The manipulator that corresponds to the circle at the Z axis.
Definition UIGizmo.hpp:95
UIGizmoCircleManipulator * mYManipulator
The manipulator that corresponds to the circle at the Y axis.
Definition UIGizmo.hpp:92
A gizmo that allows manipulating the scale of a 3D transform.
Definition UIGizmo.hpp:103
A gizmo that allows manipulating the translation of a 3D transform.
Definition UIGizmo.hpp:65
UIGizmoArrowManipulator * mXManipulator
The manipulator that corresponds to the arrow at the X axis.
Definition UIGizmo.hpp:68
UIGizmoArrowManipulator * mZManipulator
The manipulator that corresponds to the arrow at the Z axis.
Definition UIGizmo.hpp:74
UIGizmoArrowManipulator * mYManipulator
The manipulator that corresponds to the arrow at the Y axis.
Definition UIGizmo.hpp:71
The infrastructure for drawing and handling events in a UI.
Definition UIView.hpp:153
UIView()
Initializes new UIView object with an empty frame rectangle.
Definition UIViewport.hpp:21
Definition Application.hpp:19
Color UIColor
Definition UIUtility.hpp:187
Rect2 UIRect
A structure that contains the location and dimensions of a rectangle.
Definition UIUtility.hpp:33
Axis axis(const StringView &str) noexcept
Returns the Axis constant that is represented by str.
Point2 UIPoint
A type that contains a point in a two-dimensional coordinate system.
Definition UIUtility.hpp:27
@ Transform
Indicates that the object transform is dirty.
auto transform(Container &container, Transform &&transform)
Returns an iterable object that iterates over the values of the container and applies transform to ev...
Definition Iterator.hpp:436
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition UIEvent.hpp:173