Commit graph

1424 commits

Author SHA1 Message Date
Sam Atkins
a5ff6769f5 LibGUI: Make undo work for TextDocument ReplaceAllTextCommand
The undo code here was just replacing the new text with the new text.
Now we actually save the old text and use that instead. :^)
2023-01-13 13:37:19 +01:00
Karol Kosek
ca7648b1ae LibGUI: Port AbstractThemePreview::set_theme_from_file to Core::Stream 2023-01-12 13:56:11 +01:00
Karol Kosek
17012b266c LibGUI: Remove unused AbstractThemePreview::on_theme_load_from_file 2023-01-12 13:56:11 +01:00
Sam Atkins
652f87821b Userland: Replace remaining Core::Timer::construct()s with try_create() 2023-01-12 11:25:51 +01:00
Sam Atkins
a8cf0c9371 LibCore+Userland: Make Core::Timer::create_single_shot() return ErrorOr
clang-format sure has some interesting opinions about where to put a
method call that comes after a lambda. :thonk:
2023-01-12 11:25:51 +01:00
Tim Ledbetter
0267d35258 LibGUI: Update the AboutDialog copyright year 2023-01-11 16:29:43 +00:00
Sam Atkins
ae6a84c261 LibGUI: Lex INI files as Utf8
Iterating byte by byte meant that the column positions assigned to INI
tokens would be off if there were any multi-byte codepoints. Using a
Utf8View means these positions refer to whole codepoints instead, and
the column positions match what GUI::TextEditor expects. :^)

Fixes #12706.
2023-01-11 10:24:51 +01:00
Matthew Olsson
95df712c2e HackStudio: Hide autocomplete popup when switching tabs 2023-01-11 09:15:10 +00:00
implicitfield
a2ca2d8364 LibGUI: Register "jump_to_cursor" as a GML property 2023-01-09 17:32:03 +00:00
Karol Kosek
41691a7fcb LibGUI: Make CommonLocationsProvider::load_from_json() failable
... and additionally port it to Core::Stream. :^)
2023-01-09 09:45:26 +01:00
Andreas Kling
33fd9ea5b3 LibGUI: Prevent "hide unnecessary scrollbars" from showing unwanted bars
When using this mode on an AbstractScrollWidget, it was not honoring the
related "scrollbars enabled" setting.

If scrollbars are disabled, they should never be made visible by the
"unnecessary scrollbars" logic.
2023-01-08 23:01:16 +01:00
Lucas CHOLLET
cf1eea27d3 LibGUI: Add TextEditor::write_to_file(Core::Stream::File&)
This overload use the `Core::Stream` API instead of the now deprecated
one `Core::File`.
2023-01-07 19:53:35 +00:00
Andrew Kaster
ddf348daeb Everywhere: Use ElapsedTimer::elapsed_time() for comparisons
Simplify a lot of uses of ElapsedTimer by converting the callers to
elapsed_time from elapsed, as the AK::Time returned is better for unit
conversions and comparisons against constants.
2023-01-07 14:51:04 +01:00
Sam Atkins
f0395a2042 LibGUI+Userland: Rename try_load_from_gml() -> load_from_gml() :^)
It's the only one, so the `try` prefix is unnecessary now.
2023-01-07 14:39:30 +01:00
Sam Atkins
e4e12f3a96 LibGUI: Delete old now-unused Widget::load_from_gml() 2023-01-07 14:39:30 +01:00
Sam Atkins
54b1326165 Userland: Replace all uses of load_from_gml with try_load_from_gml
MOAR FIXMES! ;^)
2023-01-07 14:39:30 +01:00
Sam Atkins
703da34947 LibGUI: Create an alias for Widget UnregisteredChildHandler 2023-01-07 14:39:30 +01:00
Sam Atkins
0c24522635 LibGUI+Everywhere: Use fallible Window::set_main_widget() everywhere :^)
Rip that bandaid off!

This does the following, in one big, awkward jump:
- Replace all uses of `set_main_widget<Foo>()` with the `try` version.
- Remove `set_main_widget<Foo>()`.
- Rename the `try` version to just be `set_main_widget` because it's now
  the only one.

The majority of places that call `set_main_widget<Foo>()` are inside
constructors, so this unfortunately gives us a big batch of new
`release_value_but_fixme_should_propagate_errors()` calls.
2023-01-06 13:36:02 -07:00
Andreas Kling
3332ce01ce LibGUI: Simplify GUI::Label preferred height calculation
No need to use a TextLayout here, we can just count the number of lines
and multiply that by the font's preferred line height.

