diff options
Diffstat (limited to 'scene/gui/popup_menu.cpp')
-rw-r--r-- | scene/gui/popup_menu.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 4e8a44dd63..cf73729c0a 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -59,6 +59,7 @@ Size2 PopupMenu::_get_contents_minimum_size() const { for (int i = 0; i < items.size(); i++) { Size2 item_size; + const_cast<PopupMenu *>(this)->_shape_item(i); Size2 icon_size = items[i].get_icon_size(); item_size.height = _get_item_height(i); @@ -594,17 +595,17 @@ void PopupMenu::_draw_items() { int content_left = content_center - content_size / 2; int content_right = content_center + content_size / 2; if (content_left > item_ofs.x) { - int sep_h = theme_cache.labeled_separator_left->get_center_size().height + theme_cache.labeled_separator_left->get_minimum_size().height; + int sep_h = theme_cache.labeled_separator_left->get_minimum_size().height; int sep_ofs = Math::floor((h - sep_h) / 2.0); theme_cache.labeled_separator_left->draw(ci, Rect2(item_ofs + Point2(0, sep_ofs), Size2(MAX(0, content_left - item_ofs.x), sep_h))); } if (content_right < display_width) { - int sep_h = theme_cache.labeled_separator_right->get_center_size().height + theme_cache.labeled_separator_right->get_minimum_size().height; + int sep_h = theme_cache.labeled_separator_right->get_minimum_size().height; int sep_ofs = Math::floor((h - sep_h) / 2.0); theme_cache.labeled_separator_right->draw(ci, Rect2(Point2(content_right, item_ofs.y + sep_ofs), Size2(MAX(0, display_width - content_right), sep_h))); } } else { - int sep_h = theme_cache.separator_style->get_center_size().height + theme_cache.separator_style->get_minimum_size().height; + int sep_h = theme_cache.separator_style->get_minimum_size().height; int sep_ofs = Math::floor((h - sep_h) / 2.0); theme_cache.separator_style->draw(ci, Rect2(item_ofs + Point2(0, sep_ofs), Size2(display_width, sep_h))); } @@ -840,6 +841,9 @@ void PopupMenu::_notification(int p_what) { float pm_delay = pm->get_submenu_popup_delay(); set_submenu_popup_delay(pm_delay); } + if (!is_embedded()) { + set_flag(FLAG_NO_FOCUS, true); + } } break; case NOTIFICATION_THEME_CHANGED: @@ -1711,12 +1715,12 @@ void PopupMenu::activate_item(int p_item) { need_hide = false; } + emit_signal(SNAME("id_pressed"), id); + emit_signal(SNAME("index_pressed"), p_item); + if (need_hide) { hide(); } - - emit_signal(SNAME("id_pressed"), id); - emit_signal(SNAME("index_pressed"), p_item); } void PopupMenu::remove_item(int p_idx) { |