1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 09:47:35 +00:00

LibGUI: Refactor context menus to be event-driven instead of declarative.

The declarative approach had way too many limitations. This patch adds a
context menu event that can be hooked to prepare a custom context menu on
demand just-in-time. :^)
This commit is contained in:
Andreas Kling 2019-04-18 04:12:27 +02:00
parent e74b5bc054
commit a747a10eab
5 changed files with 37 additions and 27 deletions

View file

@ -29,6 +29,7 @@ public:
FocusIn,
FocusOut,
WindowCloseRequest,
ContextMenu,
WM_WindowRemoved,
WM_WindowStateChanged,
WM_WindowIconChanged,
@ -141,6 +142,23 @@ private:
Size m_size;
};
class GContextMenuEvent final : public GEvent {
public:
explicit GContextMenuEvent(const Point& position, const Point& screen_position)
: GEvent(GEvent::ContextMenu)
, m_position(position)
, m_screen_position(screen_position)
{
}
const Point& position() const { return m_position; }
const Point& screen_position() const { return m_screen_position; }
private:
Point m_position;
Point m_screen_position;
};
class GShowEvent final : public GEvent {
public:
GShowEvent()