summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/line_edit.cpp2
-rw-r--r--scene/gui/popup_menu.cpp19
-rw-r--r--scene/gui/rich_text_label.cpp57
-rw-r--r--scene/gui/rich_text_label.h2
-rw-r--r--scene/gui/tab_container.cpp4
-rw-r--r--scene/gui/text_edit.cpp5
6 files changed, 22 insertions, 67 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 39ea6ed87b..5f0bb453f3 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -584,7 +584,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
if (handled) {
accept_event();
- } else if (!k->get_command() || (k->get_command() && k->get_alt())) {
+ } else if (!k->get_command()) {
if (k->get_unicode() >= 32 && k->get_keycode() != KEY_DELETE) {
if (editable) {
selection_delete();
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index ecb5ac0ffc..e777e6c26b 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -72,9 +72,7 @@ Size2 PopupMenu::_get_contents_minimum_size() const {
}
size.width += items[i].text_buf->get_size().x;
- if (i > 0) {
- size.height += vseparation;
- }
+ size.height += vseparation;
if (items[i].accel || (items[i].shortcut.is_valid() && items[i].shortcut->is_valid())) {
int accel_w = hseparation * 2;
@@ -152,9 +150,7 @@ int PopupMenu::_get_mouse_over(const Point2 &p_over) const {
}
for (int i = 0; i < items.size(); i++) {
- if (i > 0) {
- ofs.y += vseparation;
- }
+ ofs.y += i > 0 ? vseparation : (float)vseparation / 2;
ofs.y += MAX(items[i].get_icon_size().height, items[i].text_buf->get_size().y);
@@ -506,10 +502,8 @@ void PopupMenu::_draw_items() {
// Loop through all items and draw each.
for (int i = 0; i < items.size(); i++) {
- // If not the first item, add the separation space between items.
- if (i > 0) {
- ofs.y += vseparation;
- }
+ // For the first item only add half a separation. For all other items, add a whole separation to the offset.
+ ofs.y += i > 0 ? vseparation : (float)vseparation / 2;
_shape_item(i);
@@ -519,9 +513,9 @@ void PopupMenu::_draw_items() {
if (i == mouse_over) {
if (rtl) {
- hover->draw(ci, Rect2(item_ofs + Point2(-hseparation + scroll_width, -vseparation / 2), Size2(display_width + hseparation * 2, h + vseparation)));
+ hover->draw(ci, Rect2(item_ofs + Point2(scroll_width, -vseparation / 2), Size2(display_width, h + vseparation)));
} else {
- hover->draw(ci, Rect2(item_ofs + Point2(-hseparation, -vseparation / 2), Size2(display_width + hseparation * 2, h + vseparation)));
+ hover->draw(ci, Rect2(item_ofs + Point2(0, -vseparation / 2), Size2(display_width, h + vseparation)));
}
}
@@ -1636,7 +1630,6 @@ void PopupMenu::_bind_methods() {
void PopupMenu::popup(const Rect2 &p_bounds) {
moved = Vector2();
popup_time_msec = OS::get_singleton()->get_ticks_msec();
- set_as_minsize();
Popup::popup(p_bounds);
}
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 8891c6ab49..05ca97491b 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -2001,46 +2001,6 @@ void RichTextLabel::_fetch_item_fx_stack(Item *p_item, Vector<ItemFX *> &r_stack
}
}
-Color RichTextLabel::_get_color_from_string(const String &p_color_str, const Color &p_default_color) {
- if (p_color_str.begins_with("#")) {
- return Color::html(p_color_str);
- } else if (p_color_str == "aqua") {
- return Color(0, 1, 1);
- } else if (p_color_str == "black") {
- return Color(0, 0, 0);
- } else if (p_color_str == "blue") {
- return Color(0, 0, 1);
- } else if (p_color_str == "fuchsia") {
- return Color(1, 0, 1);
- } else if (p_color_str == "gray" || p_color_str == "grey") {
- return Color(0.5, 0.5, 0.5);
- } else if (p_color_str == "green") {
- return Color(0, 0.5, 0);
- } else if (p_color_str == "lime") {
- return Color(0, 1, 0);
- } else if (p_color_str == "maroon") {
- return Color(0.5, 0, 0);
- } else if (p_color_str == "navy") {
- return Color(0, 0, 0.5);
- } else if (p_color_str == "olive") {
- return Color(0.5, 0.5, 0);
- } else if (p_color_str == "purple") {
- return Color(0.5, 0, 0.5);
- } else if (p_color_str == "red") {
- return Color(1, 0, 0);
- } else if (p_color_str == "silver") {
- return Color(0.75, 0.75, 0.75);
- } else if (p_color_str == "teal") {
- return Color(0, 0.5, 0.5);
- } else if (p_color_str == "white") {
- return Color(1, 1, 1);
- } else if (p_color_str == "yellow") {
- return Color(1, 1, 0);
- } else {
- return p_default_color;
- }
-}
-
bool RichTextLabel::_find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item) {
Item *item = p_item;
@@ -2905,17 +2865,18 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
}
}
push_cell();
+ const Color fallback_color = Color(0, 0, 0, 0);
for (int i = 0; i < subtag.size(); i++) {
Vector<String> subtag_a = subtag[i].split("=");
if (subtag_a.size() == 2) {
if (subtag_a[0] == "border") {
- Color color = _get_color_from_string(subtag_a[1], Color(0, 0, 0, 0));
+ Color color = Color::from_string(subtag_a[1], fallback_color);
set_cell_border_color(color);
} else if (subtag_a[0] == "bg") {
Vector<String> subtag_b = subtag_a[1].split(",");
if (subtag_b.size() == 2) {
- Color color1 = _get_color_from_string(subtag_b[0], Color(0, 0, 0, 0));
- Color color2 = _get_color_from_string(subtag_b[1], Color(0, 0, 0, 0));
+ Color color1 = Color::from_string(subtag_b[0], fallback_color);
+ Color color2 = Color::from_string(subtag_b[1], fallback_color);
set_cell_row_background_color(color1, color2);
}
}
@@ -3131,9 +3092,9 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
} else if (subtag_a[0] == "outline_size") {
outline_size = subtag_a[1].to_int();
} else if (subtag_a[0] == "color") {
- color = _get_color_from_string(subtag_a[1], color);
+ color = Color::from_string(subtag_a[1], color);
} else if (subtag_a[0] == "outline_color") {
- outline_color = _get_color_from_string(subtag_a[1], outline_color);
+ outline_color = Color::from_string(subtag_a[1], outline_color);
}
}
}
@@ -3173,7 +3134,7 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
Color color = Color(1.0, 1.0, 1.0);
OptionMap::Element *color_option = bbcode_options.find("color");
if (color_option) {
- color = _get_color_from_string(color_option->value(), color);
+ color = Color::from_string(color_option->value(), color);
}
int width = 0;
@@ -3205,14 +3166,14 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
tag_stack.push_front(bbcode_name);
} else if (tag.begins_with("color=")) {
String color_str = tag.substr(6, tag.length());
- Color color = _get_color_from_string(color_str, base_color);
+ Color color = Color::from_string(color_str, base_color);
push_color(color);
pos = brk_end + 1;
tag_stack.push_front("color");
} else if (tag.begins_with("outline_color=")) {
String color_str = tag.substr(14, tag.length());
- Color color = _get_color_from_string(color_str, base_color);
+ Color color = Color::from_string(color_str, base_color);
push_outline_color(color);
pos = brk_end + 1;
tag_stack.push_front("outline_color");
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index f828a8cd1a..a65cc5a451 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -421,8 +421,6 @@ private:
bool _find_layout_subitem(Item *from, Item *to);
void _fetch_item_fx_stack(Item *p_item, Vector<ItemFX *> &r_stack);
- static Color _get_color_from_string(const String &p_color_str, const Color &p_default_color);
-
void _update_scroll();
void _update_fx(ItemFrame *p_frame, float p_delta_time);
void _scroll_changed(double);
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 7f0d7b6e7b..64a2a1843d 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -789,6 +789,10 @@ Control *TabContainer::get_current_tab_control() const {
void TabContainer::remove_child_notify(Node *p_child) {
Container::remove_child_notify(p_child);
+ if (!Object::cast_to<Control>(p_child)) {
+ return;
+ }
+
call_deferred("_update_current_tab");
p_child->disconnect("renamed", callable_mp(this, &TabContainer::_child_renamed_callback));
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index f54e5d1dd7..7557d36298 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1285,8 +1285,7 @@ void TextEdit::_notification(int p_what) {
if (draw_tabs && ((glyphs[j].flags & TextServer::GRAPHEME_IS_TAB) == TextServer::GRAPHEME_IS_TAB)) {
int yofs = (text_height - cache.tab_icon->get_height()) / 2 - ldata->get_line_ascent(line_wrap_index);
cache.tab_icon->draw(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + yofs), current_color);
- }
- if (draw_spaces && ((glyphs[j].flags & TextServer::GRAPHEME_IS_SPACE) == TextServer::GRAPHEME_IS_SPACE)) {
+ } else if (draw_spaces && ((glyphs[j].flags & TextServer::GRAPHEME_IS_SPACE) == TextServer::GRAPHEME_IS_SPACE)) {
int yofs = (text_height - cache.space_icon->get_height()) / 2 - ldata->get_line_ascent(line_wrap_index);
int xofs = (glyphs[j].advance * glyphs[j].repeat - cache.space_icon->get_width()) / 2;
cache.space_icon->draw(ci, Point2(char_ofs + char_margin + ofs_x + xofs, ofs_y + yofs), current_color);
@@ -3619,7 +3618,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
return;
}
- if (!keycode_handled && (!k->get_command() || (k->get_command() && k->get_alt()))) { // For German keyboards.
+ if (!keycode_handled && !k->get_command()) { // For German keyboards.
if (k->get_unicode() >= 32) {
if (readonly) {