1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-14 12:37:35 +00:00
serenity/Servers/WindowServer/WSMenuManager.h
Andreas Kling 63e6b09816 WindowServer+LibGUI: Add support for nested menus
It's now possible to add a GMenu as a submenu of another GMenu.
Simply use the GMenu::add_submenu(NonnullOwnPtr<GMenu>) API :^)

The WindowServer now keeps track of a stack of open menus rather than
just one "current menu". This code needs a bit more work, but the basic
functionality is now here!
2019-08-29 06:36:29 +02:00

37 lines
835 B
C++

#pragma once
#include "WSMenu.h"
#include <LibCore/CObject.h>
#include <WindowServer/WSCPUMonitor.h>
#include <WindowServer/WSWindow.h>
class WSMenuManager final : public CObject {
C_OBJECT(WSMenuManager)
public:
WSMenuManager();
virtual ~WSMenuManager() override;
void setup();
void refresh();
virtual void event(CEvent&) override;
bool is_open(const WSMenu&) const;
Vector<WeakPtr<WSMenu>>& open_menu_stack() { return m_open_menu_stack; }
private:
WSWindow& window() { return *m_window; }
const WSWindow& window() const { return *m_window; }
void handle_menu_mouse_event(WSMenu&, const WSMouseEvent&);
void draw();
void tick_clock();
OwnPtr<WSWindow> m_window;
WSCPUMonitor m_cpu_monitor;
String m_username;
Vector<WeakPtr<WSMenu>> m_open_menu_stack;
};