Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect offset of PopupMenu separator icons #83517

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions scene/gui/popup_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,9 +711,9 @@ void PopupMenu::_draw_items() {
// Separator
item_ofs.x += items[i].indent * theme_cache.indent;
if (items[i].separator) {
if (!text.is_empty() || !items[i].icon.is_null()) {
if (!text.is_empty() || items[i].icon.is_valid()) {
int content_size = items[i].text_buf->get_size().width + theme_cache.h_separation * 2;
if (!items[i].icon.is_null()) {
if (items[i].icon.is_valid()) {
content_size += icon_size.width + theme_cache.h_separation;
}

Expand Down Expand Up @@ -742,7 +742,9 @@ void PopupMenu::_draw_items() {
icon_color *= items[i].icon_modulate;

// For non-separator items, add some padding for the content.
item_ofs.x += theme_cache.item_start_padding;
if (!items[i].separator) {
item_ofs.x += theme_cache.item_start_padding;
}

// Checkboxes
if (items[i].checkable_type && !items[i].separator) {
Expand All @@ -758,7 +760,7 @@ void PopupMenu::_draw_items() {
int separator_ofs = (display_width - items[i].text_buf->get_size().width) / 2;

// Icon
if (!items[i].icon.is_null()) {
if (items[i].icon.is_valid()) {
const Point2 icon_offset = Point2(0, Math::floor((h - icon_size.height) / 2.0));
Point2 icon_pos;

Expand All @@ -769,6 +771,7 @@ void PopupMenu::_draw_items() {
icon_pos = Size2(control->get_size().width - item_ofs.x - separator_ofs - icon_size.width, item_ofs.y);
} else {
icon_pos = item_ofs + Size2(separator_ofs, 0);
separator_ofs += icon_size.width + theme_cache.h_separation;
}
} else {
if (rtl) {
Expand All @@ -794,9 +797,6 @@ void PopupMenu::_draw_items() {
if (items[i].separator) {
if (!text.is_empty()) {
Vector2 text_pos = Point2(separator_ofs, item_ofs.y + Math::floor((h - items[i].text_buf->get_size().y) / 2.0));
if (!rtl && !items[i].icon.is_null()) {
text_pos.x += icon_size.width + theme_cache.h_separation;
}

if (theme_cache.font_separator_outline_size > 0 && theme_cache.font_separator_outline_color.a > 0) {
items[i].text_buf->draw_outline(ci, text_pos, theme_cache.font_separator_outline_size, theme_cache.font_separator_outline_color);
Expand Down
Loading