summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/find_in_files.cpp22
-rw-r--r--editor/find_in_files.h3
-rw-r--r--editor/icons/Crosshair.svg1
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp22
-rw-r--r--editor/plugins/node_3d_editor_plugin.h2
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp4
6 files changed, 23 insertions, 31 deletions
diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp
index 1bc0de1ab0..53c52b94cc 100644
--- a/editor/find_in_files.cpp
+++ b/editor/find_in_files.cpp
@@ -719,22 +719,20 @@ void FindInFilesPanel::_on_result_found(String fpath, int line_number, int begin
// Do this first because it resets properties of the cell...
item->set_cell_mode(text_index, TreeItem::CELL_MODE_CUSTOM);
- String item_text = vformat("%3s: %s", line_number, text.replace("\t", " "));
+ // Trim result item line
+ int old_text_size = text.size();
+ text = text.strip_edges(true, false);
+ int chars_removed = old_text_size - text.size();
+ String start = vformat("%3s: ", line_number);
- item->set_text(text_index, item_text);
+ item->set_text(text_index, start + text);
item->set_custom_draw(text_index, this, "_draw_result_text");
- Ref<Font> font = _results_display->get_theme_font("font");
-
- float raw_text_width = font->get_string_size(text).x;
- float item_text_width = font->get_string_size(item_text).x;
-
Result r;
r.line_number = line_number;
r.begin = begin;
r.end = end;
- r.draw_begin = (item_text_width - raw_text_width) + font->get_string_size(text.left(r.begin)).x;
- r.draw_width = font->get_string_size(text.substr(r.begin, r.end - r.begin)).x;
+ r.begin_trimmed = begin - chars_removed + start.size() - 1;
_result_items[item] = r;
if (_with_replace) {
@@ -755,10 +753,12 @@ void FindInFilesPanel::draw_result_text(Object *item_obj, Rect2 rect) {
return;
}
Result r = E->value();
+ String item_text = item->get_text(_with_replace ? 1 : 0);
+ Ref<Font> font = _results_display->get_theme_font("font");
Rect2 match_rect = rect;
- match_rect.position.x += r.draw_begin;
- match_rect.size.x = r.draw_width;
+ match_rect.position.x += font->get_string_size(item_text.left(r.begin_trimmed)).x;
+ match_rect.size.x = font->get_string_size(_search_text_label->get_text()).x;
match_rect.position.y += 1 * EDSCALE;
match_rect.size.y -= 2 * EDSCALE;
diff --git a/editor/find_in_files.h b/editor/find_in_files.h
index 41adb156b6..9815296be8 100644
--- a/editor/find_in_files.h
+++ b/editor/find_in_files.h
@@ -191,8 +191,7 @@ private:
int line_number;
int begin;
int end;
- float draw_begin;
- float draw_width;
+ int begin_trimmed;
};
void apply_replaces_in_file(String fpath, const Vector<Result> &locations, String new_text);
diff --git a/editor/icons/Crosshair.svg b/editor/icons/Crosshair.svg
deleted file mode 100644
index b6fa5ec654..0000000000
--- a/editor/icons/Crosshair.svg
+++ /dev/null
@@ -1 +0,0 @@
-<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/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 7bf8fd7d26..975957d56c 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -2174,6 +2174,8 @@ void Node3DEditorViewport::set_freelook_active(bool active_now) {
freelook_speed = base_speed * cursor.distance;
}
+ previous_mouse_position = get_local_mouse_position();
+
// Hide mouse like in an FPS (warping doesn't work)
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
@@ -2183,6 +2185,11 @@ void Node3DEditorViewport::set_freelook_active(bool active_now) {
// Restore mouse
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
+
+ // Restore the previous mouse position when leaving freelook mode.
+ // This is done because leaving `Input.MOUSE_MODE_CAPTURED` will center the cursor
+ // due to OS limitations.
+ warp_mouse(previous_mouse_position);
}
freelook_active = active_now;
@@ -2341,13 +2348,6 @@ void Node3DEditorViewport::_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_theme_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();
@@ -2473,10 +2473,6 @@ void Node3DEditorViewport::_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";
@@ -3866,10 +3862,6 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
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/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h
index 83173b5ad2..2fe1938f28 100644
--- a/editor/plugins/node_3d_editor_plugin.h
+++ b/editor/plugins/node_3d_editor_plugin.h
@@ -284,8 +284,8 @@ private:
bool freelook_active;
real_t freelook_speed;
+ Vector2 previous_mouse_position;
- TextureRect *crosshair;
Label *info_label;
Label *cinema_label;
Label *locked_label;
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index b3d4b391d3..07bf5b53cd 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -492,12 +492,14 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
tools[SHAPE_NEW_RECTANGLE]->set_toggle_mode(true);
tools[SHAPE_NEW_RECTANGLE]->set_button_group(tg);
tools[SHAPE_NEW_RECTANGLE]->set_tooltip(TTR("Create a new rectangle."));
+ tools[SHAPE_NEW_RECTANGLE]->connect("pressed", callable_mp(this, &TileSetEditor::_on_tool_clicked), varray(SHAPE_NEW_RECTANGLE));
tools[SHAPE_NEW_POLYGON] = memnew(ToolButton);
toolbar->add_child(tools[SHAPE_NEW_POLYGON]);
tools[SHAPE_NEW_POLYGON]->set_toggle_mode(true);
tools[SHAPE_NEW_POLYGON]->set_button_group(tg);
tools[SHAPE_NEW_POLYGON]->set_tooltip(TTR("Create a new polygon."));
+ tools[SHAPE_NEW_POLYGON]->connect("pressed", callable_mp(this, &TileSetEditor::_on_tool_clicked), varray(SHAPE_NEW_POLYGON));
separator_shape_toggle = memnew(VSeparator);
toolbar->add_child(separator_shape_toggle);
@@ -1908,7 +1910,7 @@ void TileSetEditor::_on_tool_clicked(int p_tool) {
}
}
}
- } else if (p_tool == TOOL_SELECT) {
+ } else if (p_tool == TOOL_SELECT || p_tool == SHAPE_NEW_POLYGON || p_tool == SHAPE_NEW_RECTANGLE) {
if (creating_shape) {
// Cancel Creation
creating_shape = false;