Debian Codegraph @

scene/gui/popup.h

raw symbols SCIP
1 /**************************************************************************/
2 /* popup.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 "scene/main/window.h"
34
35 #include "core/templates/local_vector.h"
36
37 class Panel;
38
39 class Popup : public Window {
40 GDCLASS(Popup, Window);
41
42 LocalVector<Window *> visible_parents;
43 bool popped_up = false;
44
45 public:
46 enum HideReason {
47 HIDE_REASON_NONE,
48 HIDE_REASON_CANCELED, // E.g., because of rupture of UI flow (app unfocused). Includes closed programmatically.
49 HIDE_REASON_UNFOCUSED, // E.g., user clicked outside.
50 };
51
52 private:
53 HideReason hide_reason = HIDE_REASON_NONE;
54
55 void _initialize_visible_parents();
56 void _deinitialize_visible_parents();
57
58 protected:
59 void _close_pressed();
60 virtual Rect2i _popup_adjust_rect() const override;
61 virtual void _input_from_window(const Ref<InputEvent> &p_event) override;
62
63 void _notification(int p_what);
64 void _validate_property(PropertyInfo &p_property) const;
65 static void _bind_methods();
66
67 virtual void _parent_focused();
68
69 virtual void _post_popup() override;
70
71 public:
72 HideReason get_hide_reason() const { return hide_reason; }
73
74 Popup();
75 ~Popup();
76 };
77
78 class PopupPanel : public Popup {
79 GDCLASS(PopupPanel, Popup);
80
81 Panel *panel = nullptr;
82
83 struct ThemeCache {
84 Ref<StyleBox> panel_style;
85 } theme_cache;
86
87 mutable Rect2i pre_popup_rect;
88
89 protected:
90 virtual void _input_from_window(const Ref<InputEvent> &p_event) override;
91
92 virtual Rect2i _popup_adjust_rect() const override;
93
94 void _update_shadow_offsets() const;
95 void _update_child_rects() const;
96
97 void _notification(int p_what);
98 static void _bind_methods();
99
100 virtual Size2 _get_contents_minimum_size() const override;
101
102 public:
103 #ifdef TOOLS_ENABLED
104 PackedStringArray get_configuration_warnings() const override;
105 #endif
106
107 PopupPanel();
108 };