mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:27:43 +00:00
LibGUI: Fix Splitter sometimes not working after widgets were resized
We need to skip over widgets that are not visible as the layout does not update their location. This fixes finding the correct widgets surrounding the splitter. Fixes #3491
This commit is contained in:
parent
2adcabb6b3
commit
5f9906f188
1 changed files with 23 additions and 16 deletions
|
@ -86,23 +86,30 @@ void Splitter::leave_event(Core::Event&)
|
||||||
bool Splitter::get_resize_candidates_at(const Gfx::IntPoint& position, Widget*& first, Widget*& second)
|
bool Splitter::get_resize_candidates_at(const Gfx::IntPoint& position, Widget*& first, Widget*& second)
|
||||||
{
|
{
|
||||||
int x_or_y = position.primary_offset_for_orientation(m_orientation);
|
int x_or_y = position.primary_offset_for_orientation(m_orientation);
|
||||||
|
Widget* previous_widget = nullptr;
|
||||||
auto child_widgets = this->child_widgets();
|
bool found_candidates = false;
|
||||||
if (child_widgets.size() < 2)
|
for_each_child_widget([&](auto& child_widget) {
|
||||||
return false;
|
if (!child_widget.is_visible()) {
|
||||||
|
// We need to skip over widgets that are not visible as they
|
||||||
for (size_t i = 0; i < child_widgets.size() - 1; ++i) {
|
// are not necessarily in the correct location (anymore)
|
||||||
auto* first_candidate = child_widgets[i];
|
return IterationDecision::Continue;
|
||||||
auto* second_candidate = child_widgets[i + 1];
|
|
||||||
|
|
||||||
if (x_or_y > first_candidate->content_rect().last_edge_for_orientation(m_orientation)
|
|
||||||
&& x_or_y <= second_candidate->content_rect().first_edge_for_orientation(m_orientation)) {
|
|
||||||
first = first_candidate;
|
|
||||||
second = second_candidate;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
if (!previous_widget) {
|
||||||
return false;
|
previous_widget = &child_widget;
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x_or_y > previous_widget->content_rect().last_edge_for_orientation(m_orientation)
|
||||||
|
&& x_or_y <= child_widget.content_rect().first_edge_for_orientation(m_orientation)) {
|
||||||
|
first = previous_widget;
|
||||||
|
second = &child_widget;
|
||||||
|
found_candidates = true;
|
||||||
|
return IterationDecision::Break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
});
|
||||||
|
return found_candidates;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Splitter::mousedown_event(MouseEvent& event)
|
void Splitter::mousedown_event(MouseEvent& event)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue