Browse Source

Fix `FindInFilesPanel` sizing issues

arkology 1 month ago
parent
commit
f3267c0ca7
2 changed files with 15 additions and 11 deletions
  1. 12 8
      editor/script/find_in_files.cpp
  2. 3 3
      editor/script/find_in_files.h

+ 12 - 8
editor/script/find_in_files.cpp

@@ -706,15 +706,19 @@ FindInFilesPanel::FindInFilesPanel() {
 		hbc->add_child(find_label);
 		hbc->add_child(find_label);
 
 
 		_search_text_label = memnew(Label);
 		_search_text_label = memnew(Label);
+		_search_text_label->set_text_overrun_behavior(TextServer::OVERRUN_TRIM_ELLIPSIS);
+		_search_text_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
 		_search_text_label->set_focus_mode(FOCUS_ACCESSIBILITY);
 		_search_text_label->set_focus_mode(FOCUS_ACCESSIBILITY);
+		_search_text_label->set_mouse_filter(Control::MOUSE_FILTER_PASS);
 		_search_text_label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
 		_search_text_label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
 		hbc->add_child(_search_text_label);
 		hbc->add_child(_search_text_label);
 
 
 		_progress_bar = memnew(ProgressBar);
 		_progress_bar = memnew(ProgressBar);
 		_progress_bar->set_h_size_flags(SIZE_EXPAND_FILL);
 		_progress_bar->set_h_size_flags(SIZE_EXPAND_FILL);
 		_progress_bar->set_v_size_flags(SIZE_SHRINK_CENTER);
 		_progress_bar->set_v_size_flags(SIZE_SHRINK_CENTER);
+		_progress_bar->set_stretch_ratio(2.0);
+		_progress_bar->set_visible(false);
 		hbc->add_child(_progress_bar);
 		hbc->add_child(_progress_bar);
-		set_progress_visible(false);
 
 
 		_status_label = memnew(Label);
 		_status_label = memnew(Label);
 		_status_label->set_focus_mode(FOCUS_ACCESSIBILITY);
 		_status_label->set_focus_mode(FOCUS_ACCESSIBILITY);
@@ -812,9 +816,13 @@ void FindInFilesPanel::start_search() {
 
 
 	_status_label->set_text(TTRC("Searching..."));
 	_status_label->set_text(TTRC("Searching..."));
 	_search_text_label->set_text(_finder->get_search_text());
 	_search_text_label->set_text(_finder->get_search_text());
+	_search_text_label->set_tooltip_text(_finder->get_search_text());
+
+	int label_min_width = _search_text_label->get_minimum_size().x + _search_text_label->get_character_bounds(0).size.x;
+	_search_text_label->set_custom_minimum_size(Size2(label_min_width, 0));
 
 
 	set_process(true);
 	set_process(true);
-	set_progress_visible(true);
+	_progress_bar->set_visible(true);
 
 
 	_finder->start();
 	_finder->start();
 
 
@@ -828,7 +836,7 @@ void FindInFilesPanel::stop_search() {
 
 
 	_status_label->set_text("");
 	_status_label->set_text("");
 	update_replace_buttons();
 	update_replace_buttons();
-	set_progress_visible(false);
+	_progress_bar->set_visible(false);
 	_refresh_button->show();
 	_refresh_button->show();
 	_cancel_button->hide();
 	_cancel_button->hide();
 }
 }
@@ -967,7 +975,7 @@ void FindInFilesPanel::_on_item_edited() {
 void FindInFilesPanel::_on_finished() {
 void FindInFilesPanel::_on_finished() {
 	update_matches_text();
 	update_matches_text();
 	update_replace_buttons();
 	update_replace_buttons();
-	set_progress_visible(false);
+	_progress_bar->set_visible(false);
 	_refresh_button->show();
 	_refresh_button->show();
 	_cancel_button->hide();
 	_cancel_button->hide();
 }
 }
@@ -1178,10 +1186,6 @@ void FindInFilesPanel::update_matches_text() {
 	_status_label->set_text(results_text);
 	_status_label->set_text(results_text);
 }
 }
 
 
-void FindInFilesPanel::set_progress_visible(bool p_visible) {
-	_progress_bar->set_self_modulate(Color(1, 1, 1, p_visible ? 1 : 0));
-}
-
 void FindInFilesPanel::_bind_methods() {
 void FindInFilesPanel::_bind_methods() {
 	ClassDB::bind_method("_on_result_found", &FindInFilesPanel::_on_result_found);
 	ClassDB::bind_method("_on_result_found", &FindInFilesPanel::_on_result_found);
 	ClassDB::bind_method("_on_finished", &FindInFilesPanel::_on_finished);
 	ClassDB::bind_method("_on_finished", &FindInFilesPanel::_on_finished);

+ 3 - 3
editor/script/find_in_files.h

@@ -32,6 +32,7 @@
 
 
 #include "core/templates/hash_map.h"
 #include "core/templates/hash_map.h"
 #include "scene/gui/dialogs.h"
 #include "scene/gui/dialogs.h"
+#include "scene/gui/margin_container.h"
 
 
 // Performs the actual search
 // Performs the actual search
 class FindInFiles : public Node {
 class FindInFiles : public Node {
@@ -165,8 +166,8 @@ class TreeItem;
 class ProgressBar;
 class ProgressBar;
 
 
 // Display search results
 // Display search results
-class FindInFilesPanel : public Control {
-	GDCLASS(FindInFilesPanel, Control);
+class FindInFilesPanel : public MarginContainer {
+	GDCLASS(FindInFilesPanel, MarginContainer);
 
 
 public:
 public:
 	static const char *SIGNAL_RESULT_SELECTED;
 	static const char *SIGNAL_RESULT_SELECTED;
@@ -214,7 +215,6 @@ private:
 
 
 	void draw_result_text(Object *item_obj, Rect2 rect);
 	void draw_result_text(Object *item_obj, Rect2 rect);
 
 
-	void set_progress_visible(bool p_visible);
 	void clear();
 	void clear();
 
 
 	FindInFiles *_finder = nullptr;
 	FindInFiles *_finder = nullptr;