Commit Graph

51 Commits

Author SHA1 Message Date
Ali Mohammad Pur
5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
Kemal Zebari
771467f92f LibGUI: Fix debug line causing crash when drag event has no mime data
Resolves #10618.
2023-12-13 17:26:41 -05:00
Ali Mohammad Pur
aeee98b3a1 AK+Everywhere: Remove the null state of DeprecatedString
This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>

Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
2023-10-13 18:33:21 +03:30
Adam Harald Jørgensen
258af88b29 LibGUI: Fix search highlighting so that it matches the search query
There is a bug in the "search by typing" feature of
AbstractView, where the highlighted text shown in items' title won't
match the search query if the search query contains whitespace.
This commit fixes that bug.

The bug is caused by a bad assumption made in
AbstractView::draw_item_text about the Painter::draw_text API.
Specifically that the function passed to it will be called for each
code point of the string instead of for each drawable glyph.

This is fixed by not relying on looking at the length of the highlight
string, but instead looking at its content.
2023-08-26 09:09:47 -04:00
Andreas Kling
ddbe6bd7b4 Userland: Rename Core::Object to Core::EventReceiver
This is a more precise description of what this class actually does.
2023-08-06 20:39:51 +02:00
thankyouverycool
aaf60053f1 LibGUI: Use ColorRole::DisabledText when AbstractView is disabled
And only paint GlyphMapWidget's frame if disabled
2023-05-13 12:53:49 +02:00
thankyouverycool
207409c925 LibGUI: Don't hover AbstractView indicies outside visible content
Fixes ComboBox ListView erroneously setting and scrolling to
indicies just outside its inner rect when mousing along the
bottom or top of the frame.
2023-04-04 19:15:15 +02:00
Andreas Kling
faa1a09042 LibGUI: Fix const-correctness issues 2023-02-21 00:54:04 +01:00
MacDue
a1726b1ba5 LibGfx: Avoid rounding/truncating glyph positions till blitting
This keeps some overloads that accept ints to avoid adding calls to
.to_type<float>() all over the place.
2023-01-05 12:09:35 +01:00
Aayush
7a4b912ece LibGUI: Fix invalid ModelIndices during shift-click multiselection
Previously, If the widget was unfocused, the selection start index
would be invalid. This would result in invalid selections when doing
shift+click on the widget (while it is unfocused).

Now, we reassign the selection start index to current index
before we initiate multiselection, if selection start index is invalid.

Should Fix SerenityOS#11999 and the same bug inside FileManager.
2022-12-31 00:08:35 +01:00
Jelle Raaijmakers
7b0adee487 LibGfx+Overall: Remove is_null from Point, Rect and Size
Having a `Point`, `Rect` or `Size` claim it's `null` is silly. We have
`Optional<T>` for that. For `Point`, rename `is_null` to `is_zero` to
better reflect what we're testing. For `Rect` and `Size`, `is_null` is
removed outright.

Also, remove `is_empty` from `Point`. Points can't be empty.
2022-12-28 22:32:21 -05:00
thankyouverycool
d938b9effe LibGUI+Applications: Rename automatic scrolling timer functions
Renames on_automatic_scrolling_timer_fired() =>
	automatic_scrolling_timer_did_fire()

The 'on_' prefix is usually reserved for AK::Function hooks.

Renames set_automatic_scrolling_{active,timer}() =>
	set_automatic_scrolling_timer_active()

For consistency, accuracy, and header file A E S T H E T I C S
2022-12-26 09:27:19 +01:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Karol Kosek
a0ef00cab2 LibGUI: Don't accept drag events in AbstractView if it's not editable
With a new DragCopy cursor icon being used on accepted events, this
caused a 'false assumption' that everything can be dropped into
AbstractView.

This will now only happen if the View is editable, which still isn't
perfect, but at least the Settings app will no longer change cursors.
Also note that we won't get "drag move" events as the comment below
says, which disables automatic scrolling when dragging an element.
2022-08-31 17:29:44 +01:00
Matthew B. Jones
79a5a1c209 LibGUI: Correct cursor index during mouseup_event
Previously, during a m_might_drag mouse_up event, we were updating
the selection directly, which caused the selection to be accurate
but the location of the cursor index to be stale/incorrect. The
side effect of this is then future events may point to the wrong
index.

