mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-24 12:02:51 +00:00
WindowServer: Add MenuManager helper to find closest open ancestor
This commit is contained in:
parent
db852548ce
commit
4489f9dbef
Notes:
sideshowbarker
2024-07-18 02:47:59 +09:00
Author: https://github.com/thankyouverycool
Commit: 4489f9dbef
Pull-request: https://github.com/SerenityOS/serenity/pull/14887
2 changed files with 9 additions and 0 deletions
|
@ -229,6 +229,14 @@ void MenuManager::close_everyone()
|
|||
clear_current_menu();
|
||||
}
|
||||
|
||||
Menu* MenuManager::closest_open_ancestor_of(Menu const& other) const
|
||||
{
|
||||
for (auto& menu : m_open_menu_stack.in_reverse())
|
||||
if (menu->is_menu_ancestor_of(other))
|
||||
return menu.ptr();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void MenuManager::close_everyone_not_in_lineage(Menu& menu)
|
||||
{
|
||||
Vector<Menu&> menus_to_close;
|
||||
|
|
|
@ -26,6 +26,7 @@ public:
|
|||
bool has_open_menu() const { return !m_open_menu_stack.is_empty(); }
|
||||
|
||||
Menu* current_menu() { return m_current_menu.ptr(); }
|
||||
Menu* closest_open_ancestor_of(Menu const&) const;
|
||||
void set_current_menu(Menu*);
|
||||
void clear_current_menu();
|
||||
void open_menu(Menu&, bool as_current_menu = true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue