feat: updated engine version to 4.4-rc1
This commit is contained in:
parent
ee00efde1f
commit
21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions
|
|
@ -30,7 +30,6 @@
|
|||
|
||||
#include "menu_bar.h"
|
||||
|
||||
#include "core/os/keyboard.h"
|
||||
#include "scene/main/window.h"
|
||||
#include "scene/theme/theme_db.h"
|
||||
|
||||
|
|
@ -121,8 +120,9 @@ void MenuBar::_open_popup(int p_index, bool p_focus_item) {
|
|||
}
|
||||
|
||||
Rect2 item_rect = _get_menu_item_rect(p_index);
|
||||
Point2 screen_pos = get_screen_position() + item_rect.position * get_viewport()->get_canvas_transform().get_scale();
|
||||
Size2 screen_size = item_rect.size * get_viewport()->get_canvas_transform().get_scale();
|
||||
Size2 canvas_scale = get_canvas_transform().get_scale();
|
||||
Point2 screen_pos = get_screen_position() + item_rect.position * canvas_scale;
|
||||
Size2 screen_size = item_rect.size * canvas_scale;
|
||||
|
||||
active_menu = p_index;
|
||||
|
||||
|
|
@ -217,15 +217,18 @@ void MenuBar::bind_global_menu() {
|
|||
int global_start_idx = -1;
|
||||
int count = nmenu->get_item_count(main_menu);
|
||||
String prev_tag;
|
||||
for (int i = 0; i < count; i++) {
|
||||
String tag = nmenu->get_item_tag(main_menu, i).operator String().get_slice("#", 1);
|
||||
if (!tag.is_empty() && tag != prev_tag) {
|
||||
if (i >= start_index) {
|
||||
global_start_idx = i;
|
||||
break;
|
||||
if (start_index >= 0) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
String tag = nmenu->get_item_tag(main_menu, i).operator String().get_slice("#", 1);
|
||||
if (!tag.is_empty() && tag != prev_tag) {
|
||||
MenuBar *mb = Object::cast_to<MenuBar>(ObjectDB::get_instance(ObjectID(static_cast<uint64_t>(tag.to_int()))));
|
||||
if (mb && mb->get_start_index() >= start_index) {
|
||||
global_start_idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
prev_tag = tag;
|
||||
}
|
||||
prev_tag = tag;
|
||||
}
|
||||
if (global_start_idx == -1) {
|
||||
global_start_idx = count;
|
||||
|
|
@ -503,9 +506,11 @@ void MenuBar::_refresh_menu_names() {
|
|||
|
||||
Vector<PopupMenu *> popups = _get_popups();
|
||||
for (int i = 0; i < popups.size(); i++) {
|
||||
if (!popups[i]->has_meta("_menu_name") && String(popups[i]->get_name()) != get_menu_title(i)) {
|
||||
menu_cache.write[i].name = popups[i]->get_name();
|
||||
String menu_name = popups[i]->get_title().is_empty() ? String(popups[i]->get_name()) : popups[i]->get_title();
|
||||
if (!popups[i]->has_meta("_menu_name") && menu_name != get_menu_title(i)) {
|
||||
menu_cache.write[i].name = menu_name;
|
||||
shape(menu_cache.write[i]);
|
||||
queue_redraw();
|
||||
if (is_global && menu_cache[i].submenu_rid.is_valid()) {
|
||||
int item_idx = nmenu->find_item_index_with_submenu(main_menu, menu_cache[i].submenu_rid);
|
||||
if (item_idx >= 0) {
|
||||
|
|
@ -542,6 +547,24 @@ int MenuBar::get_menu_idx_from_control(PopupMenu *p_child) const {
|
|||
return -1;
|
||||
}
|
||||
|
||||
void MenuBar::_popup_changed(ObjectID p_menu) {
|
||||
PopupMenu *pm = Object::cast_to<PopupMenu>(ObjectDB::get_instance(p_menu));
|
||||
if (!pm) {
|
||||
return;
|
||||
}
|
||||
|
||||
int idx = get_menu_idx_from_control(pm);
|
||||
|
||||
String menu_name = pm->get_title().is_empty() ? String(pm->get_name()) : pm->get_title();
|
||||
menu_name = String(pm->get_meta("_menu_name", menu_name));
|
||||
|
||||
menu_cache.write[idx].name = menu_name;
|
||||
shape(menu_cache.write[idx]);
|
||||
|
||||
update_minimum_size();
|
||||
queue_redraw();
|
||||
}
|
||||
|
||||
void MenuBar::add_child_notify(Node *p_child) {
|
||||
Control::add_child_notify(p_child);
|
||||
|
||||
|
|
@ -549,9 +572,12 @@ void MenuBar::add_child_notify(Node *p_child) {
|
|||
if (!pm) {
|
||||
return;
|
||||
}
|
||||
Menu menu = Menu(p_child->get_name());
|
||||
String menu_name = pm->get_title().is_empty() ? String(pm->get_name()) : pm->get_title();
|
||||
Menu menu = Menu(menu_name);
|
||||
shape(menu);
|
||||
|
||||
pm->connect("title_changed", callable_mp(this, &MenuBar::_popup_changed).bind(pm->get_instance_id()), CONNECT_REFERENCE_COUNTED);
|
||||
|
||||
menu_cache.push_back(menu);
|
||||
p_child->connect("renamed", callable_mp(this, &MenuBar::_refresh_menu_names));
|
||||
p_child->connect("about_to_popup", callable_mp(this, &MenuBar::_popup_visibility_changed).bind(true));
|
||||
|
|
@ -579,7 +605,8 @@ void MenuBar::move_child_notify(Node *p_child) {
|
|||
}
|
||||
|
||||
int old_idx = -1;
|
||||
String menu_name = String(pm->get_meta("_menu_name", pm->get_name()));
|
||||
String menu_name = pm->get_title().is_empty() ? String(pm->get_name()) : pm->get_title();
|
||||
menu_name = String(pm->get_meta("_menu_name", menu_name));
|
||||
// Find the previous menu index of the control.
|
||||
for (int i = 0; i < get_menu_count(); i++) {
|
||||
if (get_menu_title(i) == menu_name) {
|
||||
|
|
@ -635,6 +662,7 @@ void MenuBar::remove_child_notify(Node *p_child) {
|
|||
}
|
||||
}
|
||||
|
||||
pm->disconnect("title_changed", callable_mp(this, &MenuBar::_popup_changed));
|
||||
menu_cache.remove_at(idx);
|
||||
|
||||
p_child->remove_meta("_menu_name");
|
||||
|
|
@ -679,10 +707,7 @@ void MenuBar::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_menu_hidden", "menu", "hidden"), &MenuBar::set_menu_hidden);
|
||||
ClassDB::bind_method(D_METHOD("is_menu_hidden", "menu"), &MenuBar::is_menu_hidden);
|
||||
|
||||
// TODO: Properly handle popups when advanced GUI is disabled.
|
||||
#ifndef ADVANCED_GUI_DISABLED
|
||||
ClassDB::bind_method(D_METHOD("get_menu_popup", "menu"), &MenuBar::get_menu_popup);
|
||||
#endif // ADVANCED_GUI_DISABLED
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flat"), "set_flat", "is_flat");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "start_index"), "set_start_index", "get_start_index");
|
||||
|
|
@ -825,7 +850,8 @@ int MenuBar::get_menu_count() const {
|
|||
void MenuBar::set_menu_title(int p_menu, const String &p_title) {
|
||||
ERR_FAIL_INDEX(p_menu, menu_cache.size());
|
||||
PopupMenu *pm = get_menu_popup(p_menu);
|
||||
if (p_title == pm->get_name()) {
|
||||
String menu_name = pm->get_title().is_empty() ? String(pm->get_name()) : pm->get_title();
|
||||
if (p_title == menu_name) {
|
||||
pm->remove_meta("_menu_name");
|
||||
} else {
|
||||
pm->set_meta("_menu_name", p_title);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue