mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:38:12 +00:00
LibGUI: Add a cursor to AbstractView, separate from the selection
Views now have a cursor index (retrievable via cursor_index()) which is separate from the selection. Until now, we've been using the first entry in the selection as "the cursor", which gets messy whenever you want to select more than one index in the model. When setting the cursor, the selection is implicitly updated as well to maintain the old behavior (for the most part.) Going forward, this will make it much easier to implement things like shift-select (extend selection from cursor) and such. :^)
This commit is contained in:
parent
76a0acb5bc
commit
9cf37901cd
8 changed files with 79 additions and 49 deletions
|
@ -68,16 +68,17 @@ public:
|
|||
Gfx::IntRect content_rect(int row, int column) const;
|
||||
Gfx::IntRect row_rect(int item_index) const;
|
||||
|
||||
void scroll_into_view(const ModelIndex&, Orientation);
|
||||
void scroll_into_view(const ModelIndex&, bool scroll_horizontally, bool scroll_vertically);
|
||||
virtual void scroll_into_view(const ModelIndex&, bool scroll_horizontally = true, bool scroll_vertically = true) override;
|
||||
void scroll_into_view(const ModelIndex& index, Orientation orientation)
|
||||
{
|
||||
scroll_into_view(index, orientation == Gfx::Orientation::Horizontal, orientation == Gfx::Orientation::Vertical);
|
||||
}
|
||||
|
||||
virtual ModelIndex index_at_event_position(const Gfx::IntPoint&, bool& is_toggle) const;
|
||||
virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override;
|
||||
|
||||
virtual void select_all() override;
|
||||
|
||||
void move_selection(int vertical_steps, int horizontal_steps);
|
||||
|
||||
void header_did_change_section_visibility(Badge<HeaderView>, Gfx::Orientation, int section, bool visible);
|
||||
void header_did_change_section_size(Badge<HeaderView>, Gfx::Orientation, int section, int size);
|
||||
|
||||
|
@ -109,6 +110,8 @@ protected:
|
|||
|
||||
TableCellPaintingDelegate* column_painting_delegate(int column) const;
|
||||
|
||||
void move_cursor_relative(int vertical_steps, int horizontal_steps, SelectionUpdate);
|
||||
|
||||
private:
|
||||
void layout_headers();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue