Commit graph

330 commits

Author SHA1 Message Date
Andreas Kling
16221305ad LibELF: Remove sketchy use of "undefined" ELF::Image::Section
We were using ELF::Image::section(0) to indicate the "undefined"
section, when what we really wanted was just Optional<Section>.

So let's use Optional instead. :^)
2021-05-15 00:17:55 +02:00
Andreas Kling
3168a4afe8 ImageViewer: Rename QSWidget => ImageViewer::ViewWidget 2021-05-14 18:37:08 +02:00
Andreas Kling
8360079cac LibGUI: Fix logic typo in AbstractTableView::update_row_sizes()
We should skip over non-visible *rows*, not *columns*.
2021-05-14 11:37:24 +02:00
Andreas Kling
6387f65f87 LibGUI: Resize GUI::HeaderView section vector to final size immediately
When computing row & column sizes in AbstractTableView, it iterates
across both axes starting from 0.

This caused us to grow the corresponding HeaderView's internal section
vector by 1 entry for each step, leading to Vector::resize() thrashing.

Since we already know the final size, just resize to that immediately,
and the thrashing goes away.

This gives a huge speedup when loading large files into Profiler. :^)
2021-05-14 10:32:44 +02:00
Jelle Raaijmakers
e5647e2ddf LibGUI/Splitter: Support setting minimum resizee size 2021-05-13 00:43:41 +01:00
sin-ack
2159f90e00 Userland+LibCore: Update FileWatcher + its users for InodeWatcher 2.0
With the new InodeWatcher API, the old style of creating a watcher per
inode will no longer work.  Therefore the FileWatcher API has been
updated to support multiple watches, and its users have also been
refactored to the new style.  At the moment, all operations done on a
(Blocking)FileWatcher return Result objects, however, this may be
changed in the future if it becomes too obnoxious. :^)

Co-authored-by: Gunnar Beutner <gunnar@beutner.name>
2021-05-12 22:38:20 +02:00
Andreas Kling
bc0146932e LibGUI: Never resolve Key_Invalid to a GUI::Action
Fixes #7047.
2021-05-12 20:59:07 +02:00
Andreas Kling
8c7bce818d LibGUI: Move action-from-key-event code to a separate function
The logic that figures out which (if any) action should be activated
by a keydown event was getting a bit unwieldy. This patch moves it to
a separate helper function.
2021-05-12 20:51:45 +02:00
Ali Mohammad Pur
a91a49337c LibCore+Everywhere: Move OpenMode out of IODevice
...and make it an enum class so people don't omit "OpenMode".
2021-05-12 11:00:45 +01:00
Sergey Bugaev
f15f03376b LibGUI: Add Clipboard::clear()
Does exactly what it says on the tin :^)
2021-05-10 19:09:53 +01:00
Brian Gianforcaro
79ccba908e LibGUI: Retain Taskbar icon when toggling frameless setting
Reapply the app icon if the we are coming back from "frameless" mode.
This will re-initialize the icon representing the app in the task bar,
instead of displaying the default application icon.

This bug was visible in "Cube Demo" as well as the "Analog Clock".
2021-05-10 12:36:05 +02:00
Andreas Kling
455afd32f2 Clipboard+LibGUI: Make set_clipboard_data asynchronous
There's no need for GUI applications to block after the clipping is
already in flight.
2021-05-10 12:30:41 +02:00
Andreas Kling
8684fca9df WindowServer+LibGUI: Make "move window to front" asynchronous 2021-05-10 12:20:28 +02:00
Andreas Kling
fb93535419 WindowServer+LibGUI: Make menu and menubar teardown asynchronous
Clients don't need to wait for WindowServer to tear down a menu or
menubar before continuing.
2021-05-10 11:53:26 +02:00
Andreas Kling
9d8aa2a57a Taskbar+LibGUI+WindowServer: Shrink taskbar by one pixel
Make the taskbar 27 pixels tall instead of 28. This makes the button
icons and applets vertically centered.

On a related note, this required touching *way* too many places..
2021-05-09 00:11:37 +02:00
Andreas Kling
fbe6c275c9 LibGUI: Clear GUI::TextEditor selection before performing undo/redo
Fixes #6972.
2021-05-08 23:38:46 +02:00
Andreas Kling
194a90884c LibGUI: Remove now-unused undo coalescing timer from GUI::TextEditor
This is no longer used since commands handle merging themselves.
2021-05-08 22:17:51 +02:00
Andreas Kling
ce90d87eb6 LibGUI: Show command name in GUI::TextEditor undo/redo action text
We can now show things like "Undo Insert Text" and "Redo Remove Text"
instead of just "Undo" and "Redo" in menu items. Pretty neat! :^)
2021-05-08 22:17:51 +02:00
Andreas Kling
c670d8c56d LibGUI: Add UndoStack::{undo,redo}_action_text()
These return the action_text() for the current undo and redo commands,
if available.
2021-05-08 22:17:51 +02:00
Andreas Kling
0bfbee4596 LibGUI: Make Command::action_text() virtual
It will be easier for some commands to generate an action text on the
fly instead of having to think of it up front, so a virtual that you
can override seems more convenient here.
2021-05-08 22:17:51 +02:00
Andreas Kling
bfd2ec88f4 LibGUI: Make Action::set_text() update any associated menu items
Now you can change the text of an action and it will actually show
up in the menu. :^)
2021-05-08 22:17:51 +02:00
Andreas Kling
161568103e LibGUI: Remove UndoStack's automatic command combo'ing
UndoStack will now merge adjacent commands *if they want to be merged*
instead of bundling everything you push onto it until you tell it
to "finalize the combo."

This uses less memory and gives applications full control over how
their undo stacks end up. :^)
2021-05-08 22:17:51 +02:00
Andreas Kling
81bc861085 LibGUI: Implement merging of TextDocument's RemoveTextCommand
When deleting text by pressing backspace, the commands will be merged
into a single RemoveTextCommand.
2021-05-08 22:17:51 +02:00
Andreas Kling
ff6bac4854 LibGUI: Implement merging of TextDocument's InsertTextCommand
When performing multiple text insertions in a row, they will now
be merged into a single InsertTextCommand.
2021-05-08 22:17:51 +02:00
Andreas Kling
ff912946ae LibGUI: Support merging of adjacent commands on the UndoStack
When pushing a new command on an undo stack, we will now attempt to
merge it into the stack's current command.

Merging is implemented by overriding the "merge_with(Command const&)"
virtual on GUI::Command. :^)
2021-05-08 22:17:50 +02:00
Andreas Kling
244665d99c LibGUI: Some tweaks for TextEditor's will-execute-command virtual
Renamed the virtual from "on_edit_action" to "will_execute" so it
doesn't clash with our convention for Function hook names.

Also tighten the parameter type to GUI::TextDocumentUndoCommand
since that's the only kind of command it will receive.
2021-05-08 22:17:50 +02:00
Andreas Kling
aaa96e909b LibGUI: Don't fire TextDocument change notification after each command
The undo stack has its own notification mechanism now, and we no longer
piggyback on the document change notifications.
2021-05-08 22:17:50 +02:00
Maciej Zygmanowski
ece300e1e3 LibGUI: Add missing <AK/Function.h> include 2021-05-08 13:19:24 +01:00
Andreas Kling
2905e10513 LibGUI+TextEditor: Make TextDocument modified state track undo stack
This was quite unreliable before. Changes to the undo stack's modified
state are now reflected in the document's modified state, and the
GUI::TextEditor widget has its undo/redo actions updated automatically.

UndoStack is still a bit hard to understand due to the lazy coalescing
of commands, and that's something we should improve upon (e.g with more
explicit, incremental command merging.) But for now, this is a nice
improvement and undo/redo finally behaves in a way that feels natural.
2021-05-08 13:49:34 +02:00
Andreas Kling
ee19f7c0aa LibGUI: Use UndoStack::on_state_change inside TextDocument/TextEditor
Have TextDocument listen for state changes on the internal undo stack,
and forward those to all clients via a new virtual function.

This simplifies updating the can_undo / can_redo states of TextEditor.
2021-05-08 13:49:34 +02:00
Andreas Kling
0cb6103928 LibGUI: Add UndoStack::on_state_change hook
This will allow clients to react to the undo stack changing state.
It's invoked when the stack or clean index are changed.
2021-05-08 13:49:34 +02:00
Andreas Kling
74a4571f02 LibGUI: Reverse internal direction of GUI::UndoStack
The undo stack was very difficult to understand as it grew by adding
new undo commands to the front of the internal vector. This meant we
had to keep updating indices as the stack grew and shrank.

This patch makes the internal vector grow by appending instead.
2021-05-08 13:49:34 +02:00
Andreas Kling
2ef4fbc5c1 Revert "LibGUI: Fix undo stack reporting wrong modified state"
This reverts commit 0b7e19e2bb.

