Commit graph

1551 commits

Author SHA1 Message Date
Linus Groh
e76394d96c AK: Remove infallible version of StringBuilder::to_byte_buffer
Also drop the try_ prefix from the fallible function, as it is no longer
needed to distinguish the two.
2023-03-09 15:51:00 +00:00
Linus Groh
ad5e8f2742 WebServer+LibGUI: Use fallible version of StringBuilder::to_byte_buffer
...and simply ignore the errors for now. This allows us to remove the
infallible function and avoid accumulating more callers of it.
2023-03-09 15:50:45 +00:00
Lucas CHOLLET
8faed20603 LibGUI: Use the global setting to show dotfiles in FilePicker
`FilePicker` will now look at the global setting at startup. Note that
changing this parameter inside `FilePicker` won't affect the global
parameter.
2023-03-09 09:12:00 +00:00
Lucas CHOLLET
af8b715aac LibGUI: Add "New Directory" to the contextual menu in FilePicker 2023-03-09 09:12:00 +00:00
Andreas Kling
21db2b7b90 Everywhere: Remove NonnullOwnPtr.h includes 2023-03-06 23:46:35 +01:00
Andreas Kling
359d6e7b0b Everywhere: Stop using NonnullOwnPtrVector
Same as NonnullRefPtrVector: weird semantics, questionable benefits.
2023-03-06 23:46:35 +01:00
Andreas Kling
689ca370d4 Everywhere: Remove NonnullRefPtr.h includes 2023-03-06 23:46:35 +01:00
Andreas Kling
8a48246ed1 Everywhere: Stop using NonnullRefPtrVector
This class had slightly confusing semantics and the added weirdness
doesn't seem worth it just so we can say "." instead of "->" when
iterating over a vector of NNRPs.

This patch replaces NonnullRefPtrVector<T> with Vector<NNRP<T>>.
2023-03-06 23:46:35 +01:00
Sam Atkins
774f328783 LibCore+Everywhere: Return an Error from DirIterator::error()
This also removes DirIterator::error_string(), since the same strerror()
string will be included when you print the Error itself. Except in `ls`
which is still using fprintf() for now.
2023-03-05 20:23:42 +01:00
Timothy Flynn
bc0bb98c01 LibGUI: Paint emoji using text in the EmojiInputDialog
This widget originally used text, but at the time we did not support
painting multi-code point emoji as text at all. So it was changed to
paint emoji with their bitmaps in commit 8190120f95.

Now that we can paint text with multi-code point emoji, revert this
widget to use text again. This has the added benefit that the dialog has
a what-you-see-is-what-you-get effect; any emoji with text presentation
in the font (e.g. U+00A9 Copyright) will be displayed as such in the
dialog, which is how the text would be painted when selected anyways.

Note that to accommodate some emoji sizes, this also had to bump the
button sizes a bit, otherwise they would be displayed with an ellipsis.
2023-03-05 20:21:57 +01:00
Timothy Flynn
054297431a LibGUI: Fix typo in the name of the EmojiCategory struct 2023-03-05 20:21:57 +01:00
Timothy Flynn
153218ed76 LibGUI: Allow overriding toolbar button tooltips
The EmojiInputDialog, for example, will want its toolbar buttons to have
a tooltip which differs from its text. If no tooltip override has been
provided, we fall back to the button text still.
2023-03-05 20:21:57 +01:00
Andreas Kling
bb4b747424 LibGUI: Make Button height adapt to the current font size 2023-03-04 00:29:38 +01:00
Andreas Kling
508fb7e1e9 Userland: Use Font::pixel_size_rounded_up() in more places 2023-03-04 00:29:38 +01:00
Andreas Kling
b71c7a6e44 Userland: Use Font::pixel_size_rounded_up() instead of glyph_height()
The only remaining clients of this API are specific to bitmap fonts and
editing thereof.
2023-03-04 00:29:38 +01:00
Andreas Kling
6c8e9fa1b3 LibGUI: Paint the GroupBox title with left alignment
This fixes an issue where the title would shift around at the subpixel
level when appended to. (Only matters for vector fonts.)
2023-03-04 00:29:38 +01:00
Timothy Flynn
4463de3d10 LibGUI: Compute syntax-highlighted visual text spans using float rects
For vector fonts in particular, we need to take care to compute offsets
using floating point math. For example, with Berkeley Mono at font size
16, with syntax highlighting enabled, we are currently truncating these
offsets to integers. This results in a leftward-drift when we paint the
text.

This changes the rect in which we paint syntax-highlighted text spans to
a float rect. As we traverse the spans, we now no longer truncate any of
the text offsets, and we draw the text in the correct positions.

