mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-23 04:55:15 +00:00
VisualBuilder: Fix hit testing for composite widgets
When we ask LibGUI to hit test, it may return a subwidget of a widget composed of many smaller widgets. In those cases we need to locate the appropriate corresponding VBWidget for the composite widget.
This commit is contained in:
parent
b37fc9f655
commit
5e439bb3c8
Notes:
sideshowbarker
2024-07-19 12:03:45 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/5e439bb3c88
1 changed files with 10 additions and 1 deletions
|
@ -113,7 +113,13 @@ VBWidget* VBForm::widget_at(const Point& position)
|
|||
auto result = hit_test(position, GWidget::ShouldRespectGreediness::No);
|
||||
if (!result.widget)
|
||||
return nullptr;
|
||||
return m_gwidget_map.get(result.widget).value_or(nullptr);
|
||||
auto* gwidget = result.widget;
|
||||
while (gwidget) {
|
||||
if (auto* widget = m_gwidget_map.get(gwidget).value_or(nullptr))
|
||||
return widget;
|
||||
gwidget = gwidget->parent_widget();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void VBForm::grabber_mousedown_event(GMouseEvent& event, Direction grabber)
|
||||
|
@ -411,9 +417,12 @@ void VBForm::delete_selected_widgets()
|
|||
for_each_selected_widget([&](auto& widget) {
|
||||
to_delete.append(&widget);
|
||||
});
|
||||
if (to_delete.is_empty())
|
||||
return;
|
||||
for (auto& widget : to_delete)
|
||||
m_widgets.remove_first_matching([&widget](auto& entry) { return entry == widget; });
|
||||
on_widget_selected(single_selected_widget());
|
||||
update();
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
|
|
Loading…
Add table
Reference in a new issue