Instead, call the set_cursor function with SelectionUpdate::Set,
which handles both updating the cursor index as well as the
selection index.
2022-08-08 16:41:36 -04:00
networkException
30d68d71b4 LibGUI: Move range selection calculations into separate function
AbstractView currently assumes a certain layout of rows and colums to
perform a range selection on.

This patch moves the implementation into a helper that can be overriden
by other views.
2022-07-24 13:40:31 +01:00
kleines Filmröllchen
fc6ffbc006 LibGUI: Register many properties of AbstractView 2022-04-06 12:47:50 +02:00
Vrins
4b4ee95cdb LibGUI: Set cursor when using highlighted_search in abstractview
Previously using the highlighted_search would not set the cursor
to the item found by the search. This results in some unfamiliar
behavior such as jumping back up to the previously selected element,
before searching, when using the arrow keys to navigate.
2022-03-15 20:00:09 +01:00
Linus Groh
cab032f1ee LibGfx+LibGUI: Support multi code point emojis in text painting :^)
This necessitates switching from passing a single code point to the
callback to passing a non-const Utf8CodePointIterator instead.

Note that the text selection mechanisms in LibGUI and LibWeb don't
handle this properly yet; they still assume that each code point
renders as one glyph. Similarly, width calculations for text widths
don't either, so a single such an emoji will require space for more
than one glyph.

It also doesn't work in LibVT's TerminalWidget, where each code point
is handled and rendered separately, so LibGfx never gets a chance to
check if subsequent code points could result in a combined emoji.
2022-02-23 21:53:30 +00:00
kleines Filmröllchen
145eeb57ab Userland: Remove a bunch of unnecessary Vector imports
How silly :^)
2022-01-28 23:40:25 +01:00
Marcus Nilsson
4459cb33ed LibGUI+AK: Add DRAG_DEBUG opt and put drag operations behind dbgln_if
No need to have this enabled all the time.
2022-01-10 14:23:04 +01:00
Andreas Kling
2375e1bcda LibGUI: Rename ModelSelection::remove_matching => remove_all_matching
Let's be consistent with how Vector, HashTable and HashMap names these.
2022-01-05 18:57:14 +01:00
Elyse
d53e1fa1fa Everywhere: Use 'increase_slider_by()' method from AbstractSlider
This method help us to avoid repeating the pattern
'set_value(value() + delta)'.
2021-12-30 14:31:50 +01:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Filiph Sandström
d6a0726302 Everywhere: Rename left/right-click to primary/secondary
This resolves #10641.
2021-10-27 22:05:58 +03:00
Marcus Nilsson
d660e86d13 LibGUI: Implement automatic scrolling in AbstractView
This adds automatic scrolling when dragging items in TreeViews and other
widgets that inherit from AbstractView when the overloaded
accepts_drag() returns true. This is implemented in FileSystemModel to
allow directories and files to be dragged.
2021-09-29 23:58:55 +02:00
Dawid Wolosowicz
484b9c1ba3 LibGUI: West Const to East Const refactor 2021-09-08 15:48:02 +04:30
Dawid Wolosowicz
8419eef85e LibGUI: Sync the highlighting after each model update
Without this, the highlighting would stay on the initial index even if
the matching row is no longer there.
2021-09-08 15:48:02 +04:30
Dawid Wolosowicz
d0e44993a1 LibGUI: Refactor AbstractView::do_search() into two standalone steps
This change splits the do_search() into find_next_search_match() and
highlight_search() to allow the given index be independently highlighted
when needed.
2021-09-08 15:48:02 +04:30
Dawid Wolosowicz
cc93736f21 LibGUI: Remove barely used AbstractView::is_searching() 2021-09-08 15:48:02 +04:30
Dawid Wolosowicz
b775b1c199 LibGUI: Unify naming of searching timer related members 2021-09-08 15:48:02 +04:30
Dawid Wolosowicz
9225b45c2d LibGUI: Rename AbstractView::m_searching => m_highlighted_search 2021-09-08 15:48:02 +04:30
Dawid Wolosowicz
aeffd9024e LibGUI: Remove barely used AbstractView::is_highlighting_searching() 2021-09-08 15:48:02 +04:30
Dawid Wolosowicz
0cbc222c17 LibGUI: Remove barely used AbstractView::searching() 2021-09-08 15:48:02 +04:30
Marcus Nilsson
0583f75926 LibGUI: Dynamically resize editing content rect in IconView
This makes IconView aware of the text width of the
ModelEditingDelegate widget when editing an index and allows us to
resize the content rect as needed.

