mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +00:00
LibGUI: Add AbstractView::move_cursor() and share some movement logic
A view can now be told to move its cursor in one of multiple directions as specified by the CursorMovement enum. View subclasses can override move_cursor(CursorMovement) to implement their own cursor behavior. By default, AbstractView::move_cursor() is a no-op. This patch improves code sharing between TableView and TreeView. :^)
This commit is contained in:
parent
1b3169f405
commit
0b9d765f6b
7 changed files with 154 additions and 55 deletions
|
@ -33,9 +33,22 @@
|
|||
namespace GUI {
|
||||
|
||||
class AbstractView : public ScrollableWidget {
|
||||
C_OBJECT_ABSTRACT(AbstractView)
|
||||
C_OBJECT_ABSTRACT(AbstractView);
|
||||
|
||||
public:
|
||||
enum class CursorMovement {
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right,
|
||||
Home,
|
||||
End,
|
||||
PageUp,
|
||||
PageDown,
|
||||
};
|
||||
|
||||
virtual void move_cursor(CursorMovement) { }
|
||||
|
||||
void set_model(RefPtr<Model>);
|
||||
Model* model() { return m_model.ptr(); }
|
||||
const Model* model() const { return m_model.ptr(); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue