summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_node.cpp47
-rw-r--r--editor/editor_node.h2
-rw-r--r--editor/editor_resource_preview.cpp2
-rw-r--r--editor/icons/icon_crosshair.svg1
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp2
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp25
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp11
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp15
-rw-r--r--editor/plugins/spatial_editor_plugin.h1
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp10
10 files changed, 76 insertions, 40 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 0ea8e04471..c5b67eb971 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -369,6 +369,19 @@ void EditorNode::_notification(int p_what) {
case NOTIFICATION_READY: {
+ {
+ _initializing_addons = true;
+ Vector<String> addons;
+ if (ProjectSettings::get_singleton()->has_setting("editor_plugins/enabled")) {
+ addons = ProjectSettings::get_singleton()->get("editor_plugins/enabled");
+ }
+
+ for (int i = 0; i < addons.size(); i++) {
+ set_addon_plugin_enabled(addons[i], true);
+ }
+ _initializing_addons = false;
+ }
+
VisualServer::get_singleton()->viewport_set_hide_scenario(get_scene_root()->get_viewport_rid(), true);
VisualServer::get_singleton()->viewport_set_hide_canvas(get_scene_root()->get_viewport_rid(), true);
VisualServer::get_singleton()->viewport_set_disable_environment(get_viewport()->get_viewport_rid(), true);
@@ -660,12 +673,14 @@ void EditorNode::_sources_changed(bool p_exist) {
if (waiting_for_first_scan) {
waiting_for_first_scan = false;
- EditorResourcePreview::get_singleton()->start(); //start previes now that it's safe
+ // Start preview thread now that it's safe.
+ if (!singleton->cmdline_export_mode) {
+ EditorResourcePreview::get_singleton()->start();
+ }
_load_docks();
if (defer_load_scene != "") {
-
load_scene(defer_load_scene);
defer_load_scene = "";
}
@@ -1155,7 +1170,10 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
save.step(TTR("Saving Scene"), 4);
_save_scene(p_file, p_idx);
- EditorResourcePreview::get_singleton()->check_for_invalidation(p_file);
+
+ if (!singleton->cmdline_export_mode) {
+ EditorResourcePreview::get_singleton()->check_for_invalidation(p_file);
+ }
}
bool EditorNode::_validate_scene_recursive(const String &p_filename, Node *p_node) {
@@ -3839,7 +3857,7 @@ Ref<Texture> EditorNode::get_class_icon(const String &p_class, const String &p_f
void EditorNode::progress_add_task(const String &p_task, const String &p_label, int p_steps, bool p_can_cancel) {
- if (singleton->disable_progress_dialog) {
+ if (singleton->cmdline_export_mode) {
print_line(p_task + ": begin: " + p_label + " steps: " + itos(p_steps));
} else {
singleton->progress_dialog->add_task(p_task, p_label, p_steps, p_can_cancel);
@@ -3848,7 +3866,7 @@ void EditorNode::progress_add_task(const String &p_task, const String &p_label,
bool EditorNode::progress_task_step(const String &p_task, const String &p_state, int p_step, bool p_force_refresh) {
- if (singleton->disable_progress_dialog) {
+ if (singleton->cmdline_export_mode) {
print_line("\t" + p_task + ": step " + itos(p_step) + ": " + p_state);
return false;
} else {
@@ -3859,7 +3877,7 @@ bool EditorNode::progress_task_step(const String &p_task, const String &p_state,
void EditorNode::progress_end_task(const String &p_task) {
- if (singleton->disable_progress_dialog) {
+ if (singleton->cmdline_export_mode) {
print_line(p_task + ": end");
} else {
singleton->progress_dialog->end_task(p_task);
@@ -3945,7 +3963,7 @@ Error EditorNode::export_preset(const String &p_preset, const String &p_path, bo
export_defer.path = p_path;
export_defer.debug = p_debug;
export_defer.pack_only = p_pack_only;
- disable_progress_dialog = true;
+ cmdline_export_mode = true;
return OK;
}
@@ -5587,7 +5605,7 @@ EditorNode::EditorNode() {
_initializing_addons = false;
docks_visible = true;
restoring_scenes = false;
- disable_progress_dialog = false;
+ cmdline_export_mode = false;
scene_distraction = false;
script_distraction = false;
@@ -6776,19 +6794,6 @@ EditorNode::EditorNode() {
import_dock->initialize_import_options();
- {
- _initializing_addons = true;
- Vector<String> addons;
- if (ProjectSettings::get_singleton()->has_setting("editor_plugins/enabled")) {
- addons = ProjectSettings::get_singleton()->get("editor_plugins/enabled");
- }
-
- for (int i = 0; i < addons.size(); i++) {
- set_addon_plugin_enabled(addons[i], true);
- }
- _initializing_addons = false;
- }
-
FileAccess::set_file_close_fail_notify_callback(_file_access_close_error_notify);
waiting_for_first_scan = true;
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 7f53f77c76..a5c04d3531 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -561,7 +561,7 @@ private:
bool pack_only;
} export_defer;
- bool disable_progress_dialog;
+ bool cmdline_export_mode;
static EditorNode *singleton;
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp
index 9d31e26086..f63d4884e2 100644
--- a/editor/editor_resource_preview.cpp
+++ b/editor/editor_resource_preview.cpp
@@ -215,7 +215,6 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref<
void EditorResourcePreview::_thread() {
-#ifndef SERVER_ENABLED
exited = false;
while (!exit) {
@@ -349,7 +348,6 @@ void EditorResourcePreview::_thread() {
preview_mutex->unlock();
}
}
-#endif
exited = true;
}
diff --git a/editor/icons/icon_crosshair.svg b/editor/icons/icon_crosshair.svg
new file mode 100644
index 0000000000..b6fa5ec654
--- /dev/null
+++ b/editor/icons/icon_crosshair.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m6 1v5h-5v1 3h5v5h4v-5h5v-4h-5v-5z" fill-opacity=".627451"/><path d="m2 7v2l5.0000803.0000197-.0000803 4.9999803h2l-.0000803-4.9999803 5.0000803-.0000197v-2l-5.0000803.0001803.0000803-5.0001803h-2l.0000803 5.0001803z" fill="#fefefe" fill-opacity=".862745"/></svg> \ No newline at end of file
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 5b41da6e8e..5e69ce4e69 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -997,9 +997,9 @@ void AnimationPlayerEditor::_animation_duplicate() {
String new_name = current;
while (player->has_animation(new_name)) {
-
new_name = new_name + " (copy)";
}
+ new_anim->set_name(new_name);
undo_redo->create_action(TTR("Duplicate Animation"));
undo_redo->add_do_method(player, "add_animation", new_name, new_anim);
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 9223e86f42..e9a705a0dc 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -3987,29 +3987,21 @@ void CanvasItemEditor::_update_scrollbars() {
updating_scroll = true;
- // Move the zoom buttons
+ // Move the zoom buttons.
Point2 controls_vb_begin = Point2(5, 5);
controls_vb_begin += (show_rulers) ? Point2(RULER_WIDTH, RULER_WIDTH) : Point2();
controls_vb->set_begin(controls_vb_begin);
- // Move and resize the scrollbars
- Size2 size = viewport->get_size();
Size2 hmin = h_scroll->get_minimum_size();
Size2 vmin = v_scroll->get_minimum_size();
- v_scroll->set_begin(Point2(size.width - vmin.width, (show_rulers) ? RULER_WIDTH : 0));
- v_scroll->set_end(Point2(size.width, size.height));
-
- h_scroll->set_begin(Point2((show_rulers) ? RULER_WIDTH : 0, size.height - hmin.height));
- h_scroll->set_end(Point2(size.width - vmin.width, size.height));
-
- // Get the visible frame
+ // Get the visible frame.
Size2 screen_rect = Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"));
Rect2 local_rect = Rect2(Point2(), viewport->get_size() - Size2(vmin.width, hmin.height));
_queue_update_bone_list();
- // Calculate scrollable area
+ // Calculate scrollable area.
Rect2 canvas_item_rect = Rect2(Point2(), screen_rect);
if (editor->get_edited_scene()) {
Rect2 content_rect = _get_encompassing_rect(editor->get_edited_scene());
@@ -4019,7 +4011,8 @@ void CanvasItemEditor::_update_scrollbars() {
canvas_item_rect.size += screen_rect * 2;
canvas_item_rect.position -= screen_rect;
- // Constraints the view offset and updates the scrollbars
+ // Constraints the view offset and updates the scrollbars.
+ Size2 size = viewport->get_size();
Point2 begin = canvas_item_rect.position;
Point2 end = canvas_item_rect.position + canvas_item_rect.size - local_rect.size / zoom;
bool constrain_editor_view = bool(EditorSettings::get_singleton()->get("editors/2d/constrain_editor_view"));
@@ -4066,7 +4059,13 @@ void CanvasItemEditor::_update_scrollbars() {
h_scroll->set_page(screen_rect.x);
}
- // Calculate scrollable area
+ // Move and resize the scrollbars, avoiding overlap.
+ v_scroll->set_begin(Point2(size.width - vmin.width, (show_rulers) ? RULER_WIDTH : 0));
+ v_scroll->set_end(Point2(size.width, size.height - (h_scroll->is_visible() ? hmin.height : 0)));
+ h_scroll->set_begin(Point2((show_rulers) ? RULER_WIDTH : 0, size.height - hmin.height));
+ h_scroll->set_end(Point2(size.width - (v_scroll->is_visible() ? vmin.width : 0), size.height));
+
+ // Calculate scrollable area.
v_scroll->set_value(view_offset.y);
h_scroll->set_value(view_offset.x);
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index de23193df0..04d595461d 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -1196,7 +1196,9 @@ void Polygon2DEditor::_uv_draw() {
rect.position -= uv_edit_draw->get_size();
rect.size += uv_edit_draw->get_size() * 2.0;
+
updating_uv_scroll = true;
+
uv_hscroll->set_min(rect.position.x);
uv_hscroll->set_max(rect.position.x + rect.size.x);
if (ABS(rect.position.x - (rect.position.x + rect.size.x)) <= uv_edit_draw->get_size().x) {
@@ -1216,6 +1218,14 @@ void Polygon2DEditor::_uv_draw() {
uv_vscroll->set_page(uv_edit_draw->get_size().y);
uv_vscroll->set_value(uv_draw_ofs.y);
}
+
+ Size2 hmin = uv_hscroll->get_combined_minimum_size();
+ Size2 vmin = uv_vscroll->get_combined_minimum_size();
+
+ // Avoid scrollbar overlapping.
+ uv_hscroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, uv_vscroll->is_visible() ? -vmin.width : 0);
+ uv_vscroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, uv_hscroll->is_visible() ? -hmin.height : 0);
+
updating_uv_scroll = false;
}
@@ -1467,7 +1477,6 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
uv_hscroll->set_step(0.001);
uv_edit_draw->add_child(uv_hscroll);
uv_hscroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE);
- uv_hscroll->set_margin(MARGIN_RIGHT, -uv_vscroll->get_size().x * EDSCALE);
uv_hscroll->connect("value_changed", this, "_uv_scroll_changed");
bone_scroll_main_vb = memnew(VBoxContainer);
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 252f067eb1..31dce720db 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -2135,6 +2135,13 @@ void SpatialEditorViewport::_notification(int p_what) {
call_deferred("update_transform_gizmo_view");
}
+ if (p_what == NOTIFICATION_READY) {
+ // The crosshair icon doesn't depend on the editor theme.
+ crosshair->set_texture(get_icon("Crosshair", "EditorIcons"));
+ // Set the anchors and margins after changing the icon to ensure it's centered correctly.
+ crosshair->set_anchors_and_margins_preset(PRESET_CENTER);
+ }
+
if (p_what == NOTIFICATION_PROCESS) {
real_t delta = get_process_delta_time();
@@ -2255,6 +2262,10 @@ void SpatialEditorViewport::_notification(int p_what) {
current_camera = camera;
}
+ // Display the crosshair only while freelooking. Hide it otherwise,
+ // as the crosshair can be distracting.
+ crosshair->set_visible(freelook_active);
+
if (show_info) {
String text;
text += "X: " + rtos(current_camera->get_translation().x).pad_decimals(1) + "\n";
@@ -3546,6 +3557,10 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
camera->make_current();
surface->set_focus_mode(FOCUS_ALL);
+ crosshair = memnew(TextureRect);
+ crosshair->set_mouse_filter(MOUSE_FILTER_IGNORE);
+ surface->add_child(crosshair);
+
VBoxContainer *vbox = memnew(VBoxContainer);
surface->add_child(vbox);
vbox->set_position(Point2(10, 10) * EDSCALE);
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index 356646221e..5cc2b24cbb 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -217,6 +217,7 @@ private:
bool freelook_active;
real_t freelook_speed;
+ TextureRect *crosshair;
Label *info_label;
Label *fps_label;
Label *cinema_label;
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index 13faeb0edb..f9b1e3b43a 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -178,6 +178,7 @@ void TextureRegionEditor::_region_draw() {
scroll_rect.size += scroll_margin * 2;
updating_scroll = true;
+
hscroll->set_min(scroll_rect.position.x);
hscroll->set_max(scroll_rect.position.x + scroll_rect.size.x);
if (ABS(scroll_rect.position.x - (scroll_rect.position.x + scroll_rect.size.x)) <= scroll_margin.x) {
@@ -198,6 +199,14 @@ void TextureRegionEditor::_region_draw() {
vscroll->set_page(scroll_margin.y);
vscroll->set_value(draw_ofs.y);
}
+
+ Size2 hmin = hscroll->get_combined_minimum_size();
+ Size2 vmin = vscroll->get_combined_minimum_size();
+
+ // Avoid scrollbar overlapping.
+ hscroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, vscroll->is_visible() ? -vmin.width : 0);
+ vscroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, hscroll->is_visible() ? -hmin.height : 0);
+
updating_scroll = false;
if (node_ninepatch || obj_styleBox.is_valid()) {
@@ -1019,7 +1028,6 @@ TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) {
hscroll->set_step(0.001);
edit_draw->add_child(hscroll);
hscroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE);
- hscroll->set_margin(MARGIN_RIGHT, -vscroll->get_size().x * EDSCALE);
hscroll->connect("value_changed", this, "_scroll_changed");
updating_scroll = false;