This also removes the border from the textbox since it could collide
with the icon in ColumnsView. While editing we also skip painting the
inactive selection rect since it would otherwise show when the content
rect gets smaller.
2021-09-06 17:38:26 +02:00
sin-ack
16ac3bbfd7 LibGUI+Applications: Rename Model::is_valid to is_within_range
The previous name did not describe what the function checked, and was
easy to confuse with ModelIndex::is_valid.
2021-08-06 21:03:53 +02:00
Andreas Kling
b368560800 LibGUI: Only repaint the affected indices on AbstractView item hover
Previously, moving the cursor over items in an item view would cause it
to repaint itself completely. Now we only repaint the two affected
items (the old hovered item and the new hovered item.)
2021-07-10 18:30:46 +02:00
Andreas Kling
148e72bfa0 LibGUI: Add AbstractView::editing_rect() to allow custom editing rects
This allows view classes to customize the editing rect for an index.
2021-07-10 18:30:46 +02:00
Andreas Kling
bac200885c LibGUI: Don't restart AbstractView drag on mousemove after escape key
Previously, if a drag operation was aborted by pressing the escape key
(handled by WindowServer), the drag would immediately restart if you
moved the mouse cursor before releasing the mouse button.
2021-06-18 17:40:05 +02:00
Matthew B. Jones
e7cfa9bf8e
LibGUI: Properly wrap multiple lines in IconView search highlighting 2021-06-03 08:32:31 +01:00
Jelle Raaijmakers
2c772d1848 LibGUI/AbstractView: Remove on_selection
Since the introduction of multi-select, we have had both `on_selection`
and `on_selection_change`, the latter of which was only invoked when a
change in selection came in through the model.

This removes `AbstractView::on_selection` and replaces it usage with
the more explicit `on_selection_change` everywhere.
2021-05-26 17:39:13 +04:30
Jelle Raaijmakers
dbbc583860 LibGUI/AbstractView: Expose activates_on_selection 2021-05-24 23:31:42 +04:30
Andreas Kling
d47f15ab8b LibGUI: Rename ScrollableWidget => AbstractScrollableWidget 2021-05-03 21:03:13 +02:00
Andreas Kling
3d4afe7614 Everywhere: "indexes" => "indices"
I've wasted a silly amount of time in the past fretting over which
of these words to use. Let's just choose one and use it everywhere. :^)
2021-04-29 22:23:52 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
iCristalrope
8bb4409a5d
LibGUI: Track selection starting index in AbstractView (#6515)
Modifying the selection while holding the shift button and selecting
with the mouse or the arrow keys no longer results in broken selections.

Fixes #6279.
2021-04-21 17:09:04 +02:00
Andreas Kling
a2baab38fd Everywhere: It's now "Foobar", not "FooBar", and not "foo bar"
I hereby declare these to be full nouns that we don't split,
neither by space, nor by underscore:

- Breadcrumbbar
- Coolbar
- Menubar
- Progressbar
- Scrollbar
- Statusbar
- Taskbar
- Toolbar

This patch makes everything consistent by replacing every other variant
of these with the proper one. :^)
2021-04-13 16:58:15 +02:00
Tom
6cdb657493 LibGUI: Improve IconView rubberband performance
Rather than invalidating the entire window, which is very expensive on
the transparent desktop widget, just invalidate the areas that actually
need updating.
2021-02-25 18:04:06 +01:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Andreas Kling
4853576db7 LibGUI: Ignore keydown events with Alt modifier in AbstractView
AbstractView doesn't actually do anything with them anyway, but they
would get swallowed by the cursor logic and not bubble up the widget
parent chain.
2021-02-20 13:27:21 +01:00