summaryrefslogtreecommitdiff
path: root/scene/gui/popup_menu.h
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/popup_menu.h')
-rw-r--r--scene/gui/popup_menu.h38
1 files changed, 33 insertions, 5 deletions
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index e8f82ba869..c050e61d50 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,6 +35,7 @@
#include "scene/gui/popup.h"
#include "scene/gui/scroll_container.h"
#include "scene/gui/shortcut.h"
+#include "scene/resources/text_line.h"
class PopupMenu : public Popup {
GDCLASS(PopupMenu, Popup);
@@ -43,6 +44,13 @@ class PopupMenu : public Popup {
Ref<Texture2D> icon;
String text;
String xl_text;
+ Ref<TextLine> text_buf;
+ Ref<TextLine> accel_text_buf;
+
+ Dictionary opentype_features;
+ String language;
+ Control::TextDirection text_direction = Control::TEXT_DIRECTION_AUTO;
+
bool checked;
enum {
CHECKABLE_TYPE_NONE,
@@ -53,6 +61,7 @@ class PopupMenu : public Popup {
int state;
bool separator;
bool disabled;
+ bool dirty;
int id;
Variant metadata;
String submenu;
@@ -71,6 +80,9 @@ class PopupMenu : public Popup {
}
Item() {
+ text_buf.instance();
+ accel_text_buf.instance();
+ dirty = true;
checked = false;
checkable_type = CHECKABLE_TYPE_NONE;
separator = false;
@@ -86,6 +98,9 @@ class PopupMenu : public Popup {
}
};
+ bool close_allowed = false;
+
+ Timer *minimum_lifetime_timer = nullptr;
Timer *submenu_timer;
List<Rect2> autohide_areas;
Vector<Item> items;
@@ -94,15 +109,17 @@ class PopupMenu : public Popup {
int mouse_over;
int submenu_over;
Rect2 parent_rect;
- String _get_accel_text(int p_item) const;
+ String _get_accel_text(const Item &p_item) const;
int _get_mouse_over(const Point2 &p_over) const;
virtual Size2 _get_contents_minimum_size() const override;
int _get_items_total_height() const;
void _scroll_to_item(int p_item);
+ void _shape_item(int p_item);
+
void _gui_input(const Ref<InputEvent> &p_event);
- void _activate_submenu(int over);
+ void _activate_submenu(int p_over);
void _submenu_timeout();
uint64_t popup_time_msec = 0;
@@ -130,6 +147,9 @@ class PopupMenu : public Popup {
void _draw_items();
void _draw_background();
+ void _minimum_lifetime_timeout();
+ void _close_pressed();
+
protected:
friend class MenuButton;
void _notification(int p_what);
@@ -155,6 +175,11 @@ public:
void add_submenu_item(const String &p_label, const String &p_submenu, int p_id = -1);
void set_item_text(int p_idx, const String &p_text);
+
+ void set_item_text_direction(int p_idx, Control::TextDirection p_text_direction);
+ void set_item_opentype_feature(int p_idx, const String &p_name, int p_value);
+ void clear_item_opentype_features(int p_idx);
+ void set_item_language(int p_idx, const String &p_language);
void set_item_icon(int p_idx, const Ref<Texture2D> &p_icon);
void set_item_checked(int p_idx, bool p_checked);
void set_item_id(int p_idx, int p_id);
@@ -175,6 +200,9 @@ public:
void toggle_item_checked(int p_idx);
String get_item_text(int p_idx) const;
+ Control::TextDirection get_item_text_direction(int p_idx) const;
+ int get_item_opentype_feature(int p_idx, const String &p_name) const;
+ String get_item_language(int p_idx) const;
int get_item_idx_from_text(const String &text) const;
Ref<Texture2D> get_item_icon(int p_idx) const;
bool is_item_checked(int p_idx) const;
@@ -200,7 +228,7 @@ public:
void remove_item(int p_idx);
- void add_separator(const String &p_text = String());
+ void add_separator(const String &p_text = String(), int p_id = -1);
void clear();