Commit graph

1502 commits

Author SHA1 Message Date
Tim Ledbetter
c63f70d0fd LibGUI: Allow clipboard items to have no associated data 2023-02-19 01:35:29 +01:00
Sam Atkins
5b77346f53 LibGUI: Allow double-clicking PathBreadcrumbbar buttons to edit path
When viewing a deeply nested path, there may be very little of the
PathBreadcrumbbar itself visible to double-click on. This solves that
by allowing double-clicks on its segment buttons to behave the same.
(With the caveat that it first selects the double-clicked segment.)

In order to make this work, `on_double_click` now takes the modifiers
instead of the MouseEvent. In this case we don't use it so that's fine,
but maybe we should make all mouse callbacks consistently take the
MouseEvent& as a parameter.
2023-02-19 01:09:09 +01:00
Sam Atkins
8f717927f2 LibGUI: Add Button double-click callback 2023-02-19 01:09:09 +01:00
Sam Atkins
f0c2dcdbac LibGUI: Add PathBreadcrumbbar
This Widget wraps both a Breadcrumbbar and a TextBox for editing the
path manually, based heavily on the existing code in FileManager.

Breadcrumbbar itself requires outside code to micro-manage what it does.
This class provides a simpler interface for it: Users don't have to
worry about segments, they just give/receive a string for the current
path.
2023-02-19 01:09:09 +01:00
Sam Atkins
f5cf41eb5d LibGUI+FileManager: Move has_{parent,child}_segment logic into BCB 2023-02-19 01:09:09 +01:00
Sam Atkins
6b66e39df4 LibGUI+Userland: Stop returning Layout from Widget::(try_)set_layout()
Nobody uses this return value any more. It also lets us remove a whole
bunch of `(void)` casts. :^)
2023-02-18 16:56:56 +00:00
Sam Atkins
77ad0fdb07 Userland: Specify margins and spacing in the GUI::Layout constructor 2023-02-18 16:56:56 +00:00
Sam Atkins
9561ec15f4 Userland: Use Widget::add_spacer() everywhere 2023-02-18 16:56:56 +00:00
Sam Atkins
43dddafd16 LibGUI: Allow specifying Layout margins and spacing in the constructor
This is comfier than `my_widget->layout()->set_margins(...)`.
2023-02-18 16:56:56 +00:00
Sam Atkins
ab6ef53247 LibGUI: Add Widget::add_spacer() wrapper
This just calls Layout::try_add_spacer(), but saves you having to access
the Widget's Layout directly.

We verify that the Widget has a Layout, since it would be a programming
error if we tried to do so without one.
2023-02-18 16:56:56 +00:00
Timothy Flynn
8a94c7a7f7 LibGUI: Skip over grapheme clusters on left/right arrow key presses
Currently, if you use the left/right arrow keys to move over a multi-
code point glyph, we will move through that glyph one code point at a
time. This means you can "pause" your movement in the middle of a glyph
and delete a subsection of a grapheme cluster. This now moves the cursor
across the entire cluster.

Visually, we will need to separately track physical and virtual cursor
positions. That is, when you move across a multi-code point glyph, the
visual cursor should only move one position at a time, while a physical
cursor stores the "real" position in terms of number of code points.

