blob: 6179011e4c0827ba72a4bca1e915e2bad5e7a46c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/*
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "Menu.h"
#include "Menubar.h"
#include "Window.h"
#include <AK/HashMap.h>
#include <AK/StringBuilder.h>
namespace WindowServer {
class MenuManager final : public Core::Object {
C_OBJECT(MenuManager);
public:
static MenuManager& the();
MenuManager();
virtual ~MenuManager() override;
bool is_open(const Menu&) const;
bool has_open_menu() const { return !m_open_menu_stack.is_empty(); }
Menu* current_menu() { return m_current_menu.ptr(); }
void set_current_menu(Menu*);
void clear_current_menu();
void open_menu(Menu&, bool as_current_menu = true);
void close_everyone();
void close_everyone_not_in_lineage(Menu&);
void close_menu_and_descendants(Menu&);
void close_all_menus_from_client(Badge<ClientConnection>, ClientConnection&);
int theme_index() const { return m_theme_index; }
Menu* previous_menu(Menu* current);
Menu* next_menu(Menu* current);
void did_change_theme();
void set_hovered_menu(Menu*);
Menu* hovered_menu() { return m_hovered_menu; }
private:
void close_menus(const Vector<Menu&>&);
virtual void event(Core::Event&) override;
void handle_mouse_event(MouseEvent&);
void refresh();
WeakPtr<Menu> m_current_menu;
WeakPtr<Window> m_previous_input_window;
Vector<WeakPtr<Menu>> m_open_menu_stack;
int m_theme_index { 0 };
WeakPtr<Menu> m_hovered_menu;
};
}
|