ladybird/WindowServer/WSMenuBar.h
Andreas Kling fa452fadca WindowServer: Let menu objects reference the WSClientConnection by pointer.
Since these are owner/ownee relationships, there's no need for indirection.
2019-02-17 09:07:07 +01:00

31 lines
766 B
C++

#pragma once
#include "WSMenu.h"
#include <AK/Vector.h>
#include <AK/Weakable.h>
#include <AK/WeakPtr.h>
class WSMenuBar : public Weakable<WSMenuBar> {
public:
WSMenuBar(WSClientConnection& client, int menubar_id);
~WSMenuBar();
WSClientConnection& client() { return m_client; }
const WSClientConnection& client() const { return m_client; }
int menubar_id() const { return m_menubar_id; }
void add_menu(WSMenu* menu) { m_menus.append(menu); }
template<typename Callback>
void for_each_menu(Callback callback)
{
for (auto& menu : m_menus) {
if (!callback(*menu))
return;
}
}
private:
WSClientConnection& m_client;
int m_menubar_id { 0 };
Vector<WSMenu*> m_menus;
};