This also converts a couple of ints to auto - these are actually size_t,
and are being passed to functions that expect size_t, so let's not cast
them to ints.
2023-02-18 16:54:46 +01:00
FrHun
30309bac1b LibGUI: Force re-layout on Frame thickness changes 2023-02-17 16:25:57 +00:00
FrHun
cb872f5c9a LibGUI: Adjust OpacitySlider min size for consistency
22 is the size usually used for default widget height, like Buttons and
Labels.
2023-02-17 16:25:57 +00:00
FrHun
f1271c7860 LibGUI: Use calculated_preferred_size for Progressbar default size 2023-02-17 16:25:57 +00:00
FrHun
6d79d932f9 LibGUI: Implement calculated sizes for Slider 2023-02-17 16:25:57 +00:00
FrHun
caf6dd5680 LibGUI: Implement calculated sizes for ValueSlider 2023-02-17 16:25:57 +00:00
FrHun
b6d45f9c1f LibGUI: Use calculated_preferred_size in SeparatorWidget 2023-02-17 16:25:57 +00:00
Fausto Tommasi
f7458b3e17 LibGUI: Update TextEditor to delete emoji based on gbp cluster
Updated TextDocument and TextEditor to use calls to
`find_grapheme_segmentation_boundary` in order to make "correct-feeling"
deletions on backspace and delete keys being pressed
2023-02-17 07:50:09 -05:00
Cameron Youell
cb96c892cc LibGUI: Add highlighting to UrlBox 2023-02-16 10:47:22 +00:00
Cameron Youell
dad70d8d6e LibGUI: Account for glyph_spacing() in spans 2023-02-16 10:47:22 +00:00
Timothy Flynn
4ab7216827 LibGUI: Use Unicode's text segmentation for traversing word breaks
Note that for traversing words with ctrl+(left or right arrow) on the
keyboard, we want to "skip" some boundaries. Consider the text:

    The ("quick") fox can't jump 32.3 feet, right?

Using "|" to denote word break boundaries, we will have:

    |The| |(|"|quick|"|)| |fox| |can't| |jump| |32.3| |feet|,| |right|?|

When starting at "The" and using ctrl+right to move rightward in this
text, it is unlikely that users will want to break at every single one
of those boundaries. Most text editors, for example, will skip from the
end of "The" to the end of "quick", not breaking at the parentheses or
opening quotation marks.

We try to mimic such desired behavior here. It likely isn't perfect, but
we can improve upon it as we find edge cases.
2023-02-15 12:36:47 +01:00
Sam Atkins
2dc1682274 LibGUI: Take gutter into account when measuring TextEditor content area 2023-02-13 16:54:56 +00:00
Sam Atkins
6905622b41 LibGUI: Don't show caret cursor when hovering TextEditor's gutter 2023-02-13 16:54:56 +00:00
Sam Atkins
69333e5dbd LibGUI: Combine wrapping/non-wrapping TextEditor code paths
The `is_wrapping_enabled()` paths function just fine when wrapping is
disabled. We already calculate `m_line_visual_data`. The only reason to
use a special path is for speed, since you can skip some steps if you
know each line is only 1 line high visually.

However, with code-folding being added, we can't make assumptions about
line height because a line could be hidden and have an effective height
of 0px. So `text_position_at_content_position()` always needs to loop
through the lines to see what our position is, and that function always
needs to be called to calculate the real position.
2023-02-13 16:54:56 +00:00
Sam Atkins
7aef096f85 LibGUI: Fix typo in span_consumed variable 2023-02-13 16:54:56 +00:00
Tim Schumacher
874c7bba28 LibCore: Remove Stream.h 2023-02-13 00:50:07 +00:00
Tim Schumacher
606a3982f3 LibCore: Move Stream-based file into the Core namespace 2023-02-13 00:50:07 +00:00
Tim Schumacher
a96339b72b LibCore: Move Stream-based sockets into the Core namespace 2023-02-13 00:50:07 +00:00
Tim Schumacher
d43a7eae54 LibCore: Rename File to DeprecatedFile
As usual, this removes many unused includes and moves used includes
further down the chain.
2023-02-13 00:50:07 +00:00
Karol Kosek
14951b92ca LibGUI: Remove deprecated text and set_text functions in AbstractButton
This moves the functions to lambda when registering a property.
External code can now only communicate using the new String API.
2023-02-13 00:45:09 +00:00
Karol Kosek
e39adc4772 Userland: Set Button text using the new String class 2023-02-13 00:45:09 +00:00
Karol Kosek
b5cb9a9ebb LibGUI+TaskBar: Make Calendar::formatted_date() return ErrorOr<String>
This commit introduces no error propagation.
2023-02-13 00:45:09 +00:00
Karol Kosek
d32d4029d3 Userland: Replace usages of AbstractButton::text_deprecated with text() 2023-02-13 00:45:09 +00:00
Karol Kosek
fca29eae09 LibGUI: Store text using the new String class in the AbstractButton
This change also adds non-deprecated text() and set_text() functions and
helper constructors for Button, CheckBox, and RadioButton to call the
strings directly.