In addition to being much simpler, it also fixes a bug where labels were
got too tall if we calculated their preferred height before assigning
a final width to them.
2023-01-06 13:43:04 +01:00
Andreas Kling
b2d3ceaec5 LibGfx: Make text painting better at aligning vector fonts vertically
This is achieved by simplifying the logic in TextLayout. We get rid
of all the various ways that the layout bounding rect can get cropped.
Then we make sure to use the right pixel metrics.

Finally we use the font's own line gap metrics instead of hard-coding 4.

The end result is that text painted with vector fonts now gets pretty
reasonable vertical alignment in most cases.
2023-01-06 12:02:21 +01:00
Andreas Kling
dd8d65ada0 LibGUI: Tweak GUI::Label auto-sizing logic for floating point font sizes
We have to ceil the font size or we risk being 1px too small.
2023-01-06 12:02:20 +01:00
Andreas Kling
6b421fb521 LibGfx: Slim down Gfx::TextLayout API by removing unused accessors
Also store the Font as a const reference instead of a raw pointer,
since we don't allow a null Font here.
2023-01-06 12:02:20 +01:00
Andreas Kling
2a61d66b0a LibGfx: Make Font::preferred_line_height() more correct
Return a float, and fix a bogus calculation of ascender + descender.
2023-01-06 12:02:20 +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
MacDue
c7ab6daf26 LibGUI: Stop duplicating mouse events of cursor tracking widget
Previously we didn't always return when there was an automatic cursor
tracking widget. This meant for certain events e.g. a MouseUp over
the tracking widget, the event would be fired twice on the same widget
(once on `m_automatic_cursor_tracking_widget` then again on
`result.widget` outside the if).

Fixes #16737
2023-01-03 21:25:08 +01:00
Timothy Flynn
ee95cb37cd LibGUI: Don't highlight extension text when saving files with FilePicker
By default, only highlight the base name of the file to-be-saved. When
the file includes an extension, it's useful to be able to just start
typing a file name without having to manually de-select the extension
(or having to rewrite the extension).
2023-01-03 11:50:18 -05:00
Andreas Kling
3407ab0fd1 LibGfx: Make Font::width() return a float 2023-01-03 15:25:02 +01:00
martinfalisse
481c0419ba LibGUI: Fix highlighting of elements in TreeView
Previously, incorrect items were highlighted when hovering over
elements in TreeView when there was a column header.
2023-01-03 12:46:51 +00:00
Ben Wiederhake
6b7ce19161 Everywhere: Remove unused includes of LibC/stdlib.h
These instances were detected by searching for files that include
stdlib.h, but don't match the regex:

\\b(_abort|abort|abs|aligned_alloc|arc4random|arc4random_buf|arc4random_
uniform|atexit|atof|atoi|atol|atoll|bsearch|calloc|clearenv|div|div_t|ex
it|_Exit|EXIT_FAILURE|EXIT_SUCCESS|free|getenv|getprogname|grantpt|labs|
ldiv|ldiv_t|llabs|lldiv|lldiv_t|malloc|malloc_good_size|malloc_size|mble
n|mbstowcs|mbtowc|mkdtemp|mkstemp|mkstemps|mktemp|posix_memalign|posix_o
penpt|ptsname|ptsname_r|putenv|qsort|qsort_r|rand|RAND_MAX|random|reallo
c|realpath|secure_getenv|serenity_dump_malloc_stats|serenity_setenv|sete
nv|setprogname|srand|srandom|strtod|strtof|strtol|strtold|strtoll|strtou
l|strtoull|system|unlockpt|unsetenv|wcstombs|wctomb)\\b

(Without the linebreaks.)

This regex is pessimistic, so there might be more files that don't
actually use anything from the stdlib.

In theory, one might use LibCPP to detect things like this
automatically, but let's do this one step after another.
2023-01-02 20:27:20 -05:00
Ben Wiederhake
6fd478b6ce Everywhere: Remove unused includes of AK/Format.h
These instances were detected by searching for files that include
AK/Format.h, but don't match the regex:

\\b(CheckedFormatString|critical_dmesgln|dbgln|dbgln_if|dmesgln|FormatBu
ilder|__FormatIfSupported|FormatIfSupported|FormatParser|FormatString|Fo
rmattable|Formatter|__format_value|HasFormatter|max_format_arguments|out
|outln|set_debug_enabled|StandardFormatter|TypeErasedFormatParams|TypeEr
asedParameter|VariadicFormatParams|v_critical_dmesgln|vdbgln|vdmesgln|vf
ormat|vout|warn|warnln|warnln_if)\\b

(Without the linebreaks.)

This regex is pessimistic, so there might be more files that don't
actually use any formatting functions.

Observe that this revealed that Userland/Libraries/LibC/signal.cpp is
missing an include.

