diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-08-24 09:50:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-24 09:50:46 +0200 |
commit | c3a8ec3cbb43cc311d88a1b11aedc4db2785499b (patch) | |
tree | 04b325f4008796e4f6f79beff6fec31921853fa5 /scene/gui | |
parent | 854eb58074e2aa25a0f7b65b1833dc2dc51e49a6 (diff) | |
parent | 19ad31b89fc293cbd3c826b4dab6140b65895121 (diff) |
Merge pull request #64800 from KoBeWi/split_hax
Handle child control size changes in SplitContainer
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/split_container.cpp | 11 | ||||
-rw-r--r-- | scene/gui/split_container.h | 1 |
2 files changed, 9 insertions, 3 deletions
diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp index 9505a30540..cba36885a0 100644 --- a/scene/gui/split_container.cpp +++ b/scene/gui/split_container.cpp @@ -95,11 +95,16 @@ void SplitContainer::_resort() { no_offset_middle_sep = ms_first[axis]; } - // Compute the final middle separation + // Compute the final middle separation. middle_sep = no_offset_middle_sep; + if (prev_no_offset_middle_sep != INT_MAX) { + split_offset -= middle_sep - prev_no_offset_middle_sep; + } + prev_no_offset_middle_sep = middle_sep; + if (!collapsed) { - int clamped_split_offset = CLAMP(split_offset, ms_first[axis] - no_offset_middle_sep, get_size()[axis] - ms_second[axis] - sep); - middle_sep = MAX(middle_sep, clamped_split_offset); + int clamped_split_offset = CLAMP(split_offset, ms_first[axis] - no_offset_middle_sep, (get_size()[axis] - ms_second[axis] - sep) - no_offset_middle_sep); + middle_sep += clamped_split_offset; if (should_clamp_split_offset) { split_offset = clamped_split_offset; should_clamp_split_offset = false; diff --git a/scene/gui/split_container.h b/scene/gui/split_container.h index a69ffe4de9..dd15362199 100644 --- a/scene/gui/split_container.h +++ b/scene/gui/split_container.h @@ -47,6 +47,7 @@ private: bool should_clamp_split_offset = false; int split_offset = 0; int middle_sep = 0; + int prev_no_offset_middle_sep = INT_MAX; bool vertical = false; bool dragging = false; int drag_from = 0; |