Skip to content

Commit 186d687

Browse files
committed
FindReplaceBar: Fix "Replace (All)" buttons repositioning, improve "Hide" button visual feedback
"Replace" and "Replace All" buttons now do not change their position depending on the availability of search results. Additional changes: - `VBoxContainer *vbc_lineedit` declaration has been removed from the header because it is not used outside the `FindReplaceBar` constructor. - `hide_button` was changed from `TextureButton` to `Button` for consistency - this allows to visually see the feedback when hovering and pressing and also not set its icon 3 times instead of 1.
1 parent b5bdb88 commit 186d687

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

editor/code_editor.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,7 @@ void FindReplaceBar::_notification(int p_what) {
137137
case NOTIFICATION_READY: {
138138
find_prev->set_button_icon(get_editor_theme_icon(SNAME("MoveUp")));
139139
find_next->set_button_icon(get_editor_theme_icon(SNAME("MoveDown")));
140-
hide_button->set_texture_normal(get_editor_theme_icon(SNAME("Close")));
141-
hide_button->set_texture_hover(get_editor_theme_icon(SNAME("Close")));
142-
hide_button->set_texture_pressed(get_editor_theme_icon(SNAME("Close")));
143-
hide_button->set_custom_minimum_size(hide_button->get_texture_normal()->get_size());
140+
hide_button->set_button_icon(get_editor_theme_icon(SNAME("Close")));
144141
_update_toggle_replace_button(replace_text->is_visible_in_tree());
145142
} break;
146143

@@ -752,7 +749,7 @@ FindReplaceBar::FindReplaceBar() {
752749
toggle_replace_button->set_focus_mode(FOCUS_NONE);
753750
toggle_replace_button->connect(SceneStringName(pressed), callable_mp(this, &FindReplaceBar::_toggle_replace_pressed));
754751

755-
vbc_lineedit = memnew(VBoxContainer);
752+
VBoxContainer *vbc_lineedit = memnew(VBoxContainer);
756753
add_child(vbc_lineedit);
757754
vbc_lineedit->set_alignment(BoxContainer::ALIGNMENT_CENTER);
758755
vbc_lineedit->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -762,18 +759,20 @@ FindReplaceBar::FindReplaceBar() {
762759
add_child(vbc_option);
763760

764761
HBoxContainer *hbc_button_search = memnew(HBoxContainer);
765-
vbc_button->add_child(hbc_button_search);
762+
hbc_button_search->set_v_size_flags(SIZE_EXPAND_FILL);
766763
hbc_button_search->set_alignment(BoxContainer::ALIGNMENT_END);
764+
vbc_button->add_child(hbc_button_search);
767765
hbc_button_replace = memnew(HBoxContainer);
768-
vbc_button->add_child(hbc_button_replace);
766+
hbc_button_replace->set_v_size_flags(SIZE_EXPAND_FILL);
769767
hbc_button_replace->set_alignment(BoxContainer::ALIGNMENT_END);
768+
vbc_button->add_child(hbc_button_replace);
770769

771770
HBoxContainer *hbc_option_search = memnew(HBoxContainer);
772771
vbc_option->add_child(hbc_option_search);
773772
hbc_option_replace = memnew(HBoxContainer);
774773
vbc_option->add_child(hbc_option_replace);
775774

776-
// Search toolbar
775+
// Search toolbar.
777776
search_text = memnew(LineEdit);
778777
search_text->set_keep_editing_on_text_submit(true);
779778
vbc_lineedit->add_child(search_text);
@@ -813,7 +812,7 @@ FindReplaceBar::FindReplaceBar() {
813812
whole_words->set_focus_mode(FOCUS_NONE);
814813
whole_words->connect(SceneStringName(toggled), callable_mp(this, &FindReplaceBar::_search_options_changed));
815814

816-
// Replace toolbar
815+
// Replace toolbar.
817816
replace_text = memnew(LineEdit);
818817
vbc_lineedit->add_child(replace_text);
819818
replace_text->set_placeholder(TTR("Replace"));
@@ -837,12 +836,13 @@ FindReplaceBar::FindReplaceBar() {
837836
selection_only->set_focus_mode(FOCUS_NONE);
838837
selection_only->connect(SceneStringName(toggled), callable_mp(this, &FindReplaceBar::_search_options_changed));
839838

840-
hide_button = memnew(TextureButton);
841-
add_child(hide_button);
839+
hide_button = memnew(Button);
840+
hide_button->set_flat(true);
842841
hide_button->set_tooltip_text(TTR("Hide"));
843842
hide_button->set_focus_mode(FOCUS_NONE);
844843
hide_button->connect(SceneStringName(pressed), callable_mp(this, &FindReplaceBar::_hide_bar));
845844
hide_button->set_v_size_flags(SIZE_SHRINK_CENTER);
845+
add_child(hide_button);
846846
}
847847

848848
/*** CODE EDITOR ****/

editor/code_editor.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,13 @@ class FindReplaceBar : public HBoxContainer {
7979
Button *find_next = nullptr;
8080
CheckBox *case_sensitive = nullptr;
8181
CheckBox *whole_words = nullptr;
82-
TextureButton *hide_button = nullptr;
82+
Button *hide_button = nullptr;
8383

8484
LineEdit *replace_text = nullptr;
8585
Button *replace = nullptr;
8686
Button *replace_all = nullptr;
8787
CheckBox *selection_only = nullptr;
8888

89-
VBoxContainer *vbc_lineedit = nullptr;
9089
HBoxContainer *hbc_button_replace = nullptr;
9190
HBoxContainer *hbc_option_replace = nullptr;
9291

0 commit comments

Comments
 (0)