summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/array_property_edit.cpp8
-rw-r--r--editor/editor_file_system.cpp15
-rw-r--r--editor/editor_help.cpp19
-rw-r--r--editor/editor_node.cpp9
-rw-r--r--editor/editor_node.h2
-rw-r--r--editor/editor_properties_array_dict.cpp8
-rw-r--r--editor/editor_resource_preview.cpp21
-rw-r--r--editor/editor_themes.cpp2
-rw-r--r--editor/filesystem_dock.cpp14
-rw-r--r--editor/filesystem_dock.h1
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp118
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h1
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp4
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp4
-rw-r--r--editor/scene_tree_dock.cpp3
15 files changed, 165 insertions, 64 deletions
diff --git a/editor/array_property_edit.cpp b/editor/array_property_edit.cpp
index f2471e80d4..906139e239 100644
--- a/editor/array_property_edit.cpp
+++ b/editor/array_property_edit.cpp
@@ -267,9 +267,9 @@ void ArrayPropertyEdit::edit(Object *p_obj, const StringName &p_prop, const Stri
default_type = p_deftype;
if (!p_hint_string.empty()) {
- int hint_subtype_seperator = p_hint_string.find(":");
- if (hint_subtype_seperator >= 0) {
- String subtype_string = p_hint_string.substr(0, hint_subtype_seperator);
+ int hint_subtype_separator = p_hint_string.find(":");
+ if (hint_subtype_separator >= 0) {
+ String subtype_string = p_hint_string.substr(0, hint_subtype_separator);
int slash_pos = subtype_string.find("/");
if (slash_pos >= 0) {
@@ -277,7 +277,7 @@ void ArrayPropertyEdit::edit(Object *p_obj, const StringName &p_prop, const Stri
subtype_string = subtype_string.substr(0, slash_pos);
}
- subtype_hint_string = p_hint_string.substr(hint_subtype_seperator + 1, p_hint_string.size() - hint_subtype_seperator - 1);
+ subtype_hint_string = p_hint_string.substr(hint_subtype_separator + 1, p_hint_string.size() - hint_subtype_separator - 1);
subtype = Variant::Type(subtype_string.to_int());
}
}
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index 3663bdee27..2467e1f722 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -325,14 +325,12 @@ void EditorFileSystem::_save_filesystem_cache() {
String fscache = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(CACHE_FILE_NAME);
FileAccess *f = FileAccess::open(fscache, FileAccess::WRITE);
- if (f == NULL) {
- ERR_PRINTS("Error writing fscache '" + fscache + "'.");
- } else {
- f->store_line(filesystem_settings_version_for_import);
- _save_filesystem_cache(filesystem, f);
- f->close();
- memdelete(f);
- }
+ ERR_FAIL_COND_MSG(!f, "Cannot create file '" + fscache + "'. Check user write permissions.");
+
+ f->store_line(filesystem_settings_version_for_import);
+ _save_filesystem_cache(filesystem, f);
+ f->close();
+ memdelete(f);
}
void EditorFileSystem::_thread_func(void *_userdata) {
@@ -1373,6 +1371,7 @@ void EditorFileSystem::_save_late_updated_files() {
//files that already existed, and were modified, need re-scanning for dependencies upon project restart. This is done via saving this special file
String fscache = EditorSettings::get_singleton()->get_project_settings_dir().plus_file("filesystem_update4");
FileAccessRef f = FileAccess::open(fscache, FileAccess::WRITE);
+ ERR_FAIL_COND_MSG(!f, "Cannot create file '" + fscache + "'. Check user write permissions.");
for (Set<String>::Element *E = late_update_files.front(); E; E = E->next()) {
f->store_line(E->get());
}
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index d2306abfd7..dd49e38d7f 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -1224,11 +1224,18 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
Ref<Font> doc_font = p_rt->get_font("doc", "EditorFonts");
Ref<Font> doc_bold_font = p_rt->get_font("doc_bold", "EditorFonts");
Ref<Font> doc_code_font = p_rt->get_font("doc_source", "EditorFonts");
+
Color font_color_hl = p_rt->get_color("headline_color", "EditorHelp");
- Color link_color = p_rt->get_color("accent_color", "Editor").linear_interpolate(font_color_hl, 0.8);
+ Color accent_color = p_rt->get_color("accent_color", "Editor");
+ Color link_color = accent_color.linear_interpolate(font_color_hl, 0.8);
+ Color code_color = accent_color.linear_interpolate(font_color_hl, 0.6);
String bbcode = p_bbcode.dedent().replace("\t", "").replace("\r", "").strip_edges();
+ // remove extra new lines around code blocks
+ bbcode = bbcode.replace("[codeblock]\n", "[codeblock]");
+ bbcode = bbcode.replace("\n[/codeblock]", "[/codeblock]");
+
List<String> tag_stack;
bool code_tag = false;
@@ -1276,9 +1283,14 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
tag_stack.pop_front();
pos = brk_end + 1;
- code_tag = false;
- if (tag != "/img")
+ if (tag != "/img") {
p_rt->pop();
+ if (code_tag) {
+ p_rt->pop();
+ }
+ }
+ code_tag = false;
+
} else if (code_tag) {
p_rt->add_text("[");
@@ -1323,6 +1335,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
//use monospace font
p_rt->push_font(doc_code_font);
+ p_rt->push_color(code_color);
code_tag = true;
pos = brk_end + 1;
tag_stack.push_front(tag);
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 9fa33044e1..d42345d9a2 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -5171,14 +5171,20 @@ void EditorNode::_open_imported() {
}
void EditorNode::dim_editor(bool p_dimming, bool p_force_dim) {
- // Dimming can be forced regardless of the editor setting, which is useful when quitting the editor
+ // Dimming can be forced regardless of the editor setting, which is useful when quitting the editor.
if ((p_force_dim || EditorSettings::get_singleton()->get("interface/editor/dim_editor_on_dialog_popup")) && p_dimming) {
+ dimmed = true;
gui_base->set_modulate(Color(0.5, 0.5, 0.5));
} else {
+ dimmed = false;
gui_base->set_modulate(Color(1, 1, 1));
}
}
+bool EditorNode::is_editor_dimmed() const {
+ return dimmed;
+}
+
void EditorNode::open_export_template_manager() {
export_template_manager->popup_manager();
@@ -5487,6 +5493,7 @@ EditorNode::EditorNode() {
singleton = this;
exiting = false;
+ dimmed = false;
last_checked_version = 0;
changing_scene = false;
_initializing_addons = false;
diff --git a/editor/editor_node.h b/editor/editor_node.h
index fb7e81d2d2..b7775b5e83 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -260,6 +260,7 @@ private:
int tab_closing;
bool exiting;
+ bool dimmed;
int old_split_ofs;
VSplitContainer *top_split;
@@ -850,6 +851,7 @@ public:
void restart_editor();
void dim_editor(bool p_dimming, bool p_force_dim = false);
+ bool is_editor_dimmed() const;
void edit_current() { _edit_current(); };
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
index 8abe91bdc1..c75b66c601 100644
--- a/editor/editor_properties_array_dict.cpp
+++ b/editor/editor_properties_array_dict.cpp
@@ -475,16 +475,16 @@ void EditorPropertyArray::setup(Variant::Type p_array_type, const String &p_hint
array_type = p_array_type;
if (array_type == Variant::ARRAY && !p_hint_string.empty()) {
- int hint_subtype_seperator = p_hint_string.find(":");
- if (hint_subtype_seperator >= 0) {
- String subtype_string = p_hint_string.substr(0, hint_subtype_seperator);
+ int hint_subtype_separator = p_hint_string.find(":");
+ if (hint_subtype_separator >= 0) {
+ String subtype_string = p_hint_string.substr(0, hint_subtype_separator);
int slash_pos = subtype_string.find("/");
if (slash_pos >= 0) {
subtype_hint = PropertyHint(subtype_string.substr(slash_pos + 1, subtype_string.size() - slash_pos - 1).to_int());
subtype_string = subtype_string.substr(0, slash_pos);
}
- subtype_hint_string = p_hint_string.substr(hint_subtype_seperator + 1, p_hint_string.size() - hint_subtype_seperator - 1);
+ subtype_hint_string = p_hint_string.substr(hint_subtype_separator + 1, p_hint_string.size() - hint_subtype_separator - 1);
subtype = Variant::Type(subtype_string.to_int());
}
}
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp
index 65a1704770..55f9347045 100644
--- a/editor/editor_resource_preview.cpp
+++ b/editor/editor_resource_preview.cpp
@@ -201,9 +201,8 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref<
if (has_small_texture) {
ResourceSaver::save(cache_base + "_small.png", r_small_texture);
}
- Error err;
- FileAccess *f = FileAccess::open(cache_base + ".txt", FileAccess::WRITE, &err);
- ERR_FAIL_COND_MSG(err != OK, "Cannot create file '" + cache_base + ".txt'.");
+ FileAccess *f = FileAccess::open(cache_base + ".txt", FileAccess::WRITE);
+ ERR_FAIL_COND_MSG(!f, "Cannot create file '" + cache_base + ".txt'. Check user write permissions.");
f->store_line(itos(thumbnail_size));
f->store_line(itos(has_small_texture));
f->store_line(itos(FileAccess::get_modified_time(p_item.path)));
@@ -295,11 +294,17 @@ void EditorResourcePreview::_thread() {
//update modified time
f = FileAccess::open(file, FileAccess::WRITE);
- f->store_line(itos(thumbnail_size));
- f->store_line(itos(has_small_texture));
- f->store_line(itos(modtime));
- f->store_line(md5);
- memdelete(f);
+ if (!f) {
+ // Not returning as this would leave the thread hanging and would require
+ // some proper cleanup/disabling of resource preview generation.
+ ERR_PRINTS("Cannot create file '" + file + "'. Check user write permissions.");
+ } else {
+ f->store_line(itos(thumbnail_size));
+ f->store_line(itos(has_small_texture));
+ f->store_line(itos(modtime));
+ f->store_line(md5);
+ memdelete(f);
+ }
}
} else {
memdelete(f);
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index a49c3eac73..f05c7709d4 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -1089,7 +1089,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_icon("port", "GraphNode", theme->get_icon("GuiGraphNodePort", "EditorIcons"));
// GridContainer
- theme->set_constant("vseperation", "GridContainer", (extra_spacing + default_margin_size) * EDSCALE);
+ theme->set_constant("vseparation", "GridContainer", (extra_spacing + default_margin_size) * EDSCALE);
// FileDialog
theme->set_icon("folder", "FileDialog", theme->get_icon("Folder", "EditorIcons"));
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index be05183f92..fa171ddb0c 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -115,6 +115,10 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
file_item->select(0);
file_item->set_as_cursor(0);
}
+ String main_scene = ProjectSettings::get_singleton()->get("application/run/main_scene");
+ if (main_scene == file_metadata) {
+ file_item->set_custom_color(0, get_color("accent_color", "Editor"));
+ }
Array udata;
udata.push_back(tree_update_id);
udata.push_back(file_item);
@@ -1565,6 +1569,15 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
}
} break;
+ case FILE_MAIN_SCENE: {
+ // Set as main scene with selected scene file.
+ if (p_selected.size() == 1) {
+ ProjectSettings::get_singleton()->set("application/run/main_scene", p_selected[0]);
+ ProjectSettings::get_singleton()->save();
+ _update_tree(_compute_uncollapsed_paths());
+ }
+ } break;
+
case FILE_INSTANCE: {
// Instance all selected scenes.
Vector<String> paths;
@@ -2138,6 +2151,7 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str
if (filenames.size() == 1) {
p_popup->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open Scene"), FILE_OPEN);
p_popup->add_icon_item(get_icon("CreateNewSceneFrom", "EditorIcons"), TTR("New Inherited Scene"), FILE_INHERIT);
+ p_popup->add_item(TTR("Set As Main Scene"), FILE_MAIN_SCENE);
} else {
p_popup->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open Scenes"), FILE_OPEN);
}
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index 49eb31e330..099f4ad273 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -74,6 +74,7 @@ private:
enum FileMenu {
FILE_OPEN,
FILE_INHERIT,
+ FILE_MAIN_SCENE,
FILE_INSTANCE,
FILE_ADD_FAVORITE,
FILE_REMOVE_FAVORITE,
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 7659363cdf..2d9a713cad 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -67,6 +67,7 @@ class SnapDialog : public ConfirmationDialog {
SpinBox *grid_offset_y;
SpinBox *grid_step_x;
SpinBox *grid_step_y;
+ SpinBox *primary_grid_steps;
SpinBox *rotation_offset;
SpinBox *rotation_step;
@@ -132,8 +133,28 @@ public:
grid_step_y->set_h_size_flags(SIZE_EXPAND_FILL);
child_container->add_child(grid_step_y);
+ child_container = memnew(GridContainer);
+ child_container->set_columns(2);
+ container->add_child(child_container);
+
+ label = memnew(Label);
+ label->set_text(TTR("Primary Line Every:"));
+ label->set_h_size_flags(SIZE_EXPAND_FILL);
+ child_container->add_child(label);
+
+ primary_grid_steps = memnew(SpinBox);
+ primary_grid_steps->set_min(0);
+ primary_grid_steps->set_step(1);
+ primary_grid_steps->set_max(100);
+ primary_grid_steps->set_allow_greater(true);
+ primary_grid_steps->set_suffix(TTR("steps"));
+ primary_grid_steps->set_h_size_flags(SIZE_EXPAND_FILL);
+ child_container->add_child(primary_grid_steps);
+
container->add_child(memnew(HSeparator));
+ // We need to create another GridContainer with the same column count,
+ // so we can put an HSeparator above
child_container = memnew(GridContainer);
child_container->set_columns(2);
container->add_child(child_container);
@@ -163,18 +184,20 @@ public:
child_container->add_child(rotation_step);
}
- void set_fields(const Point2 p_grid_offset, const Point2 p_grid_step, const float p_rotation_offset, const float p_rotation_step) {
+ void set_fields(const Point2 p_grid_offset, const Point2 p_grid_step, const int p_primary_grid_steps, const float p_rotation_offset, const float p_rotation_step) {
grid_offset_x->set_value(p_grid_offset.x);
grid_offset_y->set_value(p_grid_offset.y);
grid_step_x->set_value(p_grid_step.x);
grid_step_y->set_value(p_grid_step.y);
+ primary_grid_steps->set_value(p_primary_grid_steps);
rotation_offset->set_value(p_rotation_offset * (180 / Math_PI));
rotation_step->set_value(p_rotation_step * (180 / Math_PI));
}
- void get_fields(Point2 &p_grid_offset, Point2 &p_grid_step, float &p_rotation_offset, float &p_rotation_step) {
+ void get_fields(Point2 &p_grid_offset, Point2 &p_grid_step, int &p_primary_grid_steps, float &p_rotation_offset, float &p_rotation_step) {
p_grid_offset = Point2(grid_offset_x->get_value(), grid_offset_y->get_value());
p_grid_step = Point2(grid_step_x->get_value(), grid_step_y->get_value());
+ p_primary_grid_steps = int(primary_grid_steps->get_value());
p_rotation_offset = rotation_offset->get_value() / (180 / Math_PI);
p_rotation_step = rotation_step->get_value() / (180 / Math_PI);
}
@@ -898,7 +921,7 @@ void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_ite
}
void CanvasItemEditor::_snap_changed() {
- ((SnapDialog *)snap_dialog)->get_fields(grid_offset, grid_step, snap_rotation_offset, snap_rotation_step);
+ ((SnapDialog *)snap_dialog)->get_fields(grid_offset, grid_step, primary_grid_steps, snap_rotation_offset, snap_rotation_step);
grid_step_multiplier = 0;
viewport->update();
}
@@ -1791,7 +1814,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
if (_is_node_movable(canvas_item)) {
Transform2D xform = transform * canvas_item->get_global_transform_with_canvas();
- Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * Transform2D(canvas_item->_edit_get_rotation(), canvas_item->_edit_get_position())).orthonormalized();
+ Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
drag_type = DRAG_SCALE_BOTH;
@@ -1825,7 +1848,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
drag_to = transform.affine_inverse().xform(m->get_position());
Transform2D parent_xform = canvas_item->get_global_transform_with_canvas() * canvas_item->get_transform().affine_inverse();
- Transform2D unscaled_transform = (transform * parent_xform * Transform2D(canvas_item->_edit_get_rotation(), canvas_item->_edit_get_position())).orthonormalized();
+ Transform2D unscaled_transform = (transform * parent_xform * canvas_item->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = (viewport->get_transform() * unscaled_transform).affine_inverse() * transform;
bool uniform = m->get_shift();
@@ -2639,41 +2662,72 @@ void CanvasItemEditor::_draw_rulers() {
}
void CanvasItemEditor::_draw_grid() {
- if (show_grid || grid_snap_active) {
- //Draw the grid
- Size2 s = viewport->get_size();
- int last_cell = 0;
- Transform2D xform = transform.affine_inverse();
+ if (show_grid || grid_snap_active) {
+ // Draw the grid
Vector2 real_grid_offset;
- List<CanvasItem *> selection = _get_edited_canvas_items();
+ const List<CanvasItem *> selection = _get_edited_canvas_items();
+
if (snap_relative && selection.size() > 0) {
- Vector2 topleft = _get_encompassing_rect_from_list(selection).position;
+ const Vector2 topleft = _get_encompassing_rect_from_list(selection).position;
real_grid_offset.x = fmod(topleft.x, grid_step.x * (real_t)Math::pow(2.0, grid_step_multiplier));
real_grid_offset.y = fmod(topleft.y, grid_step.y * (real_t)Math::pow(2.0, grid_step_multiplier));
} else {
real_grid_offset = grid_offset;
}
- const Color grid_color = EditorSettings::get_singleton()->get("editors/2d/grid_color");
+ // Draw a "primary" line every several lines to make measurements easier.
+ // The step is configurable in the Configure Snap dialog.
+ const Color secondary_grid_color = EditorSettings::get_singleton()->get("editors/2d/grid_color");
+ const Color primary_grid_color =
+ Color(secondary_grid_color.r, secondary_grid_color.g, secondary_grid_color.b, secondary_grid_color.a * 2.5);
+
+ const Size2 viewport_size = viewport->get_size();
+ const Transform2D xform = transform.affine_inverse();
+ int last_cell = 0;
+
if (grid_step.x != 0) {
- for (int i = 0; i < s.width; i++) {
- int cell = Math::fast_ftoi(Math::floor((xform.xform(Vector2(i, 0)).x - real_grid_offset.x) / (grid_step.x * Math::pow(2.0, grid_step_multiplier))));
- if (i == 0)
+ for (int i = 0; i < viewport_size.width; i++) {
+ const int cell =
+ Math::fast_ftoi(Math::floor((xform.xform(Vector2(i, 0)).x - real_grid_offset.x) / (grid_step.x * Math::pow(2.0, grid_step_multiplier))));
+
+ if (i == 0) {
last_cell = cell;
- if (last_cell != cell)
- viewport->draw_line(Point2(i, 0), Point2(i, s.height), grid_color, Math::round(EDSCALE));
+ }
+
+ if (last_cell != cell) {
+ Color grid_color;
+ if (primary_grid_steps == 0) {
+ grid_color = secondary_grid_color;
+ } else {
+ grid_color = cell % primary_grid_steps == 0 ? primary_grid_color : secondary_grid_color;
+ }
+
+ viewport->draw_line(Point2(i, 0), Point2(i, viewport_size.height), grid_color, Math::round(EDSCALE));
+ }
last_cell = cell;
}
}
if (grid_step.y != 0) {
- for (int i = 0; i < s.height; i++) {
- int cell = Math::fast_ftoi(Math::floor((xform.xform(Vector2(0, i)).y - real_grid_offset.y) / (grid_step.y * Math::pow(2.0, grid_step_multiplier))));
- if (i == 0)
+ for (int i = 0; i < viewport_size.height; i++) {
+ const int cell =
+ Math::fast_ftoi(Math::floor((xform.xform(Vector2(0, i)).y - real_grid_offset.y) / (grid_step.y * Math::pow(2.0, grid_step_multiplier))));
+
+ if (i == 0) {
last_cell = cell;
- if (last_cell != cell)
- viewport->draw_line(Point2(0, i), Point2(s.width, i), grid_color, Math::round(EDSCALE));
+ }
+
+ if (last_cell != cell) {
+ Color grid_color;
+ if (primary_grid_steps == 0) {
+ grid_color = secondary_grid_color;
+ } else {
+ grid_color = cell % primary_grid_steps == 0 ? primary_grid_color : secondary_grid_color;
+ }
+
+ viewport->draw_line(Point2(0, i), Point2(viewport_size.width, i), grid_color, Math::round(EDSCALE));
+ }
last_cell = cell;
}
}
@@ -3074,7 +3128,7 @@ void CanvasItemEditor::_draw_selection() {
}
} else {
- Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * Transform2D(canvas_item->_edit_get_rotation(), canvas_item->_edit_get_position())).orthonormalized();
+ Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
viewport->draw_set_transform_matrix(simple_xform);
viewport->draw_texture(position_icon, -(position_icon->get_size() / 2));
@@ -3086,7 +3140,7 @@ void CanvasItemEditor::_draw_selection() {
if (canvas_item->_edit_use_pivot()) {
// Draw the node's pivot
- Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * Transform2D(canvas_item->_edit_get_rotation(), canvas_item->_edit_get_position() + canvas_item->_edit_get_pivot())).orthonormalized();
+ Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
viewport->draw_set_transform_matrix(simple_xform);
@@ -3131,7 +3185,7 @@ void CanvasItemEditor::_draw_selection() {
bool is_alt = Input::get_singleton()->is_key_pressed(KEY_ALT);
if ((is_alt && is_ctrl) || tool == TOOL_SCALE || drag_type == DRAG_SCALE_X || drag_type == DRAG_SCALE_Y) {
if (_is_node_movable(canvas_item)) {
- Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * Transform2D(canvas_item->_edit_get_rotation(), canvas_item->_edit_get_position())).orthonormalized();
+ Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE);
@@ -3350,7 +3404,7 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans
// Draw the node's position
Ref<Texture> position_icon = get_icon("EditorPositionUnselected", "EditorIcons");
- Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * Transform2D(canvas_item->_edit_get_rotation(), canvas_item->_edit_get_position())).orthonormalized();
+ Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
viewport->draw_set_transform_matrix(simple_xform);
viewport->draw_texture(position_icon, -position_icon->get_size() / 2, Color(1.0, 1.0, 1.0, 0.5));
@@ -4309,8 +4363,8 @@ void CanvasItemEditor::_popup_callback(int p_op) {
snap_config_menu->get_popup()->set_item_checked(idx, snap_pixel);
} break;
case SNAP_CONFIGURE: {
- ((SnapDialog *)snap_dialog)->set_fields(grid_offset, grid_step, snap_rotation_offset, snap_rotation_step);
- snap_dialog->popup_centered(Size2(220, 160));
+ ((SnapDialog *)snap_dialog)->set_fields(grid_offset, grid_step, primary_grid_steps, snap_rotation_offset, snap_rotation_step);
+ snap_dialog->popup_centered(Size2(220, 160) * EDSCALE);
} break;
case SKELETON_SHOW_BONES: {
skeleton_show_bones = !skeleton_show_bones;
@@ -4857,6 +4911,7 @@ Dictionary CanvasItemEditor::get_state() const {
state["ofs"] = view_offset;
state["grid_offset"] = grid_offset;
state["grid_step"] = grid_step;
+ state["primary_grid_steps"] = primary_grid_steps;
state["snap_rotation_offset"] = snap_rotation_offset;
state["snap_rotation_step"] = snap_rotation_step;
state["smart_snap_active"] = smart_snap_active;
@@ -4905,6 +4960,10 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) {
grid_step = state["grid_step"];
}
+ if (state.has("primary_grid_steps")) {
+ primary_grid_steps = state["primary_grid_steps"];
+ }
+
if (state.has("snap_rotation_step")) {
snap_rotation_step = state["snap_rotation_step"];
}
@@ -5094,6 +5153,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
previous_update_view_offset = view_offset; // Moves the view a little bit to the left so that (0,0) is visible. The values a relative to a 16/10 screen
grid_offset = Point2();
grid_step = Point2(10, 10);
+ primary_grid_steps = 8; // A power-of-two value works better as a default
grid_step_multiplier = 0;
snap_rotation_offset = 0;
snap_rotation_step = 15 / (180 / Math_PI);
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 480fb89621..35efc14b5e 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -255,6 +255,7 @@ private:
Point2 grid_offset;
Point2 grid_step;
+ int primary_grid_steps;
int grid_step_multiplier;
float snap_rotation_step;
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index 21eebf9ca2..bda3d142fa 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -866,8 +866,8 @@ void TextureRegionEditor::_edit_region() {
Vector2 TextureRegionEditor::snap_point(Vector2 p_target) const {
if (snap_mode == SNAP_GRID) {
- p_target.x = Math::snap_scalar_seperation(snap_offset.x, snap_step.x, p_target.x, snap_separation.x);
- p_target.y = Math::snap_scalar_seperation(snap_offset.y, snap_step.y, p_target.y, snap_separation.y);
+ p_target.x = Math::snap_scalar_separation(snap_offset.x, snap_step.x, p_target.x, snap_separation.x);
+ p_target.y = Math::snap_scalar_separation(snap_offset.y, snap_step.y, p_target.y, snap_separation.y);
}
return p_target;
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index e0bf8dfdb2..d81c6d3f96 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -3038,8 +3038,8 @@ Vector2 TileSetEditor::snap_point(const Vector2 &point) {
}
if (tools[TOOL_GRID_SNAP]->is_pressed()) {
- p.x = Math::snap_scalar_seperation(snap_offset.x, snap_step.x, p.x, snap_separation.x);
- p.y = Math::snap_scalar_seperation(snap_offset.y, snap_step.y, p.y, snap_separation.y);
+ p.x = Math::snap_scalar_separation(snap_offset.x, snap_step.x, p.x, snap_separation.x);
+ p.y = Math::snap_scalar_separation(snap_offset.y, snap_step.y, p.y, snap_separation.y);
}
if (tools[SHAPE_KEEP_INSIDE_TILE]->is_pressed()) {
if (p.x < region.position.x)
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 0884620e5d..beead9e7f1 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -340,8 +340,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (!profile_allow_editing) {
break;
}
- Tree *tree = scene_tree->get_scene_tree();
- if (tree->is_anything_selected()) {
+ if (editor_selection->get_selected_node_list().size() > 1) {
rename_dialog->popup_centered();
}
} break;