1 | /**************************************************************************/ |
2 | /* editor_properties_vector.h */ |
3 | /**************************************************************************/ |
4 | /* This file is part of: */ |
5 | /* GODOT ENGINE */ |
6 | /* https://godotengine.org */ |
7 | /**************************************************************************/ |
8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
10 | /* */ |
11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
12 | /* a copy of this software and associated documentation files (the */ |
13 | /* "Software"), to deal in the Software without restriction, including */ |
14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
17 | /* the following conditions: */ |
18 | /* */ |
19 | /* The above copyright notice and this permission notice shall be */ |
20 | /* included in all copies or substantial portions of the Software. */ |
21 | /* */ |
22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
29 | /**************************************************************************/ |
30 | |
31 | #ifndef EDITOR_PROPERTIES_VECTOR_H |
32 | #define EDITOR_PROPERTIES_VECTOR_H |
33 | |
34 | #include "editor/editor_inspector.h" |
35 | |
36 | class EditorSpinSlider; |
37 | class TextureButton; |
38 | |
39 | class EditorPropertyVectorN : public EditorProperty { |
40 | GDCLASS(EditorPropertyVectorN, EditorProperty); |
41 | |
42 | static const String COMPONENT_LABELS[4]; |
43 | |
44 | int component_count = 0; |
45 | Variant::Type vector_type; |
46 | |
47 | Vector<EditorSpinSlider *> spin_sliders; |
48 | TextureButton *linked = nullptr; |
49 | Vector<double> ratio; |
50 | bool is_grabbed = false; |
51 | |
52 | bool angle_in_radians = false; |
53 | |
54 | void _update_ratio(); |
55 | void _store_link(bool p_linked); |
56 | void _grab_changed(bool p_grab); |
57 | void _value_changed(double p_val, const String &p_name); |
58 | |
59 | protected: |
60 | virtual void _set_read_only(bool p_read_only) override; |
61 | void _notification(int p_what); |
62 | |
63 | public: |
64 | virtual void update_property() override; |
65 | void setup(double p_min, double p_max, double p_step = 1.0, bool p_hide_slider = true, bool p_link = false, const String &p_suffix = String(), bool p_angle_in_radians = false); |
66 | EditorPropertyVectorN(Variant::Type p_type, bool p_force_wide, bool p_horizontal); |
67 | }; |
68 | |
69 | class EditorPropertyVector2 : public EditorPropertyVectorN { |
70 | GDCLASS(EditorPropertyVector2, EditorPropertyVectorN); |
71 | |
72 | public: |
73 | EditorPropertyVector2(bool p_force_wide = false); |
74 | }; |
75 | |
76 | class EditorPropertyVector2i : public EditorPropertyVectorN { |
77 | GDCLASS(EditorPropertyVector2i, EditorPropertyVectorN); |
78 | |
79 | public: |
80 | EditorPropertyVector2i(bool p_force_wide = false); |
81 | }; |
82 | |
83 | class EditorPropertyVector3 : public EditorPropertyVectorN { |
84 | GDCLASS(EditorPropertyVector3, EditorPropertyVectorN); |
85 | |
86 | public: |
87 | EditorPropertyVector3(bool p_force_wide = false); |
88 | }; |
89 | |
90 | class EditorPropertyVector3i : public EditorPropertyVectorN { |
91 | GDCLASS(EditorPropertyVector3i, EditorPropertyVectorN); |
92 | |
93 | public: |
94 | EditorPropertyVector3i(bool p_force_wide = false); |
95 | }; |
96 | |
97 | class EditorPropertyVector4 : public EditorPropertyVectorN { |
98 | GDCLASS(EditorPropertyVector4, EditorPropertyVectorN); |
99 | |
100 | public: |
101 | EditorPropertyVector4(bool p_force_wide = false); |
102 | }; |
103 | |
104 | class EditorPropertyVector4i : public EditorPropertyVectorN { |
105 | GDCLASS(EditorPropertyVector4i, EditorPropertyVectorN); |
106 | |
107 | public: |
108 | EditorPropertyVector4i(bool p_force_wide = false); |
109 | }; |
110 | |
111 | #endif // EDITOR_PROPERTIES_VECTOR_H |
112 | |