The whole codebase at this point is still using the deprecated string
functions, which the class will quietly convert to a new String.
2023-02-13 00:45:09 +00:00
Karol Kosek
d32b052f22 LibGUI+Userland: Add _deprecated suffix to AbstractButton::{set_,}text 2023-02-13 00:45:09 +00:00
Karol Kosek
61b49daf0a LibGUI: Make Clipboard::set_plain_text take text as a StringView 2023-02-13 00:45:09 +00:00
Karol Kosek
67ffc687d8 LibGUI+PixelPaint: Port GUI::ValueSlider's suffix to the new String 2023-02-13 00:26:39 +00:00
Zaggy1024
0c230f5ff0 LibGUI: Callback with the clamped value of Sliders on a jump to cursor 2023-02-12 09:53:05 +01:00
Lucas CHOLLET
db80425a65 LibGUI: Remove the Core::File overload of write_to_file()
One less usage of `Core::File`, yay!
2023-02-11 14:20:26 +00:00
Lucas CHOLLET
107e15c5bc LibGUI: Base write_to_file(StringView path) on the stream overload
`write_to_file(StringView path)` was based on the `Core::File` overload.
The return type also changed from `bool` to `ErrorOr<void>` to ease
error propagation.
2023-02-11 14:20:26 +00:00
Tim Ledbetter
59855e49df LibGUI: Add a DontResizeColumns option to Model::UpdateFlag
This allows an application to signal that column sizes do not
need to be recalculated for a given model update.
2023-02-10 05:12:06 +03:30
Tim Ledbetter
99570cb0c4 LibGUI: Speed up Variant string conversion for string data
Add a fast path to Variant::to_deprecated_string() to return a copy
if the underlying data is of type DeprecatedString. This improves the
performance of models with a lot of string data.
2023-02-10 05:12:06 +03:30
MacDue
63b11030f0 Everywhere: Use ReadonlySpan<T> instead of Span<T const> 2023-02-08 19:15:45 +00:00
Tim Schumacher
6ea3c1659a LibGfx: Propagate errors from serializing bitmaps
We essentially just end up moving `release_value_but_fixme_...` one
layer down, but it makes adding more fallible operations in the
serialization function more comfortable.
2023-02-08 18:50:43 +00:00
Andreas Kling
2bc8cbfe8f LibGUI: Add 9 and 11 to the list of suggested sizes in FontPicker 2023-02-07 17:01:55 +01:00
Zaggy1024
d9a73bbc96 LibGUI: Add callbacks for Slider drags starting and ending 2023-02-07 14:36:58 +00:00
Zaggy1024
fa98c43c0d LibGUI: Make sliders start a drag when jumping to the cursor
This allows users to seek to any position in VideoPlayer, then continue
adjusting the playback timestamp while holding left mouse.
2023-02-07 14:36:58 +00:00
Sam Atkins
89b8d346fe LibGUI+About: Make AboutDialog creation fallible 2023-02-07 10:43:15 +00:00
Sam Atkins
65c8dfe923 LibGUI: Convert AboutDialog layout to GML 2023-02-07 10:43:15 +00:00
Arda Cinar
1ef410eb79 LibGUI: Handle utf-8 search strings in find
Similar to LibVT, we were iterating over needle bytes instead of code
points. This patch allows finding unicode substrings in a text document.
2023-02-05 13:50:38 +01:00