| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 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, |
| 49 |
HIDE_REASON_UNFOCUSED, |
| 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 |
}; |