From b8cc18896f3fe912b46051ae99c0981f291f96db Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Sat, 19 Mar 2022 13:29:55 -0400 Subject: LibGUI+FontEditor: Add context menu for editor actions GlyphMapWidget now reports context menu requests when secondary clicking the map. This also adds a new Select All action and updates the Copy Character action to work on multi-glyph selections. Glyph navigation actions have been moved to a separate Go menu, as is common in other apps. --- Userland/Libraries/LibGUI/GlyphMapWidget.cpp | 12 ++++++++++++ Userland/Libraries/LibGUI/GlyphMapWidget.h | 2 ++ 2 files changed, 14 insertions(+) (limited to 'Userland/Libraries') diff --git a/Userland/Libraries/LibGUI/GlyphMapWidget.cpp b/Userland/Libraries/LibGUI/GlyphMapWidget.cpp index b529f7c7df..2ae04e1325 100644 --- a/Userland/Libraries/LibGUI/GlyphMapWidget.cpp +++ b/Userland/Libraries/LibGUI/GlyphMapWidget.cpp @@ -182,8 +182,17 @@ int GlyphMapWidget::glyph_at_position_clamped(Gfx::IntPoint position) const return glyph; } +void GlyphMapWidget::context_menu_event(GUI::ContextMenuEvent& event) +{ + if (on_context_menu_request) + on_context_menu_request(event); +} + void GlyphMapWidget::mousedown_event(MouseEvent& event) { + if (event.button() == MouseButton::Secondary) + return; + if (auto maybe_glyph = glyph_at_position(event.position()); maybe_glyph.has_value()) { auto glyph = maybe_glyph.value(); if (event.shift()) @@ -196,6 +205,9 @@ void GlyphMapWidget::mousedown_event(MouseEvent& event) void GlyphMapWidget::mouseup_event(GUI::MouseEvent& event) { + if (event.button() == MouseButton::Secondary) + return; + if (!m_in_drag_select) return; auto constrained = event.position().constrained(widget_inner_rect()); diff --git a/Userland/Libraries/LibGUI/GlyphMapWidget.h b/Userland/Libraries/LibGUI/GlyphMapWidget.h index 66afecf806..d72a2345de 100644 --- a/Userland/Libraries/LibGUI/GlyphMapWidget.h +++ b/Userland/Libraries/LibGUI/GlyphMapWidget.h @@ -68,6 +68,7 @@ public: Function on_active_glyph_changed; Function on_glyph_double_clicked; + Function on_context_menu_request; private: GlyphMapWidget(); @@ -79,6 +80,7 @@ private: virtual void keydown_event(KeyEvent&) override; virtual void resize_event(ResizeEvent&) override; virtual void did_change_font() override; + virtual void context_menu_event(ContextMenuEvent&) override; Gfx::IntRect get_outer_rect(int glyph) const; Optional glyph_at_position(Gfx::IntPoint) const; -- cgit v1.2.3