Skip to content

Commit 2a52602

Browse files
committed
Merge pull request #108792 from arkology/find-in-files-panel-sizing
Fix `FindInFilesPanel` sizing issues
2 parents 916af46 + f3267c0 commit 2a52602

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

editor/script/find_in_files.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -706,15 +706,19 @@ FindInFilesPanel::FindInFilesPanel() {
706706
hbc->add_child(find_label);
707707

708708
_search_text_label = memnew(Label);
709+
_search_text_label->set_text_overrun_behavior(TextServer::OVERRUN_TRIM_ELLIPSIS);
710+
_search_text_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
709711
_search_text_label->set_focus_mode(FOCUS_ACCESSIBILITY);
712+
_search_text_label->set_mouse_filter(Control::MOUSE_FILTER_PASS);
710713
_search_text_label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
711714
hbc->add_child(_search_text_label);
712715

713716
_progress_bar = memnew(ProgressBar);
714717
_progress_bar->set_h_size_flags(SIZE_EXPAND_FILL);
715718
_progress_bar->set_v_size_flags(SIZE_SHRINK_CENTER);
719+
_progress_bar->set_stretch_ratio(2.0);
720+
_progress_bar->set_visible(false);
716721
hbc->add_child(_progress_bar);
717-
set_progress_visible(false);
718722

719723
_status_label = memnew(Label);
720724
_status_label->set_focus_mode(FOCUS_ACCESSIBILITY);
@@ -812,9 +816,13 @@ void FindInFilesPanel::start_search() {
812816

813817
_status_label->set_text(TTRC("Searching..."));
814818
_search_text_label->set_text(_finder->get_search_text());
819+
_search_text_label->set_tooltip_text(_finder->get_search_text());
820+
821+
int label_min_width = _search_text_label->get_minimum_size().x + _search_text_label->get_character_bounds(0).size.x;
822+
_search_text_label->set_custom_minimum_size(Size2(label_min_width, 0));
815823

816824
set_process(true);
817-
set_progress_visible(true);
825+
_progress_bar->set_visible(true);
818826

819827
_finder->start();
820828

@@ -828,7 +836,7 @@ void FindInFilesPanel::stop_search() {
828836

829837
_status_label->set_text("");
830838
update_replace_buttons();
831-
set_progress_visible(false);
839+
_progress_bar->set_visible(false);
832840
_refresh_button->show();
833841
_cancel_button->hide();
834842
}
@@ -967,7 +975,7 @@ void FindInFilesPanel::_on_item_edited() {
967975
void FindInFilesPanel::_on_finished() {
968976
update_matches_text();
969977
update_replace_buttons();
970-
set_progress_visible(false);
978+
_progress_bar->set_visible(false);
971979
_refresh_button->show();
972980
_cancel_button->hide();
973981
}
@@ -1178,10 +1186,6 @@ void FindInFilesPanel::update_matches_text() {
11781186
_status_label->set_text(results_text);
11791187
}
11801188

1181-
void FindInFilesPanel::set_progress_visible(bool p_visible) {
1182-
_progress_bar->set_self_modulate(Color(1, 1, 1, p_visible ? 1 : 0));
1183-
}
1184-
11851189
void FindInFilesPanel::_bind_methods() {
11861190
ClassDB::bind_method("_on_result_found", &FindInFilesPanel::_on_result_found);
11871191
ClassDB::bind_method("_on_finished", &FindInFilesPanel::_on_finished);

editor/script/find_in_files.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include "core/templates/hash_map.h"
3434
#include "scene/gui/dialogs.h"
35+
#include "scene/gui/margin_container.h"
3536

3637
// Performs the actual search
3738
class FindInFiles : public Node {
@@ -165,8 +166,8 @@ class TreeItem;
165166
class ProgressBar;
166167

167168
// Display search results
168-
class FindInFilesPanel : public Control {
169-
GDCLASS(FindInFilesPanel, Control);
169+
class FindInFilesPanel : public MarginContainer {
170+
GDCLASS(FindInFilesPanel, MarginContainer);
170171

171172
public:
172173
static const char *SIGNAL_RESULT_SELECTED;
@@ -214,7 +215,6 @@ class FindInFilesPanel : public Control {
214215

215216
void draw_result_text(Object *item_obj, Rect2 rect);
216217

217-
void set_progress_visible(bool p_visible);
218218
void clear();
219219

220220
FindInFiles *_finder = nullptr;

0 commit comments

Comments
 (0)