Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/inspector/editor_properties_vector.h
9896 views
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
#pragma once
32
33
#include "editor/inspector/editor_inspector.h"
34
35
class EditorSpinSlider;
36
class TextureButton;
37
38
class EditorPropertyVectorN : public EditorProperty {
39
GDCLASS(EditorPropertyVectorN, EditorProperty);
40
41
static const String COMPONENT_LABELS[4];
42
43
int component_count = 0;
44
Variant::Type vector_type;
45
46
Vector<EditorSpinSlider *> spin_sliders;
47
TextureButton *linked = nullptr;
48
Vector<double> ratio;
49
bool is_grabbed = false;
50
51
bool radians_as_degrees = false;
52
53
void _update_ratio();
54
void _store_link(bool p_linked);
55
void _grab_changed(bool p_grab);
56
void _value_changed(double p_val, const String &p_name);
57
58
protected:
59
virtual void _set_read_only(bool p_read_only) override;
60
void _notification(int p_what);
61
62
public:
63
virtual void update_property() override;
64
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_radians_as_degrees = false, bool p_is_int = false);
65
EditorPropertyVectorN(Variant::Type p_type, bool p_force_wide, bool p_horizontal);
66
};
67
68
class EditorPropertyVector2 : public EditorPropertyVectorN {
69
GDCLASS(EditorPropertyVector2, EditorPropertyVectorN);
70
71
public:
72
EditorPropertyVector2(bool p_force_wide = false);
73
};
74
75
class EditorPropertyVector2i : public EditorPropertyVectorN {
76
GDCLASS(EditorPropertyVector2i, EditorPropertyVectorN);
77
78
public:
79
EditorPropertyVector2i(bool p_force_wide = false);
80
};
81
82
class EditorPropertyVector3 : public EditorPropertyVectorN {
83
GDCLASS(EditorPropertyVector3, EditorPropertyVectorN);
84
85
public:
86
EditorPropertyVector3(bool p_force_wide = false);
87
};
88
89
class EditorPropertyVector3i : public EditorPropertyVectorN {
90
GDCLASS(EditorPropertyVector3i, EditorPropertyVectorN);
91
92
public:
93
EditorPropertyVector3i(bool p_force_wide = false);
94
};
95
96
class EditorPropertyVector4 : public EditorPropertyVectorN {
97
GDCLASS(EditorPropertyVector4, EditorPropertyVectorN);
98
99
public:
100
EditorPropertyVector4(bool p_force_wide = false);
101
};
102
103
class EditorPropertyVector4i : public EditorPropertyVectorN {
104
GDCLASS(EditorPropertyVector4i, EditorPropertyVectorN);
105
106
public:
107
EditorPropertyVector4i(bool p_force_wide = false);
108
};
109
110