1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 09:18:11 +00:00

WindowServer+LibGfx: Show menus in windows! :^)

This patch begins the transition away from the global menu towards
per-window menus instead.

The global menu looks neat, but has always felt clunky, and there
are a number of usability problems with it, especially in programs
with multiple windows.

You can now call GUI::Window::set_menubar() to add a menubar to
your window. It will be specific to that one window only.
This commit is contained in:
Andreas Kling 2021-03-25 21:01:19 +01:00
parent 1daaa4f38d
commit e76771bfad
21 changed files with 335 additions and 44 deletions

View file

@ -74,11 +74,15 @@ public:
callback(item);
}
Gfx::IntRect text_rect_in_menubar() const { return m_text_rect_in_menubar; }
void set_text_rect_in_menubar(const Gfx::IntRect& rect) { m_text_rect_in_menubar = rect; }
Gfx::IntRect text_rect_in_global_menubar() const { return m_text_rect_in_global_menubar; }
void set_text_rect_in_global_menubar(const Gfx::IntRect& rect) { m_text_rect_in_global_menubar = rect; }
Gfx::IntRect rect_in_global_menubar() const { return m_rect_in_global_menubar; }
void set_rect_in_global_menubar(const Gfx::IntRect& rect) { m_rect_in_global_menubar = rect; }
Gfx::IntRect rect_in_menubar() const { return m_rect_in_menubar; }
void set_rect_in_menubar(const Gfx::IntRect& rect) { m_rect_in_menubar = rect; }
Gfx::IntRect text_rect_in_window_menubar() const { return m_text_rect_in_window_menubar; }
void set_text_rect_in_window_menubar(const Gfx::IntRect& rect) { m_text_rect_in_window_menubar = rect; }
Gfx::IntRect rect_in_window_menubar() const { return m_rect_in_window_menubar; }
void set_rect_in_window_menubar(const Gfx::IntRect& rect) { m_rect_in_window_menubar = rect; }
Window* menu_window() { return m_menu_window.ptr(); }
Window& ensure_menu_window();
@ -149,8 +153,10 @@ private:
ClientConnection* m_client { nullptr };
int m_menu_id { 0 };
String m_name;
Gfx::IntRect m_rect_in_menubar;
Gfx::IntRect m_text_rect_in_menubar;
Gfx::IntRect m_rect_in_global_menubar;
Gfx::IntRect m_text_rect_in_global_menubar;
Gfx::IntRect m_rect_in_window_menubar;
Gfx::IntRect m_text_rect_in_window_menubar;
MenuBar* m_menubar { nullptr };
NonnullOwnPtrVector<MenuItem> m_items;
RefPtr<Window> m_menu_window;