diff options
Diffstat (limited to 'scene/gui')
26 files changed, 279 insertions, 344 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index a05ac08e9d..1cdc6f8057 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -498,7 +498,7 @@ BaseButton *ButtonGroup::get_pressed_button() { return E->get(); } - return NULL; + return nullptr; } void ButtonGroup::_bind_methods() { diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 2ec9bb2292..5e0f4c91e8 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -80,7 +80,7 @@ void ColorPicker::_notification(int p_what) { } break; case NOTIFICATION_WM_CLOSE_REQUEST: { - if (screen != NULL && screen->is_visible()) + if (screen != nullptr && screen->is_visible()) screen->hide(); } break; } @@ -275,7 +275,7 @@ void ColorPicker::_text_type_toggled() { c_text->set_editable(false); } else { text_type->set_text("#"); - text_type->set_icon(NULL); + text_type->set_icon(nullptr); c_text->set_editable(true); } @@ -732,7 +732,7 @@ ColorPicker::ColorPicker() : changing_color = false; presets_enabled = true; presets_visible = true; - screen = NULL; + screen = nullptr; HBoxContainer *hb_edit = memnew(HBoxContainer); add_child(hb_edit); @@ -1024,8 +1024,8 @@ ColorPickerButton::ColorPickerButton() { // Initialization is now done deferred, // this improves performance in the inspector as the color picker // can be expensive to initialize. - picker = NULL; - popup = NULL; + picker = nullptr; + popup = nullptr; edit_alpha = true; set_toggle_mode(true); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 0d982dbc02..b4dc37c74f 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -455,13 +455,13 @@ void Control::remove_child_notify(Node *p_child) { Control *child_c = Object::cast_to<Control>(p_child); if (child_c && (child_c->data.theme_owner || child_c->data.theme_owner_window) && child_c->data.theme.is_null()) { - _propagate_theme_changed(child_c, NULL, NULL); + _propagate_theme_changed(child_c, nullptr, nullptr); } Window *child_w = Object::cast_to<Window>(p_child); if (child_w && (child_w->theme_owner || child_w->theme_owner_window) && child_w->theme.is_null()) { - _propagate_theme_changed(child_w, NULL, NULL); + _propagate_theme_changed(child_w, nullptr, nullptr); } } @@ -495,7 +495,7 @@ void Control::_notification(int p_notification) { data.parent = Object::cast_to<Control>(get_parent()); Node *parent = this; //meh - Control *parent_control = NULL; + Control *parent_control = nullptr; bool subwindow = false; while (parent) { @@ -548,7 +548,7 @@ void Control::_notification(int p_notification) { if (data.parent_canvas_item) { data.parent_canvas_item->disconnect("item_rect_changed", callable_mp(this, &Control::_size_changed)); - data.parent_canvas_item = NULL; + data.parent_canvas_item = nullptr; } else if (!is_set_as_toplevel()) { //disconnect viewport get_viewport()->disconnect("size_changed", callable_mp(this, &Control::_size_changed)); @@ -556,17 +556,11 @@ void Control::_notification(int p_notification) { if (data.RI) { get_viewport()->_gui_remove_root_control(data.RI); - data.RI = NULL; + data.RI = nullptr; } - data.parent = NULL; - data.parent_canvas_item = NULL; - /* - if (data.theme_owner && data.theme.is_null()) { - data.theme_owner=NULL; - notification(NOTIFICATION_THEME_CHANGED); - } - */ + data.parent = nullptr; + data.parent_canvas_item = nullptr; } break; case NOTIFICATION_MOVED_IN_PARENT: { @@ -621,7 +615,7 @@ void Control::_notification(int p_notification) { if (!is_visible_in_tree()) { - if (get_viewport() != NULL) + if (get_viewport() != nullptr) get_viewport()->_gui_hid_control(this); //remove key focus @@ -753,7 +747,7 @@ Size2 Control::get_minimum_size() const { if (si) { Callable::CallError ce; - Variant s = si->call(SceneStringNames::get_singleton()->_get_minimum_size, NULL, 0, ce); + Variant s = si->call(SceneStringNames::get_singleton()->_get_minimum_size, nullptr, 0, ce); if (ce.error == Callable::CallError::CALL_OK) return s; } @@ -799,8 +793,8 @@ bool Control::_find_theme_item(Control *p_theme_owner, Window *p_theme_owner_win theme_owner_window = parent_w->theme_owner_window; } else { - theme_owner = NULL; - theme_owner_window = NULL; + theme_owner = nullptr; + theme_owner_window = nullptr; } } } @@ -843,8 +837,8 @@ bool Control::_has_theme_item(Control *p_theme_owner, Window *p_theme_owner_wind theme_owner_window = parent_w->theme_owner_window; } else { - theme_owner = NULL; - theme_owner_window = NULL; + theme_owner = nullptr; + theme_owner_window = nullptr; } } } @@ -1034,37 +1028,37 @@ int Control::get_constants(Control *p_theme_owner, Window *p_theme_owner_window, bool Control::has_theme_icon_override(const StringName &p_name) const { const Ref<Texture2D> *tex = data.icon_override.getptr(p_name); - return tex != NULL; + return tex != nullptr; } bool Control::has_theme_shader_override(const StringName &p_name) const { const Ref<Shader> *sdr = data.shader_override.getptr(p_name); - return sdr != NULL; + return sdr != nullptr; } bool Control::has_theme_stylebox_override(const StringName &p_name) const { const Ref<StyleBox> *style = data.style_override.getptr(p_name); - return style != NULL; + return style != nullptr; } bool Control::has_theme_font_override(const StringName &p_name) const { const Ref<Font> *font = data.font_override.getptr(p_name); - return font != NULL; + return font != nullptr; } bool Control::has_theme_color_override(const StringName &p_name) const { const Color *color = data.color_override.getptr(p_name); - return color != NULL; + return color != nullptr; } bool Control::has_theme_constant_override(const StringName &p_name) const { const int *constant = data.constant_override.getptr(p_name); - return constant != NULL; + return constant != nullptr; } bool Control::has_theme_icon(const StringName &p_name, const StringName &p_type) const { @@ -1890,17 +1884,17 @@ void Control::set_focus_mode(FocusMode p_focus_mode) { static Control *_next_control(Control *p_from) { if (p_from->is_set_as_toplevel()) - return NULL; // can't go above + return nullptr; // can't go above Control *parent = Object::cast_to<Control>(p_from->get_parent()); if (!parent) { - return NULL; + return nullptr; } - int next = p_from->get_position_in_parent(); - ERR_FAIL_INDEX_V(next, parent->get_child_count(), NULL); + int next = p_from->get_index(); + ERR_FAIL_INDEX_V(next, parent->get_child_count(), nullptr); for (int i = (next + 1); i < parent->get_child_count(); i++) { Control *c = Object::cast_to<Control>(parent->get_child(i)); @@ -1927,9 +1921,9 @@ Control *Control::find_next_valid_focus() const { Control *c; if (n) { c = Object::cast_to<Control>(n); - ERR_FAIL_COND_V_MSG(!c, NULL, "Next focus node is not a control: " + n->get_name() + "."); + ERR_FAIL_COND_V_MSG(!c, nullptr, "Next focus node is not a control: " + n->get_name() + "."); } else { - return NULL; + return nullptr; } if (c->is_visible() && c->get_focus_mode() != FOCUS_NONE) return c; @@ -1937,7 +1931,7 @@ Control *Control::find_next_valid_focus() const { // find next child - Control *next_child = NULL; + Control *next_child = nullptr; for (int i = 0; i < from->get_child_count(); i++) { @@ -1974,7 +1968,7 @@ Control *Control::find_next_valid_focus() const { } if (next_child == this) // no next control-> - return (get_focus_mode() == FOCUS_ALL) ? next_child : NULL; + return (get_focus_mode() == FOCUS_ALL) ? next_child : nullptr; if (next_child) { if (next_child->get_focus_mode() == FOCUS_ALL) return next_child; @@ -1983,12 +1977,12 @@ Control *Control::find_next_valid_focus() const { break; } - return NULL; + return nullptr; } static Control *_prev_control(Control *p_from) { - Control *child = NULL; + Control *child = nullptr; for (int i = p_from->get_child_count() - 1; i >= 0; i--) { Control *c = Object::cast_to<Control>(p_from->get_child(i)); @@ -2018,9 +2012,9 @@ Control *Control::find_prev_valid_focus() const { Control *c; if (n) { c = Object::cast_to<Control>(n); - ERR_FAIL_COND_V_MSG(!c, NULL, "Previous focus node is not a control: " + n->get_name() + "."); + ERR_FAIL_COND_V_MSG(!c, nullptr, "Previous focus node is not a control: " + n->get_name() + "."); } else { - return NULL; + return nullptr; } if (c->is_visible() && c->get_focus_mode() != FOCUS_NONE) return c; @@ -2028,7 +2022,7 @@ Control *Control::find_prev_valid_focus() const { // find prev child - Control *prev_child = NULL; + Control *prev_child = nullptr; if (from->is_set_as_toplevel() || !Object::cast_to<Control>(from->get_parent())) { @@ -2038,7 +2032,7 @@ Control *Control::find_prev_valid_focus() const { } else { - for (int i = (from->get_position_in_parent() - 1); i >= 0; i--) { + for (int i = (from->get_index() - 1); i >= 0; i--) { Control *c = Object::cast_to<Control>(from->get_parent()->get_child(i)); @@ -2060,7 +2054,7 @@ Control *Control::find_prev_valid_focus() const { } if (prev_child == this) // no prev control-> - return (get_focus_mode() == FOCUS_ALL) ? prev_child : NULL; + return (get_focus_mode() == FOCUS_ALL) ? prev_child : nullptr; if (prev_child->get_focus_mode() == FOCUS_ALL) return prev_child; @@ -2068,7 +2062,7 @@ Control *Control::find_prev_valid_focus() const { from = prev_child; } - return NULL; + return nullptr; } Control::FocusMode Control::get_focus_mode() const { @@ -2221,7 +2215,7 @@ Control *Control::make_custom_tooltip(const String &p_text) const { if (get_script_instance()) { return const_cast<Control *>(this)->call("_make_custom_tooltip", p_text); } - return NULL; + return nullptr; } void Control::set_default_cursor_shape(CursorShape p_shape) { @@ -2288,19 +2282,19 @@ NodePath Control::get_focus_previous() const { Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) { - ERR_FAIL_INDEX_V((int)p_margin, 4, NULL); + ERR_FAIL_INDEX_V((int)p_margin, 4, nullptr); if (p_count >= MAX_NEIGHBOUR_SEARCH_COUNT) - return NULL; + return nullptr; if (!data.focus_neighbour[p_margin].is_empty()) { - Control *c = NULL; + Control *c = nullptr; Node *n = get_node(data.focus_neighbour[p_margin]); if (n) { c = Object::cast_to<Control>(n); - ERR_FAIL_COND_V_MSG(!c, NULL, "Neighbor focus node is not a control: " + n->get_name() + "."); + ERR_FAIL_COND_V_MSG(!c, nullptr, "Neighbor focus node is not a control: " + n->get_name() + "."); } else { - return NULL; + return nullptr; } bool valid = true; if (!c->is_visible()) @@ -2315,7 +2309,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) { } float dist = 1e7; - Control *result = NULL; + Control *result = nullptr; Point2 points[4]; @@ -2357,7 +2351,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) { } if (!base) - return NULL; + return nullptr; _window_find_focus_neighbour(vdir, base, points, maxd, dist, &result); @@ -2515,7 +2509,7 @@ Control::MouseFilter Control::get_mouse_filter() const { Control *Control::get_focus_owner() const { - ERR_FAIL_COND_V(!is_inside_tree(), NULL); + ERR_FAIL_COND_V(!is_inside_tree(), nullptr); return get_viewport()->_gui_get_focus_owner(); } @@ -2991,19 +2985,19 @@ void Control::_bind_methods() { } Control::Control() { - data.parent = NULL; + data.parent = nullptr; data.mouse_filter = MOUSE_FILTER_STOP; - data.RI = NULL; - data.theme_owner = NULL; - data.theme_owner_window = NULL; + data.RI = nullptr; + data.theme_owner = nullptr; + data.theme_owner_window = nullptr; data.default_cursor = CURSOR_ARROW; data.h_size_flags = SIZE_FILL; data.v_size_flags = SIZE_FILL; data.expand = 1; data.rotation = 0; - data.parent_canvas_item = NULL; + data.parent_canvas_item = nullptr; data.scale = Vector2(1, 1); data.block_minimum_size_adjust = false; diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 2e87a92969..5654219a3e 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -322,7 +322,6 @@ AcceptDialog::AcceptDialog() { label->set_end(Point2(-margin, -button_margin - 10)); add_child(label); - hbc = memnew(HBoxContainer); add_child(hbc); hbc->add_spacer(); diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index a4f0338f00..89d13ecd7f 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -34,11 +34,11 @@ #include "core/print_string.h" #include "scene/gui/label.h" -FileDialog::GetIconFunc FileDialog::get_icon_func = NULL; -FileDialog::GetIconFunc FileDialog::get_large_icon_func = NULL; +FileDialog::GetIconFunc FileDialog::get_icon_func = nullptr; +FileDialog::GetIconFunc FileDialog::get_large_icon_func = nullptr; -FileDialog::RegisterFunc FileDialog::register_func = NULL; -FileDialog::RegisterFunc FileDialog::unregister_func = NULL; +FileDialog::RegisterFunc FileDialog::register_func = nullptr; +FileDialog::RegisterFunc FileDialog::unregister_func = nullptr; VBoxContainer *FileDialog::get_vbox() { return vbox; @@ -46,9 +46,9 @@ VBoxContainer *FileDialog::get_vbox() { void FileDialog::_theme_changed() { - Color font_color = vbc->get_theme_color("font_color", "ToolButton"); - Color font_color_hover = vbc->get_theme_color("font_color_hover", "ToolButton"); - Color font_color_pressed = vbc->get_theme_color("font_color_pressed", "ToolButton"); + Color font_color = vbox->get_theme_color("font_color", "ToolButton"); + Color font_color_hover = vbox->get_theme_color("font_color_hover", "ToolButton"); + Color font_color_pressed = vbox->get_theme_color("font_color_pressed", "ToolButton"); dir_up->add_theme_color_override("icon_color_normal", font_color); dir_up->add_theme_color_override("icon_color_hover", font_color_hover); @@ -73,9 +73,9 @@ void FileDialog::_notification(int p_what) { } if (p_what == NOTIFICATION_ENTER_TREE) { - dir_up->set_icon(vbc->get_theme_icon("parent_folder")); - refresh->set_icon(vbc->get_theme_icon("reload")); - show_hidden->set_icon(vbc->get_theme_icon("toggle_hidden")); + dir_up->set_icon(vbox->get_theme_icon("parent_folder", "FileDialog")); + refresh->set_icon(vbox->get_theme_icon("reload", "FileDialog")); + show_hidden->set_icon(vbox->get_theme_icon("toggle_hidden", "FileDialog")); _theme_changed(); } } @@ -195,7 +195,7 @@ void FileDialog::_action_pressed() { if (mode == FILE_MODE_OPEN_FILES) { - TreeItem *ti = tree->get_next_selected(NULL); + TreeItem *ti = tree->get_next_selected(nullptr); String fbase = dir_access->get_current_dir(); Vector<String> files; @@ -429,8 +429,8 @@ void FileDialog::update_file_list() { dir_access->list_dir_begin(); TreeItem *root = tree->create_item(); - Ref<Texture2D> folder = vbc->get_theme_icon("folder"); - const Color folder_color = vbc->get_theme_color("folder_icon_modulate"); + Ref<Texture2D> folder = vbox->get_theme_icon("folder", "FileDialog"); + const Color folder_color = vbox->get_theme_color("folder_icon_modulate", "FileDialog"); List<String> files; List<String> dirs; @@ -528,7 +528,7 @@ void FileDialog::update_file_list() { } if (mode == FILE_MODE_OPEN_DIR) { - ti->set_custom_color(0, vbc->get_theme_color("files_disabled")); + ti->set_custom_color(0, vbox->get_theme_color("files_disabled", "FileDialog")); ti->set_selectable(0, false); } Dictionary d; @@ -543,7 +543,7 @@ void FileDialog::update_file_list() { files.pop_front(); } - if (tree->get_root() && tree->get_root()->get_children() && tree->get_selected() == NULL) + if (tree->get_root() && tree->get_root()->get_children() && tree->get_selected() == nullptr) tree->get_root()->get_children()->select(0); } @@ -888,9 +888,9 @@ FileDialog::FileDialog() { mode_overrides_title = true; - vbc = memnew(VBoxContainer); - add_child(vbc); - vbc->connect("theme_changed", callable_mp(this, &FileDialog::_theme_changed)); + vbox = memnew(VBoxContainer); + add_child(vbox); + vbox->connect("theme_changed", callable_mp(this, &FileDialog::_theme_changed)); mode = FILE_MODE_SAVE_FILE; set_title(RTR("Save a File")); @@ -909,6 +909,7 @@ FileDialog::FileDialog() { drives = memnew(OptionButton); drives->connect("item_selected", callable_mp(this, &FileDialog::_select_drive)); + hbc->add_child(drives); dir = memnew(LineEdit); hbc->add_child(dir); @@ -933,11 +934,11 @@ FileDialog::FileDialog() { makedir->set_text(RTR("Create Folder")); makedir->connect("pressed", callable_mp(this, &FileDialog::_make_dir)); hbc->add_child(makedir); - vbc->add_child(hbc); + vbox->add_child(hbc); tree = memnew(Tree); tree->set_hide_root(true); - vbc->add_margin_child(RTR("Directories & Files:"), tree, true); + vbox->add_margin_child(RTR("Directories & Files:"), tree, true); file_box = memnew(HBoxContainer); file_box->add_child(memnew(Label(RTR("File:")))); @@ -950,7 +951,7 @@ FileDialog::FileDialog() { filter->set_h_size_flags(Control::SIZE_EXPAND_FILL); filter->set_clip_text(true); // too many extensions overflows it file_box->add_child(filter); - vbc->add_child(file_box); + vbox->add_child(file_box); dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES); access = ACCESS_RESOURCES; @@ -993,7 +994,6 @@ FileDialog::FileDialog() { update_dir(); set_hide_on_ok(false); - vbox = vbc; invalidated = true; if (register_func) @@ -1006,37 +1006,3 @@ FileDialog::~FileDialog() { unregister_func(this); memdelete(dir_access); } - -void LineEditFileChooser::_bind_methods() { - - ClassDB::bind_method(D_METHOD("get_button"), &LineEditFileChooser::get_button); - ClassDB::bind_method(D_METHOD("get_line_edit"), &LineEditFileChooser::get_line_edit); - ClassDB::bind_method(D_METHOD("get_file_dialog"), &LineEditFileChooser::get_file_dialog); -} - -void LineEditFileChooser::_chosen(const String &p_text) { - - line_edit->set_text(p_text); - line_edit->emit_signal("text_entered", p_text); -} - -void LineEditFileChooser::_browse() { - - dialog->popup_centered_ratio(); -} - -LineEditFileChooser::LineEditFileChooser() { - - line_edit = memnew(LineEdit); - add_child(line_edit); - line_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL); - button = memnew(Button); - button->set_text(" .. "); - add_child(button); - button->connect("pressed", callable_mp(this, &LineEditFileChooser::_browse)); - dialog = memnew(FileDialog); - add_child(dialog); - dialog->connect("file_selected", callable_mp(this, &LineEditFileChooser::_chosen)); - dialog->connect("dir_selected", callable_mp(this, &LineEditFileChooser::_chosen)); - dialog->connect("files_selected", callable_mp(this, &LineEditFileChooser::_chosen)); -} diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h index 295ae023d1..ac0e733abc 100644 --- a/scene/gui/file_dialog.h +++ b/scene/gui/file_dialog.h @@ -70,7 +70,6 @@ private: ConfirmationDialog *makedialog; LineEdit *makedirname; - VBoxContainer *vbc; Button *makedir; Access access; //Button *action; @@ -178,27 +177,6 @@ public: ~FileDialog(); }; -class LineEditFileChooser : public HBoxContainer { - - GDCLASS(LineEditFileChooser, HBoxContainer); - Button *button; - LineEdit *line_edit; - FileDialog *dialog; - - void _chosen(const String &p_text); - void _browse(); - -protected: - static void _bind_methods(); - -public: - Button *get_button() { return button; } - LineEdit *get_line_edit() { return line_edit; } - FileDialog *get_file_dialog() { return dialog; } - - LineEditFileChooser(); -}; - VARIANT_ENUM_CAST(FileDialog::FileMode); VARIANT_ENUM_CAST(FileDialog::Access); diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index fd7935b376..e37e93e2a9 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -854,7 +854,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { if (in_box) gn->set_selected(box_selection_mode_aditive); else - gn->set_selected(previus_selected.find(gn) != NULL); + gn->set_selected(previus_selected.find(gn) != nullptr); } top_layer->update(); @@ -872,7 +872,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { if (!gn) continue; - gn->set_selected(previus_selected.find(gn) != NULL); + gn->set_selected(previus_selected.find(gn) != nullptr); } top_layer->update(); } else { @@ -922,7 +922,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { if (b->get_button_index() == BUTTON_LEFT && b->is_pressed()) { - GraphNode *gn = NULL; + GraphNode *gn = nullptr; for (int i = get_child_count() - 1; i >= 0; i--) { @@ -1323,7 +1323,7 @@ GraphEdit::GraphEdit() { set_focus_mode(FOCUS_ALL); awaiting_scroll_offset_update = false; - top_layer = NULL; + top_layer = nullptr; top_layer = memnew(GraphEditFilter(this)); add_child(top_layer); top_layer->set_mouse_filter(MOUSE_FILTER_PASS); diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index c28a60ff87..5dbc5bc50d 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -593,7 +593,7 @@ void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) { Ref<InputEventMouseButton> mb = p_ev; if (mb.is_valid()) { - ERR_FAIL_COND_MSG(get_parent_control() == NULL, "GraphNode must be the child of a GraphEdit node."); + ERR_FAIL_COND_MSG(get_parent_control() == nullptr, "GraphNode must be the child of a GraphEdit node."); if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 1ffc9712cc..bedcef2df2 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -282,7 +282,7 @@ void Label::_notification(int p_what) { from = from->next; } - wc = to ? to->next : 0; + wc = to ? to->next : nullptr; line++; } } @@ -404,7 +404,7 @@ void Label::regenerate_word_cache() { line_count = 1; total_char_cache = 0; - WordCache *last = NULL; + WordCache *last = nullptr; for (int i = 0; i <= xl_text.length(); i++) { @@ -447,7 +447,7 @@ void Label::regenerate_word_cache() { } if (i < xl_text.length() && xl_text[i] == ' ') { - if (line_width > 0 || last == NULL || last->char_pos != WordCache::CHAR_WRAPLINE) { + if (line_width > 0 || last == nullptr || last->char_pos != WordCache::CHAR_WRAPLINE) { space_count++; line_width += space_width; } else { @@ -697,7 +697,7 @@ Label::Label(const String &p_text) { align = ALIGN_LEFT; valign = VALIGN_TOP; xl_text = ""; - word_cache = NULL; + word_cache = nullptr; word_cache_dirty = true; autowrap = false; line_count = 0; diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 6c5f77f874..b9b7560f2e 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -630,7 +630,7 @@ void LineEdit::drop_data(const Point2 &p_point, const Variant &p_data) { int selected = selection.end - selection.begin; Ref<Font> font = get_theme_font("font"); - if (font != NULL) { + if (font != nullptr) { for (int i = selection.begin; i < selection.end; i++) cached_width -= font->get_char_size(pass ? secret_character[0] : text[i]).width; } @@ -1001,7 +1001,7 @@ void LineEdit::paste_text() { } void LineEdit::undo() { - if (undo_stack_pos == NULL) { + if (undo_stack_pos == nullptr) { if (undo_stack.size() <= 1) { return; } @@ -1023,7 +1023,7 @@ void LineEdit::undo() { } void LineEdit::redo() { - if (undo_stack_pos == NULL) { + if (undo_stack_pos == nullptr) { return; } if (undo_stack_pos == undo_stack.back()) { @@ -1096,7 +1096,7 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) { while (ofs < text.length()) { int char_w = 0; - if (font != NULL) { + if (font != nullptr) { char_w = font->get_char_size(pass ? secret_character[0] : text[ofs]).width; } pixel_ofs += char_w; @@ -1148,7 +1148,7 @@ int LineEdit::get_cursor_pixel_pos() { } while (ofs < cursor_pos) { - if (font != NULL) { + if (font != nullptr) { pixel_ofs += font->get_char_size(pass ? secret_character[0] : text[ofs]).width; } ofs++; @@ -1207,7 +1207,7 @@ void LineEdit::delete_char() { if ((text.length() <= 0) || (cursor_pos == 0)) return; Ref<Font> font = get_theme_font("font"); - if (font != NULL) { + if (font != nullptr) { cached_width -= font->get_char_size(pass ? secret_character[0] : text[cursor_pos - 1]).width; } @@ -1226,7 +1226,7 @@ void LineEdit::delete_text(int p_from_column, int p_to_column) { if (text.size() > 0) { Ref<Font> font = get_theme_font("font"); - if (font != NULL) { + if (font != nullptr) { for (int i = p_from_column; i < p_to_column; i++) cached_width -= font->get_char_size(pass ? secret_character[0] : text[i]).width; } @@ -1709,7 +1709,7 @@ void LineEdit::_emit_text_change() { void LineEdit::update_cached_width() { Ref<Font> font = get_theme_font("font"); cached_width = 0; - if (font != NULL) { + if (font != nullptr) { String text = get_text(); for (int i = 0; i < text.length(); i++) { cached_width += font->get_char_size(pass ? secret_character[0] : text[i]).width; @@ -1720,7 +1720,7 @@ void LineEdit::update_cached_width() { void LineEdit::update_placeholder_width() { Ref<Font> font = get_theme_font("font"); cached_placeholder_width = 0; - if (font != NULL) { + if (font != nullptr) { for (int i = 0; i < placeholder_translated.length(); i++) { cached_placeholder_width += font->get_char_size(placeholder_translated[i]).width; } @@ -1729,7 +1729,7 @@ void LineEdit::update_placeholder_width() { void LineEdit::_clear_redo() { _create_undo_state(); - if (undo_stack_pos == NULL) { + if (undo_stack_pos == nullptr) { return; } @@ -1744,7 +1744,7 @@ void LineEdit::_clear_redo() { void LineEdit::_clear_undo_stack() { undo_stack.clear(); - undo_stack_pos = NULL; + undo_stack_pos = nullptr; _create_undo_state(); } @@ -1865,7 +1865,7 @@ void LineEdit::_bind_methods() { LineEdit::LineEdit() { - undo_stack_pos = NULL; + undo_stack_pos = nullptr; _create_undo_state(); align = ALIGN_LEFT; cached_width = 0; diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index c096dc94cb..1e933c9aa1 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -394,7 +394,7 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventKey> k = p_event; - if (allow_search && k.is_valid() && k->get_unicode()) { + if (allow_search && k.is_valid() && k->get_unicode() && k->is_pressed()) { uint64_t now = OS::get_singleton()->get_ticks_msec(); uint64_t diff = now - search_time_msec; @@ -1514,6 +1514,7 @@ PopupMenu::PopupMenu() { submenu_over = -1; initial_button_mask = 0; during_grabbed_click = false; + invalidated_click = false; allow_search = false; search_time_msec = 0; diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp index adc5f81465..ab2f64e1b4 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -236,7 +236,7 @@ void Range::_unref_shared() { shared->owners.erase(this); if (shared->owners.size() == 0) { memdelete(shared); - shared = NULL; + shared = nullptr; } } } diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index d17eec4050..0b314d57c5 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -53,7 +53,7 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) { return p_item->subitems.front()->get(); } else if (!p_item->parent) { - return NULL; + return nullptr; } else if (p_item->E->next()) { return p_item->E->next()->get(); @@ -66,7 +66,7 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) { if (p_item->parent) return p_item->E->next()->get(); else - return NULL; + return nullptr; } } else { @@ -74,7 +74,7 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) { return p_item->subitems.front()->get(); } else if (p_item->type == ITEM_FRAME) { - return NULL; + return nullptr; } else if (p_item->E->next()) { return p_item->E->next()->get(); @@ -87,11 +87,11 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) { if (p_item->type != ITEM_FRAME) return p_item->E->next()->get(); else - return NULL; + return nullptr; } } - return NULL; + return nullptr; } RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) { @@ -101,7 +101,7 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) { return p_item->subitems.back()->get(); } else if (!p_item->parent) { - return NULL; + return nullptr; } else if (p_item->E->prev()) { return p_item->E->prev()->get(); @@ -114,7 +114,7 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) { if (p_item->parent) return p_item->E->prev()->get(); else - return NULL; + return nullptr; } } else { @@ -122,7 +122,7 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) { return p_item->subitems.back()->get(); } else if (p_item->type == ITEM_FRAME) { - return NULL; + return nullptr; } else if (p_item->E->prev()) { return p_item->E->prev()->get(); @@ -135,11 +135,11 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) { if (p_item->type != ITEM_FRAME) return p_item->E->prev()->get(); else - return NULL; + return nullptr; } } - return NULL; + return nullptr; } Rect2 RichTextLabel::_get_text_rect() { @@ -158,7 +158,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & ci = get_canvas_item(); if (r_click_item) - *r_click_item = NULL; + *r_click_item = nullptr; } Line &l = p_frame->lines.write[p_line]; Item *it = l.from; @@ -356,7 +356,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & Color font_color_shadow; bool underline = false; bool strikethrough = false; - ItemFade *fade = NULL; + ItemFade *fade = nullptr; int it_char_start = p_char_count; Vector<ItemFX *> fx_stack = Vector<ItemFX *>(); @@ -411,7 +411,6 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & break; //don't allow lines longer than assigned width } - w += cw; fw += cw; end++; @@ -552,8 +551,10 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & } } - if (visible) + if (visible) { line_is_blank = false; + w += font->get_char_size(c[i], c[i + 1]).x; + } if (c[i] == '\t') visible = false; @@ -582,13 +583,14 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & } else { cw = drawer.draw_char(ci, p_ofs + Point2(align_ofs + pofs, y + lh - line_descent) + fx_offset, fx_char, c[i + 1], fx_color); } - } else if (previously_visible) { + } else if (previously_visible && c[i] != '\t') { backtrack += font->get_char_size(fx_char, c[i + 1]).x; } p_char_count++; if (c[i] == '\t') { cw = tab_size * font->get_char_size(' ').width; + backtrack = MAX(0, backtrack - cw); } ofs += cw; @@ -607,7 +609,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & } else if (strikethrough) { Color uc = color; uc.a *= 0.5; - int uy = y + lh / 2 - line_descent + 2; + int uy = y + lh - (line_ascent + line_descent) / 2; float strikethrough_width = 1.0; #ifdef TOOLS_ENABLED strikethrough_width *= EDSCALE; @@ -915,7 +917,7 @@ void RichTextLabel::_update_scroll() { void RichTextLabel::_update_fx(RichTextLabel::ItemFrame *p_frame, float p_delta_time) { Item *it = p_frame; while (it) { - ItemFX *ifx = NULL; + ItemFX *ifx = nullptr; if (it->type == ITEM_CUSTOMFX || it->type == ITEM_SHAKE || it->type == ITEM_WAVE || it->type == ITEM_TORNADO || it->type == ITEM_RAINBOW) { ifx = static_cast<ItemFX *>(it); @@ -928,7 +930,7 @@ void RichTextLabel::_update_fx(RichTextLabel::ItemFrame *p_frame, float p_delta_ ifx->elapsed_time += p_delta_time; - ItemShake *shake = NULL; + ItemShake *shake = nullptr; if (it->type == ITEM_SHAKE) { shake = static_cast<ItemShake *>(it); @@ -952,7 +954,7 @@ void RichTextLabel::_notification(int p_what) { case NOTIFICATION_MOUSE_EXIT: { if (meta_hovering) { - meta_hovering = NULL; + meta_hovering = nullptr; emit_signal("meta_hover_ended", current_meta); current_meta = false; update(); @@ -1022,7 +1024,7 @@ void RichTextLabel::_notification(int p_what) { visible_line_count = 0; while (y < size.height && from_line < main->lines.size()) { - visible_line_count += _process_line(main, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, from_line, PROCESS_DRAW, base_font, base_color, font_color_shadow, use_outline, shadow_ofs, Point2i(), NULL, NULL, NULL, total_chars); + visible_line_count += _process_line(main, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, from_line, PROCESS_DRAW, base_font, base_color, font_color_shadow, use_outline, shadow_ofs, Point2i(), nullptr, nullptr, nullptr, total_chars); total_chars += main->lines[from_line].char_count; from_line++; @@ -1040,7 +1042,7 @@ void RichTextLabel::_notification(int p_what) { void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, Item **r_click_item, int *r_click_char, bool *r_outside) { if (r_click_item) - *r_click_item = NULL; + *r_click_item = nullptr; Rect2 text_rect = _get_text_rect(); int ofs = vscroll->get_value(); @@ -1086,11 +1088,11 @@ Control::CursorShape RichTextLabel::get_cursor_shape(const Point2 &p_pos) const return CURSOR_ARROW; //invalid int line = 0; - Item *item = NULL; + Item *item = nullptr; bool outside; ((RichTextLabel *)(this))->_find_click(main, p_pos, &item, &line, &outside); - if (item && !outside && ((RichTextLabel *)(this))->_find_meta(item, NULL)) + if (item && !outside && ((RichTextLabel *)(this))->_find_meta(item, nullptr)) return CURSOR_POINTING_HAND; return CURSOR_ARROW; @@ -1108,7 +1110,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { if (b->is_pressed() && !b->is_doubleclick()) { scroll_updated = false; int line = 0; - Item *item = NULL; + Item *item = nullptr; bool outside; _find_click(main, b->get_position(), &item, &line, &outside); @@ -1122,9 +1124,9 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { // Erase previous selection. if (selection.active) { - selection.from = NULL; + selection.from = nullptr; selection.from_char = '\0'; - selection.to = NULL; + selection.to = nullptr; selection.to_char = '\0'; selection.active = false; @@ -1136,7 +1138,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { //doubleclick: select word int line = 0; - Item *item = NULL; + Item *item = nullptr; bool outside; _find_click(main, b->get_position(), &item, &line, &outside); @@ -1163,11 +1165,11 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { } } else if (!b->is_pressed()) { - selection.click = NULL; + selection.click = nullptr; if (!b->is_doubleclick() && !scroll_updated) { int line = 0; - Item *item = NULL; + Item *item = nullptr; bool outside; _find_click(main, b->get_position(), &item, &line, &outside); @@ -1276,7 +1278,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { return; int line = 0; - Item *item = NULL; + Item *item = nullptr; bool outside; _find_click(main, m->get_position(), &item, &line, &outside); @@ -1325,7 +1327,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { emit_signal("meta_hover_started", meta); } } else if (meta_hovering) { - meta_hovering = NULL; + meta_hovering = nullptr; emit_signal("meta_hover_ended", current_meta); current_meta = false; } @@ -1641,7 +1643,7 @@ void RichTextLabel::_add_item(Item *p_item, bool p_enter, bool p_ensure_newline) } } - if (current_frame->lines[current_frame->lines.size() - 1].from == NULL) { + if (current_frame->lines[current_frame->lines.size() - 1].from == nullptr) { current_frame->lines.write[current_frame->lines.size() - 1].from = p_item; } p_item->line = current_frame->lines.size() - 1; @@ -1938,7 +1940,7 @@ void RichTextLabel::push_cell() { item->cell = true; item->parent_line = item->parent_frame->lines.size() - 1; item->lines.resize(1); - item->lines.write[0].from = NULL; + item->lines.write[0].from = nullptr; item->first_invalid_line = 0; } @@ -1969,7 +1971,7 @@ void RichTextLabel::clear() { main->lines.resize(1); main->first_invalid_line = 0; update(); - selection.click = NULL; + selection.click = nullptr; selection.active = false; current_idx = 1; @@ -2953,7 +2955,7 @@ RichTextLabel::RichTextLabel() { tab_size = 4; default_align = ALIGN_LEFT; underline_meta = true; - meta_hovering = NULL; + meta_hovering = nullptr; override_selected_font_color = false; scroll_visible = false; @@ -2977,7 +2979,7 @@ RichTextLabel::RichTextLabel() { current_idx = 1; use_bbcode = false; - selection.click = NULL; + selection.click = nullptr; selection.active = false; selection.enabled = false; diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index dd439208af..7f2b5facb9 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -98,7 +98,7 @@ private: int maximum_width; Line() { - from = NULL; + from = nullptr; char_count = 0; } }; @@ -119,9 +119,11 @@ private: } Item() { - parent = NULL; - E = NULL; + parent = nullptr; + E = nullptr; line = 0; + index = 0; + type = ITEM_FRAME; } virtual ~Item() { _clear_children(); } }; @@ -135,7 +137,7 @@ private: ItemFrame() { type = ITEM_FRAME; - parent_frame = NULL; + parent_frame = nullptr; cell = false; parent_line = 0; } @@ -368,8 +370,8 @@ private: int visible_characters; float percent_visible; - int _process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Color &p_font_color_shadow, bool p_shadow_as_outline, const Point2 &shadow_ofs, const Point2i &p_click_pos = Point2i(), Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL, int p_char_count = 0); - void _find_click(ItemFrame *p_frame, const Point2i &p_click, Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL); + int _process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Color &p_font_color_shadow, bool p_shadow_as_outline, const Point2 &shadow_ofs, const Point2i &p_click_pos = Point2i(), Item **r_click_item = nullptr, int *r_click_char = nullptr, bool *r_outside = nullptr, int p_char_count = 0); + void _find_click(ItemFrame *p_frame, const Point2i &p_click, Item **r_click_item = nullptr, int *r_click_char = nullptr, bool *r_outside = nullptr); Ref<Font> _find_font(Item *p_item); int _find_margin(Item *p_item, const Ref<Font> &p_base_font); @@ -377,7 +379,7 @@ private: Color _find_color(Item *p_item, const Color &p_default_color); bool _find_underline(Item *p_item); bool _find_strikethrough(Item *p_item); - bool _find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item = NULL); + bool _find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item = nullptr); bool _find_layout_subitem(Item *from, Item *to); bool _find_by_type(Item *p_item, ItemType p_type); void _fetch_item_fx_stack(Item *p_item, Vector<ItemFX *> &r_stack); diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 5e9541730e..1c63c25e28 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -308,7 +308,7 @@ void ScrollBar::_notification(int p_what) { drag_node->disconnect("tree_exiting", callable_mp(this, &ScrollBar::_drag_node_exit)); } - drag_node = NULL; + drag_node = nullptr; } if (p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) { @@ -542,7 +542,7 @@ void ScrollBar::_drag_node_exit() { if (drag_node) { drag_node->disconnect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input)); } - drag_node = NULL; + drag_node = nullptr; } void ScrollBar::_drag_node_input(const Ref<InputEvent> &p_input) { @@ -616,7 +616,7 @@ void ScrollBar::set_drag_node(const NodePath &p_path) { } } - drag_node = NULL; + drag_node = nullptr; drag_node_path = p_path; if (is_inside_tree()) { @@ -662,7 +662,7 @@ ScrollBar::ScrollBar(Orientation p_orientation) { orientation = p_orientation; highlight = HIGHLIGHT_NONE; custom_step = -1; - drag_node = NULL; + drag_node = nullptr; drag.active = false; diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index ccfa8ebf63..8572d570fb 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -60,7 +60,7 @@ void SpinBox::_text_entered(const String &p_string) { return; } - Variant value = expr->execute(Array(), NULL, false); + Variant value = expr->execute(Array(), nullptr, false); if (value.get_type() != Variant::NIL) { set_value(value); _value_changed(0); diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp index 4eb614a9ac..de892a4fb9 100644 --- a/scene/gui/split_container.cpp +++ b/scene/gui/split_container.cpp @@ -50,7 +50,7 @@ Control *SplitContainer::_getch(int p_idx) const { idx++; } - return NULL; + return nullptr; } void SplitContainer::_resort() { diff --git a/scene/gui/viewport_container.cpp b/scene/gui/subviewport_container.cpp index 7ce1d9e551..50f468741d 100644 --- a/scene/gui/viewport_container.cpp +++ b/scene/gui/subviewport_container.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* viewport_container.cpp */ +/* subviewport_container.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,12 +28,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "viewport_container.h" +#include "subviewport_container.h" #include "core/engine.h" #include "scene/main/viewport.h" -Size2 ViewportContainer::get_minimum_size() const { +Size2 SubViewportContainer::get_minimum_size() const { if (stretch) return Size2(); @@ -52,19 +52,19 @@ Size2 ViewportContainer::get_minimum_size() const { return ms; } -void ViewportContainer::set_stretch(bool p_enable) { +void SubViewportContainer::set_stretch(bool p_enable) { stretch = p_enable; queue_sort(); update(); } -bool ViewportContainer::is_stretch_enabled() const { +bool SubViewportContainer::is_stretch_enabled() const { return stretch; } -void ViewportContainer::set_stretch_shrink(int p_shrink) { +void SubViewportContainer::set_stretch_shrink(int p_shrink) { ERR_FAIL_COND(p_shrink < 1); if (shrink == p_shrink) @@ -87,12 +87,12 @@ void ViewportContainer::set_stretch_shrink(int p_shrink) { update(); } -int ViewportContainer::get_stretch_shrink() const { +int SubViewportContainer::get_stretch_shrink() const { return shrink; } -void ViewportContainer::_notification(int p_what) { +void SubViewportContainer::_notification(int p_what) { if (p_what == NOTIFICATION_RESIZED) { @@ -142,7 +142,7 @@ void ViewportContainer::_notification(int p_what) { } } -void ViewportContainer::_input(const Ref<InputEvent> &p_event) { +void SubViewportContainer::_input(const Ref<InputEvent> &p_event) { if (Engine::get_singleton()->is_editor_hint()) return; @@ -167,7 +167,7 @@ void ViewportContainer::_input(const Ref<InputEvent> &p_event) { } } -void ViewportContainer::_unhandled_input(const Ref<InputEvent> &p_event) { +void SubViewportContainer::_unhandled_input(const Ref<InputEvent> &p_event) { if (Engine::get_singleton()->is_editor_hint()) return; @@ -192,21 +192,21 @@ void ViewportContainer::_unhandled_input(const Ref<InputEvent> &p_event) { } } -void ViewportContainer::_bind_methods() { +void SubViewportContainer::_bind_methods() { - ClassDB::bind_method(D_METHOD("_unhandled_input", "event"), &ViewportContainer::_unhandled_input); - ClassDB::bind_method(D_METHOD("_input", "event"), &ViewportContainer::_input); - ClassDB::bind_method(D_METHOD("set_stretch", "enable"), &ViewportContainer::set_stretch); - ClassDB::bind_method(D_METHOD("is_stretch_enabled"), &ViewportContainer::is_stretch_enabled); + ClassDB::bind_method(D_METHOD("_unhandled_input", "event"), &SubViewportContainer::_unhandled_input); + ClassDB::bind_method(D_METHOD("_input", "event"), &SubViewportContainer::_input); + ClassDB::bind_method(D_METHOD("set_stretch", "enable"), &SubViewportContainer::set_stretch); + ClassDB::bind_method(D_METHOD("is_stretch_enabled"), &SubViewportContainer::is_stretch_enabled); - ClassDB::bind_method(D_METHOD("set_stretch_shrink", "amount"), &ViewportContainer::set_stretch_shrink); - ClassDB::bind_method(D_METHOD("get_stretch_shrink"), &ViewportContainer::get_stretch_shrink); + ClassDB::bind_method(D_METHOD("set_stretch_shrink", "amount"), &SubViewportContainer::set_stretch_shrink); + ClassDB::bind_method(D_METHOD("get_stretch_shrink"), &SubViewportContainer::get_stretch_shrink); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stretch"), "set_stretch", "is_stretch_enabled"); ADD_PROPERTY(PropertyInfo(Variant::INT, "stretch_shrink"), "set_stretch_shrink", "get_stretch_shrink"); } -ViewportContainer::ViewportContainer() { +SubViewportContainer::SubViewportContainer() { stretch = false; shrink = 1; diff --git a/scene/gui/viewport_container.h b/scene/gui/subviewport_container.h index 8597444426..6ff3d188e2 100644 --- a/scene/gui/viewport_container.h +++ b/scene/gui/subviewport_container.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* viewport_container.h */ +/* subviewport_container.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -33,9 +33,9 @@ #include "scene/gui/container.h" -class ViewportContainer : public Container { +class SubViewportContainer : public Container { - GDCLASS(ViewportContainer, Container); + GDCLASS(SubViewportContainer, Container); bool stretch; int shrink; @@ -55,7 +55,7 @@ public: virtual Size2 get_minimum_size() const; - ViewportContainer(); + SubViewportContainer(); }; #endif // VIEWPORTCONTAINER_H diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 7cecbf7fa2..de80049862 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -602,7 +602,7 @@ Control *TabContainer::get_tab_control(int p_idx) const { if (p_idx >= 0 && p_idx < tabs.size()) return tabs[p_idx]; else - return NULL; + return nullptr; } Control *TabContainer::get_current_tab_control() const { @@ -611,7 +611,7 @@ Control *TabContainer::get_current_tab_control() const { if (current >= 0 && current < tabs.size()) return tabs[current]; else - return NULL; + return nullptr; } void TabContainer::remove_child_notify(Node *p_child) { @@ -1041,7 +1041,7 @@ TabContainer::TabContainer() { previous = 0; align = ALIGN_CENTER; tabs_visible = true; - popup = NULL; + popup = nullptr; drag_to_rearrange_enabled = false; tabs_rearrange_group = -1; use_hidden_tabs_for_min_size = false; diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index ea6d44e3a7..1a3b53f489 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -184,10 +184,7 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) { } int found = -1; - for (int i = 0; i < tabs.size(); i++) { - - if (i < offset) - continue; + for (int i = offset; i < tabs.size(); i++) { if (tabs[i].rb_rect.has_point(pos)) { rb_pressing = true; @@ -276,10 +273,7 @@ void Tabs::_notification(int p_what) { missing_right = false; - for (int i = 0; i < tabs.size(); i++) { - - if (i < offset) - continue; + for (int i = offset; i < tabs.size(); i++) { tabs.write[i].ofs_cache = w; @@ -499,10 +493,7 @@ void Tabs::_update_hover() { // test hovering to display right or close button int hover_now = -1; int hover_buttons = -1; - for (int i = 0; i < tabs.size(); i++) { - - if (i < offset) - continue; + for (int i = offset; i < tabs.size(); i++) { Rect2 rect = get_tab_rect(i); if (rect.has_point(pos)) { @@ -559,9 +550,8 @@ void Tabs::_update_cache() { if (count_resize > 0) { m_width = MAX((limit - size_fixed) / count_resize, min_width); } - for (int i = 0; i < tabs.size(); i++) { - if (i < offset) - continue; + for (int i = offset; i < tabs.size(); i++) { + Ref<StyleBox> sb; if (tabs[i].disabled) { sb = tab_disabled; @@ -753,10 +743,7 @@ void Tabs::drop_data(const Point2 &p_point, const Variant &p_data) { int Tabs::get_tab_idx_at_point(const Point2 &p_point) const { int hover_now = -1; - for (int i = 0; i < tabs.size(); i++) { - - if (i < offset) - continue; + for (int i = offset; i < tabs.size(); i++) { Rect2 rect = get_tab_rect(i); if (rect.has_point(p_point)) { @@ -850,10 +837,7 @@ void Tabs::_ensure_no_over_offset() { while (offset > 0) { int total_w = 0; - for (int i = 0; i < tabs.size(); i++) { - - if (i < offset - 1) - continue; + for (int i = offset - 1; i < tabs.size(); i++) { total_w += tabs[i].size_cache; } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 7071652f2a..36e35897d1 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2186,7 +2186,7 @@ Vector2i TextEdit::_get_cursor_pixel_pos() { int x = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width - cursor.x_ofs; int ix = 0; while (ix < rows2[0].size() && ix < cursor.column) { - if (cache.font != NULL) { + if (cache.font != nullptr) { x += cache.font->get_char_size(rows2[0].get(ix)).width; } ix++; @@ -3990,7 +3990,7 @@ void TextEdit::_base_insert_text(int p_line, int p_char, const String &p_text, i text.set_breakpoint(p_line, false); text.set_hidden(p_line, false); - text.set_info_icon(p_line, NULL, ""); + text.set_info_icon(p_line, nullptr, ""); } text.set_line_wrap_amount(p_line, -1); @@ -6087,7 +6087,7 @@ void TextEdit::_do_text_op(const TextOperation &p_op, bool p_reverse) { void TextEdit::_clear_redo() { - if (undo_stack_pos == NULL) + if (undo_stack_pos == nullptr) return; // Nothing to clear. _push_current_op(); @@ -6103,7 +6103,7 @@ void TextEdit::undo() { _push_current_op(); - if (undo_stack_pos == NULL) { + if (undo_stack_pos == nullptr) { if (!undo_stack.size()) return; // Nothing to undo. @@ -6152,7 +6152,7 @@ void TextEdit::redo() { _push_current_op(); - if (undo_stack_pos == NULL) + if (undo_stack_pos == nullptr) return; // Nothing to do. deselect(); @@ -6184,7 +6184,7 @@ void TextEdit::clear_undo_history() { saved_version = 0; current_op.type = TextOperation::TYPE_NONE; - undo_stack_pos = NULL; + undo_stack_pos = nullptr; undo_stack.clear(); } @@ -6633,8 +6633,8 @@ void TextEdit::_update_completion_candidates() { const CharType *tgt = &option.display[0]; const CharType *tgt_lower = &display_lower[0]; - const CharType *ssq_last_tgt = NULL; - const CharType *ssq_lower_last_tgt = NULL; + const CharType *ssq_last_tgt = nullptr; + const CharType *ssq_lower_last_tgt = nullptr; for (; *tgt; tgt++, tgt_lower++) { if (*ssq == *tgt) { @@ -6701,7 +6701,7 @@ void TextEdit::query_code_comple() { bool ignored = completion_active && !completion_options.empty(); if (ignored) { ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_PLAIN_TEXT; - const ScriptCodeCompletionOption *previous_option = NULL; + const ScriptCodeCompletionOption *previous_option = nullptr; for (int i = 0; i < completion_options.size(); i++) { const ScriptCodeCompletionOption ¤t_option = completion_options[i]; if (!previous_option) { @@ -7259,7 +7259,7 @@ TextEdit::TextEdit() { wrap_at = 0; wrap_right_offset = 10; set_focus_mode(FOCUS_ALL); - syntax_highlighter = NULL; + syntax_highlighter = nullptr; _update_caches(); cache.row_height = 1; cache.line_spacing = 1; @@ -7323,7 +7323,7 @@ TextEdit::TextEdit() { current_op.type = TextOperation::TYPE_NONE; undo_enabled = true; - undo_stack_pos = NULL; + undo_stack_pos = nullptr; setting_text = false; last_dblclk = 0; current_op.version = 0; @@ -7333,7 +7333,7 @@ TextEdit::TextEdit() { completion_enabled = false; completion_active = false; completion_line_ofs = 0; - tooltip_obj = NULL; + tooltip_obj = nullptr; line_numbers = false; line_numbers_zero_padded = false; line_length_guidelines = false; @@ -7394,7 +7394,7 @@ Map<int, TextEdit::HighlighterInfo> TextEdit::_get_line_syntax_highlighting(int return syntax_highlighting_cache[p_line]; } - if (syntax_highlighter != NULL) { + if (syntax_highlighter != nullptr) { Map<int, HighlighterInfo> color_map = syntax_highlighter->_get_line_syntax_highlighting(p_line); syntax_highlighting_cache[p_line] = color_map; return color_map; @@ -7508,7 +7508,7 @@ Map<int, TextEdit::HighlighterInfo> TextEdit::_get_line_syntax_highlighting(int if (col) { for (int k = j - 1; k >= 0; k--) { if (str[k] == '.') { - col = NULL; // Member indexing not allowed. + col = nullptr; // Member indexing not allowed. break; } else if (str[k] > 32) { break; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 7d096f7897..ef8c39d32f 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -530,7 +530,7 @@ private: protected: virtual String get_tooltip(const Point2 &p_pos) const; - void _insert_text(int p_line, int p_char, const String &p_text, int *r_end_line = NULL, int *r_end_char = NULL); + void _insert_text(int p_line, int p_char, const String &p_text, int *r_end_line = nullptr, int *r_end_char = nullptr); void _remove_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column); void _insert_text_at_cursor(const String &p_text); void _gui_input(const Ref<InputEvent> &p_gui_input); diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp index baa138847f..92f3c5b5d9 100644 --- a/scene/gui/texture_rect.cpp +++ b/scene/gui/texture_rect.cpp @@ -95,6 +95,15 @@ void TextureRect::_notification(int p_what) { } break; } + Ref<AtlasTexture> p_atlas = texture; + + if (p_atlas.is_valid() && region.has_no_area()) { + Size2 scale_size(size.width / texture->get_width(), size.height / texture->get_height()); + + offset.width += hflip ? p_atlas->get_margin().get_position().width * scale_size.width * 2 : 0; + offset.height += vflip ? p_atlas->get_margin().get_position().height * scale_size.height * 2 : 0; + } + size.width *= hflip ? -1.0f : 1.0f; size.height *= vflip ? -1.0f : 1.0f; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 87425b49cd..a7acaae8df 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -71,7 +71,7 @@ void TreeItem::move_to_bottom() { parent->children = next; } last->next = this; - next = NULL; + next = nullptr; } Size2 TreeItem::Cell::get_icon_size() const { @@ -371,7 +371,7 @@ TreeItem *TreeItem::get_next() { TreeItem *TreeItem::get_prev() { if (!parent || parent->children == this) - return NULL; + return nullptr; TreeItem *prev = parent->children; while (prev && prev->next != this) @@ -400,7 +400,7 @@ TreeItem *TreeItem::get_prev_visible(bool p_wrap) { current = current->parent; if (current == tree->root && tree->hide_root) { - return NULL; + return nullptr; } else if (!current) { if (p_wrap) { current = this; @@ -410,7 +410,7 @@ TreeItem *TreeItem::get_prev_visible(bool p_wrap) { temp = temp->get_next_visible(); } } else { - return NULL; + return nullptr; } } } else { @@ -450,7 +450,7 @@ TreeItem *TreeItem::get_next_visible(bool p_wrap) { if (p_wrap) return tree->root; else - return NULL; + return nullptr; } else { current = current->next; } @@ -472,7 +472,7 @@ void TreeItem::remove_child(TreeItem *p_item) { *c = (*c)->next; - aux->parent = NULL; + aux->parent = nullptr; return; } @@ -890,11 +890,11 @@ void TreeItem::clear_children() { TreeItem *aux = c; c = c->get_next(); - aux->parent = 0; // so it won't try to recursively autoremove from me in here + aux->parent = nullptr; // so it won't try to recursively autoremove from me in here memdelete(aux); } - children = 0; + children = nullptr; }; TreeItem::TreeItem(Tree *p_tree) { @@ -904,9 +904,9 @@ TreeItem::TreeItem(Tree *p_tree) { disable_folding = false; custom_min_height = 0; - parent = 0; // parent item - next = 0; // next in list - children = 0; //child items + parent = nullptr; // parent item + next = nullptr; // next in list + children = nullptr; //child items } TreeItem::~TreeItem() { @@ -918,29 +918,29 @@ TreeItem::~TreeItem() { if (tree && tree->root == this) { - tree->root = 0; + tree->root = nullptr; } if (tree && tree->popup_edited_item == this) { - tree->popup_edited_item = NULL; + tree->popup_edited_item = nullptr; tree->pressing_for_editor = false; } if (tree && tree->cache.hover_item == this) { - tree->cache.hover_item = NULL; + tree->cache.hover_item = nullptr; } if (tree && tree->selected_item == this) - tree->selected_item = NULL; + tree->selected_item = nullptr; if (tree && tree->drop_mode_over == this) - tree->drop_mode_over = NULL; + tree->drop_mode_over = nullptr; if (tree && tree->single_select_defer == this) - tree->single_select_defer = NULL; + tree->single_select_defer = nullptr; if (tree && tree->edited_item == this) { - tree->edited_item = NULL; + tree->edited_item = nullptr; tree->pressing_for_editor = false; } } @@ -1498,7 +1498,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 int parent_ofs = p_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin); Point2i root_pos = Point2i(root_ofs, children_pos.y + label_h / 2) - cache.offset + p_draw_ofs; - if (c->get_children() != NULL) + if (c->get_children() != nullptr) root_pos -= Point2i(cache.arrow->get_width(), 0); float line_width = 1.0; @@ -2131,7 +2131,7 @@ void Tree::popup_select(int p_option) { void Tree::_go_left() { if (selected_col == 0) { - if (selected_item->get_children() != NULL && !selected_item->is_collapsed()) { + if (selected_item->get_children() != nullptr && !selected_item->is_collapsed()) { selected_item->set_collapsed(true); } else { if (columns.size() == 1) { // goto parent with one column @@ -2160,7 +2160,7 @@ void Tree::_go_left() { void Tree::_go_right() { if (selected_col == (columns.size() - 1)) { - if (selected_item->get_children() != NULL && selected_item->is_collapsed()) { + if (selected_item->get_children() != nullptr && selected_item->is_collapsed()) { selected_item->set_collapsed(false); } else if (selected_item->get_next_visible()) { selected_col = 0; @@ -2181,7 +2181,7 @@ void Tree::_go_right() { } void Tree::_go_up() { - TreeItem *prev = NULL; + TreeItem *prev = nullptr; if (!selected_item) { prev = get_last_item(); selected_col = 0; @@ -2221,7 +2221,7 @@ void Tree::_go_up() { } void Tree::_go_down() { - TreeItem *next = NULL; + TreeItem *next = nullptr; if (!selected_item) { if (root) { @@ -2324,7 +2324,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { if (!cursor_can_exit_tree) accept_event(); - TreeItem *next = NULL; + TreeItem *next = nullptr; if (!selected_item) return; next = selected_item; @@ -2362,7 +2362,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { if (!cursor_can_exit_tree) accept_event(); - TreeItem *prev = NULL; + TreeItem *prev = nullptr; if (!selected_item) return; prev = selected_item; @@ -2584,7 +2584,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { if (single_select_defer) { select_single_item(single_select_defer, root, single_select_defer_column); - single_select_defer = NULL; + single_select_defer = nullptr; } range_click_timer->stop(); @@ -2609,7 +2609,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { pressing_for_editor = false; } - if (cache.click_type == Cache::CLICK_BUTTON && cache.click_item != NULL) { + if (cache.click_type == Cache::CLICK_BUTTON && cache.click_item != nullptr) { // make sure in case of wrong reference after reconstructing whole TreeItems cache.click_item = get_item_at_position(cache.click_pos); emit_signal("button_pressed", cache.click_item, cache.click_column, cache.click_id); @@ -2617,7 +2617,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { cache.click_type = Cache::CLICK_NONE; cache.click_index = -1; cache.click_id = -1; - cache.click_item = NULL; + cache.click_item = nullptr; cache.click_column = 0; if (drag_touching) { @@ -2711,7 +2711,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { } if (b->get_button_index() == BUTTON_LEFT) { - if (get_item_at_position(b->get_position()) == NULL && !b->get_shift() && !b->get_control() && !b->get_command()) + if (get_item_at_position(b->get_position()) == nullptr && !b->get_shift() && !b->get_control() && !b->get_command()) emit_signal("nothing_selected"); } } @@ -2946,7 +2946,7 @@ void Tree::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAG_BEGIN) { - single_select_defer = NULL; + single_select_defer = nullptr; if (cache.scroll_speed > 0) { scrolling = true; set_physics_process_internal(true); @@ -3076,7 +3076,7 @@ void Tree::_notification(int p_what) { if (p_what == NOTIFICATION_RESIZED || p_what == NOTIFICATION_TRANSFORM_CHANGED) { - if (popup_edited_item != NULL) { + if (popup_edited_item != nullptr) { Rect2 rect = popup_edited_item->get_meta("__focus_rect"); Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2); Point2i textedpos = get_global_position() + rect.position - ofs; @@ -3097,18 +3097,18 @@ Size2 Tree::get_minimum_size() const { TreeItem *Tree::create_item(TreeItem *p_parent, int p_idx) { - ERR_FAIL_COND_V(blocked > 0, NULL); + ERR_FAIL_COND_V(blocked > 0, nullptr); - TreeItem *ti = NULL; + TreeItem *ti = nullptr; if (p_parent) { // Append or insert a new item to the given parent. ti = memnew(TreeItem(this)); - ERR_FAIL_COND_V(!ti, NULL); + ERR_FAIL_COND_V(!ti, nullptr); ti->cells.resize(columns.size()); - TreeItem *prev = NULL; + TreeItem *prev = nullptr; TreeItem *c = p_parent->children; int idx = 0; @@ -3132,7 +3132,7 @@ TreeItem *Tree::create_item(TreeItem *p_parent, int p_idx) { if (!root) { // No root exists, make the given item the new root. ti = memnew(TreeItem(this)); - ERR_FAIL_COND_V(!ti, NULL); + ERR_FAIL_COND_V(!ti, nullptr); ti->cells.resize(columns.size()); root = ti; @@ -3227,7 +3227,7 @@ void Tree::deselect_all() { ERR_FAIL_COND(item == prev_item); } - selected_item = NULL; + selected_item = nullptr; selected_col = -1; update(); @@ -3235,7 +3235,7 @@ void Tree::deselect_all() { bool Tree::is_anything_selected() { - return (selected_item != NULL); + return (selected_item != nullptr); } void Tree::clear() { @@ -3253,12 +3253,12 @@ void Tree::clear() { if (root) { memdelete(root); - root = NULL; + root = nullptr; }; - selected_item = NULL; - edited_item = NULL; - popup_edited_item = NULL; + selected_item = nullptr; + edited_item = nullptr; + popup_edited_item = nullptr; update(); }; @@ -3315,10 +3315,10 @@ TreeItem *Tree::get_next_selected(TreeItem *p_item) { /* if (!p_item) - return NULL; + return nullptr; */ if (!root) - return NULL; + return nullptr; while (true) { @@ -3338,8 +3338,8 @@ TreeItem *Tree::get_next_selected(TreeItem *p_item) { while (!p_item->next) { p_item = p_item->parent; - if (p_item == NULL) - return NULL; + if (p_item == nullptr) + return nullptr; } p_item = p_item->next; @@ -3351,7 +3351,7 @@ TreeItem *Tree::get_next_selected(TreeItem *p_item) { return p_item; } - return NULL; + return nullptr; } int Tree::get_column_width(int p_column) const { @@ -3458,7 +3458,7 @@ int Tree::get_item_offset(TreeItem *p_item) const { while (!it->next) { it = it->parent; - if (it == NULL) + if (it == nullptr) return 0; } @@ -3626,7 +3626,7 @@ TreeItem *Tree::_search_item_text(TreeItem *p_at, const String &p_find, int *r_c break; } - return NULL; + return nullptr; } TreeItem *Tree::search_item_text(const String &p_find, int *r_col, bool p_selectable) { @@ -3636,7 +3636,7 @@ TreeItem *Tree::search_item_text(const String &p_find, int *r_col, bool p_select if (!from) from = root; if (!from) - return NULL; + return nullptr; return _search_item_text(from->get_next_visible(true), p_find, r_col, p_selectable); } @@ -3649,7 +3649,7 @@ TreeItem *Tree::get_item_with_text(const String &p_find) const { } } } - return NULL; + return nullptr; } void Tree::_do_incr_search(const String &p_add) { @@ -3703,7 +3703,7 @@ TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_ pos.x -= w; } - return NULL; + return nullptr; } else { pos.y -= h; @@ -3714,7 +3714,7 @@ TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_ } if (p_item->is_collapsed()) - return NULL; // do not try children, it's collapsed + return nullptr; // do not try children, it's collapsed TreeItem *n = p_item->get_children(); while (n) { @@ -3728,7 +3728,7 @@ TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_ n = n->get_next(); } - return NULL; + return nullptr; } int Tree::get_column_at_position(const Point2 &p_pos) const { @@ -3790,7 +3790,7 @@ TreeItem *Tree::get_item_at_position(const Point2 &p_pos) const { pos -= cache.bg->get_offset(); pos.y -= _get_title_button_height(); if (pos.y < 0) - return NULL; + return nullptr; if (h_scroll->is_visible_in_tree()) pos.x += h_scroll->get_value(); @@ -3806,7 +3806,7 @@ TreeItem *Tree::get_item_at_position(const Point2 &p_pos) const { } } - return NULL; + return nullptr; } String Tree::get_tooltip(const Point2 &p_pos) const { @@ -3883,7 +3883,7 @@ void Tree::set_drop_mode_flags(int p_flags) { return; drop_mode_flags = p_flags; if (drop_mode_flags == 0) { - drop_mode_over = NULL; + drop_mode_over = nullptr; } update(); @@ -4015,17 +4015,17 @@ Tree::Tree() { selected_col = 0; columns.resize(1); - selected_item = NULL; - edited_item = NULL; + selected_item = nullptr; + edited_item = nullptr; selected_col = -1; edited_col = -1; hide_root = false; select_mode = SELECT_SINGLE; - root = 0; - popup_menu = NULL; - popup_edited_item = NULL; - text_editor = NULL; + root = nullptr; + popup_menu = nullptr; + popup_edited_item = nullptr; + text_editor = nullptr; set_focus_mode(FOCUS_ALL); popup_menu = memnew(PopupMenu); @@ -4078,7 +4078,7 @@ Tree::Tree() { cache.hover_index = -1; cache.click_index = -1; cache.click_id = -1; - cache.click_item = NULL; + cache.click_item = nullptr; cache.click_column = 0; cache.hover_cell = -1; last_keypress = 0; @@ -4098,9 +4098,9 @@ Tree::Tree() { hide_folding = false; drop_mode_flags = 0; - drop_mode_over = NULL; + drop_mode_over = nullptr; drop_mode_section = 0; - single_select_defer = NULL; + single_select_defer = nullptr; scrolling = false; allow_rmb_select = false; @@ -4108,7 +4108,7 @@ Tree::Tree() { set_clip_contents(true); - cache.hover_item = NULL; + cache.hover_item = nullptr; cache.hover_cell = -1; allow_reselect = false; diff --git a/scene/gui/tree.h b/scene/gui/tree.h index becbe76598..87c2588a12 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -383,7 +383,7 @@ private: //void draw_item_text(String p_text,const Ref<Texture2D>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color); void draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color); int draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item); - void select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev = NULL, bool *r_in_range = NULL, bool p_force_deselect = false); + void select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev = nullptr, bool *r_in_range = nullptr, bool p_force_deselect = false); int propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool p_doubleclick, TreeItem *p_item, int p_button, const Ref<InputEventWithModifiers> &p_mod); void _text_editor_enter(String p_text); void _text_editor_modal_close(); @@ -584,7 +584,7 @@ public: bool edit_selected(); // First item that starts with the text, from the current focused item down and wraps around. - TreeItem *search_item_text(const String &p_find, int *r_col = NULL, bool p_selectable = false); + TreeItem *search_item_text(const String &p_find, int *r_col = nullptr, bool p_selectable = false); // First item that matches the whole text, from the first item down. TreeItem *get_item_with_text(const String &p_find) const; |