Debian Codegraph @

editor/scene/particle_process_material_editor_plugin.h

raw symbols SCIP
1 /**************************************************************************/
2 /* particle_process_material_editor_plugin.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_properties.h"
34 #include "editor/plugins/editor_plugin.h"
35
36 class Button;
37 class EditorSpinSlider;
38 class Label;
39 class ParticleProcessMaterial;
40 class Range;
41 class VBoxContainer;
42
43 class ParticleProcessMaterialMinMaxPropertyEditor : public EditorProperty {
44 GDCLASS(ParticleProcessMaterialMinMaxPropertyEditor, EditorProperty);
45
46 enum class Hover {
47 NONE,
48 LEFT,
49 RIGHT,
50 MIDDLE,
51 };
52
53 enum class Drag {
54 NONE,
55 LEFT,
56 RIGHT,
57 MIDDLE,
58 SCALE,
59 };
60
61 enum class Mode {
62 RANGE,
63 MIDPOINT,
64 };
65
66 Ref<Texture2D> range_slider_left_icon;
67 Ref<Texture2D> range_slider_right_icon;
68
69 Color background_color;
70 Color normal_color;
71 Color hovered_color;
72 Color drag_color;
73 Color midpoint_color;
74
75 Control *range_edit_widget = nullptr;
76 Button *toggle_mode_button = nullptr;
77 Range *min_range = nullptr;
78 Range *max_range = nullptr;
79
80 EditorSpinSlider *min_edit = nullptr;
81 EditorSpinSlider *max_edit = nullptr;
82
83 Vector2 edit_size;
84 Vector2 margin;
85 Vector2 usable_area;
86
87 Vector2 property_range;
88
89 bool mouse_inside = false;
90 Hover hover = Hover::NONE;
91
92 Drag drag = Drag::NONE;
93 float drag_from_value = 0.0;
94 float drag_midpoint = 0.0;
95 float drag_origin = 0.0;
96
97 Mode slider_mode = Mode::RANGE;
98
99 void _update_sizing();
100 void _range_edit_draw();
101 void _range_edit_gui_input(const Ref<InputEvent> &p_event);
102 void _set_mouse_inside(bool p_inside);
103
104 float _get_min_ratio() const;
105 float _get_max_ratio() const;
106 float _get_left_offset() const;
107 float _get_right_offset() const;
108 Rect2 _get_middle_rect() const;
109
110 void _set_clamped_values(float p_min, float p_max);
111 void _sync_property();
112
113 void _update_mode();
114 void _toggle_mode(bool p_edit_mode);
115 void _update_slider_values();
116 void _sync_sliders(float, const EditorSpinSlider *p_changed_slider);
117 float _get_max_spread() const;
118
119 protected:
120 void _notification(int p_what);
121
122 public:
123 void setup(float p_min, float p_max, float p_step, bool p_allow_less, bool p_allow_greater, bool p_degrees);
124 virtual void update_property() override;
125
126 ParticleProcessMaterialMinMaxPropertyEditor();
127 };
128
129 class EditorInspectorParticleProcessMaterialPlugin : public EditorInspectorPlugin {
130 GDCLASS(EditorInspectorParticleProcessMaterialPlugin, EditorInspectorPlugin);
131
132 public:
133 virtual bool can_handle(Object *p_object) override;
134 virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide = false) override;
135 };