summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2022-09-29 12:53:28 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2022-10-07 11:32:33 +0300
commit0103af1ddda6a2aa31227965141dd7d3a513e081 (patch)
treeb0965bb65919bc1495ee02204a91e5ed3a9b56a7 /scene/gui
parent5b7f62af55b7f322192f95258d825b163cbf9dc1 (diff)
Fix MSVC warnings, rename shadowed variables, fix uninitialized values, change warnings=all to use /W4.
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/code_edit.cpp16
-rw-r--r--scene/gui/color_picker.cpp94
-rw-r--r--scene/gui/control.cpp2
-rw-r--r--scene/gui/dialogs.cpp10
-rw-r--r--scene/gui/file_dialog.cpp8
-rw-r--r--scene/gui/graph_edit.cpp6
-rw-r--r--scene/gui/graph_node.cpp4
-rw-r--r--scene/gui/item_list.cpp14
-rw-r--r--scene/gui/label.cpp6
-rw-r--r--scene/gui/line_edit.cpp4
-rw-r--r--scene/gui/menu_bar.cpp20
-rw-r--r--scene/gui/menu_button.cpp20
-rw-r--r--scene/gui/popup.cpp40
-rw-r--r--scene/gui/popup_menu.cpp16
-rw-r--r--scene/gui/rich_text_label.cpp176
-rw-r--r--scene/gui/rich_text_label.h12
-rw-r--r--scene/gui/text_edit.cpp54
-rw-r--r--scene/gui/tree.cpp44
18 files changed, 273 insertions, 273 deletions
diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp
index 94d296977b..70707dba11 100644
--- a/scene/gui/code_edit.cpp
+++ b/scene/gui/code_edit.cpp
@@ -201,7 +201,7 @@ void CodeEdit::_notification(int p_what) {
if (caret_visible && !code_hint.is_empty() && (!code_completion_active || (code_completion_below != code_hint_draw_below))) {
const int font_height = font->get_height(font_size);
Ref<StyleBox> sb = get_theme_stylebox(SNAME("panel"), SNAME("TooltipPanel"));
- Color font_color = get_theme_color(SNAME("font_color"), SNAME("TooltipLabel"));
+ Color color = get_theme_color(SNAME("font_color"), SNAME("TooltipLabel"));
Vector<String> code_hint_lines = code_hint.split("\n");
int line_count = code_hint_lines.size();
@@ -238,17 +238,17 @@ void CodeEdit::_notification(int p_what) {
Point2 round_ofs = hint_ofs + sb->get_offset() + Vector2(0, font->get_ascent(font_size) + font_height * i + yofs);
round_ofs = round_ofs.round();
- draw_string(font, round_ofs, line.replace(String::chr(0xFFFF), ""), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, font_color);
+ draw_string(font, round_ofs, line.replace(String::chr(0xFFFF), ""), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, color);
if (end > 0) {
// Draw an underline for the currently edited function parameter.
const Vector2 b = hint_ofs + sb->get_offset() + Vector2(begin, font_height + font_height * i + yofs);
- draw_line(b, b + Vector2(end - begin, 0), font_color, 2);
+ draw_line(b, b + Vector2(end - begin, 0), color, 2);
// Draw a translucent text highlight as well.
const Rect2 highlight_rect = Rect2(
b - Vector2(0, font_height),
Vector2(end - begin, font_height));
- draw_rect(highlight_rect, font_color * Color(1, 1, 1, 0.2));
+ draw_rect(highlight_rect, color * Color(1, 1, 1, 0.2));
}
yofs += line_spacing;
}
@@ -2135,15 +2135,15 @@ String CodeEdit::get_text_for_symbol_lookup() {
StringBuilder lookup_text;
const int text_size = get_line_count();
for (int i = 0; i < text_size; i++) {
- String text = get_line(i);
+ String line_text = get_line(i);
if (i == line) {
- lookup_text += text.substr(0, col);
+ lookup_text += line_text.substr(0, col);
/* Not unicode, represents the cursor. */
lookup_text += String::chr(0xFFFF);
- lookup_text += text.substr(col, text.size());
+ lookup_text += line_text.substr(col, line_text.size());
} else {
- lookup_text += text;
+ lookup_text += line_text;
}
if (i != text_size - 1) {
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 36b770408e..f1e18640e6 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -357,59 +357,59 @@ void ColorPicker::add_mode(ColorMode *p_mode) {
}
void ColorPicker::create_slider(GridContainer *gc, int idx) {
- Label *l = memnew(Label());
- l->set_v_size_flags(SIZE_SHRINK_CENTER);
- gc->add_child(l);
+ Label *lbl = memnew(Label());
+ lbl->set_v_size_flags(SIZE_SHRINK_CENTER);
+ gc->add_child(lbl);
- HSlider *s = memnew(HSlider);
- s->set_v_size_flags(SIZE_SHRINK_CENTER);
- s->set_focus_mode(FOCUS_NONE);
- gc->add_child(s);
+ HSlider *slider = memnew(HSlider);
+ slider->set_v_size_flags(SIZE_SHRINK_CENTER);
+ slider->set_focus_mode(FOCUS_NONE);
+ gc->add_child(slider);
- SpinBox *v = memnew(SpinBox);
- s->share(v);
- gc->add_child(v);
+ SpinBox *val = memnew(SpinBox);
+ slider->share(val);
+ gc->add_child(val);
- LineEdit *vle = v->get_line_edit();
+ LineEdit *vle = val->get_line_edit();
vle->connect("focus_entered", callable_mp(this, &ColorPicker::_focus_enter), CONNECT_DEFERRED);
vle->connect("focus_exited", callable_mp(this, &ColorPicker::_focus_exit));
vle->connect("text_changed", callable_mp(this, &ColorPicker::_text_changed));
vle->connect("gui_input", callable_mp(this, &ColorPicker::_line_edit_input));
vle->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT);
- v->connect("gui_input", callable_mp(this, &ColorPicker::_slider_or_spin_input));
+ val->connect("gui_input", callable_mp(this, &ColorPicker::_slider_or_spin_input));
- s->set_h_size_flags(SIZE_EXPAND_FILL);
+ slider->set_h_size_flags(SIZE_EXPAND_FILL);
- s->connect("value_changed", callable_mp(this, &ColorPicker::_value_changed));
- s->connect("draw", callable_mp(this, &ColorPicker::_slider_draw).bind(idx));
- s->connect("gui_input", callable_mp(this, &ColorPicker::_slider_or_spin_input));
+ slider->connect("value_changed", callable_mp(this, &ColorPicker::_value_changed));
+ slider->connect("draw", callable_mp(this, &ColorPicker::_slider_draw).bind(idx));
+ slider->connect("gui_input", callable_mp(this, &ColorPicker::_slider_or_spin_input));
if (idx < SLIDER_COUNT) {
- sliders[idx] = s;
- values[idx] = v;
- labels[idx] = l;
+ sliders[idx] = slider;
+ values[idx] = val;
+ labels[idx] = lbl;
} else {
- alpha_slider = s;
- alpha_value = v;
- alpha_label = l;
+ alpha_slider = slider;
+ alpha_value = val;
+ alpha_label = lbl;
}
}
-HSlider *ColorPicker::get_slider(int idx) {
- if (idx < SLIDER_COUNT) {
- return sliders[idx];
+HSlider *ColorPicker::get_slider(int p_idx) {
+ if (p_idx < SLIDER_COUNT) {
+ return sliders[p_idx];
}
return alpha_slider;
}
Vector<float> ColorPicker::get_active_slider_values() {
- Vector<float> values;
+ Vector<float> cur_values;
for (int i = 0; i < current_slider_count; i++) {
- values.push_back(sliders[i]->get_value());
+ cur_values.push_back(sliders[i]->get_value());
}
- values.push_back(alpha_slider->get_value());
- return values;
+ cur_values.push_back(alpha_slider->get_value());
+ return cur_values;
}
void ColorPicker::_copy_color_to_hsv() {
@@ -629,23 +629,23 @@ inline int ColorPicker::_get_preset_size() {
}
void ColorPicker::_add_preset_button(int p_size, const Color &p_color) {
- ColorPresetButton *btn_preset = memnew(ColorPresetButton(p_color, p_size));
- btn_preset->set_tooltip_text(vformat(RTR("Color: #%s\nLMB: Apply color\nRMB: Remove preset"), p_color.to_html(p_color.a < 1)));
- btn_preset->set_drag_forwarding(this);
- btn_preset->set_button_group(preset_group);
- preset_container->add_child(btn_preset);
- btn_preset->set_pressed(true);
- btn_preset->connect("gui_input", callable_mp(this, &ColorPicker::_preset_input).bind(p_color));
+ ColorPresetButton *btn_preset_new = memnew(ColorPresetButton(p_color, p_size));
+ btn_preset_new->set_tooltip_text(vformat(RTR("Color: #%s\nLMB: Apply color\nRMB: Remove preset"), p_color.to_html(p_color.a < 1)));
+ btn_preset_new->set_drag_forwarding(this);
+ btn_preset_new->set_button_group(preset_group);
+ preset_container->add_child(btn_preset_new);
+ btn_preset_new->set_pressed(true);
+ btn_preset_new->connect("gui_input", callable_mp(this, &ColorPicker::_preset_input).bind(p_color));
}
void ColorPicker::_add_recent_preset_button(int p_size, const Color &p_color) {
- ColorPresetButton *btn_preset = memnew(ColorPresetButton(p_color, p_size));
- btn_preset->set_tooltip_text(vformat(RTR("Color: #%s\nLMB: Apply color"), p_color.to_html(p_color.a < 1)));
- btn_preset->set_button_group(recent_preset_group);
- recent_preset_hbc->add_child(btn_preset);
- recent_preset_hbc->move_child(btn_preset, 0);
- btn_preset->set_pressed(true);
- btn_preset->connect("toggled", callable_mp(this, &ColorPicker::_recent_preset_pressed).bind(btn_preset));
+ ColorPresetButton *btn_preset_new = memnew(ColorPresetButton(p_color, p_size));
+ btn_preset_new->set_tooltip_text(vformat(RTR("Color: #%s\nLMB: Apply color"), p_color.to_html(p_color.a < 1)));
+ btn_preset_new->set_button_group(recent_preset_group);
+ recent_preset_hbc->add_child(btn_preset_new);
+ recent_preset_hbc->move_child(btn_preset_new, 0);
+ btn_preset_new->set_pressed(true);
+ btn_preset_new->connect("toggled", callable_mp(this, &ColorPicker::_recent_preset_pressed).bind(btn_preset_new));
}
void ColorPicker::_show_hide_preset(const bool &p_is_btn_pressed, Button *p_btn_preset, Container *p_preset_container) {
@@ -904,7 +904,7 @@ bool ColorPicker::is_deferred_mode() const {
}
void ColorPicker::_update_text_value() {
- bool visible = true;
+ bool text_visible = true;
if (text_is_constructor) {
String t = "Color(" + String::num(color.r) + ", " + String::num(color.g) + ", " + String::num(color.b);
if (edit_alpha && color.a < 1) {
@@ -916,13 +916,13 @@ void ColorPicker::_update_text_value() {
}
if (color.r > 1 || color.g > 1 || color.b > 1 || color.r < 0 || color.g < 0 || color.b < 0) {
- visible = false;
+ text_visible = false;
} else if (!text_is_constructor) {
c_text->set_text(color.to_html(edit_alpha && color.a < 1));
}
- text_type->set_visible(visible);
- c_text->set_visible(visible);
+ text_type->set_visible(text_visible);
+ c_text->set_visible(text_visible);
}
void ColorPicker::_sample_input(const Ref<InputEvent> &p_event) {
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index dc9294df6d..2dcae2553c 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1793,7 +1793,7 @@ bool Control::can_drop_data(const Point2 &p_point, const Variant &p_data) const
}
}
- bool ret;
+ bool ret = false;
if (GDVIRTUAL_CALL(_can_drop_data, p_point, p_data, ret)) {
return ret;
}
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index f5edaf02d8..bf4dd3d245 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -208,24 +208,24 @@ void AcceptDialog::register_text_enter(Control *p_line_edit) {
}
void AcceptDialog::_update_child_rects() {
- Size2 size = get_size();
+ Size2 dlg_size = get_size();
float h_margins = theme_cache.panel_style->get_margin(SIDE_LEFT) + theme_cache.panel_style->get_margin(SIDE_RIGHT);
float v_margins = theme_cache.panel_style->get_margin(SIDE_TOP) + theme_cache.panel_style->get_margin(SIDE_BOTTOM);
// Fill the entire size of the window with the background.
bg_panel->set_position(Point2());
- bg_panel->set_size(size);
+ bg_panel->set_size(dlg_size);
// Place the buttons from the bottom edge to their minimum required size.
Size2 buttons_minsize = buttons_hbox->get_combined_minimum_size();
- Size2 buttons_size = Size2(size.x - h_margins, buttons_minsize.y);
- Point2 buttons_position = Point2(theme_cache.panel_style->get_margin(SIDE_LEFT), size.y - theme_cache.panel_style->get_margin(SIDE_BOTTOM) - buttons_size.y);
+ Size2 buttons_size = Size2(dlg_size.x - h_margins, buttons_minsize.y);
+ Point2 buttons_position = Point2(theme_cache.panel_style->get_margin(SIDE_LEFT), dlg_size.y - theme_cache.panel_style->get_margin(SIDE_BOTTOM) - buttons_size.y);
buttons_hbox->set_position(buttons_position);
buttons_hbox->set_size(buttons_size);
// Place the content from the top to fill the rest of the space (minus the separation).
Point2 content_position = Point2(theme_cache.panel_style->get_margin(SIDE_LEFT), theme_cache.panel_style->get_margin(SIDE_TOP));
- Size2 content_size = Size2(size.x - h_margins, size.y - v_margins - buttons_size.y - theme_cache.buttons_separation);
+ Size2 content_size = Size2(dlg_size.x - h_margins, dlg_size.y - v_margins - buttons_size.y - theme_cache.buttons_separation);
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index cf7f439aef..cade65108c 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -743,10 +743,10 @@ void FileDialog::set_current_path(const String &p_path) {
if (pos == -1) {
set_current_file(p_path);
} else {
- String dir = p_path.substr(0, pos);
- String file = p_path.substr(pos + 1, p_path.length());
- set_current_dir(dir);
- set_current_file(file);
+ String path_dir = p_path.substr(0, pos);
+ String path_file = p_path.substr(pos + 1, p_path.length());
+ set_current_dir(path_dir);
+ set_current_file(path_file);
}
}
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 7295ab9e9d..90552c32c2 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -92,8 +92,8 @@ void GraphEditMinimap::update_minimap() {
Rect2 GraphEditMinimap::get_camera_rect() {
Vector2 camera_center = _convert_from_graph_position(camera_position + camera_size / 2) + minimap_offset;
Vector2 camera_viewport = _convert_from_graph_position(camera_size);
- Vector2 camera_position = (camera_center - camera_viewport / 2);
- return Rect2(camera_position, camera_viewport);
+ Vector2 camera_pos = (camera_center - camera_viewport / 2);
+ return Rect2(camera_pos, camera_viewport);
}
Vector2 GraphEditMinimap::_get_render_size() {
@@ -1475,7 +1475,7 @@ void GraphEdit::force_connection_drag_end() {
}
bool GraphEdit::is_node_hover_valid(const StringName &p_from, const int p_from_port, const StringName &p_to, const int p_to_port) {
- bool valid;
+ bool valid = false;
if (GDVIRTUAL_CALL(_is_node_hover_valid, p_from, p_from_port, p_to, p_to_port, valid)) {
return valid;
}
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index 21c0b5a842..5df4c066e4 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -294,14 +294,14 @@ void GraphNode::_resort() {
bool GraphNode::has_point(const Point2 &p_point) const {
if (comment) {
- Ref<StyleBox> comment = get_theme_stylebox(SNAME("comment"));
+ Ref<StyleBox> comment_sb = get_theme_stylebox(SNAME("comment"));
Ref<Texture2D> resizer = get_theme_icon(SNAME("resizer"));
if (Rect2(get_size() - resizer->get_size(), resizer->get_size()).has_point(p_point)) {
return true;
}
- if (Rect2(0, 0, get_size().width, comment->get_margin(SIDE_TOP)).has_point(p_point)) {
+ if (Rect2(0, 0, get_size().width, comment_sb->get_margin(SIDE_TOP)).has_point(p_point)) {
return true;
}
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 357f2480bd..0dc791f71d 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -1296,9 +1296,9 @@ void ItemList::_notification(int p_what) {
draw_rect.size = adj.size;
}
- Color modulate = items[i].icon_modulate;
+ Color icon_modulate = items[i].icon_modulate;
if (items[i].disabled) {
- modulate.a *= 0.5;
+ icon_modulate.a *= 0.5;
}
// If the icon is transposed, we have to switch the size so that it is drawn correctly
@@ -1313,7 +1313,7 @@ void ItemList::_notification(int p_what) {
if (rtl) {
draw_rect.position.x = size.width - draw_rect.position.x - draw_rect.size.x;
}
- draw_texture_rect_region(items[i].icon, draw_rect, region, modulate, items[i].icon_transposed);
+ draw_texture_rect_region(items[i].icon, draw_rect, region, icon_modulate, items[i].icon_transposed);
}
if (items[i].tag_icon.is_valid()) {
@@ -1336,9 +1336,9 @@ void ItemList::_notification(int p_what) {
max_len = size2.x;
}
- Color modulate = items[i].selected ? theme_cache.font_selected_color : (items[i].custom_fg != Color() ? items[i].custom_fg : theme_cache.font_color);
+ Color txt_modulate = items[i].selected ? theme_cache.font_selected_color : (items[i].custom_fg != Color() ? items[i].custom_fg : theme_cache.font_color);
if (items[i].disabled) {
- modulate.a *= 0.5;
+ txt_modulate.a *= 0.5;
}
if (icon_mode == ICON_MODE_TOP && max_text_lines > 0) {
@@ -1355,7 +1355,7 @@ void ItemList::_notification(int p_what) {
items[i].text_buf->draw_outline(get_canvas_item(), text_ofs, theme_cache.font_outline_size, theme_cache.font_outline_color);
}
- items[i].text_buf->draw(get_canvas_item(), text_ofs, modulate);
+ items[i].text_buf->draw(get_canvas_item(), text_ofs, txt_modulate);
} else {
if (fixed_column_width > 0) {
size2.x = MIN(size2.x, fixed_column_width);
@@ -1387,7 +1387,7 @@ void ItemList::_notification(int p_what) {
}
if (width - text_ofs.x > 0) {
- items[i].text_buf->draw(get_canvas_item(), text_ofs, modulate);
+ items[i].text_buf->draw(get_canvas_item(), text_ofs, txt_modulate);
}
}
}
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index 306ca3d340..bf7c59d1cd 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -102,12 +102,12 @@ void Label::_shape() {
const Ref<Font> &font = (settings.is_valid() && settings->get_font().is_valid()) ? settings->get_font() : theme_cache.font;
int font_size = settings.is_valid() ? settings->get_font_size() : theme_cache.font_size;
ERR_FAIL_COND(font.is_null());
- String text = (uppercase) ? TS->string_to_upper(xl_text, language) : xl_text;
+ String txt = (uppercase) ? TS->string_to_upper(xl_text, language) : xl_text;
if (visible_chars >= 0 && visible_chars_behavior == TextServer::VC_CHARS_BEFORE_SHAPING) {
- text = text.substr(0, visible_chars);
+ txt = txt.substr(0, visible_chars);
}
if (dirty) {
- TS->shaped_text_add_string(text_rid, text, font->get_rids(), font_size, font->get_opentype_features(), language);
+ TS->shaped_text_add_string(text_rid, txt, font->get_rids(), font_size, font->get_opentype_features(), language);
} else {
int spans = TS->shaped_get_span_count(text_rid);
for (int i = 0; i < spans; i++) {
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index eb34559a14..36e85b5d02 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -1058,8 +1058,8 @@ void LineEdit::_notification(int p_what) {
if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_IME)) {
DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
- Point2 caret_column = Point2(get_caret_column(), 1) * get_minimum_size().height;
- DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + caret_column, get_viewport()->get_window_id());
+ Point2 column = Point2(get_caret_column(), 1) * get_minimum_size().height;
+ DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + column, get_viewport()->get_window_id());
}
show_virtual_keyboard();
diff --git a/scene/gui/menu_bar.cpp b/scene/gui/menu_bar.cpp
index 75592a1b99..742042f65f 100644
--- a/scene/gui/menu_bar.cpp
+++ b/scene/gui/menu_bar.cpp
@@ -213,19 +213,19 @@ void MenuBar::_popup_visibility_changed(bool p_visible) {
}
if (switch_on_hover) {
- Window *window = Object::cast_to<Window>(get_viewport());
- if (window) {
- mouse_pos_adjusted = window->get_position();
-
- if (window->is_embedded()) {
- Window *window_parent = Object::cast_to<Window>(window->get_parent()->get_viewport());
- while (window_parent) {
- if (!window_parent->is_embedded()) {
- mouse_pos_adjusted += window_parent->get_position();
+ Window *wnd = Object::cast_to<Window>(get_viewport());
+ if (wnd) {
+ mouse_pos_adjusted = wnd->get_position();
+
+ if (wnd->is_embedded()) {
+ Window *wnd_parent = Object::cast_to<Window>(wnd->get_parent()->get_viewport());
+ while (wnd_parent) {
+ if (!wnd_parent->is_embedded()) {
+ mouse_pos_adjusted += wnd_parent->get_position();
break;
}
- window_parent = Object::cast_to<Window>(window_parent->get_parent()->get_viewport());
+ wnd_parent = Object::cast_to<Window>(wnd_parent->get_parent()->get_viewport());
}
}
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index fa8df48412..78aeab9457 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -61,19 +61,19 @@ void MenuButton::_popup_visibility_changed(bool p_visible) {
}
if (switch_on_hover) {
- Window *window = Object::cast_to<Window>(get_viewport());
- if (window) {
- mouse_pos_adjusted = window->get_position();
-
- if (window->is_embedded()) {
- Window *window_parent = Object::cast_to<Window>(window->get_parent()->get_viewport());
- while (window_parent) {
- if (!window_parent->is_embedded()) {
- mouse_pos_adjusted += window_parent->get_position();
+ Window *wnd = Object::cast_to<Window>(get_viewport());
+ if (wnd) {
+ mouse_pos_adjusted = wnd->get_position();
+
+ if (wnd->is_embedded()) {
+ Window *wnd_parent = Object::cast_to<Window>(wnd->get_parent()->get_viewport());
+ while (wnd_parent) {
+ if (!wnd_parent->is_embedded()) {
+ mouse_pos_adjusted += wnd_parent->get_position();
break;
}
- window_parent = Object::cast_to<Window>(window_parent->get_parent()->get_viewport());
+ wnd_parent = Object::cast_to<Window>(wnd_parent->get_parent()->get_viewport());
}
}
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index ceae3791f3..a6915f9e61 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -128,50 +128,50 @@ void Popup::_bind_methods() {
Rect2i Popup::_popup_adjust_rect() const {
ERR_FAIL_COND_V(!is_inside_tree(), Rect2());
- Rect2i parent = get_usable_parent_rect();
+ Rect2i parent_rect = get_usable_parent_rect();
- if (parent == Rect2i()) {
+ if (parent_rect == Rect2i()) {
return Rect2i();
}
Rect2i current(get_position(), get_size());
- if (current.position.x + current.size.x > parent.position.x + parent.size.x) {
- current.position.x = parent.position.x + parent.size.x - current.size.x;
+ if (current.position.x + current.size.x > parent_rect.position.x + parent_rect.size.x) {
+ current.position.x = parent_rect.position.x + parent_rect.size.x - current.size.x;
}
- if (current.position.x < parent.position.x) {
- current.position.x = parent.position.x;
+ if (current.position.x < parent_rect.position.x) {
+ current.position.x = parent_rect.position.x;
}
- if (current.position.y + current.size.y > parent.position.y + parent.size.y) {
- current.position.y = parent.position.y + parent.size.y - current.size.y;
+ if (current.position.y + current.size.y > parent_rect.position.y + parent_rect.size.y) {
+ current.position.y = parent_rect.position.y + parent_rect.size.y - current.size.y;
}
- if (current.position.y < parent.position.y) {
- current.position.y = parent.position.y;
+ if (current.position.y < parent_rect.position.y) {
+ current.position.y = parent_rect.position.y;
}
- if (current.size.y > parent.size.y) {
- current.size.y = parent.size.y;
+ if (current.size.y > parent_rect.size.y) {
+ current.size.y = parent_rect.size.y;
}
- if (current.size.x > parent.size.x) {
- current.size.x = parent.size.x;
+ if (current.size.x > parent_rect.size.x) {
+ current.size.x = parent_rect.size.x;
}
// Early out if max size not set.
- Size2i max_size = get_max_size();
- if (max_size <= Size2()) {
+ Size2i popup_max_size = get_max_size();
+ if (popup_max_size <= Size2()) {
return current;
}
- if (current.size.x > max_size.x) {
- current.size.x = max_size.x;
+ if (current.size.x > popup_max_size.x) {
+ current.size.x = popup_max_size.x;
}
- if (current.size.y > max_size.y) {
- current.size.y = max_size.y;
+ if (current.size.y > popup_max_size.y) {
+ current.size.y = popup_max_size.y;
}
return current;
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 10e13042a7..4cdde5902e 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -58,20 +58,20 @@ Size2 PopupMenu::_get_contents_minimum_size() const {
bool has_check = false;
for (int i = 0; i < items.size(); i++) {
- Size2 size;
+ Size2 item_size;
Size2 icon_size = items[i].get_icon_size();
- size.height = _get_item_height(i);
+ item_size.height = _get_item_height(i);
icon_w = MAX(icon_size.width, icon_w);
- size.width += items[i].indent * theme_cache.indent;
+ item_size.width += items[i].indent * theme_cache.indent;
if (items[i].checkable_type && !items[i].separator) {
has_check = true;
}
- size.width += items[i].text_buf->get_size().x;
- size.height += theme_cache.v_separation;
+ item_size.width += items[i].text_buf->get_size().x;
+ item_size.height += theme_cache.v_separation;
if (items[i].accel != Key::NONE || (items[i].shortcut.is_valid() && items[i].shortcut->has_valid_event())) {
int accel_w = theme_cache.h_separation * 2;
@@ -80,12 +80,12 @@ Size2 PopupMenu::_get_contents_minimum_size() const {
}
if (!items[i].submenu.is_empty()) {
- size.width += theme_cache.submenu->get_width();
+ item_size.width += theme_cache.submenu->get_width();
}
- max_w = MAX(max_w, size.width);
+ max_w = MAX(max_w, item_size.width);
- minsize.height += size.height;
+ minsize.height += item_size.height;
}
int item_side_padding = theme_cache.item_start_padding + theme_cache.item_end_padding;
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 7ea46a0b4f..5060bacba5 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -167,17 +167,17 @@ String RichTextLabel::_roman(int p_num, bool p_capitalize) const {
};
String s;
if (p_capitalize) {
- const String M[] = { "", "M", "MM", "MMM" };
- const String C[] = { "", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM" };
- const String X[] = { "", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC" };
- const String I[] = { "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX" };
- s = M[p_num / 1000] + C[(p_num % 1000) / 100] + X[(p_num % 100) / 10] + I[p_num % 10];
+ const String roman_M[] = { "", "M", "MM", "MMM" };
+ const String roman_C[] = { "", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM" };
+ const String roman_X[] = { "", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC" };
+ const String roman_I[] = { "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX" };
+ s = roman_M[p_num / 1000] + roman_C[(p_num % 1000) / 100] + roman_X[(p_num % 100) / 10] + roman_I[p_num % 10];
} else {
- const String M[] = { "", "m", "mm", "mmm" };
- const String C[] = { "", "c", "cc", "ccc", "cd", "d", "dc", "dcc", "dccc", "cm" };
- const String X[] = { "", "x", "xx", "xxx", "xl", "l", "lx", "lxx", "lxxx", "xc" };
- const String I[] = { "", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix" };
- s = M[p_num / 1000] + C[(p_num % 1000) / 100] + X[(p_num % 100) / 10] + I[p_num % 10];
+ const String roman_M[] = { "", "m", "mm", "mmm" };
+ const String roman_C[] = { "", "c", "cc", "ccc", "cd", "d", "dc", "dcc", "dccc", "cm" };
+ const String roman_X[] = { "", "x", "xx", "xxx", "xl", "l", "lx", "lxx", "lxxx", "xc" };
+ const String roman_I[] = { "", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix" };
+ s = roman_M[p_num / 1000] + roman_C[(p_num % 1000) / 100] + roman_X[(p_num % 100) / 10] + roman_I[p_num % 10];
}
return s;
}
@@ -468,7 +468,7 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
}
// Shape current paragraph.
- String text;
+ String txt;
Item *it_to = (p_line + 1 < (int)p_frame->lines.size()) ? p_frame->lines[p_line + 1].from : nullptr;
int remaining_characters = visible_characters - l.char_offset;
for (Item *it = l.from; it && it != it_to; it = _get_next_item(it)) {
@@ -502,7 +502,7 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
font_size = font_size_it->font_size;
}
l.text_buf->add_string("\n", font, font_size);
- text += "\n";
+ txt += "\n";
l.char_count++;
remaining_characters--;
} break;
@@ -532,13 +532,13 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
remaining_characters -= tx.length();
l.text_buf->add_string(tx, font, font_size, lang, (uint64_t)it);
- text += tx;
+ txt += tx;
l.char_count += tx.length();
} break;
case ITEM_IMAGE: {
ItemImage *img = static_cast<ItemImage *>(it);
l.text_buf->add_object((uint64_t)it, img->size, img->inline_align, 1);
- text += String::chr(0xfffc);
+ txt += String::chr(0xfffc);
l.char_count++;
remaining_characters--;
} break;
@@ -693,15 +693,15 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
}
l.text_buf->add_object((uint64_t)it, Size2(table->total_width, table->total_height), table->inline_align, t_char_count);
- text += String::chr(0xfffc).repeat(t_char_count);
+ txt += String::chr(0xfffc).repeat(t_char_count);
} break;
default:
break;
}
}
- //Apply BiDi override.
- l.text_buf->set_bidi_override(structured_text_parser(_find_stt(l.from), st_args, text));
+ // Apply BiDi override.
+ l.text_buf->set_bidi_override(structured_text_parser(_find_stt(l.from), st_args, txt));
*r_char_offset = l.char_offset + l.char_count;
@@ -987,7 +987,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
font_shadow_color.a = faded_visibility;
}
- bool visible = (font_outline_color.a != 0) || (font_shadow_color.a != 0);
+ bool txt_visible = (font_outline_color.a != 0) || (font_shadow_color.a != 0);
for (int j = 0; j < fx_stack.size(); j++) {
ItemFX *item_fx = fx_stack[j];
@@ -1002,7 +1002,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
if (!custom_effect.is_null()) {
charfx->elapsed_time = item_custom->elapsed_time;
charfx->range = Vector2i(l.char_offset + glyphs[i].start, l.char_offset + glyphs[i].end);
- charfx->visibility = visible;
+ charfx->visibility = txt_visible;
charfx->outline = true;
charfx->font = frid;
charfx->glyph_index = gl;
@@ -1018,7 +1018,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
font_color = charfx->color;
frid = charfx->font;
gl = charfx->glyph_index;
- visible &= charfx->visibility;
+ txt_visible &= charfx->visibility;
}
} else if (item_fx->type == ITEM_SHAKE) {
ItemShake *item_shake = static_cast<ItemShake *>(item_fx);
@@ -1062,7 +1062,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
const Color modulated_outline_color = font_outline_color * Color(1, 1, 1, font_color.a);
const Color modulated_shadow_color = font_shadow_color * Color(1, 1, 1, font_color.a);
for (int j = 0; j < glyphs[i].repeat; j++) {
- if (visible) {
+ if (txt_visible) {
bool skip = (trim_chars && l.char_offset + glyphs[i].end > visible_characters) || (trim_glyphs_ltr && (processed_glyphs_ol >= visible_glyphs)) || (trim_glyphs_rtl && (processed_glyphs_ol < total_glyphs - visible_glyphs));
if (!skip && frid != RID()) {
if (modulated_shadow_color.a > 0) {
@@ -1205,7 +1205,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
font_color.a = faded_visibility;
}
- bool visible = (font_color.a != 0);
+ bool txt_visible = (font_color.a != 0);
for (int j = 0; j < fx_stack.size(); j++) {
ItemFX *item_fx = fx_stack[j];
@@ -1220,7 +1220,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
if (!custom_effect.is_null()) {
charfx->elapsed_time = item_custom->elapsed_time;
charfx->range = Vector2i(l.char_offset + glyphs[i].start, l.char_offset + glyphs[i].end);
- charfx->visibility = visible;
+ charfx->visibility = txt_visible;
charfx->outline = false;
charfx->font = frid;
charfx->glyph_index = gl;
@@ -1236,7 +1236,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
font_color = charfx->color;
frid = charfx->font;
gl = charfx->glyph_index;
- visible &= charfx->visibility;
+ txt_visible &= charfx->visibility;
}
} else if (item_fx->type == ITEM_SHAKE) {
ItemShake *item_shake = static_cast<ItemShake *>(item_fx);
@@ -1283,7 +1283,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
// Draw glyphs.
for (int j = 0; j < glyphs[i].repeat; j++) {
bool skip = (trim_chars && l.char_offset + glyphs[i].end > visible_characters) || (trim_glyphs_ltr && (r_processed_glyphs >= visible_glyphs)) || (trim_glyphs_rtl && (r_processed_glyphs < total_glyphs - visible_glyphs));
- if (visible) {
+ if (txt_visible) {
if (!skip) {
if (frid != RID()) {
TS->font_draw_glyph(frid, ci, glyphs[i].font_size, p_ofs + fx_offset + off, gl, selected ? selection_fg : font_color);
@@ -3609,21 +3609,21 @@ void RichTextLabel::append_text(const String &p_bbcode) {
brk_pos = p_bbcode.length();
}
- String text = brk_pos > pos ? p_bbcode.substr(pos, brk_pos - pos) : "";
+ String txt = brk_pos > pos ? p_bbcode.substr(pos, brk_pos - pos) : "";
// Trim the first newline character, it may be added later as needed.
if (after_list_close_tag || after_list_open_tag) {
- text = text.trim_prefix("\n");
+ txt = txt.trim_prefix("\n");
}
if (brk_pos == p_bbcode.length()) {
// For tags that are not properly closed.
- if (text.is_empty() && after_list_open_tag) {
- text = "\n";
+ if (txt.is_empty() && after_list_open_tag) {
+ txt = "\n";
}
- if (!text.is_empty()) {
- add_text(text);
+ if (!txt.is_empty()) {
+ add_text(txt);
}
break; //nothing else to add
}
@@ -3632,8 +3632,8 @@ void RichTextLabel::append_text(const String &p_bbcode) {
if (brk_end == -1) {
//no close, add the rest
- text += p_bbcode.substr(brk_pos, p_bbcode.length() - brk_pos);
- add_text(text);
+ txt += p_bbcode.substr(brk_pos, p_bbcode.length() - brk_pos);
+ add_text(txt);
break;
}
@@ -3679,36 +3679,36 @@ void RichTextLabel::append_text(const String &p_bbcode) {
}
if (!tag_ok) {
- text += "[" + tag;
- add_text(text);
+ txt += "[" + tag;
+ add_text(txt);
after_list_open_tag = false;
after_list_close_tag = false;
pos = brk_end;
continue;
}
- if (text.is_empty() && after_list_open_tag) {
- text = "\n"; // Make empty list have at least one item.
+ if (txt.is_empty() && after_list_open_tag) {
+ txt = "\n"; // Make empty list have at least one item.
}
after_list_open_tag = false;
if (tag == "/ol" || tag == "/ul") {
- if (!text.is_empty()) {
+ if (!txt.is_empty()) {
// Make sure text ends with a newline character, that is, the last item
// will wrap at the end of block.
- if (!text.ends_with("\n")) {
- text += "\n";
+ if (!txt.ends_with("\n")) {
+ txt += "\n";
}
} else if (!after_list_close_tag) {
- text = "\n"; // Make the innermost list item wrap at the end of lists.
+ txt = "\n"; // Make the innermost list item wrap at the end of lists.
}
after_list_close_tag = true;
} else {
after_list_close_tag = false;
}
- if (!text.is_empty()) {
- add_text(text);
+ if (!txt.is_empty()) {
+ add_text(txt);
}
tag_stack.pop_front();
@@ -3720,15 +3720,15 @@ void RichTextLabel::append_text(const String &p_bbcode) {
}
if (tag == "ol" || tag.begins_with("ol ") || tag == "ul" || tag.begins_with("ul ")) {
- if (text.is_empty() && after_list_open_tag) {
- text = "\n"; // Make each list have at least one item at the beginning.
+ if (txt.is_empty() && after_list_open_tag) {
+ txt = "\n"; // Make each list have at least one item at the beginning.
}
after_list_open_tag = true;
} else {
after_list_open_tag = false;
}
- if (!text.is_empty()) {
- add_text(text);
+ if (!txt.is_empty()) {
+ add_text(txt);
}
after_list_close_tag = false;
@@ -3970,7 +3970,7 @@ void RichTextLabel::append_text(const String &p_bbcode) {
HorizontalAlignment alignment = HORIZONTAL_ALIGNMENT_LEFT;
Control::TextDirection dir = Control::TEXT_DIRECTION_INHERITED;
String lang;
- TextServer::StructuredTextParser st_parser = TextServer::STRUCTURED_TEXT_DEFAULT;
+ TextServer::StructuredTextParser st_parser_type = TextServer::STRUCTURED_TEXT_DEFAULT;
for (int i = 0; i < subtag.size(); i++) {
Vector<String> subtag_a = subtag[i].split("=");
if (subtag_a.size() == 2) {
@@ -3996,24 +3996,24 @@ void RichTextLabel::append_text(const String &p_bbcode) {
lang = subtag_a[1];
} else if (subtag_a[0] == "st" || subtag_a[0] == "bidi_override") {
if (subtag_a[1] == "d" || subtag_a[1] == "default") {
- st_parser = TextServer::STRUCTURED_TEXT_DEFAULT;
+ st_parser_type = TextServer::STRUCTURED_TEXT_DEFAULT;
} else if (subtag_a[1] == "u" || subtag_a[1] == "uri") {
- st_parser = TextServer::STRUCTURED_TEXT_URI;
+ st_parser_type = TextServer::STRUCTURED_TEXT_URI;
} else if (subtag_a[1] == "f" || subtag_a[1] == "file") {
- st_parser = TextServer::STRUCTURED_TEXT_FILE;
+ st_parser_type = TextServer::STRUCTURED_TEXT_FILE;
} else if (subtag_a[1] == "e" || subtag_a[1] == "email") {
- st_parser = TextServer::STRUCTURED_TEXT_EMAIL;
+ st_parser_type = TextServer::STRUCTURED_TEXT_EMAIL;
} else if (subtag_a[1] == "l" || subtag_a[1] == "list") {
- st_parser = TextServer::STRUCTURED_TEXT_LIST;
+ st_parser_type = TextServer::STRUCTURED_TEXT_LIST;
} else if (subtag_a[1] == "n" || subtag_a[1] == "none") {
- st_parser = TextServer::STRUCTURED_TEXT_NONE;
+ st_parser_type = TextServer::STRUCTURED_TEXT_NONE;
} else if (subtag_a[1] == "c" || subtag_a[1] == "custom") {
- st_parser = TextServer::STRUCTURED_TEXT_CUSTOM;
+ st_parser_type = TextServer::STRUCTURED_TEXT_CUSTOM;
}
}
}
}
- push_paragraph(alignment, dir, lang, st_parser);
+ push_paragraph(alignment, dir, lang, st_parser_type);
pos = brk_end + 1;
tag_stack.push_front("p");
} else if (tag == "url") {
@@ -4079,9 +4079,9 @@ void RichTextLabel::append_text(const String &p_bbcode) {
end = p_bbcode.length();
}
- String txt = p_bbcode.substr(brk_end + 1, end - brk_end - 1);
+ String dc_txt = p_bbcode.substr(brk_end + 1, end - brk_end - 1);
- push_dropcap(txt, f, fs, dropcap_margins, color, outline_size, outline_color);
+ push_dropcap(dc_txt, f, fs, dropcap_margins, color, outline_size, outline_color);
pos = end;
tag_stack.push_front(bbcode_name);
@@ -4668,19 +4668,19 @@ bool RichTextLabel::_search_line(ItemFrame *p_frame, int p_line, const String &p
Line &l = p_frame->lines[p_line];
- String text;
+ String txt;
Item *it_to = (p_line + 1 < (int)p_frame->lines.size()) ? p_frame->lines[p_line + 1].from : nullptr;
for (Item *it = l.from; it && it != it_to; it = _get_next_item(it)) {
switch (it->type) {
case ITEM_NEWLINE: {
- text += "\n";
+ txt += "\n";
} break;
case ITEM_TEXT: {
ItemText *t = static_cast<ItemText *>(it);
- text += t->text;
+ txt += t->text;
} break;
case ITEM_IMAGE: {
- text += " ";
+ txt += " ";
} break;
case ITEM_TABLE: {
ItemTable *table = static_cast<ItemTable *>(it);
@@ -4696,9 +4696,9 @@ bool RichTextLabel::_search_line(ItemFrame *p_frame, int p_line, const String &p
int sp = -1;
if (p_reverse_search) {
- sp = text.rfindn(p_string, p_char_idx);
+ sp = txt.rfindn(p_string, p_char_idx);
} else {
- sp = text.findn(p_string, p_char_idx);
+ sp = txt.findn(p_string, p_char_idx);
}
if (sp != -1) {
@@ -4802,10 +4802,10 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p
}
String RichTextLabel::_get_line_text(ItemFrame *p_frame, int p_line, Selection p_selection) const {
- String text;
+ String txt;
- ERR_FAIL_COND_V(p_frame == nullptr, text);
- ERR_FAIL_COND_V(p_line < 0 || p_line >= (int)p_frame->lines.size(), text);
+ ERR_FAIL_COND_V(p_frame == nullptr, txt);
+ ERR_FAIL_COND_V(p_line < 0 || p_line >= (int)p_frame->lines.size(), txt);
Line &l = p_frame->lines[p_line];
@@ -4825,7 +4825,7 @@ String RichTextLabel::_get_line_text(ItemFrame *p_frame, int p_line, Selection p
ERR_CONTINUE(E->type != ITEM_FRAME); // Children should all be frames.
ItemFrame *frame = static_cast<ItemFrame *>(E);
for (int i = 0; i < (int)frame->lines.size(); i++) {
- text += _get_line_text(frame, i, p_selection);
+ txt += _get_line_text(frame, i, p_selection);
}
}
}
@@ -4837,23 +4837,23 @@ String RichTextLabel::_get_line_text(ItemFrame *p_frame, int p_line, Selection p
}
if (it->type == ITEM_DROPCAP) {
const ItemDropcap *dc = static_cast<ItemDropcap *>(it);
- text += dc->text;
+ txt += dc->text;
} else if (it->type == ITEM_TEXT) {
const ItemText *t = static_cast<ItemText *>(it);
- text += t->text;
+ txt += t->text;
} else if (it->type == ITEM_NEWLINE) {
- text += "\n";
+ txt += "\n";
} else if (it->type == ITEM_IMAGE) {
- text += " ";
+ txt += " ";
}
}
if ((l.from != nullptr) && (p_frame == p_selection.to_frame) && (p_selection.to_item != nullptr) && (p_selection.to_item->index >= l.from->index) && (p_selection.to_item->index < end_idx)) {
- text = text.substr(0, p_selection.to_char);
+ txt = txt.substr(0, p_selection.to_char);
}
if ((l.from != nullptr) && (p_frame == p_selection.from_frame) && (p_selection.from_item != nullptr) && (p_selection.from_item->index >= l.from->index) && (p_selection.from_item->index < end_idx)) {
- text = text.substr(p_selection.from_char, -1);
+ txt = txt.substr(p_selection.from_char, -1);
}
- return text;
+ return txt;
}
void RichTextLabel::set_context_menu_enabled(bool p_enabled) {
@@ -4887,12 +4887,12 @@ String RichTextLabel::get_selected_text() const {
return "";
}
- String text;
+ String txt;
int to_line = main->first_invalid_line.load();
for (int i = 0; i < to_line; i++) {
- text += _get_line_text(main, i, selection);
+ txt += _get_line_text(main, i, selection);
}
- return text;
+ return txt;
}
void RichTextLabel::deselect() {
@@ -4901,10 +4901,10 @@ void RichTextLabel::deselect() {
}
void RichTextLabel::selection_copy() {
- String text = get_selected_text();
+ String txt = get_selected_text();
- if (!text.is_empty()) {
- DisplayServer::get_singleton()->clipboard_set(text);
+ if (!txt.is_empty()) {
+ DisplayServer::get_singleton()->clipboard_set(txt);
}
}
@@ -5018,25 +5018,25 @@ bool RichTextLabel::is_using_bbcode() const {
}
String RichTextLabel::get_parsed_text() const {
- String text = "";
+ String txt = "";
Item *it = main;
while (it) {
if (it->type == ITEM_DROPCAP) {
ItemDropcap *dc = static_cast<ItemDropcap *>(it);
- text += dc->text;
+ txt += dc->text;
} else if (it->type == ITEM_TEXT) {
ItemText *t = static_cast<ItemText *>(it);
- text += t->text;
+ txt += t->text;
} else if (it->type == ITEM_NEWLINE) {
- text += "\n";
+ txt += "\n";
} else if (it->type == ITEM_IMAGE) {
- text += " ";
+ txt += " ";
} else if (it->type == ITEM_INDENT || it->type == ITEM_LIST) {
- text += "\t";
+ txt += "\t";
}
it = _get_next_item(it, true);
}
- return text;
+ return txt;
}
void RichTextLabel::set_text_direction(Control::TextDirection p_text_direction) {
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index 71123602ad..73b7676c22 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -301,14 +301,14 @@ private:
_current_rng = Math::rand();
}
- uint64_t offset_random(int index) {
- return (_current_rng >> (index % 64)) |
- (_current_rng << (64 - (index % 64)));
+ uint64_t offset_random(int p_index) {
+ return (_current_rng >> (p_index % 64)) |
+ (_current_rng << (64 - (p_index % 64)));
}
- uint64_t offset_previous_random(int index) {
- return (_previous_rng >> (index % 64)) |
- (_previous_rng << (64 - (index % 64)));
+ uint64_t offset_previous_random(int p_index) {
+ return (_previous_rng >> (p_index % 64)) |
+ (_previous_rng << (64 - (p_index % 64)));
}
};
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index b8973df185..f8501f3570 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -151,7 +151,7 @@ void TextEdit::Text::_calculate_line_height() {
}
void TextEdit::Text::_calculate_max_line_width() {
- int width = 0;
+ int line_width = 0;
for (const Line &l : text) {
if (l.hidden) {
continue;
@@ -159,12 +159,12 @@ void TextEdit::Text::_calculate_max_line_width() {
// Found another line with the same width...nothing to update.
if (l.width == max_width) {
- width = max_width;
+ line_width = max_width;
break;
}
- width = MAX(width, l.width);
+ line_width = MAX(line_width, l.width);
}
- max_width = width;
+ max_width = line_width;
}
void TextEdit::Text::invalidate_cache(int p_line, int p_column, bool p_text_changed, const String &p_ime_text, const Array &p_bidi_override) {
@@ -233,14 +233,14 @@ void TextEdit::Text::invalidate_cache(int p_line, int p_column, bool p_text_chan
// Update width.
const int old_width = text.write[p_line].width;
- int width = get_line_width(p_line);
- text.write[p_line].width = width;
+ int line_width = get_line_width(p_line);
+ text.write[p_line].width = line_width;
// If this line has shrunk, this may no longer the the longest line.
- if (old_width == max_width && width < max_width) {
+ if (old_width == max_width && line_width < max_width) {
_calculate_max_line_width();
} else if (!is_hidden(p_line)) {
- max_width = MAX(width, max_width);
+ max_width = MAX(line_width, max_width);
}
}
@@ -698,9 +698,9 @@ void TextEdit::_notification(int p_what) {
carets_wrap_index.write[i] = wrap_index;
}
- int first_visible_line = get_first_visible_line() - 1;
+ int first_vis_line = get_first_visible_line() - 1;
int draw_amount = visible_rows + (smooth_scroll_enabled ? 1 : 0);
- draw_amount += draw_placeholder ? placeholder_wraped_rows.size() - 1 : get_line_wrap_count(first_visible_line + 1);
+ draw_amount += draw_placeholder ? placeholder_wraped_rows.size() - 1 : get_line_wrap_count(first_vis_line + 1);
// Draw minimap.
if (draw_minimap) {
@@ -711,13 +711,13 @@ void TextEdit::_notification(int p_what) {
// calculate viewport size and y offset
int viewport_height = (draw_amount - 1) * minimap_line_height;
int control_height = _get_control_height() - viewport_height;
- int viewport_offset_y = round(get_scroll_pos_for_line(first_visible_line + 1) * control_height) / ((v_scroll->get_max() <= minimap_visible_lines) ? (minimap_visible_lines - draw_amount) : (v_scroll->get_max() - draw_amount));
+ int viewport_offset_y = round(get_scroll_pos_for_line(first_vis_line + 1) * control_height) / ((v_scroll->get_max() <= minimap_visible_lines) ? (minimap_visible_lines - draw_amount) : (v_scroll->get_max() - draw_amount));
// calculate the first line.
int num_lines_before = round((viewport_offset_y) / minimap_line_height);
- int minimap_line = (v_scroll->get_max() <= minimap_visible_lines) ? -1 : first_visible_line;
+ int minimap_line = (v_scroll->get_max() <= minimap_visible_lines) ? -1 : first_vis_line;
if (minimap_line >= 0) {
- minimap_line -= get_next_visible_line_index_offset_from(first_visible_line, 0, -num_lines_before).x;
+ minimap_line -= get_next_visible_line_index_offset_from(first_vis_line, 0, -num_lines_before).x;
minimap_line -= (minimap_line > 0 && smooth_scroll_enabled ? 1 : 0);
}
int minimap_draw_amount = minimap_visible_lines + get_line_wrap_count(minimap_line + 1);
@@ -885,7 +885,7 @@ void TextEdit::_notification(int p_what) {
// Draw main text.
line_drawing_cache.clear();
int row_height = draw_placeholder ? placeholder_line_height + line_spacing : get_line_height();
- int line = first_visible_line;
+ int line = first_vis_line;
for (int i = 0; i < draw_amount; i++) {
line++;
@@ -1012,14 +1012,14 @@ void TextEdit::_notification(int p_what) {
switch (gutter.type) {
case GUTTER_TYPE_STRING: {
- const String &text = get_line_gutter_text(line, g);
- if (text.is_empty()) {
+ const String &txt = get_line_gutter_text(line, g);
+ if (txt.is_empty()) {
break;
}
Ref<TextLine> tl;
tl.instantiate();
- tl->add_string(text, font, font_size);
+ tl->add_string(txt, font, font_size);
int yofs = ofs_y + (row_height - tl->get_size().y) / 2;
if (outline_size > 0 && outline_color.a > 0) {
@@ -4209,21 +4209,21 @@ int TextEdit::get_minimap_line_at_pos(const Point2i &p_pos) const {
// calculate visible lines
int minimap_visible_lines = get_minimap_visible_lines();
int visible_rows = get_visible_line_count() + 1;
- int first_visible_line = get_first_visible_line() - 1;
+ int first_vis_line = get_first_visible_line() - 1;
int draw_amount = visible_rows + (smooth_scroll_enabled ? 1 : 0);
- draw_amount += get_line_wrap_count(first_visible_line + 1);
+ draw_amount += get_line_wrap_count(first_vis_line + 1);
int minimap_line_height = (minimap_char_size.y + minimap_line_spacing);
// calculate viewport size and y offset
int viewport_height = (draw_amount - 1) * minimap_line_height;
int control_height = _get_control_height() - viewport_height;
- int viewport_offset_y = round(get_scroll_pos_for_line(first_visible_line + 1) * control_height) / ((v_scroll->get_max() <= minimap_visible_lines) ? (minimap_visible_lines - draw_amount) : (v_scroll->get_max() - draw_amount));
+ int viewport_offset_y = round(get_scroll_pos_for_line(first_vis_line + 1) * control_height) / ((v_scroll->get_max() <= minimap_visible_lines) ? (minimap_visible_lines - draw_amount) : (v_scroll->get_max() - draw_amount));
// calculate the first line.
int num_lines_before = round((viewport_offset_y) / minimap_line_height);
- int minimap_line = (v_scroll->get_max() <= minimap_visible_lines) ? -1 : first_visible_line;
- if (first_visible_line > 0 && minimap_line >= 0) {
- minimap_line -= get_next_visible_line_index_offset_from(first_visible_line, 0, -num_lines_before).x;
+ int minimap_line = (v_scroll->get_max() <= minimap_visible_lines) ? -1 : first_vis_line;
+ if (first_vis_line > 0 && minimap_line >= 0) {
+ minimap_line -= get_next_visible_line_index_offset_from(first_vis_line, 0, -num_lines_before).x;
minimap_line -= (minimap_line > 0 && smooth_scroll_enabled ? 1 : 0);
} else {
minimap_line = 0;
@@ -7340,10 +7340,10 @@ void TextEdit::_remove_text(int p_from_line, int p_from_column, int p_to_line, i
idle_detect->start();
}
- String text;
+ String txt;
if (undo_enabled) {
_clear_redo();
- text = _base_get_text(p_from_line, p_from_column, p_to_line, p_to_column);
+ txt = _base_get_text(p_from_line, p_from_column, p_to_line, p_to_column);
}
_base_remove_text(p_from_line, p_from_column, p_to_line, p_to_column);
@@ -7359,7 +7359,7 @@ void TextEdit::_remove_text(int p_from_line, int p_from_column, int p_to_line, i
op.from_column = p_from_column;
op.to_line = p_to_line;
op.to_column = p_to_column;
- op.text = text;
+ op.text = txt;
op.version = ++version;
op.chain_forward = false;
op.chain_backward = false;
@@ -7376,7 +7376,7 @@ void TextEdit::_remove_text(int p_from_line, int p_from_column, int p_to_line, i
// See if it can be merged.
if (current_op.from_line == p_to_line && current_op.from_column == p_to_column) {
// Backspace or similar.
- current_op.text = text + current_op.text;
+ current_op.text = txt + current_op.text;
current_op.from_line = p_from_line;
current_op.from_column = p_from_column;
current_op.end_carets = carets;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index db7d390b16..acf398305c 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -738,9 +738,9 @@ TreeItem *TreeItem::get_first_child() const {
TreeItem *TreeItem::_get_prev_visible(bool p_wrap) {
TreeItem *current = this;
- TreeItem *prev = current->get_prev();
+ TreeItem *prev_item = current->get_prev();
- if (!prev) {
+ if (!prev_item) {
current = current->parent;
if (current == tree->root && tree->hide_root) {
return nullptr;
@@ -757,7 +757,7 @@ TreeItem *TreeItem::_get_prev_visible(bool p_wrap) {
}
}
} else {
- current = prev;
+ current = prev_item;
while (!current->collapsed && current->first_child) {
//go to the very end
@@ -773,16 +773,16 @@ TreeItem *TreeItem::_get_prev_visible(bool p_wrap) {
TreeItem *TreeItem::get_prev_visible(bool p_wrap) {
TreeItem *loop = this;
- TreeItem *prev = this->_get_prev_visible(p_wrap);
- while (prev && !prev->is_visible()) {
- prev = prev->_get_prev_visible(p_wrap);
- if (prev == loop) {
+ TreeItem *prev_item = this->_get_prev_visible(p_wrap);
+ while (prev_item && !prev_item->is_visible()) {
+ prev_item = prev_item->_get_prev_visible(p_wrap);
+ if (prev_item == loop) {
// Check that we haven't looped all the way around to the start.
- prev = nullptr;
+ prev_item = nullptr;
break;
}
}
- return prev;
+ return prev_item;
}
TreeItem *TreeItem::_get_next_visible(bool p_wrap) {
@@ -814,16 +814,16 @@ TreeItem *TreeItem::_get_next_visible(bool p_wrap) {
TreeItem *TreeItem::get_next_visible(bool p_wrap) {
TreeItem *loop = this;
- TreeItem *next = this->_get_next_visible(p_wrap);
- while (next && !next->is_visible()) {
- next = next->_get_next_visible(p_wrap);
- if (next == loop) {
+ TreeItem *next_item = this->_get_next_visible(p_wrap);
+ while (next_item && !next_item->is_visible()) {
+ next_item = next_item->_get_next_visible(p_wrap);
+ if (next_item == loop) {
// Check that we haven't looped all the way around to the start.
- next = nullptr;
+ next_item = nullptr;
break;
}
}
- return next;
+ return next_item;
}
TreeItem *TreeItem::get_child(int p_idx) {
@@ -1317,8 +1317,8 @@ bool TreeItem::is_folding_disabled() const {
Size2 TreeItem::get_minimum_size(int p_column) {
ERR_FAIL_INDEX_V(p_column, cells.size(), Size2());
- Tree *tree = get_tree();
- ERR_FAIL_COND_V(!tree, Size2());
+ Tree *parent_tree = get_tree();
+ ERR_FAIL_COND_V(!parent_tree, Size2());
const TreeItem::Cell &cell = cells[p_column];
@@ -1328,7 +1328,7 @@ Size2 TreeItem::get_minimum_size(int p_column) {
// Text.
if (!cell.text.is_empty()) {
if (cell.dirty) {
- tree->update_item_cell(this, p_column);
+ parent_tree->update_item_cell(this, p_column);
}
Size2 text_size = cell.text_buf->get_size();
size.width += text_size.width;
@@ -1337,14 +1337,14 @@ Size2 TreeItem::get_minimum_size(int p_column) {
// Icon.
if (cell.mode == CELL_MODE_CHECK) {
- size.width += tree->theme_cache.checked->get_width() + tree->theme_cache.hseparation;
+ size.width += parent_tree->theme_cache.checked->get_width() + parent_tree->theme_cache.hseparation;
}
if (cell.icon.is_valid()) {
Size2i icon_size = cell.get_icon_size();
if (cell.icon_max_w > 0 && icon_size.width > cell.icon_max_w) {
icon_size.width = cell.icon_max_w;
}
- size.width += icon_size.width + tree->theme_cache.hseparation;
+ size.width += icon_size.width + parent_tree->theme_cache.hseparation;
size.height = MAX(size.height, icon_size.height);
}
@@ -1352,13 +1352,13 @@ Size2 TreeItem::get_minimum_size(int p_column) {
for (int i = 0; i < cell.buttons.size(); i++) {
Ref<Texture2D> texture = cell.buttons[i].texture;
if (texture.is_valid()) {
- Size2 button_size = texture->get_size() + tree->theme_cache.button_pressed->get_minimum_size();
+ Size2 button_size = texture->get_size() + parent_tree->theme_cache.button_pressed->get_minimum_size();
size.width += button_size.width;
size.height = MAX(size.height, button_size.height);
}
}
if (cell.buttons.size() >= 2) {
- size.width += (cell.buttons.size() - 1) * tree->theme_cache.button_margin;
+ size.width += (cell.buttons.size() - 1) * parent_tree->theme_cache.button_margin;
}
cells.write[p_column].cached_minimum_size = size;