diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/file_dialog.cpp | 3 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 15 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 28 | ||||
-rw-r--r-- | scene/gui/slider.cpp | 6 | ||||
-rw-r--r-- | scene/gui/subviewport_container.cpp | 2 | ||||
-rw-r--r-- | scene/gui/subviewport_container.h | 2 | ||||
-rw-r--r-- | scene/gui/tabs.cpp | 6 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 3 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 18 |
9 files changed, 56 insertions, 27 deletions
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 89d13ecd7f..a449d680a8 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -410,7 +410,8 @@ void FileDialog::_tree_item_activated() { void FileDialog::update_file_name() { int idx = filter->get_selected() - 1; if ((idx == -1 && filter->get_item_count() == 2) || (filter->get_item_count() > 2 && idx >= 0 && idx < filter->get_item_count() - 2)) { - if (idx == -1) idx += 1; + if (idx == -1) + idx += 1; String filter_str = filters[idx]; String file_str = file->get_text(); String base_name = file_str.get_basename(); diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index b9b7560f2e..8574b05016 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -463,14 +463,16 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { case KEY_UP: { shift_selection_check_pre(k->get_shift()); - if (get_cursor_position() == 0) handled = false; + if (get_cursor_position() == 0) + handled = false; set_cursor_position(0); shift_selection_check_post(k->get_shift()); } break; case KEY_DOWN: { shift_selection_check_pre(k->get_shift()); - if (get_cursor_position() == text.length()) handled = false; + if (get_cursor_position() == text.length()) + handled = false; set_cursor_position(text.length()); shift_selection_check_post(k->get_shift()); } break; @@ -988,7 +990,8 @@ void LineEdit::paste_text() { if (paste_buffer != "") { int prev_len = text.length(); - if (selection.enabled) selection_delete(); + if (selection.enabled) + selection_delete(); append_at_cursor(paste_buffer); if (!text_changed_dirty) { @@ -1204,7 +1207,8 @@ void LineEdit::_toggle_draw_caret() { void LineEdit::delete_char() { - if ((text.length() <= 0) || (cursor_pos == 0)) return; + if ((text.length() <= 0) || (cursor_pos == 0)) + return; Ref<Font> font = get_theme_font("font"); if (font != nullptr) { @@ -1379,7 +1383,8 @@ int LineEdit::get_cursor_position() const { void LineEdit::set_window_pos(int p_pos) { window_pos = p_pos; - if (window_pos < 0) window_pos = 0; + if (window_pos < 0) + window_pos = 0; } void LineEdit::append_at_cursor(String p_text) { diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 84097eb6a1..a6c0c99bdb 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -230,10 +230,18 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & } else { \ int used = wofs - margin; \ switch (align) { \ - case ALIGN_LEFT: l.offset_caches.push_back(0); break; \ - case ALIGN_CENTER: l.offset_caches.push_back(((p_width - margin) - used) / 2); break; \ - case ALIGN_RIGHT: l.offset_caches.push_back(((p_width - margin) - used)); break; \ - case ALIGN_FILL: l.offset_caches.push_back(line_wrapped ? ((p_width - margin) - used) : 0); break; \ + case ALIGN_LEFT: \ + l.offset_caches.push_back(0); \ + break; \ + case ALIGN_CENTER: \ + l.offset_caches.push_back(((p_width - margin) - used) / 2); \ + break; \ + case ALIGN_RIGHT: \ + l.offset_caches.push_back(((p_width - margin) - used)); \ + break; \ + case ALIGN_FILL: \ + l.offset_caches.push_back(line_wrapped ? ((p_width - margin) - used) : 0); \ + break; \ } \ l.height_caches.push_back(line_height); \ l.ascent_caches.push_back(line_ascent); \ @@ -255,7 +263,8 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & line_descent = line < l.descent_caches.size() ? l.descent_caches[line] : 1; \ } \ if (p_mode == PROCESS_POINTER && r_click_item && p_click_pos.y >= p_ofs.y + y && p_click_pos.y <= p_ofs.y + y + lh && p_click_pos.x < p_ofs.x + wofs) { \ - if (r_outside) *r_outside = true; \ + if (r_outside) \ + *r_outside = true; \ *r_click_item = it; \ *r_click_char = rchar; \ RETURN; \ @@ -275,7 +284,8 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & } \ const bool x_in_range = (p_click_pos.x > p_ofs.x + wofs) && (!p_frame->cell || p_click_pos.x < p_ofs.x + p_width); \ if (p_mode == PROCESS_POINTER && r_click_item && p_click_pos.y >= p_ofs.y + y && p_click_pos.y <= p_ofs.y + y + lh && x_in_range) { \ - if (r_outside) *r_outside = true; \ + if (r_outside) \ + *r_outside = true; \ *r_click_item = it; \ *r_click_char = rchar; \ RETURN; \ @@ -286,7 +296,8 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & #define ADVANCE(m_width) \ { \ if (p_mode == PROCESS_POINTER && r_click_item && p_click_pos.y >= p_ofs.y + y && p_click_pos.y <= p_ofs.y + y + lh && p_click_pos.x >= p_ofs.x + wofs && p_click_pos.x < p_ofs.x + wofs + m_width) { \ - if (r_outside) *r_outside = false; \ + if (r_outside) \ + *r_outside = false; \ *r_click_item = it; \ *r_click_char = rchar; \ RETURN; \ @@ -855,7 +866,8 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & if (p_mode == PROCESS_POINTER && r_click_item && p_click_pos.y >= p_ofs.y + y && p_click_pos.y <= p_ofs.y + y + lh) { //went to next line, but pointer was on the previous one - if (r_outside) *r_outside = true; + if (r_outside) + *r_outside = true; *r_click_item = itp; *r_click_char = rchar; RETURN; diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index 1f135163d4..910d5f8230 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -182,7 +182,8 @@ void Slider::_notification(int p_what) { if (ticks > 1) { int grabber_offset = (grabber->get_size().height / 2 - tick->get_height() / 2); for (int i = 0; i < ticks; i++) { - if (!ticks_on_borders && (i == 0 || i + 1 == ticks)) continue; + if (!ticks_on_borders && (i == 0 || i + 1 == ticks)) + continue; int ofs = (i * areasize / (ticks - 1)) + grabber_offset; tick->draw(ci, Point2i((size.width - widget_width) / 2, ofs)); } @@ -199,7 +200,8 @@ void Slider::_notification(int p_what) { if (ticks > 1) { int grabber_offset = (grabber->get_size().width / 2 - tick->get_width() / 2); for (int i = 0; i < ticks; i++) { - if ((!ticks_on_borders) && ((i == 0) || ((i + 1) == ticks))) continue; + if ((!ticks_on_borders) && ((i == 0) || ((i + 1) == ticks))) + continue; int ofs = (i * areasize / (ticks - 1)) + grabber_offset; tick->draw(ci, Point2i(ofs, (size.height - widget_height) / 2)); } diff --git a/scene/gui/subviewport_container.cpp b/scene/gui/subviewport_container.cpp index 50f468741d..7252a43651 100644 --- a/scene/gui/subviewport_container.cpp +++ b/scene/gui/subviewport_container.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* subviewport_container.cpp */ +/* subviewport_container.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ diff --git a/scene/gui/subviewport_container.h b/scene/gui/subviewport_container.h index 6ff3d188e2..13b711f838 100644 --- a/scene/gui/subviewport_container.h +++ b/scene/gui/subviewport_container.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* subviewport_container.h */ +/* subviewport_container.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index 1a3b53f489..b856d3ab3a 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -399,7 +399,8 @@ int Tabs::get_tab_count() const { void Tabs::set_current_tab(int p_current) { - if (current == p_current) return; + if (current == p_current) + return; ERR_FAIL_INDEX(p_current, get_tab_count()); current = p_current; @@ -856,7 +857,8 @@ void Tabs::ensure_tab_visible(int p_idx) { if (!is_inside_tree()) return; - if (tabs.size() == 0) return; + if (tabs.size() == 0) + return; ERR_FAIL_INDEX(p_idx, tabs.size()); if (p_idx == offset) { diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index aa518fbb7d..132ee0f249 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2991,7 +2991,8 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } } break; case KEY_TAB: { - if (k->get_command()) break; // Avoid tab when command. + if (k->get_command()) + break; // Avoid tab when command. if (readonly) break; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 329c1085df..4a550727fc 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -2277,7 +2277,8 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { bool is_command = k.is_valid() && k->get_command(); if (p_event->is_action("ui_right") && p_event->is_pressed()) { - if (!cursor_can_exit_tree) accept_event(); + if (!cursor_can_exit_tree) + accept_event(); if (!selected_item || select_mode == SELECT_ROW || selected_col > (columns.size() - 1)) { return; @@ -2294,7 +2295,8 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { } } else if (p_event->is_action("ui_left") && p_event->is_pressed()) { - if (!cursor_can_exit_tree) accept_event(); + if (!cursor_can_exit_tree) + accept_event(); if (!selected_item || select_mode == SELECT_ROW || selected_col < 0) { return; @@ -2313,19 +2315,22 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { } else if (p_event->is_action("ui_up") && p_event->is_pressed() && !is_command) { - if (!cursor_can_exit_tree) accept_event(); + if (!cursor_can_exit_tree) + accept_event(); _go_up(); } else if (p_event->is_action("ui_down") && p_event->is_pressed() && !is_command) { - if (!cursor_can_exit_tree) accept_event(); + if (!cursor_can_exit_tree) + accept_event(); _go_down(); } else if (p_event->is_action("ui_page_down") && p_event->is_pressed()) { - if (!cursor_can_exit_tree) accept_event(); + if (!cursor_can_exit_tree) + accept_event(); TreeItem *next = nullptr; if (!selected_item) @@ -2363,7 +2368,8 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { ensure_cursor_is_visible(); } else if (p_event->is_action("ui_page_up") && p_event->is_pressed()) { - if (!cursor_can_exit_tree) accept_event(); + if (!cursor_can_exit_tree) + accept_event(); TreeItem *prev = nullptr; if (!selected_item) |