Commit graph

21 commits

Author SHA1 Message Date
Andreas Kling
9cf37901cd 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. :^)
2020-08-27 18:36:31 +02:00
Andreas Kling
0b9d765f6b 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. :^)
2020-08-27 17:47:19 +02:00
Andreas Kling
55f7ddfb8c LibGUI: Don't make views sort by column 0 by default
If you want to sort by some column, you can tell the view which one.
2020-08-27 10:37:31 +02:00
Andreas Kling
44e371635e LibGUI: Move table view headers into their own widget
This patch introduces the HeaderView class, which is a widget that
implements the column headers of TableView and TreeView.

This greatly simplifies event management in the view implementations
and also makes it much easier to eventually implement row headers.
2020-08-26 00:51:35 +02:00
Andreas Kling
f86c074be8 LibGUI: Pressing Return in an editable TableView should begin editing
This matches what happens when you double-click on a cell.
2020-08-24 21:20:54 +02:00
Andreas Kling
e1ed71ef9e LibGUI: Make model sorting imperative and move order to AbstractView
Instead of SortingProxyModel having a column+order, we move that state
to AbstractView. When you click on a column header, the view tells the
model to resort the relevant column with the new order.

This is implemented in SortingProxyModel by simply walking all the
reified source/proxy mappings and resorting their row indexes.
2020-08-16 16:44:09 +02:00
thankyouverycool
6a78db07f1 LibGUI: Add hover highlighting and keyboard controls to ComboBox
Adds a new highlighting effect to the actively selected row in
ComboBox ListView. ComboBoxEditor can now be controlled with
page up, page down, and the up and down arrow keys. ESC and loss
of focus now cause comboboxes to close. Now activates on mouseup
as well as return.
2020-07-15 13:19:44 +02:00
Tom
d4c6ae8263 LibGUI: Add ability to disable multiselect for views 2020-07-13 19:49:34 +02:00
Tom
f266f0e880 LibGUI: Improve IconView performance with large selections
This implements the following optimizations:

* Rather than clearing a HashTable of selected items and re-populating
  it every time the selection rectangle changes, determine the delta
  by only examining the items that might be in the area where the
  selection may have changed compared to the previous area. Then
  only add/remove selection items as needed.

* When painting, only query and paint the items actually visible.
  Also, keep a local cache of item information such as calculated
  rectangles and selection state, so it doesn't have to be calculated
  over and over again.
2020-07-13 19:49:34 +02:00
Andreas Kling
116cf92156 LibGfx: Rename Rect,Point,Size => IntRect,IntPoint,IntSize
This fits nicer with FloatRect,FloatPoint,FloatSize and gives a much
better visual clue about what type of metric is being used.
2020-06-10 10:59:04 +02:00
Ben Wiederhake
55ff392835 LibGUI: Remove unneeded access rights 2020-05-02 14:12:36 +02:00
Andreas Kling
8e4751a963 LibGUI: Add a way for models to update without invalidating indexes
This is really just a workaround to keep SystemMonitor's process table
working right wrt selection retention during resorts (while also doing
full index invalidation on things like ProfileViewer inversion.)

It's starting to feel like the model abstraction is not super great
and we'll need a better approach if we want to actually build some more
dynamic functionality into our views.
2020-04-12 12:03:33 +02:00
Andreas Kling
031d242e0e LibGUI: Clear any hovered index when the cursor leaves an AbstractView 2020-04-03 21:14:34 +02:00
Andreas Kling
b4fde72013 LibGUI: Brighten icons when hovering items in item views
View classes now track their hovered item and paint them in a slightly
brighter shade to liven up the user interface. :^)
2020-03-30 19:57:44 +02:00
DAlperin
8e1645423f
LibGUI: Make descendants of AbstractView define their own select_all() (#1201)
AbstractView does not know which column it's displaying which makes it
impossible to implement the select_all functionality up there. Now
descendants override the pure virtual select_all method and implement
it themselves.
2020-02-25 16:03:15 +01:00
Andreas Kling
bc64f8c502 LibGUI: Make AbstractView::set_model() take a RefPtr<Model>
Let's face it: Taking RefPtr<T>&& arguments is obnoxious and puts too
much unnecessary burden on the caller.
2020-02-24 20:47:16 +01:00
Andreas Kling
c5d913970a LibGUI: Remove parent parameter to GUI::Widget constructor 2020-02-23 12:27:53 +01:00
Andreas Kling
428582e805 LibGUI: Don't require passing a parent to widget constructors
This is a step towards using Core::Object::add<T> more, which takes
care of parenting the newly created child automatically.
2020-02-23 11:10:52 +01:00
Andreas Kling
2143da6434 LibGUI: Add forwarding header
This patch adds <LibGUI/Forward.h> and uses it a bunch.
It also dragged various header dependency reduction changes into it.
2020-02-16 09:41:56 +01:00
Andreas Kling
f0ae353c9e LibGUI: Allow dropping drags on AbstractView
You can now drop things on an AbstractView, which will ask its model if
the drag is acceptable to drop at the index where it's dropped.

If it's accepted by the model, the view will fire the on_drop hook.
2020-02-13 21:49:14 +01:00
Andreas Kling
6a9cc66b97 LibGUI: Remove leading G from filenames 2020-02-06 20:33:02 +01:00
Renamed from Libraries/LibGUI/GAbstractView.h (Browse further)