diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/box_container.cpp | 1 | ||||
-rw-r--r-- | scene/gui/control.cpp | 35 | ||||
-rw-r--r-- | scene/gui/control.h | 4 | ||||
-rw-r--r-- | scene/gui/file_dialog.cpp | 7 | ||||
-rw-r--r-- | scene/gui/label.cpp | 1 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 5 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 109 | ||||
-rw-r--r-- | scene/gui/scroll_container.cpp | 22 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 11 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 2 |
10 files changed, 76 insertions, 121 deletions
diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp index cc37d4cf7d..b7d2131ee9 100644 --- a/scene/gui/box_container.cpp +++ b/scene/gui/box_container.cpp @@ -91,7 +91,6 @@ void BoxContainer::_resort() { int stretch_diff = stretch_max - stretch_min; if (stretch_diff < 0) { //avoid negative stretch space - stretch_max = stretch_min; stretch_diff = 0; } diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 0845b56828..6e0e26312f 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1042,55 +1042,37 @@ int Control::get_constant(const StringName &p_name, const StringName &p_type) co bool Control::has_icon_override(const StringName &p_name) const { const Ref<Texture> *tex = data.icon_override.getptr(p_name); - if (tex) - return true; - else - return false; + return tex != NULL; } bool Control::has_shader_override(const StringName &p_name) const { const Ref<Shader> *sdr = data.shader_override.getptr(p_name); - if (sdr) - return true; - else - return false; + return sdr != NULL; } bool Control::has_stylebox_override(const StringName &p_name) const { const Ref<StyleBox> *style = data.style_override.getptr(p_name); - if (style) - return true; - else - return false; + return style != NULL; } bool Control::has_font_override(const StringName &p_name) const { const Ref<Font> *font = data.font_override.getptr(p_name); - if (font) - return true; - else - return false; + return font != NULL; } bool Control::has_color_override(const StringName &p_name) const { const Color *color = data.color_override.getptr(p_name); - if (color) - return true; - else - return false; + return color != NULL; } bool Control::has_constant_override(const StringName &p_name) const { const int *constant = data.constant_override.getptr(p_name); - if (constant) - return true; - else - return false; + return constant != NULL; } bool Control::has_icon(const StringName &p_name, const StringName &p_type) const { @@ -1997,10 +1979,7 @@ Control *Control::find_next_valid_focus() const { break; } - if (next_child) { - - from = next_child; - } else { + if (!next_child) { next_child = _next_control(from); if (!next_child) { //nothing else.. go up and find either window or subwindow diff --git a/scene/gui/control.h b/scene/gui/control.h index a6f9a442ae..2489a5eda4 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -139,8 +139,8 @@ private: bool operator()(const Control *p_a, const Control *p_b) const { if (p_a->get_canvas_layer() == p_b->get_canvas_layer()) return p_b->is_greater_than(p_a); - else - return p_a->get_canvas_layer() < p_b->get_canvas_layer(); + + return p_a->get_canvas_layer() < p_b->get_canvas_layer(); } }; diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index bc8dcf0e82..ba4d390fc5 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -302,11 +302,8 @@ bool FileDialog::_is_open_should_be_disabled() { Dictionary d = ti->get_metadata(0); // Opening a file, but selected a folder? Forbidden. - if (((mode == MODE_OPEN_FILE || mode == MODE_OPEN_FILES) && d["dir"]) || // Flipped case, also forbidden. - (mode == MODE_OPEN_DIR && !d["dir"])) - return true; - - return false; + return ((mode == MODE_OPEN_FILE || mode == MODE_OPEN_FILES) && d["dir"]) || // Flipped case, also forbidden. + (mode == MODE_OPEN_DIR && !d["dir"]); } void FileDialog::_go_up() { diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index e3e9368a12..e18387a52e 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -470,7 +470,6 @@ void Label::regenerate_word_cache() { wc->word_len = i - word_pos; wc->space_count = space_count; current_word_size = char_width; - space_count = 0; word_pos = i; } } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index da6bff8ab8..cd3c8c0097 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -623,10 +623,7 @@ bool LineEdit::_is_over_clear_button(const Point2 &p_pos) const { } Ref<Texture> icon = Control::get_icon("clear"); int x_ofs = get_stylebox("normal")->get_offset().x; - if (p_pos.x > get_size().width - icon->get_width() - x_ofs) { - return true; - } - return false; + return p_pos.x > get_size().width - icon->get_width() - x_ofs; } void LineEdit::_notification(int p_what) { diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 8891f679ee..134bcc91a8 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -447,14 +447,13 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & if (p_font_color_shadow.a > 0) { float x_ofs_shadow = align_ofs + pofs; float y_ofs_shadow = y + lh - line_descent; - float move = font->draw_char(ci, Point2(x_ofs_shadow, y_ofs_shadow) + shadow_ofs, c[i], c[i + 1], p_font_color_shadow); + font->draw_char(ci, Point2(x_ofs_shadow, y_ofs_shadow) + shadow_ofs, c[i], c[i + 1], p_font_color_shadow); if (p_shadow_as_outline) { font->draw_char(ci, Point2(x_ofs_shadow, y_ofs_shadow) + Vector2(-shadow_ofs.x, shadow_ofs.y), c[i], c[i + 1], p_font_color_shadow); font->draw_char(ci, Point2(x_ofs_shadow, y_ofs_shadow) + Vector2(shadow_ofs.x, -shadow_ofs.y), c[i], c[i + 1], p_font_color_shadow); font->draw_char(ci, Point2(x_ofs_shadow, y_ofs_shadow) + Vector2(-shadow_ofs.x, -shadow_ofs.y), c[i], c[i + 1], p_font_color_shadow); } - x_ofs_shadow += move; } if (selected) { @@ -935,84 +934,80 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { return; if (b->get_button_index() == BUTTON_LEFT) { + if (b->is_pressed() && !b->is_doubleclick()) { + scroll_updated = false; + int line = 0; + Item *item = NULL; - if (true) { + bool outside; + _find_click(main, b->get_position(), &item, &line, &outside); - if (b->is_pressed() && !b->is_doubleclick()) { - scroll_updated = false; - int line = 0; - Item *item = NULL; - - bool outside; - _find_click(main, b->get_position(), &item, &line, &outside); - - if (item) { + if (item) { - if (selection.enabled) { + if (selection.enabled) { - selection.click = item; - selection.click_char = line; + selection.click = item; + selection.click_char = line; - // Erase previous selection. - if (selection.active) { - selection.from = NULL; - selection.from_char = '\0'; - selection.to = NULL; - selection.to_char = '\0'; - selection.active = false; + // Erase previous selection. + if (selection.active) { + selection.from = NULL; + selection.from_char = '\0'; + selection.to = NULL; + selection.to_char = '\0'; + selection.active = false; - update(); - } + update(); } } - } else if (b->is_pressed() && b->is_doubleclick() && selection.enabled) { + } + } else if (b->is_pressed() && b->is_doubleclick() && selection.enabled) { - //doubleclick: select word - int line = 0; - Item *item = NULL; - bool outside; + //doubleclick: select word + int line = 0; + Item *item = NULL; + bool outside; - _find_click(main, b->get_position(), &item, &line, &outside); + _find_click(main, b->get_position(), &item, &line, &outside); - while (item && item->type != ITEM_TEXT) { + while (item && item->type != ITEM_TEXT) { - item = _get_next_item(item, true); - } + item = _get_next_item(item, true); + } - if (item && item->type == ITEM_TEXT) { + if (item && item->type == ITEM_TEXT) { - String itext = static_cast<ItemText *>(item)->text; + String itext = static_cast<ItemText *>(item)->text; - int beg, end; - if (select_word(itext, line, beg, end)) { + int beg, end; + if (select_word(itext, line, beg, end)) { - selection.from = item; - selection.to = item; - selection.from_char = beg; - selection.to_char = end - 1; - selection.active = true; - update(); - } + selection.from = item; + selection.to = item; + selection.from_char = beg; + selection.to_char = end - 1; + selection.active = true; + update(); } - } else if (!b->is_pressed()) { + } + } else if (!b->is_pressed()) { - selection.click = NULL; + selection.click = NULL; - if (!b->is_doubleclick() && !scroll_updated) { - int line = 0; - Item *item = NULL; + if (!b->is_doubleclick() && !scroll_updated) { + int line = 0; + Item *item = NULL; - bool outside; - _find_click(main, b->get_position(), &item, &line, &outside); + bool outside; + _find_click(main, b->get_position(), &item, &line, &outside); - if (item) { + if (item) { - Variant meta; - if (!outside && _find_meta(item, &meta)) { - //meta clicked + Variant meta; + if (!outside && _find_meta(item, &meta)) { + //meta clicked - emit_signal("meta_clicked", meta); - } + emit_signal("meta_clicked", meta); } } } diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index a1034937b5..d83ae47671 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -140,19 +140,17 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) { _cancel_drag(); } - if (true) { - drag_speed = Vector2(); - drag_accum = Vector2(); - last_drag_accum = Vector2(); - drag_from = Vector2(h_scroll->get_value(), v_scroll->get_value()); - drag_touching = OS::get_singleton()->has_touchscreen_ui_hint(); - drag_touching_deaccel = false; - beyond_deadzone = false; + drag_speed = Vector2(); + drag_accum = Vector2(); + last_drag_accum = Vector2(); + drag_from = Vector2(h_scroll->get_value(), v_scroll->get_value()); + drag_touching = OS::get_singleton()->has_touchscreen_ui_hint(); + drag_touching_deaccel = false; + beyond_deadzone = false; + time_since_motion = 0; + if (drag_touching) { + set_physics_process_internal(true); time_since_motion = 0; - if (drag_touching) { - set_physics_process_internal(true); - time_since_motion = 0; - } } } else { diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 36d7dad1d3..62b6a917fc 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1603,7 +1603,6 @@ void TextEdit::_consume_pair_symbol(CharType ch) { insert_text_at_cursor(ch_pair); cursor_set_column(cursor_position_to_move); - return; } void TextEdit::_consume_backspace_for_pair_symbol(int prev_line, int prev_column) { @@ -5404,11 +5403,7 @@ bool TextEdit::is_line_comment(int p_line) const { for (int i = 0; i < line_length - 1; i++) { if (_is_symbol(text[p_line][i]) && cri_map.has(i)) { const Text::ColorRegionInfo &cri = cri_map[i]; - if (color_regions[cri.region].begin_key == "#" || color_regions[cri.region].begin_key == "//") { - return true; - } else { - return false; - } + return color_regions[cri.region].begin_key == "#" || color_regions[cri.region].begin_key == "//"; } else if (_is_whitespace(text[p_line][i])) { continue; } else { @@ -5457,9 +5452,7 @@ bool TextEdit::is_folded(int p_line) const { ERR_FAIL_INDEX_V(p_line, text.size(), false); if (p_line + 1 >= text.size()) return false; - if (!is_line_hidden(p_line) && is_line_hidden(p_line + 1)) - return true; - return false; + return !is_line_hidden(p_line) && is_line_hidden(p_line + 1); } Vector<int> TextEdit::get_folded_lines() const { diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 54370d02ba..924c480b15 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1929,8 +1929,6 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool edited_col = col; bool on_arrow = x > col_width - cache.select_arrow->get_width(); - bring_up_editor = false; - custom_popup_rect = Rect2i(get_global_position() + Point2i(col_ofs, _get_title_button_height() + y_ofs + item_h - cache.offset.y), Size2(get_column_width(col), item_h)); if (on_arrow || !p_item->cells[col].custom_button) { |