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.
This commit is contained in:
Thomas Symalla 2022-08-18 15:38:06 +02:00 committed by Andreas Kling
parent 299cebbbcb
commit 03e9697975
Notes: sideshowbarker 2024-07-19 17:04:13 +09:00
2 changed files with 14 additions and 0 deletions

View file

@ -28,6 +28,7 @@
#include <LibGfx/Font/Font.h>
#include <LibGfx/Font/FontDatabase.h>
#include <LibGfx/Palette.h>
#include <LibGfx/StandardCursor.h>
#include <LibSyntax/Highlighter.h>
#include <fcntl.h>
#include <stdio.h>
@ -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

View file

@ -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);