This is likely not a complete solution. TextEditor blindly casts ints to
floats all over, and we will want to make all of these (hundred+) float-
aware. But this should be a step in the right direction and makes vector
fonts immediately more comfortable to use.
2023-03-03 22:49:12 +01:00
Sam Atkins
1c0c59eabe LibGUI: Add folding regions to INI syntax highlighter
This lets you fold sections into a single line. We attempt to keep 1
blank line after the folded section if possible.
2023-03-03 21:56:42 +01:00
Andreas Kling
ee001cc417 LibGUI: Make CheckBox height adapt to the current font size 2023-03-03 15:38:59 +01:00
Andreas Kling
fdcdc14fce LibGUI: Make RadioButton height adapt to the current font size 2023-03-03 15:23:47 +01:00
Andreas Kling
f1e0eb8a25 LibGUI: Round up font sizes in various widget size calculations 2023-03-03 15:23:47 +01:00
Andreas Kling
d0977ac566 LibCore+LibGUI+About: Use String in Core::Version and GUI::AboutDialog
The Core::Version API now returns ErrorOr<String>, and the
GUI::AboutDialog API was adjusted to accommodate this.
2023-03-03 15:23:47 +01:00
Sam Atkins
64eb326f26 LibGUI: Give SeparatorWidget a minimum size
Without this, it can be squished down into nothing, which looks really
odd.
2023-03-01 10:55:20 +01:00
Andreas Kling
544366ff2a LibGUI: Add a simple "recently open files" feature
This feature allows any application to easily install an automatically
updating list of recently open files in a GUI::Menu.

There are three main pieces to this mechanism:

- GUI::Application::set_config_domain(domain): This must be called
  before using the recent files feature. It informs the Application
  object about which config domain to find the relevant RecentFiles
  list under.

- GUI::Menu::add_recently_open_files(callback): This inserts the list
  in a menu. A callback must be provided to handle actually opening
  the recent file in some application-specific way.

- GUI::Application::set_most_recently_open_file(path): This updates
  the list of recently open files, both in the configuration files,
  and in the GUI menu.
2023-02-28 14:39:32 +01:00
Sam Atkins
cac14a3f0a LibGUI: Assign folding regions for GML files
Each {} block is now treated as a folding region, so that they can be
collapsed and expanded in TextEditor, GML Playground, HackStudio, and
anywhere else that uses the syntax highlighter. :^)
2023-02-28 13:23:55 +01:00
Sam Atkins
d169af117d LibSyntax+LibGUI: Let syntax highlighters assign folding regions 2023-02-28 13:23:55 +01:00
Sam Atkins
92b128e20a LibGUI: Support folding regions in TextEditor 2023-02-28 13:23:55 +01:00
Sam Atkins
3d25b4eb34 LibGUI: Add folding regions to TextDocument
A `TextDocumentFoldingRegion` represents a region of the document which
the user can collapse/expand to make code easier to navigate.
2023-02-28 13:23:55 +01:00
Sam Atkins
96cf9355b2 LibGUI: Add TextRange::line_count() 2023-02-28 13:23:55 +01:00
Sam Atkins
640f6f476c LibGUI: Store Utf32Views in TextEditor::LineVisualData
Previously this stored the position of each visual line break, meaning
that all the text would always be painted. By storing each visual
line's Utf32View, we can skip over parts of the text, such as for code
folding.
2023-02-28 13:23:55 +01:00
Sam Atkins
b5e1babc26 LibGUI: Create TextAttributes for unspanned text once, not repeatedly
Also, stop unnecessarily creating a RefPtr for the unspanned font - just
use `font()`, which returns a reference.
2023-02-28 13:23:55 +01:00
Sam Atkins
e8b7bdbd57 LibGUI: Skip painting TextEditor spans that end on previous lines
This only becomes a problem with folding, since arbitrary lines may be
invisible, meaning we try to apply a span for an invisible line N, on
line N+X instead, causing occasional crashes.

