@@ -219,8 +219,7 @@ void FoldableContainer::gui_input(const Ref<InputEvent> &p_event) {
219219
220220 Ref<InputEventMouseMotion> m = p_event;
221221 if (m.is_valid ()) {
222- Rect2 title_rect = Rect2 (0 , (title_position == POSITION_TOP) ? 0 : get_size ().height - title_minimum_size.height , get_size ().width , title_minimum_size.height );
223- if (title_rect.has_point (m->get_position ())) {
222+ if (_get_title_rect ().has_point (m->get_position ())) {
224223 if (!is_hovering) {
225224 is_hovering = true ;
226225 queue_redraw ();
@@ -241,8 +240,7 @@ void FoldableContainer::gui_input(const Ref<InputEvent> &p_event) {
241240
242241 Ref<InputEventMouseButton> b = p_event;
243242 if (b.is_valid ()) {
244- Rect2 title_rect = Rect2 (0 , (title_position == POSITION_TOP) ? 0 : get_size ().height - title_minimum_size.height , get_size ().width , title_minimum_size.height );
245- if (b->get_button_index () == MouseButton::LEFT && b->is_pressed () && title_rect.has_point (b->get_position ())) {
243+ if (b->get_button_index () == MouseButton::LEFT && b->is_pressed () && _get_title_rect ().has_point (b->get_position ())) {
246244 set_folded (!folded);
247245 emit_signal (SNAME (" folding_changed" ), folded);
248246 accept_event ();
@@ -272,9 +270,7 @@ void FoldableContainer::_notification(int p_what) {
272270 title_controls_width += h_separation;
273271 }
274272
275- Rect2 title_rect (
276- Point2 (0 , (title_position == POSITION_TOP) ? 0 : size.height - title_minimum_size.height ),
277- Size2 (size.width , title_minimum_size.height ));
273+ const Rect2 title_rect = _get_title_rect ();
278274 _draw_flippable_stylebox (title_style, title_rect);
279275
280276 Size2 title_ms = title_style->get_minimum_size ();
@@ -431,6 +427,10 @@ Ref<Texture2D> FoldableContainer::_get_title_icon() const {
431427 return theme_cache.folded_arrow ;
432428}
433429
430+ Rect2 FoldableContainer::_get_title_rect () const {
431+ return Rect2 (0 , (title_position == POSITION_TOP) ? 0 : (get_size ().height - title_minimum_size.height ), get_size ().width , title_minimum_size.height );
432+ }
433+
434434void FoldableContainer::_update_title_min_size () const {
435435 Ref<StyleBox> title_style = folded ? theme_cache.title_collapsed_style : theme_cache.title_style ;
436436 Ref<Texture2D> icon = _get_title_icon ();
0 commit comments