diff options
Diffstat (limited to 'editor')
29 files changed, 320 insertions, 256 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 77be561477..3997469e95 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -4086,6 +4086,8 @@ void AnimationTrackEditor::_move_selection_commit() { for (int i = 0; i < track_edits.size(); i++) { track_edits[i]->update(); } + + _update_key_edit(); } void AnimationTrackEditor::_move_selection_cancel() { diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp index cdf0e4b829..2f2840192a 100644 --- a/editor/editor_about.cpp +++ b/editor/editor_about.cpp @@ -47,7 +47,9 @@ void EditorAbout::_notification(int p_what) { Control *base = EditorNode::get_singleton()->get_gui_base(); Ref<Font> font = base->get_font("source", "EditorFonts"); _tpl_text->add_font_override("normal_font", font); + _tpl_text->add_constant_override("line_separation", 6 * EDSCALE); _license_text->add_font_override("normal_font", font); + _license_text->add_constant_override("line_separation", 6 * EDSCALE); _logo->set_texture(base->get_icon("Logo", "EditorIcons")); } break; } diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index f425d0a995..438d7ea306 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -1135,14 +1135,10 @@ void EditorFileDialog::_update_drives() { } void EditorFileDialog::_favorite_selected(int p_idx) { - - Vector<String> favorited = EditorSettings::get_singleton()->get_favorites(); - ERR_FAIL_INDEX(p_idx, favorited.size()); - - dir_access->change_dir(favorited[p_idx]); + dir_access->change_dir(favorites->get_item_metadata(p_idx)); file->set_text(""); - invalidate(); update_dir(); + invalidate(); _push_history(); } @@ -1192,7 +1188,7 @@ void EditorFileDialog::_update_favorites() { bool res = access == ACCESS_RESOURCES; String current = get_current_dir(); - Ref<Texture> star = get_icon("Favorites", "EditorIcons"); + Ref<Texture> folder_icon = get_icon("Folder", "EditorIcons"); favorites->clear(); favorite->set_pressed(false); @@ -1203,16 +1199,23 @@ void EditorFileDialog::_update_favorites() { if (cres != res) continue; String name = favorited[i]; - - bool setthis = name == current; + bool setthis = false; if (res && name == "res://") { + if (name == current) + setthis = true; name = "/"; + } else if (name.ends_with("/")) { + if (name == current) + setthis = true; + name = name.substr(0, name.length() - 1); + name = name.get_file(); + + favorites->add_item(name, folder_icon); } else { - name = name.get_file() + "/"; + continue; // We don't handle favorite files here } - favorites->add_item(name, star); favorites->set_item_metadata(favorites->get_item_count() - 1, favorited[i]); if (setthis) { diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index a90f15004a..3ecaa2b136 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -738,9 +738,9 @@ Control *EditorProperty::make_custom_tooltip(const String &p_text) const { tooltip_text = p_text; EditorHelpBit *help_bit = memnew(EditorHelpBit); help_bit->add_style_override("panel", get_stylebox("panel", "TooltipPanel")); - help_bit->get_rich_text()->set_fixed_size_to_width(300); + help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE); - String text = TTR("Property: ") + "[u][b]" + p_text.get_slice("::", 0) + "[/b][/u]\n"; + String text = TTR("Property:") + " [u][b]" + p_text.get_slice("::", 0) + "[/b][/u]\n"; text += p_text.get_slice("::", 1).strip_edges(); help_bit->set_text(text); help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene @@ -960,7 +960,7 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons tooltip_text = p_text; EditorHelpBit *help_bit = memnew(EditorHelpBit); help_bit->add_style_override("panel", get_stylebox("panel", "TooltipPanel")); - help_bit->get_rich_text()->set_fixed_size_to_width(300); + help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE); String text = "[u][b]" + p_text.get_slice("::", 0) + "[/b][/u]\n"; text += p_text.get_slice("::", 1).strip_edges(); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 18dd85617b..3899fcf83f 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3892,7 +3892,9 @@ void EditorNode::_scene_tab_hover(int p_tab) { tab_preview_panel->hide(); } else { String path = editor_data.get_scene_path(p_tab); - EditorResourcePreview::get_singleton()->queue_resource_preview(path, this, "_thumbnail_done", p_tab); + if (path != String()) { + EditorResourcePreview::get_singleton()->queue_resource_preview(path, this, "_thumbnail_done", p_tab); + } } } @@ -4970,7 +4972,7 @@ EditorNode::EditorNode() { dock_vb->add_child(dock_hb); dock_select = memnew(Control); - dock_select->set_custom_minimum_size(Size2(128, 64) * EDSCALE); + dock_select->set_custom_minimum_size(Size2(64, 0) * EDSCALE); dock_select->connect("gui_input", this, "_dock_select_input"); dock_select->connect("draw", this, "_dock_select_draw"); dock_select->connect("mouse_exited", this, "_dock_popup_exit"); @@ -4981,7 +4983,7 @@ EditorNode::EditorNode() { dock_select_rect_over = -1; dock_popup_selected = -1; for (int i = 0; i < DOCK_SLOT_MAX; i++) { - dock_slot[i]->set_custom_minimum_size(Size2(230, 220) * EDSCALE); + dock_slot[i]->set_custom_minimum_size(Size2(0, 64) * EDSCALE); dock_slot[i]->set_v_size_flags(Control::SIZE_EXPAND_FILL); dock_slot[i]->set_popup(dock_select_popup); dock_slot[i]->connect("pre_popup_pressed", this, "_dock_pre_popup", varray(i)); @@ -5497,8 +5499,8 @@ EditorNode::EditorNode() { right_r_vsplit->hide(); // Add some offsets to left_r and main hsplits to make LEFT_R and RIGHT_L docks wider than minsize - left_r_hsplit->set_split_offset(40 * EDSCALE); - main_hsplit->set_split_offset(-40 * EDSCALE); + left_r_hsplit->set_split_offset(100 * EDSCALE); + main_hsplit->set_split_offset(-100 * EDSCALE); // Define corresponding default layout diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 96d482f47e..5148c12160 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -1860,6 +1860,12 @@ void EditorPropertyNodePath::update_property() { Node *target_node = base_node->get_node(p); ERR_FAIL_COND(!target_node); + if (String(target_node->get_name()).find("@") != -1) { + assign->set_icon(Ref<Texture>()); + assign->set_text(p); + return; + } + assign->set_text(target_node->get_name()); assign->set_icon(EditorNode::get_singleton()->get_object_icon(target_node, "Node")); } diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 1e97920f7e..6eaa2560db 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -357,7 +357,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("text_editor/theme/color_theme", "Adaptive"); hints["text_editor/theme/color_theme"] = PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, "Adaptive,Default,Custom"); - _initial_set("text_editor/theme/line_spacing", 4); + _initial_set("text_editor/theme/line_spacing", 6); _initial_set("text_editor/theme/selection_color", Color::html("40808080")); _load_default_text_editor_theme(); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 5d155c3014..ef960f74ea 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -225,7 +225,7 @@ void FileSystemDock::_update_tree(const Vector<String> p_uncollapsed_paths, bool updating_tree = false; } -void FileSystemDock::_update_display_mode() { +void FileSystemDock::_update_display_mode(bool p_force) { // Compute the new display mode DisplayMode new_display_mode; if (display_mode_setting == DISPLAY_MODE_SETTING_TREE_ONLY) { @@ -234,7 +234,7 @@ void FileSystemDock::_update_display_mode() { new_display_mode = DISPLAY_MODE_SPLIT; } - if (new_display_mode != display_mode || old_display_mode_setting != display_mode_setting) { + if (p_force || new_display_mode != display_mode || old_display_mode_setting != display_mode_setting) { display_mode = new_display_mode; old_display_mode_setting = display_mode_setting; button_toggle_display_mode->set_pressed(display_mode_setting == DISPLAY_MODE_SETTING_SPLIT ? true : false); @@ -352,6 +352,11 @@ void FileSystemDock::_notification(int p_what) { tree->set_drop_mode_flags(0); } break; + case NOTIFICATION_THEME_CHANGED: { + if (tree->is_visible_in_tree()) { + _update_display_mode(true); + } + } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { // Update icons String ei = "EditorIcons"; @@ -360,6 +365,11 @@ void FileSystemDock::_notification(int p_what) { button_tree->set_icon(get_icon("Filesystem", ei)); button_hist_next->set_icon(get_icon("Forward", ei)); button_hist_prev->set_icon(get_icon("Back", ei)); + if (button_file_list_display_mode->is_pressed()) { + button_file_list_display_mode->set_icon(get_icon("FileThumbnail", "EditorIcons")); + } else { + button_file_list_display_mode->set_icon(get_icon("FileList", "EditorIcons")); + } tree_search_box->set_right_icon(get_icon("Search", ei)); tree_search_box->set_clear_button_enabled(true); @@ -412,7 +422,7 @@ void FileSystemDock::_tree_multi_selected(Object *p_item, int p_column, bool p_s return; TreeItem *favorites_item = tree->get_root()->get_children(); - if (selected->get_parent() == favorites_item) { + if (selected->get_parent() == favorites_item && !String(selected->get_metadata(0)).ends_with("/")) { // Go to the favorites if we click in the favorites and the path has changed path = "Favorites"; } else { @@ -1217,7 +1227,8 @@ void FileSystemDock::_make_dir_confirm() { if (dir_name.length() == 0) { EditorNode::get_singleton()->show_warning(TTR("No name provided")); return; - } else if (dir_name.find("/") != -1 || dir_name.find("\\") != -1 || dir_name.find(":") != -1 || dir_name.ends_with(".") || dir_name.ends_with(" ")) { + } else if (dir_name.find("/") != -1 || dir_name.find("\\") != -1 || dir_name.find(":") != -1 || dir_name.find("*") != -1 || + dir_name.find("|") != -1 || dir_name.find(">") != -1 || dir_name.ends_with(".") || dir_name.ends_with(" ")) { EditorNode::get_singleton()->show_warning(TTR("Provided name contains invalid characters")); return; } diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index d964515572..2aa79b1ddd 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -268,7 +268,7 @@ private: void _file_list_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata); void _tree_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata); - void _update_display_mode(); + void _update_display_mode(bool p_force = false); Vector<String> _tree_get_selected(bool remove_self_inclusion = true); diff --git a/editor/icons/icon_script_extend.svg b/editor/icons/icon_script_extend.svg new file mode 100644 index 0000000000..ef3d48af9f --- /dev/null +++ b/editor/icons/icon_script_extend.svg @@ -0,0 +1,8 @@ +<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"> +<g transform="translate(0 -1036.4)"> +<path transform="translate(0 1036.4)" d="m6 1v1c-0.55228 0-1 0.44772-1 1v10h-1v-2h-2v2c2.826e-4 0.35698 0.19084 0.68674 0.5 0.86523 0.15194 0.088045 0.32439 0.13452 0.5 0.13477v1h7c0.73866 0 1.3763-0.40437 1.7227-1h-3.7227v-4h4v-5h3v-2c0-1.1046-0.89543-2-2-2z" fill="#e0e0e0"/> +<path transform="translate(0 1036.4)" d="m6 1c-1.1046 0-2 0.89543-2 2v7h-2-1v1 2c0 1.1046 0.89543 2 2 2s2-0.89543 2-2v-10c0-0.55228 0.44772-1 1-1s1 0.44772 1 1v1 1 1h1 4v-1h-4v-1-1c0-1.1046-0.89543-2-2-2zm-4 10h2v2c0 0.55228-0.44772 1-1 1s-1-0.44772-1-1v-2z" fill="#b4b4b4"/> +<circle cx="3" cy="1048.4" rx="1" ry="1" fill="#e0e0e0"/> +<path d="m16 1048.4-3-3v2h-4v2h4v2z" fill="#68b6ff" fill-rule="evenodd"/> +</g> +</svg> diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index a334f79f5a..8e626e7111 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -180,7 +180,7 @@ PluginConfigDialog::PluginConfigDialog() { grid->add_child(desc_lb); desc_edit = memnew(TextEdit); - desc_edit->set_custom_minimum_size(Size2(400.0f, 50.0f)); + desc_edit->set_custom_minimum_size(Size2(400, 80) * EDSCALE); grid->add_child(desc_edit); Label *author_lb = memnew(Label); diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index f7e59e2beb..71a5d73b2f 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -132,8 +132,8 @@ Vector2 AbstractPolygon2DEditor::_get_offset(int p_idx) const { void AbstractPolygon2DEditor::_commit_action() { - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); } @@ -218,7 +218,7 @@ void AbstractPolygon2DEditor::_node_removed(Node *p_node) { edit(NULL); hide(); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } } @@ -334,7 +334,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) edited_point = PosVertex(closest, xform.affine_inverse().xform(closest.pos)); selected_point = closest; edge_point = PosVertex(); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); return true; } else { @@ -403,7 +403,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) wip_active = true; _wip_changed(); edited_point = PosVertex(-1, 1, cpoint); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); hover_point = Vertex(); selected_point = Vertex(0); edge_point = PosVertex(); @@ -424,7 +424,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) _wip_changed(); edited_point = PosVertex(-1, wip.size(), cpoint); selected_point = Vertex(wip.size() - 1); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); return true; } } @@ -453,7 +453,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) _set_polygon(edited_point.polygon, vertices); } - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } else if (mode == MODE_EDIT || (_is_line() && mode == MODE_CREATE)) { const PosVertex onEdgeVertex = closest_edge_point(gpoint); @@ -462,20 +462,20 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) hover_point = Vertex(); edge_point = onEdgeVertex; - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } else { if (edge_point.valid()) { edge_point = PosVertex(); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } const PosVertex new_hover_point = closest_point(gpoint); if (hover_point != new_hover_point) { hover_point = new_hover_point; - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } } } @@ -494,7 +494,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) wip.remove(selected_point.vertex); _wip_changed(); selected_point = wip.size() - 1; - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); return true; } } else { @@ -627,7 +627,7 @@ void AbstractPolygon2DEditor::edit(Node *p_polygon) { hover_point = Vertex(); selected_point = Vertex(); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } else { diff --git a/editor/plugins/camera_editor_plugin.cpp b/editor/plugins/camera_editor_plugin.cpp index 37fbb54c30..3d8b24ccc7 100644 --- a/editor/plugins/camera_editor_plugin.cpp +++ b/editor/plugins/camera_editor_plugin.cpp @@ -32,18 +32,6 @@ #include "spatial_editor_plugin.h" -void CameraEditor::_notification(int p_what) { - - switch (p_what) { - - /* case NOTIFICATION_PROCESS: { - - if (preview->is_pressed() && node) - node->call("make_current"); - - } break;*/ - } -} void CameraEditor::_node_removed(Node *p_node) { if (p_node == node) { diff --git a/editor/plugins/camera_editor_plugin.h b/editor/plugins/camera_editor_plugin.h index 275624beeb..0340808c9a 100644 --- a/editor/plugins/camera_editor_plugin.h +++ b/editor/plugins/camera_editor_plugin.h @@ -50,7 +50,6 @@ class CameraEditor : public Control { void _pressed(); protected: - void _notification(int p_what); void _node_removed(Node *p_node); static void _bind_methods(); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 712d9f8308..31dd20e453 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1025,8 +1025,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) { // Scroll or pan down if (bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan"))) { view_offset.y += int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor(); - _update_scrollbars(); - viewport->update(); + update_viewport(); } else { _zoom_on_position(zoom * (1 - (0.05 * b->get_factor())), b->get_position()); } @@ -1037,8 +1036,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) { // Scroll or pan up if (bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan"))) { view_offset.y -= int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor(); - _update_scrollbars(); - viewport->update(); + update_viewport(); } else { _zoom_on_position(zoom * ((0.95 + (0.05 * b->get_factor())) / 0.95), b->get_position()); } @@ -1049,8 +1047,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) { // Pan left if (bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan"))) { view_offset.x -= int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor(); - _update_scrollbars(); - viewport->update(); + update_viewport(); return true; } } @@ -1059,8 +1056,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) { // Pan right if (bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan"))) { view_offset.x += int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor(); - _update_scrollbars(); - viewport->update(); + update_viewport(); return true; } } @@ -1112,8 +1108,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) { } view_offset.x -= relative.x / zoom; view_offset.y -= relative.y / zoom; - _update_scrollbars(); - viewport->update(); + update_viewport(); return true; } } @@ -1131,8 +1126,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) { const Vector2 delta = (int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom) * pan_gesture->get_delta(); view_offset.x += delta.x; view_offset.y += delta.y; - _update_scrollbars(); - viewport->update(); + update_viewport(); return true; } @@ -3168,6 +3162,11 @@ void CanvasItemEditor::_draw_viewport() { _draw_hover(); } +void CanvasItemEditor::update_viewport() { + _update_scrollbars(); + viewport->update(); +} + void CanvasItemEditor::_notification(int p_what) { if (p_what == NOTIFICATION_PHYSICS_PROCESS) { @@ -3574,8 +3573,7 @@ void CanvasItemEditor::_zoom_on_position(float p_zoom, Point2 p_position) { view_offset.x = Math::round(view_offset.x + ofs.x); view_offset.y = Math::round(view_offset.y + ofs.y); - _update_scrollbars(); - viewport->update(); + update_viewport(); } void CanvasItemEditor::_button_zoom_minus() { @@ -4172,8 +4170,7 @@ void CanvasItemEditor::_focus_selection(int p_op) { Vector2 offset = viewport->get_size() / 2 - editor->get_scene_root()->get_global_canvas_transform().xform(center); view_offset.x -= offset.x / zoom; view_offset.y -= offset.y / zoom; - _update_scrollbars(); - viewport->update(); + update_viewport(); } else { // VIEW_FRAME_TO_SELECTION @@ -4210,6 +4207,7 @@ void CanvasItemEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_selection_result_pressed"), &CanvasItemEditor::_selection_result_pressed); ClassDB::bind_method(D_METHOD("_selection_menu_hide"), &CanvasItemEditor::_selection_menu_hide); ClassDB::bind_method(D_METHOD("set_state"), &CanvasItemEditor::set_state); + ClassDB::bind_method(D_METHOD("update_viewport"), &CanvasItemEditor::update_viewport); ADD_SIGNAL(MethodInfo("item_lock_status_changed")); ADD_SIGNAL(MethodInfo("item_group_status_changed")); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 4f8cc6ab5e..dc7b74112f 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -547,6 +547,8 @@ public: Control *get_viewport_control() { return viewport; } + void update_viewport(); + Tool get_current_tool() { return tool; } void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; } diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp index d1a94f5b49..5d85a64b9c 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -129,7 +129,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { capsule->set_height(parameter * 2 - capsule->get_radius() * 2); } - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } } break; @@ -138,7 +138,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { Ref<CircleShape2D> circle = node->get_shape(); circle->set_radius(p_point.length()); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } break; @@ -160,7 +160,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { line->set_normal(p_point.normalized()); } - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } } break; @@ -170,7 +170,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { ray->set_length(Math::abs(p_point.y)); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } break; @@ -183,7 +183,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { rect->set_extents(extents.abs()); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } } break; @@ -198,7 +198,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { seg->set_b(p_point); } - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } } break; @@ -207,7 +207,6 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { - Control *c = canvas_item_editor->get_viewport_control(); undo_redo->create_action(TTR("Set Handle")); switch (shape_type) { @@ -216,14 +215,14 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { if (idx == 0) { undo_redo->add_do_method(capsule.ptr(), "set_radius", capsule->get_radius()); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(capsule.ptr(), "set_radius", p_org); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); } else if (idx == 1) { undo_redo->add_do_method(capsule.ptr(), "set_height", capsule->get_height()); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(capsule.ptr(), "set_height", p_org); - undo_redo->add_undo_method(c, "update"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); } } break; @@ -232,9 +231,9 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { Ref<CircleShape2D> circle = node->get_shape(); undo_redo->add_do_method(circle.ptr(), "set_radius", circle->get_radius()); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(circle.ptr(), "set_radius", p_org); - undo_redo->add_undo_method(c, "update"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); } break; @@ -251,14 +250,14 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { if (idx == 0) { undo_redo->add_do_method(line.ptr(), "set_d", line->get_d()); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(line.ptr(), "set_d", p_org); - undo_redo->add_undo_method(c, "update"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); } else { undo_redo->add_do_method(line.ptr(), "set_normal", line->get_normal()); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(line.ptr(), "set_normal", p_org); - undo_redo->add_undo_method(c, "update"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); } } break; @@ -267,9 +266,9 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { Ref<RayShape2D> ray = node->get_shape(); undo_redo->add_do_method(ray.ptr(), "set_length", ray->get_length()); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(ray.ptr(), "set_length", p_org); - undo_redo->add_undo_method(c, "update"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); } break; @@ -277,9 +276,9 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { Ref<RectangleShape2D> rect = node->get_shape(); undo_redo->add_do_method(rect.ptr(), "set_extents", rect->get_extents()); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(rect.ptr(), "set_extents", p_org); - undo_redo->add_undo_method(c, "update"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); } break; @@ -287,14 +286,14 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { Ref<SegmentShape2D> seg = node->get_shape(); if (idx == 0) { undo_redo->add_do_method(seg.ptr(), "set_a", seg->get_a()); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(seg.ptr(), "set_a", p_org); - undo_redo->add_undo_method(c, "update"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); } else if (idx == 1) { undo_redo->add_do_method(seg.ptr(), "set_b", seg->get_b()); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(seg.ptr(), "set_b", p_org); - undo_redo->add_undo_method(c, "update"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); } } break; @@ -411,7 +410,7 @@ void CollisionShape2DEditor::_get_current_shape_type() { shape_type = -1; } - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { @@ -538,7 +537,7 @@ void CollisionShape2DEditor::edit(Node *p_node) { node = NULL; } - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } void CollisionShape2DEditor::_bind_methods() { diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp index 2f2e1dae81..6a16cf0989 100644 --- a/editor/plugins/light_occluder_2d_editor_plugin.cpp +++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp @@ -57,7 +57,7 @@ void LightOccluder2DEditor::_node_removed(Node *p_node) { if (p_node == node) { node = NULL; hide(); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } } @@ -88,8 +88,8 @@ void LightOccluder2DEditor::_wip_close(bool p_closed) { undo_redo->add_undo_method(node->get_occluder_polygon().ptr(), "set_closed", node->get_occluder_polygon()->is_closed()); undo_redo->add_do_method(node->get_occluder_polygon().ptr(), "set_closed", p_closed); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); wip.clear(); wip_active = false; @@ -139,7 +139,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { wip.push_back(cpoint); wip_active = true; edited_point_pos = cpoint; - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); edited_point = 1; return true; } else { @@ -158,7 +158,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { wip.push_back(cpoint); edited_point = wip.size(); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); return true; //add wip point @@ -183,8 +183,8 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->add_undo_method(node->get_occluder_polygon().ptr(), "set_polygon", poly); poly.push_back(cpoint); undo_redo->add_do_method(node->get_occluder_polygon().ptr(), "set_polygon", poly); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); return true; } @@ -217,7 +217,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { edited_point = closest_idx + 1; edited_point_pos = xform.affine_inverse().xform(closest_pos); node->get_occluder_polygon()->set_polygon(Variant(poly)); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); return true; } } else { @@ -244,7 +244,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { pre_move_edit = poly; edited_point = closest_idx; edited_point_pos = xform.affine_inverse().xform(closest_pos); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); return true; } } @@ -259,8 +259,8 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->create_action(TTR("Edit Poly")); undo_redo->add_do_method(node->get_occluder_polygon().ptr(), "set_polygon", poly); undo_redo->add_undo_method(node->get_occluder_polygon().ptr(), "set_polygon", pre_move_edit); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); edited_point = -1; @@ -290,8 +290,8 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->add_undo_method(node->get_occluder_polygon().ptr(), "set_polygon", poly); poly.remove(closest_idx); undo_redo->add_do_method(node->get_occluder_polygon().ptr(), "set_polygon", poly); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); return true; } @@ -312,7 +312,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { cpoint = canvas_item_editor->snap_point(cpoint); edited_point_pos = node->get_global_transform().affine_inverse().xform(cpoint); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } } @@ -369,7 +369,7 @@ void LightOccluder2DEditor::edit(Node *p_collision_polygon) { wip.clear(); wip_active = false; edited_point = -1; - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } else { node = NULL; } diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp index 88b3194490..c67c96798a 100644 --- a/editor/plugins/path_2d_editor_plugin.cpp +++ b/editor/plugins/path_2d_editor_plugin.cpp @@ -130,8 +130,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->create_action(TTR("Remove Point from Curve")); undo_redo->add_do_method(curve.ptr(), "remove_point", i); undo_redo->add_undo_method(curve.ptr(), "add_point", curve->get_point_position(i), curve->get_point_in(i), curve->get_point_out(i), i); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); return true; } else if (dist_to_p_out < grab_threshold) { @@ -139,8 +139,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->create_action(TTR("Remove Out-Control from Curve")); undo_redo->add_do_method(curve.ptr(), "set_point_out", i, Vector2()); undo_redo->add_undo_method(curve.ptr(), "set_point_out", i, curve->get_point_out(i)); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); return true; } else if (dist_to_p_in < grab_threshold) { @@ -148,8 +148,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->create_action(TTR("Remove In-Control from Curve")); undo_redo->add_do_method(curve.ptr(), "set_point_in", i, Vector2()); undo_redo->add_undo_method(curve.ptr(), "set_point_in", i, curve->get_point_in(i)); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); return true; } @@ -165,8 +165,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->create_action(TTR("Add Point to Curve")); undo_redo->add_do_method(curve.ptr(), "add_point", cpoint); undo_redo->add_undo_method(curve.ptr(), "remove_point", curve->get_point_count()); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); action = ACTION_MOVING_POINT; @@ -174,7 +174,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { moving_from = curve->get_point_position(action_point); moving_screen_from = gpoint; - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); return true; } @@ -196,8 +196,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->create_action(TTR("Move Point in Curve")); undo_redo->add_do_method(curve.ptr(), "set_point_position", action_point, cpoint); undo_redo->add_undo_method(curve.ptr(), "set_point_position", action_point, moving_from); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); } break; @@ -212,8 +212,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->add_do_method(curve.ptr(), "set_point_out", action_point, mirror_handle_length ? -new_pos : (-new_pos.normalized() * orig_out_length)); undo_redo->add_undo_method(curve.ptr(), "set_point_out", action_point, mirror_handle_length ? -moving_from : (-moving_from.normalized() * orig_out_length)); } - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); } break; @@ -228,8 +228,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->add_do_method(curve.ptr(), "set_point_in", action_point, mirror_handle_length ? -new_pos : (-new_pos.normalized() * orig_in_length)); undo_redo->add_undo_method(curve.ptr(), "set_point_in", action_point, mirror_handle_length ? -moving_from : (-moving_from.normalized() * orig_in_length)); } - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); } break; @@ -280,7 +280,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } break; } - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); return true; } } @@ -331,7 +331,7 @@ void Path2DEditor::_node_visibility_changed() { if (!node) return; - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } void Path2DEditor::edit(Node *p_path2d) { @@ -406,8 +406,8 @@ void Path2DEditor::_mode_selected(int p_mode) { undo_redo->create_action(TTR("Remove Point from Curve")); undo_redo->add_do_method(node->get_curve().ptr(), "add_point", begin); undo_redo->add_undo_method(node->get_curve().ptr(), "remove_point", node->get_curve()->get_point_count()); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); return; } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 7e11c4a253..07a7e7952a 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -490,7 +490,7 @@ void ScriptEditor::_open_recent_script(int p_idx) { edit(text_file, true); return; } - // if it's a path then its most likely a deleted file not help + // if it's a path then it's most likely a deleted file not help } else if (path.find("::") != -1) { // built-in script Ref<Script> script = ResourceLoader::load(path); @@ -2912,7 +2912,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { script_list = memnew(ItemList); list_split->add_child(script_list); - script_list->set_custom_minimum_size(Size2(150 * EDSCALE, 90)); //need to give a bit of limit to avoid it from disappearing + script_list->set_custom_minimum_size(Size2(150, 90) * EDSCALE); //need to give a bit of limit to avoid it from disappearing script_list->set_v_size_flags(SIZE_EXPAND_FILL); script_split->set_split_offset(140); _sort_list_on_update = true; @@ -2951,7 +2951,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { overview_vbox->add_child(members_overview); members_overview->set_allow_reselect(true); - members_overview->set_custom_minimum_size(Size2(0, 90)); //need to give a bit of limit to avoid it from disappearing + members_overview->set_custom_minimum_size(Size2(0, 90) * EDSCALE); //need to give a bit of limit to avoid it from disappearing members_overview->set_v_size_flags(SIZE_EXPAND_FILL); members_overview->set_allow_rmb_select(true); members_overview->set_drag_forwarding(this); @@ -2959,12 +2959,12 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { help_overview = memnew(ItemList); overview_vbox->add_child(help_overview); help_overview->set_allow_reselect(true); - help_overview->set_custom_minimum_size(Size2(0, 90)); //need to give a bit of limit to avoid it from disappearing + help_overview->set_custom_minimum_size(Size2(0, 90) * EDSCALE); //need to give a bit of limit to avoid it from disappearing help_overview->set_v_size_flags(SIZE_EXPAND_FILL); tab_container = memnew(TabContainer); tab_container->set_tabs_visible(false); - tab_container->set_custom_minimum_size(Size2(200 * EDSCALE, 0)); + tab_container->set_custom_minimum_size(Size2(200, 0) * EDSCALE); script_split->add_child(tab_container); tab_container->set_h_size_flags(SIZE_EXPAND_FILL); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 362b8543d4..27f5910d94 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -179,7 +179,7 @@ void ScriptTextEditor::_load_theme_settings() { text_edit->add_color_override("search_result_border_color", search_result_border_color); text_edit->add_color_override("symbol_color", symbol_color); - text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 4)); + text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 6)); colors_cache.symbol_color = symbol_color; colors_cache.keyword_color = keyword_color; diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index f57614b3b3..ab89d170da 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -952,8 +952,10 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (b->is_pressed()) { int mod = _get_key_modifier(b); - if (mod == _get_key_modifier_setting("editors/3d/freelook/freelook_activation_modifier")) { - set_freelook_active(true); + if (!orthogonal) { + if (mod == _get_key_modifier_setting("editors/3d/freelook/freelook_activation_modifier")) { + set_freelook_active(true); + } } } else { set_freelook_active(false); @@ -1134,7 +1136,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } if (clicked) { _select_clicked(clicked_wants_append, true); - //clickd processing was deferred + // Processing was deferred. clicked = 0; } @@ -1241,7 +1243,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (!clicked_includes_current) { _select_clicked(clicked_wants_append, true); - //clickd processing was deferred + // Processing was deferred. } _compute_edit(_edit.mouse_pos); @@ -1339,7 +1341,8 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { List<Node *> &selection = editor_selection->get_selected_node_list(); - bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); // Disable local transformation for TRANSFORM_VIEW + // Disable local transformation for TRANSFORM_VIEW + bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); float snap = 0; if (_edit.snap || spatial_editor->is_snap_enabled()) { @@ -1468,7 +1471,8 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { List<Node *> &selection = editor_selection->get_selected_node_list(); - bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); // Disable local transformation for TRANSFORM_VIEW + // Disable local transformation for TRANSFORM_VIEW + bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); float snap = 0; if (_edit.snap || spatial_editor->is_snap_enabled()) { @@ -1643,6 +1647,8 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { nav_mode = NAVIGATION_ZOOM; } else if (freelook_active) { nav_mode = NAVIGATION_LOOK; + } else if (orthogonal) { + nav_mode = NAVIGATION_PAN; } } else if (m->get_button_mask() & BUTTON_MASK_MIDDLE) { @@ -1793,7 +1799,8 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (ED_IS_SHORTCUT("spatial_editor/focus_selection", p_event)) { _menu_option(VIEW_CENTER_TO_SELECTION); } - if (ED_IS_SHORTCUT("spatial_editor/switch_perspective_orthogonal", p_event)) { + // Orthgonal mode doesn't work in freelook. + if (!freelook_active && ED_IS_SHORTCUT("spatial_editor/switch_perspective_orthogonal", p_event)) { _menu_option(orthogonal ? VIEW_PERSPECTIVE : VIEW_ORTHOGONAL); _update_name(); } @@ -1823,7 +1830,8 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { set_message(TTR("Animation Key Inserted.")); } - if (ED_IS_SHORTCUT("spatial_editor/freelook_toggle", p_event)) { + // Freelook doesn't work in orthogonal mode. + if (!orthogonal && ED_IS_SHORTCUT("spatial_editor/freelook_toggle", p_event)) { set_freelook_active(!is_freelook_active()); } else if (k->get_scancode() == KEY_ESCAPE) { @@ -1911,37 +1919,38 @@ void SpatialEditorViewport::_nav_orbit(Ref<InputEventWithModifiers> p_event, con void SpatialEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) { - // Freelook only works properly in perspective. - // It could technically work in ortho, but it's terrible for a user due to FOV being a fixed width. - if (!orthogonal) { - real_t degrees_per_pixel = EditorSettings::get_singleton()->get("editors/3d/navigation_feel/orbit_sensitivity"); - real_t radians_per_pixel = Math::deg2rad(degrees_per_pixel); - bool invert_y_axis = EditorSettings::get_singleton()->get("editors/3d/navigation/invert_y-axis"); - - // Note: do NOT assume the camera has the "current" transform, because it is interpolated and may have "lag". - Transform prev_camera_transform = to_camera_transform(cursor); + if (orthogonal) { + _nav_pan(p_event, p_relative); + return; + } - if (invert_y_axis) { - cursor.x_rot -= p_relative.y * radians_per_pixel; - } else { - cursor.x_rot += p_relative.y * radians_per_pixel; - } - cursor.y_rot += p_relative.x * radians_per_pixel; - if (cursor.x_rot > Math_PI / 2.0) - cursor.x_rot = Math_PI / 2.0; - if (cursor.x_rot < -Math_PI / 2.0) - cursor.x_rot = -Math_PI / 2.0; + real_t degrees_per_pixel = EditorSettings::get_singleton()->get("editors/3d/navigation_feel/orbit_sensitivity"); + real_t radians_per_pixel = Math::deg2rad(degrees_per_pixel); + bool invert_y_axis = EditorSettings::get_singleton()->get("editors/3d/navigation/invert_y-axis"); - // Look is like the opposite of Orbit: the focus point rotates around the camera - Transform camera_transform = to_camera_transform(cursor); - Vector3 pos = camera_transform.xform(Vector3(0, 0, 0)); - Vector3 prev_pos = prev_camera_transform.xform(Vector3(0, 0, 0)); - Vector3 diff = prev_pos - pos; - cursor.pos += diff; + // Note: do NOT assume the camera has the "current" transform, because it is interpolated and may have "lag". + Transform prev_camera_transform = to_camera_transform(cursor); - name = ""; - _update_name(); + if (invert_y_axis) { + cursor.x_rot -= p_relative.y * radians_per_pixel; + } else { + cursor.x_rot += p_relative.y * radians_per_pixel; } + cursor.y_rot += p_relative.x * radians_per_pixel; + if (cursor.x_rot > Math_PI / 2.0) + cursor.x_rot = Math_PI / 2.0; + if (cursor.x_rot < -Math_PI / 2.0) + cursor.x_rot = -Math_PI / 2.0; + + // Look is like the opposite of Orbit: the focus point rotates around the camera + Transform camera_transform = to_camera_transform(cursor); + Vector3 pos = camera_transform.xform(Vector3(0, 0, 0)); + Vector3 prev_pos = prev_camera_transform.xform(Vector3(0, 0, 0)); + Vector3 diff = prev_pos - pos; + cursor.pos += diff; + + name = ""; + _update_name(); } void SpatialEditorViewport::set_freelook_active(bool active_now) { @@ -2250,6 +2259,11 @@ void SpatialEditorViewport::_notification(int p_what) { float cinema_half_width = cinema_label->get_size().width / 2.0f; cinema_label->set_anchor_and_margin(MARGIN_LEFT, 0.5f, -cinema_half_width); } + + if (lock_rotation) { + float locked_half_width = locked_label->get_size().width / 2.0f; + locked_label->set_anchor_and_margin(MARGIN_LEFT, 0.5f, -locked_half_width); + } } if (p_what == NOTIFICATION_ENTER_TREE) { @@ -2260,27 +2274,36 @@ void SpatialEditorViewport::_notification(int p_what) { surface->connect("mouse_exited", this, "_surface_mouse_exit"); surface->connect("focus_entered", this, "_surface_focus_enter"); surface->connect("focus_exited", this, "_surface_focus_exit"); - view_menu->set_flat(false); - view_menu->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - view_menu->add_style_override("hover", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - view_menu->add_style_override("pressed", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - view_menu->add_style_override("focus", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - view_menu->add_style_override("disabled", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - info_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - fps_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - cinema_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - preview_camera->set_icon(get_icon("Camera", "EditorIcons")); + _init_gizmo_instance(index); } + if (p_what == NOTIFICATION_EXIT_TREE) { _finish_gizmo_instances(); } - if (p_what == NOTIFICATION_MOUSE_ENTER) { - } + if (p_what == NOTIFICATION_THEME_CHANGED) { + + view_menu->set_icon(get_icon("GuiMiniTabMenu", "EditorIcons")); + preview_camera->set_icon(get_icon("Camera", "EditorIcons")); + + view_menu->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); + view_menu->add_style_override("hover", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); + view_menu->add_style_override("pressed", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); + view_menu->add_style_override("focus", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); + view_menu->add_style_override("disabled", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - if (p_what == NOTIFICATION_DRAW) { + preview_camera->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); + preview_camera->add_style_override("hover", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); + preview_camera->add_style_override("pressed", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); + preview_camera->add_style_override("focus", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); + preview_camera->add_style_override("disabled", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); + + info_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); + fps_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); + cinema_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); + locked_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); } } @@ -2521,8 +2544,14 @@ void SpatialEditorViewport::_menu_option(int p_option) { if (!se) continue; - Transform xform = camera_transform; - xform.scale_basis(sp->get_scale()); + Transform xform; + if (orthogonal) { + xform = sp->get_global_transform(); + xform.basis.set_euler(camera_transform.basis.get_euler()); + } else { + xform = camera_transform; + xform.scale_basis(sp->get_scale()); + } undo_redo->add_do_method(sp, "set_global_transform", xform); undo_redo->add_undo_method(sp, "set_global_transform", sp->get_global_gizmo_transform()); @@ -2570,9 +2599,9 @@ void SpatialEditorViewport::_menu_option(int p_option) { lock_rotation = !current; view_menu->get_popup()->set_item_checked(idx, !current); if (lock_rotation) { - view_menu->set_icon(get_icon("Lock", "EditorIcons")); + locked_label->show(); } else { - view_menu->set_icon(Ref<Texture>()); + locked_label->hide(); } } break; @@ -2642,11 +2671,6 @@ void SpatialEditorViewport::_menu_option(int p_option) { bool current = view_menu->get_popup()->is_item_checked(idx); view_menu->get_popup()->set_item_checked(idx, !current); - if (current) - preview_camera->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10 * EDSCALE); - else - preview_camera->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 15 * EDSCALE + fps_label->get_size().height); - } break; case VIEW_DISPLAY_NORMAL: { @@ -2760,7 +2784,7 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) { VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore if (!preview) preview_camera->hide(); - view_menu->show(); + view_menu->set_disabled(false); surface->update(); } else { @@ -2768,7 +2792,7 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) { previewing = preview; previewing->connect("tree_exiting", this, "_preview_exited_scene"); VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), preview->get_camera()); //replace - view_menu->hide(); + view_menu->set_disabled(true); surface->update(); } } @@ -3425,8 +3449,10 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed surface->set_focus_mode(FOCUS_ALL); view_menu = memnew(MenuButton); + view_menu->set_flat(false); surface->add_child(view_menu); - view_menu->set_position(Point2(4, 4) * EDSCALE); + view_menu->set_position(Point2(10, 10) * EDSCALE); + view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/top_view"), VIEW_TOP); view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/bottom_view"), VIEW_BOTTOM); view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/left_view"), VIEW_LEFT); @@ -3477,12 +3503,8 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed ED_SHORTCUT("spatial_editor/freelook_down", TTR("Freelook Down"), KEY_Q); ED_SHORTCUT("spatial_editor/freelook_speed_modifier", TTR("Freelook Speed Modifier"), KEY_SHIFT); - preview_camera = memnew(Button); - preview_camera->set_toggle_mode(true); - preview_camera->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -90 * EDSCALE); - preview_camera->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10 * EDSCALE); - preview_camera->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -10 * EDSCALE); - preview_camera->set_h_grow_direction(GROW_DIRECTION_BEGIN); + preview_camera = memnew(CheckBox); + preview_camera->set_position(Point2(10, 38) * EDSCALE); // Below the 'view_menu' MenuButton. preview_camera->set_text(TTR("Preview")); surface->add_child(preview_camera); preview_camera->hide(); @@ -3502,7 +3524,6 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed surface->add_child(info_label); info_label->hide(); - // FPS Counter. fps_label = memnew(Label); fps_label->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -90 * EDSCALE); fps_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10 * EDSCALE); @@ -3520,6 +3541,16 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed cinema_label->hide(); previewing_cinema = false; + locked_label = memnew(Label); + locked_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -20 * EDSCALE); + locked_label->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -10 * EDSCALE); + locked_label->set_h_grow_direction(GROW_DIRECTION_END); + locked_label->set_v_grow_direction(GROW_DIRECTION_BEGIN); + locked_label->set_align(Label::ALIGN_CENTER); + surface->add_child(locked_label); + locked_label->set_text(TTR("View Rotation Locked")); + locked_label->hide(); + accept = NULL; freelook_active = false; @@ -5443,7 +5474,6 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { view_menu = memnew(MenuButton); view_menu->set_text(TTR("View")); - view_menu->set_position(Point2(212, 0)); hbc_menu->add_child(view_menu); p = view_menu->get_popup(); diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index c552f21e39..3cce76cc17 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -192,7 +192,7 @@ private: EditorSelection *editor_selection; UndoRedo *undo_redo; - Button *preview_camera; + CheckBox *preview_camera; ViewportContainer *viewport_container; MenuButton *view_menu; @@ -211,6 +211,7 @@ private: Label *info_label; Label *fps_label; Label *cinema_label; + Label *locked_label; struct _RayResult { diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 4ff7046a35..1a43b16f3e 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -131,7 +131,7 @@ void TextEditor::_load_theme_settings() { text_edit->add_color_override("search_result_border_color", search_result_border_color); text_edit->add_color_override("symbol_color", symbol_color); - text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 4)); + text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 6)); colors_cache.font_color = text_color; colors_cache.symbol_color = symbol_color; diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 27c3ff960b..ed1fa9b217 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -43,8 +43,8 @@ void TileMapEditor::_notification(int p_what) { case NOTIFICATION_PROCESS: { - if (bucket_queue.size() && canvas_item_editor_viewport) { - canvas_item_editor_viewport->update(); + if (bucket_queue.size()) { + CanvasItemEditor::get_singleton()->update_viewport(); } } break; @@ -97,27 +97,27 @@ void TileMapEditor::_menu_option(int p_option) { // immediately without pressing the left mouse button first tool = TOOL_NONE; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } break; case OPTION_BUCKET: { tool = TOOL_BUCKET; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } break; case OPTION_PICK_TILE: { tool = TOOL_PICKING; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } break; case OPTION_SELECT: { tool = TOOL_SELECTING; selection_active = false; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } break; case OPTION_COPY: { @@ -126,7 +126,7 @@ void TileMapEditor::_menu_option(int p_option) { if (selection_active) { tool = TOOL_PASTING; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } } break; case OPTION_ERASE_SELECTION: { @@ -141,7 +141,7 @@ void TileMapEditor::_menu_option(int p_option) { selection_active = false; copydata.clear(); - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } break; case OPTION_FIX_INVALID: { @@ -165,7 +165,7 @@ void TileMapEditor::_menu_option(int p_option) { tool = TOOL_PASTING; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } } break; } @@ -182,13 +182,13 @@ void TileMapEditor::_palette_multi_selected(int index, bool selected) { void TileMapEditor::_canvas_mouse_enter() { mouse_over = true; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } void TileMapEditor::_canvas_mouse_exit() { mouse_over = false; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } Vector<int> TileMapEditor::get_selected_tiles() const { @@ -524,7 +524,7 @@ void TileMapEditor::_pick_tile(const Point2 &p_pos) { transp->set_pressed(node->is_cell_transposed(p_pos.x, p_pos.y)); _update_transform_buttons(); - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool erase, bool preview) { @@ -671,7 +671,7 @@ void TileMapEditor::_select(const Point2i &p_from, const Point2i &p_to) { rectangle.position = begin; rectangle.size = end - begin; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } void TileMapEditor::_erase_selection() { @@ -978,7 +978,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { paint_undo.clear(); - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } } else if (tool == TOOL_RECTANGLE_PAINT) { @@ -995,7 +995,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } _finish_undo(); - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } } else if (tool == TOOL_PASTING) { @@ -1011,12 +1011,12 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } _finish_undo(); - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; // We want to keep the Pasting tool } else if (tool == TOOL_SELECTING) { - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } else if (tool == TOOL_BUCKET) { @@ -1055,7 +1055,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { tool = TOOL_NONE; selection_active = false; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } @@ -1065,7 +1065,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { tool = TOOL_NONE; copydata.clear(); - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } @@ -1106,7 +1106,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { _finish_undo(); if (tool == TOOL_RECTANGLE_ERASE || tool == TOOL_LINE_ERASE) { - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } tool = TOOL_NONE; @@ -1149,7 +1149,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { if (new_over_tile != over_tile) { over_tile = new_over_tile; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } if (show_tile_info) { @@ -1235,7 +1235,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { _set_cell(points[i], invalid_cell); } - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } return true; @@ -1294,7 +1294,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { tool = TOOL_NONE; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } @@ -1308,13 +1308,13 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { // NOTE: We do not set tool = TOOL_PAINTING as this begins painting // immediately without pressing the left mouse button first tool = TOOL_NONE; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } if (ED_IS_SHORTCUT("tile_map_editor/bucket_fill", p_event)) { tool = TOOL_BUCKET; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } @@ -1327,7 +1327,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { tool = TOOL_SELECTING; selection_active = false; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } @@ -1337,7 +1337,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { if (selection_active) { tool = TOOL_PASTING; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } @@ -1354,7 +1354,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { tool = TOOL_PASTING; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } } @@ -1368,21 +1368,21 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { flip_h = !flip_h; mirror_x->set_pressed(flip_h); _update_transform_buttons(); - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } if (ED_IS_SHORTCUT("tile_map_editor/mirror_y", p_event)) { flip_v = !flip_v; mirror_y->set_pressed(flip_v); _update_transform_buttons(); - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } if (ED_IS_SHORTCUT("tile_map_editor/transpose", p_event)) { transpose = !transpose; transp->set_pressed(transpose); _update_transform_buttons(); - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } } @@ -1643,9 +1643,7 @@ void TileMapEditor::edit(Node *p_tile_map) { void TileMapEditor::_tileset_settings_changed() { _update_palette(); - - if (canvas_item_editor_viewport) - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } void TileMapEditor::_icon_size_changed(float p_value) { diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 8925804710..f908641bab 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -53,6 +53,13 @@ void SceneTreeDock::_nodes_drag_begin() { } } +void SceneTreeDock::_quick_open() { + Vector<String> files = quick_open->get_selected_files(); + for (int i = 0; i < files.size(); i++) { + instance(files[i]); + } +} + void SceneTreeDock::_input(Ref<InputEvent> p_event) { Ref<InputEventMouseButton> mb = p_event; @@ -319,16 +326,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; } - file->set_mode(EditorFileDialog::MODE_OPEN_FILE); - List<String> extensions; - ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions); - file->clear_filters(); - for (int i = 0; i < extensions.size(); i++) { - - file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); - } - - file->popup_centered_ratio(); + quick_open->popup_dialog("PackedScene", true); + quick_open->set_title(TTR("Instance Child Scene")); } break; case TOOL_REPLACE: { @@ -1307,6 +1306,13 @@ bool SceneTreeDock::_validate_no_foreign() { return false; } + // When edited_scene inherits from another one the root Node will be the parent Scene, + // we don't want to consider that Node a foreign one otherwise we would not be able to + // delete it + if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene == E->get()) { + continue; + } + if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E->get())) >= 0) { accept->set_text(TTR("Can't operate on nodes the current scene inherits from!")); @@ -1613,6 +1619,14 @@ void SceneTreeDock::_delete_confirm() { void SceneTreeDock::_update_script_button() { if (EditorNode::get_singleton()->get_editor_selection()->get_selection().size() == 1) { button_create_script->show(); + Node *n = EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list()[0]; + if (n->get_script().is_null()) { + button_create_script->set_icon(get_icon("ScriptCreate", "EditorIcons")); + button_create_script->set_tooltip(TTR("Attach a new or existing script for the selected node.")); + } else { + button_create_script->set_icon(get_icon("ScriptExtend", "EditorIcons")); + button_create_script->set_tooltip(TTR("Extend the selected node's script with a new or existing script.")); + } } else { button_create_script->hide(); } @@ -2288,6 +2302,7 @@ void SceneTreeDock::_bind_methods() { ClassDB::bind_method(D_METHOD("_new_scene_from"), &SceneTreeDock::_new_scene_from); ClassDB::bind_method(D_METHOD("_nodes_dragged"), &SceneTreeDock::_nodes_dragged); ClassDB::bind_method(D_METHOD("_files_dropped"), &SceneTreeDock::_files_dropped); + ClassDB::bind_method(D_METHOD("_quick_open"), &SceneTreeDock::_quick_open); ClassDB::bind_method(D_METHOD("_script_dropped"), &SceneTreeDock::_script_dropped); ClassDB::bind_method(D_METHOD("_tree_rmb"), &SceneTreeDock::_tree_rmb); ClassDB::bind_method(D_METHOD("_filter_changed"), &SceneTreeDock::_filter_changed); @@ -2359,7 +2374,6 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel tb = memnew(ToolButton); tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_ATTACH_SCRIPT, false)); - tb->set_tooltip(TTR("Attach a new or existing script for the selected node.")); tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/attach_script")); filter_hbc->add_child(tb); tb->hide(); @@ -2438,9 +2452,9 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel accept = memnew(AcceptDialog); add_child(accept); - file = memnew(EditorFileDialog); - add_child(file); - file->connect("file_selected", this, "instance"); + quick_open = memnew(EditorQuickOpen); + add_child(quick_open); + quick_open->connect("quick_open", this, "_quick_open"); set_process_unhandled_key_input(true); delete_dialog = memnew(ConfirmationDialog); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index eea34a3ec5..3939f4f361 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -36,6 +36,7 @@ #include "editor/editor_data.h" #include "editor/editor_sub_scene.h" #include "editor/groups_editor.h" +#include "editor/quick_open.h" #include "editor/rename_dialog.h" #include "editor/reparent_dialog.h" #include "editor/script_create_dialog.h" @@ -125,7 +126,7 @@ class SceneTreeDock : public VBoxContainer { ConfirmationDialog *editable_instance_remove_dialog; ReparentDialog *reparent_dialog; - EditorFileDialog *file; + EditorQuickOpen *quick_open; EditorSubScene *import_subscene_dialog; EditorFileDialog *new_scene_from_dialog; @@ -194,6 +195,7 @@ class SceneTreeDock : public VBoxContainer { void _nodes_dragged(Array p_nodes, NodePath p_to, int p_type); void _files_dropped(Vector<String> p_files, NodePath p_to, int p_type); void _script_dropped(String p_file, NodePath p_to); + void _quick_open(); void _tree_rmb(const Vector2 &p_menu_pos); diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 6fbac0d4b5..a36a844710 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -355,7 +355,7 @@ void ScriptEditorDebugger::_video_mem_request() { Size2 ScriptEditorDebugger::get_minimum_size() const { Size2 ms = Control::get_minimum_size(); - ms.y = MAX(ms.y, 250); + ms.y = MAX(ms.y, 250 * EDSCALE); return ms; } void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_data) { diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index a321cb16c5..881f20cecb 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -3454,10 +3454,9 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { if (points.size() > 3) { - QuickHull qh; Vector<Vector3> varr = Variant(points); Geometry::MeshData md; - Error err = qh.build(varr, md); + Error err = QuickHull::build(varr, md); if (err == OK) { Vector<Vector3> points; points.resize(md.edges.size() * 2); |