Debian Codegraph @

editor/scene/2d/camera_2d_editor_plugin.h

raw symbols SCIP
1 /**************************************************************************/
2 /* camera_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/plugins/editor_plugin.h"
34
35 class Camera2D;
36 class Label;
37 class MenuButton;
38
39 class Camera2DEditor : public Control {
40 GDCLASS(Camera2DEditor, Control);
41
42 EditorPlugin *plugin = nullptr;
43
44 enum Menu {
45 MENU_SNAP_LIMITS_TO_VIEWPORT,
46 };
47
48 enum class Drag {
49 NONE,
50 LEFT,
51 TOP,
52 RIGHT,
53 BOTTOM,
54 TOP_LEFT,
55 TOP_RIGHT,
56 BOTTOM_LEFT,
57 BOTTOM_RIGHT,
58 CENTER,
59 };
60 Drag drag_type = Drag::NONE;
61 Drag hover_type = Drag::NONE;
62
63 Rect2 drag_revert;
64 Vector2 center_drag_point;
65
66 Camera2D *selected_camera = nullptr;
67
68 friend class Camera2DEditorPlugin;
69 MenuButton *options = nullptr;
70
71 void _menu_option(int p_option);
72 void _snap_limits_to_viewport(Camera2D *p_camera);
73 void _update_overlays_if_needed(Camera2D *p_camera);
74 void _update_hover(const Vector2 &p_mouse_pos);
75
76 protected:
77 static void _bind_methods();
78 void _notification(int p_what);
79
80 public:
81 void edit(Camera2D *p_camera);
82
83 bool forward_canvas_gui_input(const Ref<InputEvent> &p_event);
84 void forward_canvas_draw_over_viewport(Control *p_overlay);
85
86 Camera2DEditor(EditorPlugin *p_plugin);
87 };
88
89 class Camera2DEditorPlugin : public EditorPlugin {
90 GDCLASS(Camera2DEditorPlugin, EditorPlugin);
91
92 Camera2DEditor *camera_2d_editor = nullptr;
93
94 public:
95 virtual void edit(Object *p_object) override;
96 virtual bool handles(Object *p_object) const override;
97 virtual void make_visible(bool p_visible) override;
98
99 virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) override { return camera_2d_editor->forward_canvas_gui_input(p_event); }
100 virtual void forward_canvas_draw_over_viewport(Control *p_overlay) override { camera_2d_editor->forward_canvas_draw_over_viewport(p_overlay); }
101
102 Camera2DEditorPlugin();
103 };