Commit graph

1019 commits

Author SHA1 Message Date
Sam Atkins
ded5ba1f87 LibGUI+Applications: Give SettingsWindow tabs a string ID
This gives us a convenient way to refer to them, which will be used in
the following commit.
2022-04-21 17:24:42 +02:00
Michael Manganiello
56081cdb6e LibGUI: Remove Tile.date_time member from Calendar
Currently, navigating through different years in the Year view of the
Calendar app or the taskbar is very slow.
Profiling results show that almost all the time is spent in
`Calendar::update_tiles`, and specifically, in `DateTime::create` and
`DateTime::set_time`.

Performance can improve substantially if the `TZ` environment variable
is set [0], but we can improve the current code to perform better
nevertheless :^)

This diff focuses on removing the need of the `Tile` struct to require
the instantiation of a `DateTime` object, which avoids _at least_ 365
object instantiations in the Year view, on each `update_tiles` call.
Instead, as the `date_time` isn't used often, we can instantiate it on
demand when a particular date is selected.

[0] https://blog.packagecloud.io/set-environment-variable-save-thousands-of-system-calls/
2022-04-20 18:37:56 +02:00
faxe1008
9e323241f8 LibGUI: Use fuzzy matching in CommandPalette
This patch changes the previously used contains method for matching the
user search term with all available commands to use the fuzzy match
algorithm, which makes it more typo tolerant.
2022-04-20 18:34:09 +02:00
faxe1008
1074c399f3 LibGUI: Close CommandPalette on active window change
This patch makes CommandPalette be closed whenever the focus shifts from
the dialog. It is closer to other non-serenity implementations of the
CommandPalette and other modal dialogs in the system.
2022-04-20 18:34:09 +02:00
Ali Mohammad Pur
7a02d33cd5 LibGUI: Make GUI::Variant an actual Variant
Previously this had its own massive tagged union implementation with
some POD types to represent non-POD types that could be put in the
variant; implement it via a Variant and get rid of the manual
pointer/ref handling.

This commit does not change any semantics on the type, just the
underlying implementation (and removes an unused ::clear() method).
2022-04-20 00:15:23 +04:30
Marco Rebhan
a4639fced9 LibGUI: Don't try to get link target value if read_link failed 2022-04-14 23:44:09 +02:00
SimonFJ20
399202f1d3 LibGUI: Make class final and seperate from GML Playground 2022-04-13 21:24:48 +02:00
SimonFJ20
791e881892 LibGUI: Rename function to make intention clearer 2022-04-13 21:24:48 +02:00
SimonFJ20
50ca1b3d87 LibGUI+GMLPlayground: Reset cursor to end of text after replace 2022-04-13 21:24:48 +02:00
SimonFJ20
661e7d691e LibGUI+GMLPlayground: Replace text using ReplaceAllTextCommand 2022-04-13 21:24:48 +02:00
martinfalisse
daaa8a57f0 LibGUI: Disable editing cell when ctrl key is pressed
Disable cell editing when the ctrl key is pressed. This fixes a bug
where when doing ctrl+z (undo) and there are no more undo actions
on the undo_stack, then a "z" is entered into the cell.
2022-04-13 09:26:44 +04:30
Simon Wanner
206d6ece55 LibGfx: Move other font-related files to LibGfx/Font/ 2022-04-09 23:48:18 +02:00
martinfalisse
472a3df03b LibGUI: Calculate width of table headers when there is no content
In order to correctly calculate the width of the header add the
top left x coordinate + the width of the content. Previously was
using the width returned by the visible_content_rect(), which
when there was no content would be null. This would be problematic
as it would lead to not rendering the headers of tables when there was
no content (for example in the SystemsMonitor in the Networks tab).