This check means we can remove the loop that skips spans occurring at
the end of the line.
2023-02-28 13:23:55 +01:00
Timothy Flynn
4edd8e8c5e LibGUI: Ensure the "End" key sets the cursor to the visual line end
We are currently setting the physical mouse position to the visual
cursor content location. In a line containing only a multi-code point
emoji, this would set the cursor to column 1 rather than however many
code points there are.
2023-02-27 09:36:37 -05:00
Tim Ledbetter
cc4184cb47 LibGUI: Don't show non-visible actions in CommandPalette 2023-02-27 13:37:24 +01:00
MacDue
6cf8eeb7a4 LibGfx: Return bool not ErrorOr<bool> from ImageDecoderPlugin::sniff()
Nobody made use of the ErrorOr return value and it just added more
chance of confusion, since it was not clear if failing to sniff an
image should return an error or false. The answer was false, if you
returned Error you'd crash the ImageDecoder.
2023-02-26 19:43:17 +01:00
kleines Filmröllchen
376e7243a9 LibGUI: Use full text width for Label's preferred width
A label would prefer to be exactly as wide as its contained text
requires. This makes min_width: "fit" work better.
2023-02-25 20:49:41 -07:00
Linus Groh
09d40bfbb2 Everywhere: Use _{short_,}string to create Strings from literals 2023-02-25 20:51:49 +01:00
Timothy Flynn
16ec116133 LibGUI: Make Gfx- to text-positioning handle multi-code point glyphs 2023-02-24 20:28:23 +01:00
Humberto Alves
d50b4f3581 LibGUI: Fix Action destructor to unregister itself correctly
Changed the Action destructor to fix an issue where global scoped
actions without shortcuts were not being properly unregistered from the
application. Previously, this could cause crashes when attempting to
open the command palette.
2023-02-23 12:41:47 +00:00
Humberto Alves
2df25f8edf LibGUI: Fix missing parent in LinkLabel open action
Fixed a bug where an action was being registered in the global shortcut
scope by mistake.
2023-02-23 12:41:47 +00:00
Timothy Flynn
fdf090a299 LibGUI: Wrap words at word break boundaries and don't break up emoji
We will currently only wrap "words" at ASCII spaces and, when wrapping,
will break up multi-code point emoji. This changes word wrapping to
behave as follows:

When the wrapping mode is "anywhere", use the iterator-based font width
computation overload. This will compute the width of multi-code point
emoji, whereas we currently only handle single-code point.

When the wrapping mode is "word", use the Unicode word segmentation
boundaries to break lines.
2023-02-22 15:24:16 +00:00
Timothy Flynn
2eb2207f50 LibGUI: Convert mouse events from a visual to a physical position
When clicking a position within a TextEditor, we should interpret that
position as a visual location. That location should be converted to a
"physical" location before using it to set the physical cursor position.

For example, consider a document with 2 emoji, each consisting of 3 code
points. Visually, these will occupy 2 columns. When a mouse click occurs
between these columns, we need to convert the visual column number 1 to
the physical column number 3 when storing the new cursor location.
2023-02-22 10:14:36 +01:00
Andreas Kling
faa1a09042 LibGUI: Fix const-correctness issues 2023-02-21 00:54:04 +01:00
Andreas Kling
4b3e229157 LibGfx: Replace Bitmap::invert() with Bitmap::inverted()
The new function return a new bitmap instead of mutating the current
one in place.
2023-02-21 00:54:04 +01:00
Sam Atkins
e54a03d497 LibGUI: Use Gfx::Font::bold_variant() instead of a manual lookup
This has the nice side-effect of being cached in the Font, instead of
being repeatedly looked up in the FontDatabase.
2023-02-20 18:41:47 +01:00
Sam Atkins
efd56cda6a LibGUI: Use a while loop for iterating text spans 2023-02-20 18:41:47 +01:00
Sam Atkins
04deb81f71 LibGUI: Validate TextDocument spans when merging them, not when painting
TextDocument::merge_span_collections() automatically makes sure that the
spans are valid, move forwards, are in order, and do not overlap. This
means we don't have to check these things every time TextEditor paints
the document.

merge_span_collections() now does these checks instead. I am not certain
they are still useful, but someone in the past certainly did. I have
modified them to take advantage of the operator overloads and Formatter
that we now have.
2023-02-20 18:41:47 +01:00
Sam Atkins
54d45d4ac6 LibGUI: Add and use TextEditor::fixed_elements_width()
We were manually adding together the gutter and ruler widths in several
places. Soon we'll have a third section that needs to be included in
this width, so let's abstract it now.
2023-02-20 18:41:47 +01:00
Sam Atkins
1a5159df73 LibGUI+HackStudio: Simplify TextEditor gutter & ruler calculations
- Make gutter/ruler_content_rect() return rectangles relative to the
  TextEditor widget.
- Re-order painting code to translate the Painter after the gutter/ruler
  has been painted, to use those coordinates.
- Consistently put gutter before ruler in code, because that's the order
  they physically appear.
2023-02-20 18:41:47 +01:00
Tim Ledbetter
c63f70d0fd LibGUI: Allow clipboard items to have no associated data 2023-02-19 01:35:29 +01:00