Debian Codegraph @

editor/scene/texture/gradient_texture_2d_editor_plugin.h

raw symbols SCIP
1 /**************************************************************************/
2 /* gradient_texture_2d_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_inspector.h"
34 #include "editor/plugins/editor_plugin.h"
35
36 class Button;
37 class EditorSpinSlider;
38 class GradientTexture2D;
39
40 class GradientTexture2DEdit : public Control {
41 GDCLASS(GradientTexture2DEdit, Control);
42
43 enum Handle {
44 HANDLE_NONE,
45 HANDLE_FROM,
46 HANDLE_TO
47 };
48
49 Ref<GradientTexture2D> texture;
50 bool snap_enabled = false;
51 int snap_count = 0;
52
53 TextureRect *checkerboard = nullptr;
54
55 Handle hovered = HANDLE_NONE;
56 Handle grabbed = HANDLE_NONE;
57 Point2 initial_grab_pos;
58
59 Size2 handle_size;
60 Point2 offset;
61 Size2 size;
62
63 Point2 _get_handle_pos(const Handle p_handle);
64 Handle get_handle_at(const Vector2 &p_pos);
65 void set_fill_pos(const Vector2 &p_pos);
66
67 virtual void gui_input(const Ref<InputEvent> &p_event) override;
68
69 void _draw();
70
71 protected:
72 void _notification(int p_what);
73
74 public:
75 void set_texture(Ref<GradientTexture2D> &p_texture);
76 void set_snap_enabled(bool p_snap_enabled);
77 void set_snap_count(int p_snap_count);
78
79 GradientTexture2DEdit();
80 };
81
82 class GradientTexture2DEditor : public VBoxContainer {
83 GDCLASS(GradientTexture2DEditor, VBoxContainer);
84
85 Ref<GradientTexture2D> texture;
86
87 Button *reverse_button = nullptr;
88 Button *snap_button = nullptr;
89 EditorSpinSlider *snap_count_edit = nullptr;
90 GradientTexture2DEdit *texture_editor_rect = nullptr;
91
92 void _reverse_button_pressed();
93 void _set_snap_enabled(bool p_enabled);
94 void _set_snap_count(int p_snap_count);
95
96 protected:
97 void _notification(int p_what);
98
99 public:
100 static const int DEFAULT_SNAP;
101 void set_texture(Ref<GradientTexture2D> &p_texture);
102
103 GradientTexture2DEditor();
104 };
105
106 class EditorInspectorPluginGradientTexture2D : public EditorInspectorPlugin {
107 GDCLASS(EditorInspectorPluginGradientTexture2D, EditorInspectorPlugin);
108
109 public:
110 virtual bool can_handle(Object *p_object) override;
111 virtual void parse_begin(Object *p_object) override;
112 };
113
114 class GradientTexture2DEditorPlugin : public EditorPlugin {
115 GDCLASS(GradientTexture2DEditorPlugin, EditorPlugin);
116
117 public:
118 GradientTexture2DEditorPlugin();
119 };