Now, regardless of whether there is content or not in the table,
the header is visible.
2022-04-09 22:07:16 +02:00
Idan Horowitz
280e99073b LibGUI: Stop dropping comments between children and end of GML objects
Any left-over comments in the pending_comments vector are now inserted
as sub object children, as these are serialized last and will therefore
show up in their expected location.
2022-04-08 19:19:37 +03:00
Idan Horowitz
40c40b7551 LibGUI: Insert parsed comments in parsing order
We were accidentally reversing the order of consecutive comments when
inserting them as children of the GML object.
2022-04-08 19:19:37 +03:00
Idan Horowitz
c56bc49b70 LibGUI: Remove left-over spammy debug print 2022-04-08 19:19:37 +03:00
kleines Filmröllchen
cd5ed44f64 LibGUI: Don't stringify non-textlike data in TreeView's tree column
This would previously cause silly things like [GUI::Icon] to appear if a
non-textlike column was used as the tree column (like, in this example,
an icon column). Let's just not write anything instead.
2022-04-06 12:47:50 +02:00
kleines Filmröllchen
4e8cb0508f LibGUI: Add is_toggled getter for TreeView
This has safer fallbacks than toggle_index, because we want to be able
to call it on indices that don't have children.
2022-04-06 12:47:50 +02:00
kleines Filmröllchen
d813bf77ee LibGUI: Associate model index metadata directly with the model index
This was using internal_data beforehand, which relies on the internal
data to be distinct for different model indices. That's not the case for
example for SortingProxyModel. Using the model index directly makes tree
expansion work properly when using a tree table widget with a
SortingProxyModel.
2022-04-06 12:47:50 +02:00
kleines Filmröllchen
fc6ffbc006 LibGUI: Register many properties of AbstractView 2022-04-06 12:47:50 +02:00
kleines Filmröllchen
68a758304a LibGUI: Register should_fill_selected_rows for GML in TreeView 2022-04-06 12:47:50 +02:00
kleines Filmröllchen
b34b939a03 LibGUI: Delegate the tree column in SortingProxyModel
This was never properly delegated to the source model, so the tree
column would just always be zero.
2022-04-06 12:47:50 +02:00
kleines Filmröllchen
67b5aea2f9 LibGUI: Register AbstractTableView.column_headers_visible
This was used before by SystemMonitor but not actually registered.
2022-04-06 12:47:50 +02:00
kleines Filmröllchen
bfb587f29d LibGUI: Implement column_headers_visible in AbstractTableView
This was declared but not defined. :yakfusion:
2022-04-06 12:47:50 +02:00
Andreas Kling
1a38ab0ca1 WindowServer+LibGUI: Notify windows when their maximized state changes
Previously, GUI::Window::is_maximized() had to make a synchronous IPC
request to WindowServer in order to find out if the window was indeed
maximized.

This patch removes the need for synchronous IPC by instead pushing the
maximization state to clients when it changes.

The motivation for this change was that GUI::Statusbar was checking
if the containing window was maximized in its resize_event(), causing
all windows with a statusbar to block on sync IPC *during* resize.
Browser would typically block for ~15 milliseconds here every time
on my machine, continuously during live resize.
2022-04-05 17:45:07 +02:00
Matthew Olsson
2b9ffe2989 LibGUI: Add optional autosize padding 2022-04-04 14:59:37 +02:00
Ali Mohammad Pur
f899c19d41 LibGUI: Return Optional<Node const&> from node_for_path() 2022-04-04 12:48:31 +02:00
Rob Ryan
554709fec6 LibGUI: Extend mimic pressed across keyboard shortcuts for buttons
Primary motivation for this was to get a visual indication in the
browser for Ctrl-R refresh. This extends what ForLoveOfCats had done
for calculator button shortcuts across all buttons with shortcuts.

When an action is triggered without an activator each associated button
will be set as mimic pressed.
2022-04-03 12:21:50 +02:00
kleines Filmröllchen
e6fe66594e LibGUI: Register LazyWidget 2022-04-03 12:21:05 +02:00
kleines Filmröllchen
7e34b88ed4 LibGUI: Fully support TabWidget in GML
TabWidgets couldn't be used in GML properly, as the GML creation
routines didn't actually call the necessary functions in the TabWidget
to get a new tab added. This commit fixes that by making the name of the
tab a normal property, the previously introduced "title", which can be
trivially set from GML. Therefore, try_add_widget() loses an argument
(while try_add_tab doesn't, because it newly constructs the widget).
This allows us to get rid of the silly "fixing my widget tree after the
fact" code in Help and will make it super easy to use TabWidget in
future GML. :^)
2022-04-03 12:21:05 +02:00
kleines Filmröllchen
0410414455 LibGUI: Add a title to all Widgets
This title is a generic user-facing name for the widget. For now, it's
only used by TabWidget for tab names.
2022-04-03 12:21:05 +02:00
Olivier De Cannière
1b7850f511 LibGUI: Add TabWidget::activate_last_tab() 2022-04-02 23:38:32 +02:00
Ben Maxwell
3fbefb82ac LibGUI+Applications: Move abstract ThemeEditor preview to LibGUI
This allows most of the theme preview code to be reused by similar
theme preview widgets.
2022-04-02 21:50:41 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Itamar
53c6c36fba LibGUI: Add AutocompleteProvider::TokenInfo::type_to_string() 2022-03-31 19:10:15 +02:00
Itamar
5f2a0f03a6 LibGUI: Add search API to TextEditor with highlighted results
This adds a search API to TextEditor.

