Skip to content

Commit b9837e4

Browse files
WhalesStateKoBeWi
andcommitted
Fix scrolling to bottom panel selected button.
Co-authored-by: Tomasz Chabora <[email protected]>
1 parent 9dde568 commit b9837e4

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

editor/gui/editor_bottom_panel.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ void EditorBottomPanel::_update_disabled_buttons() {
100100
right_button->set_disabled(h_scroll->get_value() + h_scroll->get_page() == h_scroll->get_max());
101101
}
102102

103+
void EditorBottomPanel::_ensure_control_visible(ObjectID p_id) {
104+
Control *c = ObjectDB::get_instance<Control>(p_id);
105+
if (!c) {
106+
return;
107+
}
108+
109+
button_scroll->ensure_control_visible(c);
110+
}
111+
103112
void EditorBottomPanel::_switch_to_item(bool p_visible, int p_idx, bool p_ignore_lock) {
104113
ERR_FAIL_INDEX(p_idx, items.size());
105114

@@ -134,7 +143,7 @@ void EditorBottomPanel::_switch_to_item(bool p_visible, int p_idx, bool p_ignore
134143
if (expand_button->is_pressed()) {
135144
EditorNode::get_top_split()->hide();
136145
}
137-
callable_mp(button_scroll, &ScrollContainer::ensure_control_visible).call_deferred(items[p_idx].button);
146+
callable_mp(this, &EditorBottomPanel::_ensure_control_visible).call_deferred(items[p_idx].button->get_instance_id());
138147
} else {
139148
add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles)));
140149
items[p_idx].button->set_pressed_no_signal(false);

editor/gui/editor_bottom_panel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class EditorBottomPanel : public PanelContainer {
6969
void _scroll(bool p_right);
7070
void _update_scroll_buttons();
7171
void _update_disabled_buttons();
72+
void _ensure_control_visible(ObjectID p_id);
7273

7374
bool _button_drag_hover(const Vector2 &, const Variant &, Button *p_button, Control *p_control);
7475

0 commit comments

Comments
 (0)