In theory, one might use LibCPP to detect things like this
automatically, but let's do this one step after another.
2023-01-02 20:27:20 -05:00
Ben Wiederhake
c1676cdddb Everywhere: Remove unused includes of AK/IterationDecision.h
These instances were detected by searching for files that include
IterationDecision.h, but don't match the regex:
\\bIterationDecision(?!\.h>)\\b
This is the only symbol defined by IterationDecision.h.

In theory, one might use LibCPP to detect things like this
automatically, but let's do this one step after another.
2023-01-02 20:08:35 +00:00
networkException
9b50d74df2 LibGUI: Fix wrong copyright header email for recent OpacitySlider change
This patch fixes the wrong email domain being used for the copyright
header change in f828bf6479
2023-01-01 19:03:03 +01:00
Sam Atkins
fa98034ff7 LibGUI+Userland: Make GML unregistered_child_handler fallible 2023-01-01 09:55:05 -05:00
Sam Atkins
b32f5dbcff LibCore+LibGUI: Add fallible versions of Widget::load_from_gml()
The existing `load_from_gml()` methods look the same as before from the
outside. Inside though, they now forward to `try_load_from_gml()` which
returns Error when things go wrong. It also now calls the `try_create()`
factory method for Objects instead of the `construct()` one.
2023-01-01 09:55:05 -05:00
networkException
c8f9bfe026 LibGUI: Make color picker opacity sliders react to the chosen color 2023-01-01 09:38:07 +00:00
networkException
f828bf6479 LibGUI: Add base color to OpacitySlider
This patch adds a base color to OpacitySlider which will be used to
render the alpha gradient.
2023-01-01 09:38:07 +00: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
Karol Kosek
70885a3dee LibGUI: Automatically scroll to a new column on adding it in ColumnsView 2022-12-30 17:16:29 +01:00
Karol Kosek
35e3df7f13 LibGUI: Teach ColumnsView where indexes are placed (and scroll to them)
This makes the view to scroll when pressing arrow keys! :^)
2022-12-30 17:16:29 +01:00
Karol Kosek
7e52daa542 LibGUI: Don't destroy columns after selecting already opened one 2022-12-30 17:16:29 +01:00
Karol Kosek
e673fc4183 LibGUI: Determine model index from a content position in ColumnsView
We didn't take the scroll value into account when we were converting
a position to an index, which basically prevented us from selecting a
desired file if a list wasn't small enough to fit entirely in the widget
box.
2022-12-30 17:16:29 +01:00
Karol Kosek
e40726cb34 LibGUI: Don't show last separator in column 2022-12-30 17:16:29 +01:00
Karol Kosek
3b18858bb1 LibGUI: Replace a magic number with ColumnsView::column_separator_width 2022-12-30 17:16:29 +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
804baa42f9 LibGUI: Standardize automatic scrolling in TextEditor+GlyphMapWidget
Both widgets now make use of their base class's scrolling timer and
now always accept drag selection updates on mousemove_event().

This guarantees much snappier feeling selections when actively moving
the mouse.
2022-12-26 09:27:19 +01: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
thankyouverycool
5b02e6a46b LibGUI: Handle Enter+Leave events for automatic cursor trackers
Previously, automatic cursor tracking widgets consumed all mouse
events but did not update their own hover state while active, meaning
Enter and Leave events were not being dispatched.

Fixes TextEditor's automatic selection scroll timer failing to stop
and start while autotracking. Its manual workaround in mousedown
is no longer needed.
2022-12-26 09:27:19 +01:00
Baitinq
75ea339ee9 LibGUI: Fix bug in the ColorPicker's spinbox not changing colors
Before this patch, when having the initial spinbox color value
(Color::White), if you changed the color value in the vertical color
picker it didn't update the spinbox's colors.

This is fixed by manually calling update() in the color picker's
onchange() handler if the new color is equal to the previous color,
which is the case in the initial spinbox's case as it will always be
white unless it is changed (and won't be affected by the vertical
color picker).

I added a NOTE in the source to explain this "opaque" update() call :))
2022-12-20 10:30:06 +01:00
thankyouverycool
40e94a315a LibGUI+FontEditor: Restore normalized selections on Undo/Redo
Selections are always normalized when saving undo commands.
The restore_selection() function reverses this process so
negatively sized selections (created right-to-left) continue
to resize correctly with the keyboard when restored.
2022-12-20 10:22:27 +01:00
thankyouverycool
02212f373b LibGUI: Reset GlyphMapWidget scroll value when changing active range
Fixes being teleported to the old location when scrolling on a
previously browsed range.
2022-12-20 10:22:27 +01:00