From 03e969797557f93fb52f256ec2967494269186de Mon Sep 17 00:00:00 2001 From: Thomas Symalla Date: Thu, 18 Aug 2022 15:38:06 +0200 Subject: [PATCH] TextEditor: Change cursor when reaching the ruler area Noticed that mouse-overing the ruler area in the TextEditor does not change the cursor to the default cursor, instead, the beam cursor is used, which does not look nice. This PR extends the mousemove event and introduces a new set_editing_cursor() function that takes care of setting the cursor for the editor area. --- Userland/Libraries/LibGUI/TextEditor.cpp | 12 ++++++++++++ Userland/Libraries/LibGUI/TextEditor.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index 1d7fd1b251..cf2d80c8e9 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -310,6 +311,12 @@ void TextEditor::mousemove_event(MouseEvent& event) update(); return; } + + if (m_ruler_visible && (ruler_rect_in_inner_coordinates().contains(event.position()))) { + set_override_cursor(Gfx::StandardCursor::None); + } else { + set_editing_cursor(); + } } void TextEditor::select_current_line() @@ -1672,6 +1679,11 @@ void TextEditor::set_mode(const Mode mode) VERIFY_NOT_REACHED(); } + set_editing_cursor(); +} + +void TextEditor::set_editing_cursor() +{ if (!is_displayonly()) set_override_cursor(Gfx::StandardCursor::IBeam); else diff --git a/Userland/Libraries/LibGUI/TextEditor.h b/Userland/Libraries/LibGUI/TextEditor.h index 547ac759a3..fb1721f05c 100644 --- a/Userland/Libraries/LibGUI/TextEditor.h +++ b/Userland/Libraries/LibGUI/TextEditor.h @@ -95,6 +95,8 @@ public: bool is_displayonly() const { return m_mode == DisplayOnly; } void set_mode(const Mode); + void set_editing_cursor(); + bool is_ruler_visible() const { return m_ruler_visible; } void set_ruler_visible(bool);