Commit graph

26 commits

Author SHA1 Message Date
AmusedNetwork
de6483bcdb LibGUI: Set vertical distance between icons relative to scroll value
When calculating the vertical distance between icons, we should take
into account the value of the vertical scrollbar.

Fixes #4040
2020-11-11 15:14:09 +01:00
AmusedNetwork
eac0344ef0 LibGUI: Limit the height of item text in IconView
Set the max height of the text_rect to be the height difference
between two icons. Calculate the number of text lines that can be
displayed in this height, and display only that many.
2020-11-10 09:54:18 +01:00
Joseph Bywater
348cd0fdc1 LibGUI: Clip rubber band to IconView widget content area
Add a clip rect for the rubber band painter of widget_inner_rect
This ensures the rubber band is not drawn over the scrollbars.

Fixes #3926
2020-11-06 15:50:46 +01:00
Andreas Kling
d27a8e505f LibGUI: IconView was hard-coding column 0 instead of model_column()
Some of the indexes generated during cursor movement were using column
instead of model_column(), which caused inconsistent display of items
under the cursor.
2020-10-28 21:41:51 +01:00
Andreas Kling
5030f1ed4b LibGUI: Paint a focus rect around the cursor index in IconView
This makes the cursor actually visible to the user, and looks rather
neat if I may say so. :^)
2020-10-27 16:12:54 +01:00
Andreas Kling
272af7685b LibGUI: Improve and simplify IconView item name wrapping
Move the wrapping logic to get_item_rects(). This makes mouse events
able to hit the wrapped labels, and various other little things stop
glitching out as well.

Also, instead of having a per-line width when wrapping icon names,
make the text rect wide enough to fit every line.
2020-10-27 16:10:30 +01:00
Andreas Kling
4bc8768737 LibGUI: Tint selected icons in {Icon,Table,Columns}View
Add a gentle tint to selected icons based on the selection color. :^)
2020-10-26 21:32:27 +01:00
Andreas Kling
06a29e8aa5 LibGUI: Add some horizontal padding to multi-line IconView item titles
And don't use the padding from the item's text rect as extra space for
glyphs when breaking lines.
2020-10-23 09:44:56 +02:00
Andreas Kling
5b50174e5d LibGUI: Break IconView item titles into two lines if necessary
This is nice when long item titles don't fit. You can now hover them
(or select them) and we'll break the item text into two lines instead
of just one.

It might make sense to go even further in some cases. Perhaps when
hovering an item, we could show the full item text, painted above
all other items. That's something for a future patch.

It would also be nice if the text didn't jump back and forth when
going in and out of this mode. Also for a future patch.
2020-10-23 09:39:45 +02:00
Tom
52a847a0eb LibGUI: Implement searching/jumping as you type in views
This allows the user to start typing and highlighting and jumping
to a match in ColumnsView, IconView, TableView and TreeView if
the model supports it.
2020-10-22 15:23:45 +02:00
Andreas Kling
d3adbed231 LibGUI: Move keyboard item activation up to AbstractView
All views want the same behavior, so move this to the base class. :^)
2020-09-24 21:35:47 +02:00
Andreas Kling
f52527ef9c LibGUI: Move editing key handling up to AbstractView
We want all views to respond to the editing key as long as the relevant
edit trigger is activated.
2020-09-24 11:42:11 +02:00
Andreas Kling
ece555b684 LibGUI: Support inline editing in GUI::IconView
IconView now responds to the editing key (F2) if the view is editable.
It does feel a little bit weird to have content_rect() return the text
rect for an item, and not the whole item rect. This internal API could
probably be better.
2020-09-24 11:40:19 +02:00
Andreas Kling
27687b1c6e LibGUI: Handle cursor keydown events in AbstractView
Move the basic movement keys (up/down/left/right/home/end/pgup/pgdn)
up to AbstractView::keydown_event() and have it call the virtual
move_cursor() which is then implemented by subclasses.
2020-09-02 21:29:31 +02:00
Andreas Kling
27e86c03da LibGUI: Implement the virtual IconView::scroll_into_view()
This is virtual in AbstractView so let's not shadow it with an IconView
specific variant.
2020-09-01 16:17:17 +02:00
Andreas Kling
72443bd1ab LibGUI: Teach IconView to use AbstractView::move_cursor()
This makes it possible to manipulate the cursor programmatically via
the AbstractView interface.
2020-09-01 16:17:17 +02:00
Andreas Kling
9102b624ac LibGUI+DevTools+Applications: Use ModelIndex::data() in many places
This way you don't have to keep track of which model it came from.
2020-08-16 16:44:09 +02:00
Andreas Kling
a1e381a0f8 LibGUI: Move GUI::Model::Role to GUI::ModelRole
This is preparation for using ModelRole in the ModelIndex API.
2020-08-16 16:44:09 +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
Tom
d4b87fb18e LibGUI: Implement IconView auto-scrolling when trying to select items out of view
If selecting in a large icon view, and dragging the mouse outside
of the widget, or close to the border of it, start scrolling
automatically. This allows for selecting large amount of items
that exceed the amount that can be displayed.
2020-07-09 21:51:01 +02:00
Andreas Kling
d851863704 Userspace: Remove a bunch of unnecessary Kernel/API/KeyCode.h includes 2020-07-04 17:25:31 +02:00
Andreas Kling
11c4a28660 Kernel: Move headers intended for userspace use into Kernel/API/ 2020-07-04 17:22:23 +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
Andreas Kling
04187576ff LibGUI: Models should always specify font via Model::Role::Font
This gets rid of one field in ColumnData. The goal is to get rid of all
fields and lose ColumnData entirely.
2020-05-21 19:55:44 +02:00
Ben Wiederhake
ef433cb367 LibGUI: The UI calls it 'Icon view', fix the name in the code 2020-05-02 14:12:36 +02:00
Renamed from Libraries/LibGUI/ItemView.cpp (Browse further)