Let's reverse the direction of the undo stack to fix the confusion.
2021-05-08 13:48:15 +02:00
Carlos César Neves Enumo
0b7e19e2bb LibGUI: Fix undo stack reporting wrong modified state
Since the `redo` action never goes back to `index: 0`,
we have to mark the clean index as being the current
non-empty index for the undo/redo navigation to work properly.

The problem is that if we never `undo`, the stack index stays at zero,
which is the empty container waiting for commands. In that situation,
if we save the document, it registers the clean index as being 1
(the non-empty index) but because the stack index has never left zero,
the document was being reported as modified, being out of sync with
the window modified state.
2021-05-08 09:55:45 +01:00
Gunnar Beutner
eed6ce8b8b Profiler: Fix scrolling behavior
When resizing the timeline view the timelines should scroll to the
bottom when the resize operation reveals space that is beyond the
view.
2021-05-08 09:55:24 +02:00
Andreas Kling
295cc123c7 LibGUI: Rename UndoStack internals
Since we keep a stack of command combos, let's call entries on the
stack "Combo" instead of "UndoCommandsContainer".

And since it has a vector of commands, let's call it "commands"
instead of "m_undo_vector".
2021-05-08 08:53:37 +02:00
Andreas Kling
8d5eb075d8 LibGUI: Convert StringBuilder::appendf() => AK::Format 2021-05-07 21:12:09 +02:00
Max Wipfli
228c1f4968 LibGUI: Remove line-is-empty check in TextDocument return-early
This patch removes an incorrect way for TextDocument::text_in_range
to return early when the first line of the selection was empty. This
fixes an issue in TextEditor where the status bar showed that 0
characters are selected when the selection started on an empty line.
2021-05-06 23:00:43 +01:00
Andreas Kling
dfd8598bf7 LibGUI: Don't show resize corner in non-resizable window's statusbar
Fixes #6886.
2021-05-06 12:08:00 +02:00
Tom
3aaffa2c47 LibGUI: Move widget registration to LibCore
This also moves Widget::load_from_json into Core::Object as a virtual
function in order to allow loading non-widget objects in GML (e.g.
BoxLayout).

Co-authored-by: Gunnar Beutner <gbeutner@serenityos.org>
2021-05-06 08:50:39 +02:00
Carlos César Neves Enumo
928f16d360 LibGUI: Remember modified state on undo/redo actions 2021-05-06 08:40:26 +02:00
Carlos César Neves Enumo
67537bfc80 LibGUI: Clear undo stack when opening a new document 2021-05-06 08:40:26 +02:00
Andreas Kling
18d344609f LibGUI: Add ScrollableContainerWidget :^)
This widget provides a scrollable view onto another (child) widget.
If the child is larger than the parent, scrollbars are provided for
panning around the child.
2021-05-05 22:17:33 +02:00
Timothy Flynn
ee1a4a06e0 LibGUI: Allow specifying GUI::Statusbar segment count in GML 2021-05-05 21:38:45 +02:00
Andreas Kling
d136fafde7 LibGUI: Make GUI::Widget ignore wheel events by default
This makes wheel events bubble up to parent widgets, which is useful
in case they care about wheel events even if their children don't.
2021-05-04 17:32:19 +02:00
Andreas Kling
f7de453716 LibGUI: Rename ScrollableWidget.cpp => AbstractScrollableWidget.cpp 2021-05-04 14:38:43 +02:00
Linus Groh
aa70a56174 LibGUI: Fix off-by-one in Scrollbar::scrubber_rect()
Recent changes in the button painting code made this unnecessary. For
the case of value() == max(), the scrubber button would overlap the
increment button.

Fixes #6838.
2021-05-03 22:22:53 +01:00
Linus Groh
0c1d1d97d5 LibGUI: Remove unused Scrollbar::{de,in}crement_gutter_rect() 2021-05-03 22:21:21 +01:00
Andreas Kling
1aa56f0129 WindowServer+LibGUI: Make much of window construction asynchronous
Most of the IPC that happens between clients and WindowServer when
creating and configuring windows can be asynchronous. This further
reduces the amount of ping-ponging played during application startup.
2021-05-03 21:56:19 +02:00
Andreas Kling
a8a899adbf WindowServer+LibGUI: Make much of menu construction asynchronous
Creating a menu/menubar needs to be synchronous because we need the
ID from the response, but adding stuff *to* menus (and adding menus
to menubars, and menubars to windows) can all be asynchronous.

This dramatically reduces the amount of IPC ping-pong played by
each GUI application during startup.

I measured how long it takes TextEditor to enter the main event loop
and it's over 10% faster here. (Down from ~86ms to ~74ms)
2021-05-03 21:56:13 +02:00