The API that is similar to "find_text" of TextDocument (which is used
internally to do the search).

All search results (as well as the current one) are highlighted with
a "span collection", which is pretty neat :^)
2022-03-29 17:45:36 +02:00
Itamar
a12385dc4b LibGUI: Add match_case parameter to TextDocument::find_all() 2022-03-29 17:45:36 +02:00
Itamar
ab0b4f46f7 LibGUI: Support multiple layers of TextDocument spans
TextDocument::set_spans() now also takes a "span collection index"
argument.

TextDocument keeps a map between a span collection index and its spans.
It merges the spans from all collections into a single set of spans
whenever set_spans() is called.

This allows us to style a document with multiple layers of spans, where
as previously we only supported a single layer of spans that was set
from the SyntaxHighlighter.
2022-03-29 17:45:36 +02:00
Itamar
b75ed992a6 LibGUI: Add operators >,>= to TextPosition 2022-03-29 17:45:36 +02:00
Itamar
1d522e4b4c LibGUI: Add DoClamp option to AbstractSlider::set_value() 2022-03-29 17:45:36 +02:00
circl
eeeaf410fb WindowServer+LibGUI: Expose raw scroll wheel values to applications
This is useful, for instance, in games in which you can switch held
items using the scroll wheel. In order to implement this, they
previously would have to either add a hard-coded division by 4, or look
up your mouse settings to adjust correctly.

This commit adds an MouseEvent.wheel_raw_delta_x() and
MouseEvent.wheel_raw_delta_y().
2022-03-27 01:11:27 +01:00
Kenneth Myhra
4a57be824c Userland+Tests: Convert File::read_link() from String to ErrorOr<String>
This converts the return value of File::read_link() from String to
ErrorOr<String>.

The rest of the change is to support the potential of an Error being
returned and subsequent release of the value when no Error is returned.
Unfortunately at this stage none of the places affected can utililize
our TRY() macro.
2022-03-24 11:57:51 +01:00
Jelle Raaijmakers
5882d891d0 LibGUI: Simplify AbstractZoomPanWidget code
No functional changes, just making things a bit easier to read.
2022-03-23 11:53:34 +01:00
Rok Povsic
7da0d94d03 LibGUI: Add CTRL+Enter callback to TextEditor 2022-03-22 12:17:48 +01:00
thankyouverycool
b8cc18896f LibGUI+FontEditor: Add context menu for editor actions
GlyphMapWidget now reports context menu requests when secondary
clicking the map. This also adds a new Select All action and updates
the Copy Character action to work on multi-glyph selections. Glyph
navigation actions have been moved to a separate Go menu, as is
common in other apps.
2022-03-20 20:00:25 +01:00
thankyouverycool
df443863bd LibGUI: Add set_selection() convenience helper to GlyphMapWidget 2022-03-20 20:00:25 +01:00
thankyouverycool
5c6326ae23 LibGUI: Add automatic scrolling to GlyphMapWidget
Similar to TextEditor, GlyphMapWidget now automatically scrolls
when dragging a selection outside its boundaries.
2022-03-20 20:00:25 +01:00
thankyouverycool
a26e71a137 LibGUI: Use system theme when painting GlyphMapWidget focus outline 2022-03-20 20:00:25 +01:00
thankyouverycool
cf13cf7225 LibGUI: Reset GlyphMapWidget only if clicking a new active glyph
Fixes an edge case in which mousing down on the active glyph within
a larger selection would reset the selection but fail to update the
glyph map. Now we can grow or shrink the selection by dragging the
active glyph even after an initial selection is made.
2022-03-20 20:00:25 +01:00
thankyouverycool
4f7b37de9c LibGUI: Use nicer API for contrained positions in GlyphMapWidget
Forgot about this little guy. Functionally the same here, but more
robust if scrollbars change.
2022-03-20 20:00:25 +01:00