summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
AgeCommit message (Collapse)Author
2023-01-07LibGUI: Add `TextEditor::write_to_file(Core::Stream::File&)`Lucas CHOLLET
This overload use the `Core::Stream` API instead of the now deprecated one `Core::File`.
2023-01-07Everywhere: Use ElapsedTimer::elapsed_time() for comparisonsAndrew Kaster
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-07LibGUI+Userland: Rename `try_load_from_gml()` -> `load_from_gml()` :^)Sam Atkins
It's the only one, so the `try` prefix is unnecessary now.
2023-01-07LibGUI: Delete old now-unused `Widget::load_from_gml()`Sam Atkins
2023-01-07Userland: Replace all uses of `load_from_gml` with `try_load_from_gml`Sam Atkins
MOAR FIXMES! ;^)
2023-01-07LibGUI: Create an alias for Widget UnregisteredChildHandlerSam Atkins
2023-01-06LibGUI+Everywhere: Use fallible Window::set_main_widget() everywhere :^)Sam Atkins
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-06LibGUI: Simplify GUI::Label preferred height calculationAndreas Kling
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-06LibGfx: Make text painting better at aligning vector fonts verticallyAndreas Kling
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-06LibGUI: Tweak GUI::Label auto-sizing logic for floating point font sizesAndreas Kling
We have to ceil the font size or we risk being 1px too small.
2023-01-06LibGfx: Slim down Gfx::TextLayout API by removing unused accessorsAndreas Kling
Also store the Font as a const reference instead of a raw pointer, since we don't allow a null Font here.
2023-01-06LibGfx: Make Font::preferred_line_height() more correctAndreas Kling
Return a float, and fix a bogus calculation of ascender + descender.
2023-01-05LibGfx: Avoid rounding/truncating glyph positions till blittingMacDue
This keeps some overloads that accept ints to avoid adding calls to .to_type<float>() all over the place.
2023-01-03LibGUI: Stop duplicating mouse events of cursor tracking widgetMacDue
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-03LibGUI: Don't highlight extension text when saving files with FilePickerTimothy Flynn
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-03LibGfx: Make Font::width() return a floatAndreas Kling
2023-01-03LibGUI: Fix highlighting of elements in TreeViewmartinfalisse
Previously, incorrect items were highlighted when hovering over elements in TreeView when there was a column header.
2023-01-02Everywhere: Remove unused includes of LibC/stdlib.hBen Wiederhake
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-02Everywhere: Remove unused includes of AK/Format.hBen Wiederhake
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-02Everywhere: Remove unused includes of AK/IterationDecision.hBen Wiederhake
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-01LibGUI: Fix wrong copyright header email for recent OpacitySlider changenetworkException
This patch fixes the wrong email domain being used for the copyright header change in f828bf64791c976d75d53dc73a41790adc727017
2023-01-01LibGUI+Userland: Make GML unregistered_child_handler fallibleSam Atkins
2023-01-01LibCore+LibGUI: Add fallible versions of Widget::load_from_gml()Sam Atkins
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-01LibGUI: Make color picker opacity sliders react to the chosen colornetworkException
2023-01-01LibGUI: Add base color to OpacitySlidernetworkException
This patch adds a base color to OpacitySlider which will be used to render the alpha gradient.
2022-12-31LibGUI: Fix invalid ModelIndices during shift-click multiselectionAayush
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-30LibGUI: Automatically scroll to a new column on adding it in ColumnsViewKarol Kosek
2022-12-30LibGUI: Teach ColumnsView where indexes are placed (and scroll to them)Karol Kosek
This makes the view to scroll when pressing arrow keys! :^)
2022-12-30LibGUI: Don't destroy columns after selecting already opened oneKarol Kosek
2022-12-30LibGUI: Determine model index from a content position in ColumnsViewKarol Kosek
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-30LibGUI: Don't show last separator in columnKarol Kosek
2022-12-30LibGUI: Replace a magic number with ColumnsView::column_separator_widthKarol Kosek
2022-12-28LibGfx+Overall: Remove `is_null` from `Point`, `Rect` and `Size`Jelle Raaijmakers
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-26LibGUI: Standardize automatic scrolling in TextEditor+GlyphMapWidgetthankyouverycool
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-26LibGUI+Applications: Rename automatic scrolling timer functionsthankyouverycool
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-26LibGUI: Handle Enter+Leave events for automatic cursor trackersthankyouverycool
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-20LibGUI: Fix bug in the ColorPicker's spinbox not changing colorsBaitinq
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-20LibGUI+FontEditor: Restore normalized selections on Undo/Redothankyouverycool
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-20LibGUI: Reset GlyphMapWidget scroll value when changing active rangethankyouverycool
Fixes being teleported to the old location when scrolling on a previously browsed range.
2022-12-20LibGUI: Focus the actively resizing end of GlyphMapWidget selectionsthankyouverycool
2022-12-20LibGUI: Only reset GlyphMapWidget selection on Escapethankyouverycool
and when using unmodified arrows.
2022-12-20LibGUI: Add Page{Up,Down} support for GlyphMapWidgetthankyouverycool
2022-12-20LibGUI: Improve visible glyph estimate in GlyphMapWidgetthankyouverycool
Previously the widget used a very rough estimate for visible glyphs based on viewport and glyph areas. Now it simply figures rows times columns with a two row overdraw to accommodate fractional glyphs on either end of visible content. For KaticaRegular10, this ends up reducing unnecessary glyph iterations during painting by about 30%.
2022-12-20LibGUI: Adjust GlyphMapWidget content sizing and glyph paddingthankyouverycool
Fixes a slightly oversized content rect and erroneous glyph outer rect values. Increases glyph rect padding to guarantee at least 1px between the focus rect and glyph.
2022-12-20LibGUI: Implement calculated_min_size() for GlyphMapWidgetthankyouverycool
2022-12-20LibGUI: Check bounds when moving GlyphMapWidget selectionsthankyouverycool
Fixes crashing on invalid code points when creating selections with the keyboard and applying actions to them. Also adds Home/End key support for selections. Ctrl+Shift+{Home,End} now extends the selection to the beginning or end of the active range, respectively. Shift+{Home,End} extends the selection to the start or end of the row. Alt+{Home,End} resets the selection and moves the active glyph to the beginning or end of the active range.
2022-12-20LibGUI: Ensure GlyphMapWidget selection resets when requestedthankyouverycool
Previously selection reset was ignored on active glyph change if the old glyph equaled the new one. This was an intentional behavior that allowed selections to resize by dragging the focused glyph, but has proved more counterintuitive than useful. Now the widget behaves like other text selection controls: selections can be reset by clicking anywhere in them or shift can be held to grow the selection.
2022-12-20LibGUI: Disallow GlyphMapWidget selection sizes equal to zerothankyouverycool
This is a bogus size as the map must always have at least 1 glyph selected, and it was causing occasional desync between selection contents and the focused glyph when manipulating selections with the keyboard.
2022-12-20LibGUI: Forward GlyphMapWidget Key_Tab eventsthankyouverycool
Allows focus to be passed using the keyboard.
2022-12-16LibGUI: Prevent key_down event from bubbling for Key_Up and Key_DownTimothy Slater
This just corrects an oversight in EditingEngine where we do not properly signal "we handled this event" for Key_Up and Key_Down like we do for the other keys