1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:48:12 +00:00
serenity/Servers/WindowServer/WSMenuManager.h
Andreas Kling df129bbe0e WindowServer+CPUGraph: Make menu applets be "regular" windows
Instead of implementing menu applets as their own thing, they are now
WSWindows of WSWindowType::MenuApplet.

This makes it much easier to work with them on the client side, since
you can just create a GWindow with the right type and you're in the
menubar doing applet stuff :^)
2019-12-16 15:05:45 +01:00

75 lines
1.8 KiB
C++

#pragma once
#include "WSMenu.h"
#include <LibCore/CObject.h>
#include <LibCore/CTimer.h>
#include <WindowServer/WSWindow.h>
class AClientConnection;
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; }
Rect menubar_rect() const;
static int menubar_menu_margin() { return 16; }
void set_needs_window_resize();
WSMenu* current_menu() { return m_current_menu.ptr(); }
void set_current_menu(WSMenu*, bool is_submenu = false);
void close_bar();
void close_everyone();
void close_everyone_not_in_lineage(WSMenu&);
void close_menu_and_descendants(WSMenu&);
void add_applet(WSWindow&);
void remove_applet(WSWindow&);
void invalidate_applet(const WSWindow&, const Rect&);
private:
void close_menus(const Vector<WSMenu*>&);
WSWindow& window() { return *m_window; }
const WSWindow& window() const { return *m_window; }
void handle_menu_mouse_event(WSMenu&, const WSMouseEvent&);
void draw();
void draw_applet(const WSWindow&);
void tick_clock();
RefPtr<WSWindow> m_window;
String m_username;
RefPtr<CTimer> m_timer;
WeakPtr<WSMenu> m_current_menu;
Vector<WeakPtr<WSMenu>> m_open_menu_stack;
RefPtr<GraphicsBitmap> m_muted_bitmap;
RefPtr<GraphicsBitmap> m_unmuted_bitmap;
Vector<WeakPtr<WSWindow>> m_applets;
OwnPtr<AClientConnection> m_audio_client;
Rect m_audio_rect;
Rect m_username_rect;
Rect m_time_rect;
bool m_needs_window_resize { false };
bool m_bar_open { false };
bool m_audio_muted { false };
};