mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 13:49:54 +00:00
Use EditorDock for Search Results
This commit is contained in:
parent
2ecefada8d
commit
51bfe186a9
4 changed files with 34 additions and 30 deletions
|
|
@ -33,10 +33,9 @@
|
|||
#include "core/config/project_settings.h"
|
||||
#include "core/io/dir_access.h"
|
||||
#include "core/os/os.h"
|
||||
#include "editor/docks/editor_dock.h"
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_string_names.h"
|
||||
#include "editor/gui/editor_bottom_panel.h"
|
||||
#include "editor/settings/editor_command_palette.h"
|
||||
#include "editor/themes/editor_scale.h"
|
||||
#include "scene/gui/box_container.h"
|
||||
#include "scene/gui/button.h"
|
||||
|
|
@ -1293,6 +1292,17 @@ void FindInFilesPanel::_bind_methods() {
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
FindInFilesContainer::FindInFilesContainer() {
|
||||
set_name(TTRC("Search Results"));
|
||||
set_icon_name("Search");
|
||||
set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_search_results_bottom_panel", TTRC("Toggle Search Results Bottom Panel")));
|
||||
set_default_slot(DockConstants::DOCK_SLOT_BOTTOM);
|
||||
set_available_layouts(EditorDock::DOCK_LAYOUT_HORIZONTAL | EditorDock::DOCK_LAYOUT_FLOATING);
|
||||
set_global(false);
|
||||
set_transient(true);
|
||||
set_closable(true);
|
||||
set_custom_minimum_size(Size2(0, 200 * EDSCALE));
|
||||
set_clip_contents(false);
|
||||
|
||||
_tabs = memnew(TabContainer);
|
||||
_tabs->set_tabs_visible(false);
|
||||
add_child(_tabs);
|
||||
|
|
@ -1311,7 +1321,7 @@ FindInFilesContainer::FindInFilesContainer() {
|
|||
_tabs_context_menu->add_item(TTRC("Close All Tabs"), PANEL_CLOSE_ALL);
|
||||
_tabs_context_menu->connect(SceneStringName(id_pressed), callable_mp(this, &FindInFilesContainer::_bar_menu_option));
|
||||
|
||||
EditorNode::get_bottom_panel()->connect(SceneStringName(theme_changed), callable_mp(this, &FindInFilesContainer::_on_theme_changed));
|
||||
EditorNode::get_singleton()->get_gui_base()->connect(SceneStringName(theme_changed), callable_mp(this, &FindInFilesContainer::_on_theme_changed));
|
||||
}
|
||||
|
||||
FindInFilesPanel *FindInFilesContainer::_create_new_panel() {
|
||||
|
|
@ -1364,18 +1374,12 @@ void FindInFilesContainer::_bind_methods() {
|
|||
PropertyInfo(Variant::INT, "end")));
|
||||
|
||||
ADD_SIGNAL(MethodInfo("files_modified", PropertyInfo(Variant::STRING, "paths")));
|
||||
|
||||
ADD_SIGNAL(MethodInfo("close_button_clicked"));
|
||||
}
|
||||
|
||||
void FindInFilesContainer::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_READY: {
|
||||
// TODO: Replace this hack once FindInFilesContainer is converted to a dock. It should be in the constructor.
|
||||
EditorDock *parent = Object::cast_to<EditorDock>(get_parent());
|
||||
if (parent) {
|
||||
parent->set_clip_contents(false);
|
||||
}
|
||||
case NOTIFICATION_POSTINITIALIZE: {
|
||||
connect("closed", callable_mp(this, &FindInFilesContainer::_on_dock_closed));
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1406,7 +1410,7 @@ void FindInFilesContainer::_on_find_in_files_close_button_clicked(FindInFilesPan
|
|||
p_panel->queue_free();
|
||||
_update_bar_visibility();
|
||||
if (_tabs->get_tab_count() == 0) {
|
||||
emit_signal(SNAME("close_button_clicked"));
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1482,3 +1486,12 @@ void FindInFilesContainer::_bar_input(const Ref<InputEvent> &p_input) {
|
|||
_tabs_context_menu->popup();
|
||||
}
|
||||
}
|
||||
|
||||
void FindInFilesContainer::_on_dock_closed() {
|
||||
while (_tabs->get_tab_count() > 0) {
|
||||
Control *tab = _tabs->get_tab_control(0);
|
||||
_tabs->remove_child(tab);
|
||||
tab->queue_free();
|
||||
}
|
||||
_update_bar_visibility();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "core/templates/hash_map.h"
|
||||
#include "editor/docks/editor_dock.h"
|
||||
#include "scene/gui/dialogs.h"
|
||||
#include "scene/gui/margin_container.h"
|
||||
|
||||
// Performs the actual search
|
||||
class FindInFiles : public Node {
|
||||
|
|
@ -253,8 +253,8 @@ class TabContainer;
|
|||
// `Find in Files` search or a `Replace in Files` search, while a
|
||||
// FindInFilesContainer can contain several FindInFilesPanels so that multiple search
|
||||
// results can remain at the same time.
|
||||
class FindInFilesContainer : public MarginContainer {
|
||||
GDCLASS(FindInFilesContainer, MarginContainer);
|
||||
class FindInFilesContainer : public EditorDock {
|
||||
GDCLASS(FindInFilesContainer, EditorDock);
|
||||
|
||||
enum {
|
||||
PANEL_CLOSE,
|
||||
|
|
@ -268,6 +268,7 @@ class FindInFilesContainer : public MarginContainer {
|
|||
void _update_bar_visibility();
|
||||
void _bar_menu_option(int p_option);
|
||||
void _bar_input(const Ref<InputEvent> &p_input);
|
||||
void _on_dock_closed();
|
||||
|
||||
TabContainer *_tabs = nullptr;
|
||||
bool _update_bar = true;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@
|
|||
#include "editor/debugger/editor_debugger_node.h"
|
||||
#include "editor/debugger/script_editor_debugger.h"
|
||||
#include "editor/doc/editor_help_search.h"
|
||||
#include "editor/docks/editor_dock_manager.h"
|
||||
#include "editor/docks/filesystem_dock.h"
|
||||
#include "editor/docks/inspector_dock.h"
|
||||
#include "editor/docks/signals_dock.h"
|
||||
|
|
@ -52,7 +53,6 @@
|
|||
#include "editor/editor_string_names.h"
|
||||
#include "editor/file_system/editor_paths.h"
|
||||
#include "editor/gui/code_editor.h"
|
||||
#include "editor/gui/editor_bottom_panel.h"
|
||||
#include "editor/gui/editor_file_dialog.h"
|
||||
#include "editor/gui/editor_toaster.h"
|
||||
#include "editor/gui/window_wrapper.h"
|
||||
|
|
@ -4146,9 +4146,7 @@ void ScriptEditor::_start_find_in_files(bool with_replace) {
|
|||
panel->set_replace_text(find_in_files_dialog->get_replace_text());
|
||||
panel->start_search();
|
||||
|
||||
EditorNode::get_bottom_panel()->move_item_to_end(find_in_files);
|
||||
find_in_files_button->show();
|
||||
EditorNode::get_bottom_panel()->make_item_visible(find_in_files);
|
||||
find_in_files->make_visible();
|
||||
}
|
||||
|
||||
void ScriptEditor::_on_find_in_files_modified_files(const PackedStringArray &paths) {
|
||||
|
|
@ -4170,11 +4168,6 @@ void ScriptEditor::_update_code_editor_zoom_factor(CodeTextEditor *p_code_text_e
|
|||
}
|
||||
}
|
||||
|
||||
void ScriptEditor::_on_find_in_files_close_button_clicked() {
|
||||
EditorNode::get_bottom_panel()->hide_bottom_panel();
|
||||
find_in_files_button->hide();
|
||||
}
|
||||
|
||||
void ScriptEditor::_window_changed(bool p_visible) {
|
||||
make_floating->set_visible(!p_visible);
|
||||
is_floating = p_visible;
|
||||
|
|
@ -4549,13 +4542,12 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
|
|||
find_in_files_dialog->connect(FindInFilesDialog::SIGNAL_FIND_REQUESTED, callable_mp(this, &ScriptEditor::_start_find_in_files).bind(false));
|
||||
find_in_files_dialog->connect(FindInFilesDialog::SIGNAL_REPLACE_REQUESTED, callable_mp(this, &ScriptEditor::_start_find_in_files).bind(true));
|
||||
add_child(find_in_files_dialog);
|
||||
|
||||
find_in_files = memnew(FindInFilesContainer);
|
||||
find_in_files_button = EditorNode::get_bottom_panel()->add_item(TTRC("Search Results"), find_in_files, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_search_results_bottom_panel", TTRC("Toggle Search Results Bottom Panel")));
|
||||
find_in_files->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
|
||||
EditorDockManager::get_singleton()->add_dock(find_in_files);
|
||||
find_in_files->close();
|
||||
find_in_files->connect("result_selected", callable_mp(this, &ScriptEditor::_on_find_in_files_result_selected));
|
||||
find_in_files->connect("files_modified", callable_mp(this, &ScriptEditor::_on_find_in_files_modified_files));
|
||||
find_in_files->connect("close_button_clicked", callable_mp(this, &ScriptEditor::_on_find_in_files_close_button_clicked));
|
||||
find_in_files_button->hide();
|
||||
|
||||
history_pos = -1;
|
||||
|
||||
|
|
|
|||
|
|
@ -368,7 +368,6 @@ class ScriptEditor : public PanelContainer {
|
|||
|
||||
FindInFilesDialog *find_in_files_dialog = nullptr;
|
||||
FindInFilesContainer *find_in_files = nullptr;
|
||||
Button *find_in_files_button = nullptr;
|
||||
|
||||
WindowWrapper *window_wrapper = nullptr;
|
||||
|
||||
|
|
@ -554,7 +553,6 @@ class ScriptEditor : public PanelContainer {
|
|||
void _on_find_in_files_result_selected(const String &fpath, int line_number, int begin, int end);
|
||||
void _start_find_in_files(bool with_replace);
|
||||
void _on_find_in_files_modified_files(const PackedStringArray &paths);
|
||||
void _on_find_in_files_close_button_clicked();
|
||||
|
||||
void _set_script_zoom_factor(float p_zoom_factor);
|
||||
void _update_code_editor_zoom_factor(CodeTextEditor *p_code_text_editor);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue