Commit graph

407 commits

Author SHA1 Message Date
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
Gunnar Beutner
eb21aa65d1 Userland: Make IPC results with one return value available directly
This changes client methods so that they return the IPC response's
return value directly - instead of the response struct - for IPC
methods which only have a single return value.
2021-05-03 21:14:40 +02:00
Gunnar Beutner
5bb79ea0a7 Userland: Update IPC calls to use proxies
This updates all existing code to use the auto-generated client
methods instead of post_message/send_sync.
2021-05-03 21:14:40 +02:00
Gunnar Beutner
065040872f Userland: Change IPC funcs to use plain arguments instead of a struct
Instead of having a single overloaded handle method each method gets
its own unique method name now.
2021-05-03 21:14:06 +02:00
Andreas Kling
d47f15ab8b LibGUI: Rename ScrollableWidget => AbstractScrollableWidget 2021-05-03 21:03:13 +02:00
Andreas Kling
381dcca2f6 Revert "LibGfx: Add directional floating-point scaling to Painter"
This reverts commit ff76a5b8d2.
2021-05-03 16:37:05 +02:00
Paul Berg
bd68ca362b TextEditor: Clear the selection before deleting it
This patches fixes a crash of the Userland/TextEditor where it would
crash when deleting a range spanning two lines. This was because the
TextEditor would delete the range and modify the cursor position
before clearing the selection. This would trigger a status bar update
with the invalid selection.
2021-05-03 08:45:32 +02:00
Carlos César Neves Enumo
97d0028098 LibGUI: Debounce TextDocument undo stack
This replaces the repeating 2-sec timer with a debounced single-shot
timer on user input.
2021-05-03 08:43:10 +02:00
Matthew Olsson
ff76a5b8d2 LibGfx: Add directional floating-point scaling to Painter
This allows the painter to be scaled separately in both directions, and
not just in integer intervals. This is crucial for proper SVG viewBox
support.

Most bitmap-related things verify the scale to be one as of now.
2021-05-02 22:48:06 +02:00
Matthew Olsson
88cfaf7bf0 LibGfx: Unify Rect, Point, and Size
This commit unifies methods and method/param names between the above
classes, as well as adds [[nodiscard]] and ALWAYS_INLINE where
appropriate. It also renamed the various move_by methods to
translate_by, as that more closely matches the transformation
terminology.
2021-05-02 22:48:06 +02:00
Andreas Kling
68a0e4f8d5 LibGUI+HackStudio: Remove editing specific hacks from GUI::Command
Use is<T> to check for specific types of command in HackStudio instead
of cluttering up GUI::Command with specialized getters.
2021-05-02 14:49:46 +02:00
Andreas Kling
cc6db526a6 WindowServer+LibGUI+Taskbar: Store window progress as Optional<int>
We were previously using the magical constant -1 to signify that a
window had no progress state. Be more explicit an use an Optional. :^)
2021-05-02 10:43:39 +02:00
Gunnar Beutner
6cf59b6ae9 Everywhere: Turn #if *_DEBUG into dbgln_if/if constexpr 2021-05-01 21:25:06 +02:00
Andreas Kling
6536a979d8 LibGUI: Improve a FIXME comment in TextDocument 2021-05-01 19:42:29 +02:00
Andreas Kling
5b68a76c77 LibGUI: Track modified state in GUI::TextDocument
Until now, this has been hackishly tracked by the TextEditor app's
main widget. Let's do it in GUI::TextDocument instead, so that anyone
who uses this class can know whether it's modified or not.
2021-05-01 19:42:29 +02:00
Andreas Kling
2fa765bbd5 LibGUI: Add getter/setter for GUI::Window modified state
This state lives in WindowServer and has no local copy in the client
process for now. This may turn out to be a performance issue, and if
it does we can easily cache it.
2021-05-01 19:42:29 +02:00
Valtteri Koskivuori
8fac7a1d5d
LibGUI: Bump up common locations width from 90 to 95
The Documents directory shows up properly now when selected.
Previously the bold text would not fit horizontally, causing an
ellipsis at the end.
2021-04-30 23:27:29 +02:00
Andreas Kling
3d4afe7614 Everywhere: "indexes" => "indices"
I've wasted a silly amount of time in the past fretting over which
of these words to use. Let's just choose one and use it everywhere. :^)
2021-04-29 22:23:52 +02:00
Andreas Kling
7ae7170d61 Everywhere: "file name" => "filename" 2021-04-29 22:16:18 +02:00
Gunnar Beutner
c861195557 Userland: Fix new GCC warnings 2021-04-29 10:33:44 +02:00
Mart G
d96aae32ef LibGUI: Fix issue where buttons with a menu sometimes stayed depressed
When a Button has a menu, the AbstractButton behaviour will now not
be used in the mousemove_event. This was already the case for
mousedown_event.

Why only sometimes?
Normally the presence of the menu prevents mousemove_events from being
delivered to the button. But the menu doesn't spawn immediately. So
sometimes mousemove events got through to the AbstractButton after the
menu was told to spawn but before it appeared. This caused the
m_being_pressed field of AbstractButton to be set to true. But there
was never a mouseup_event because the menu got those instead.
2021-04-29 01:01:39 +02:00
Linus Groh
45f97e577e Userland: Fix two misaligned copyright headers 2021-04-29 00:59:26 +02:00
Linus Groh
649d2faeab Everywhere: Use "the SerenityOS developers." in copyright headers
We had some inconsistencies before:

- Sometimes "The", sometimes "the"
- Sometimes trailing ".", sometimes no trailing "."

I picked the most common one (lowecase "the", trailing ".") and applied
it to all copyright headers.

By using the exact same string everywhere we can ensure nothing gets
missed during a global search (and replace), and that these
inconsistencies are not spread any further (as copyright headers are
commonly copied to new files).
2021-04-29 00:59:26 +02:00
Paul Berg
03d8ee1082 VimEditingEngine: allow selection of the endline character
This patch fixes the visual selection of endline characters in the
VimEditingEngine. When the visual mode is disabled and the cursor
is located on the endline character, it is shifted back to the last
character of the line.
2021-04-27 19:05:16 +02:00
sin-ack
ace2c337dc VimEditingEngine: Handle arrow, Home/End and Page keys
This patch adds handling of the arrow, Home/End, and PageUp/PageDown
keys to the Vim emulation mode.  Home acts as 0, End acts as $, arrow
keys act as their HJKL variants, and PageUp/Down behaves as you would
expect.

This patch also moves the default handling of the aforementioned keys
to insert mode, since regular EditingEngine semantics are more
appropriate there.
2021-04-27 13:10:10 +02:00
sin-ack
d6dc81874d EditingEngine: Split selection from movement functions
This patch moves selection updates outside movement functions in
EditingEngine.  Previously, movement functions would automatically
update the selection based on whether the Shift key was pressed down
during movement.  However, not all EditingEngine subclasses want that;
VimEditingEngine being a good example (because all selection is handled
in visual mode).

Therefore, this patch moves all selection updating to
EditingEngine::on_key().  Subclasses wishing to provide custom movement
and selection semantics should override it (and VimEditingEngine already
does).
2021-04-27 09:03:38 +02:00
Jelle Raaijmakers
83dfc4aa46 LibGUI/Window: Do not reset mouse cursor on show()
Window::m_cursor already has ::None as its default value, so let's not
overwrite its value if it was set to something else.
2021-04-27 08:58:13 +02:00
DexesTTP
91c210c39a LibGUI: Make common locations configurable 2021-04-26 18:57:57 +02:00
thankyouverycool
67f81adc55 Calendar: Swap Liza for Marieta 2021-04-26 18:41:54 +02:00
Linus Groh
dbe72fd962 Everywhere: Remove empty line after function body opening curly brace 2021-04-25 20:20:00 +02:00
Rafał
2d6be48c6f
LibGUI: Select last word when double clicking at the end of a line
Fixes #6565.
2021-04-25 19:51:03 +02:00
sin-ack
53aec3e06d LibGUI: Implement Vim motion system
This patch implements Vim motions.  The VimMotion class will accept
keycodes from the editing engine to build up a motion, and will
signal when a motion is complete via VimMotion::is_complete().  The
editing engine can then call VimMotion::get_range() to obtain a
TextRange object which can be used to perform operations on the text,
or VimMotion::get_position() to obtain a TextPosition which is the
new position of the cursor after the motion.

Currently, the following motions are supported:

- h/j/k/l, regular Vim line and character movements
- 0/^/$, start/end of line and start of non-blank
- w/e/b/ge, word-related movements
- W/E/B/gE, WORD (anything non-blank) versions of the above motions
- gg/G, document related movements
- t/f, to/find character

All motions except gg/G accept a number prefix to repeat the motion that
many times.

This patch updates insert, normal and visual modes to use this motion
system for movement.
2021-04-25 10:41:16 +02:00
Rok Povsic
77d4b6e435 VimEditingEngine: Add handling { and } to move between empty lines 2021-04-25 09:34:51 +02:00
Andreas Kling
8ebb9d350c LibGUI: Remove some unused cruft from GUI::IconView 2021-04-24 18:50:12 +02:00
Mart G
157cd7c819 LibGUI: Prevent a Painter's clip_rect from being outside of its target
Previously a Painter's m_clip_origin field was initialized to a
widget's window_relative_rect, which is not ensured to be within
the target rect.
m_clip_origin is normally not used for clipping, but after calling
clear_clip_rect the clip rect that IS used for clipping gets reset
to m_clip_origin (so an invalid state is entered).
Now the window_relative_rect will be clipped by the target rect
first, and will only then be used to initialize both the active
clip_rect and m_clip_origin.
2021-04-24 15:57:20 +02:00
Andreas Kling
b91c49364d AK: Rename adopt() to adopt_ref()
This makes it more symmetrical with adopt_own() (which is used to
create a NonnullOwnPtr from the result of a naked new.)
2021-04-23 16:46:57 +02:00
thankyouverycool
99e7ad4b76 LibGUI: Allow bypassing hook when setting SpinBox range
Pass false to set_range to avoid on_change side-effects.
2021-04-23 11:08:11 +02:00
Linus Groh
ebdeed087c Everywhere: Use linusg@serenityos.org for my copyright headers 2021-04-22 22:51:19 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
9db2036437 LibGUI: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Rafał
c41c41cc0f
LibGUI: Prevent selecting empty line in TextEditor on double click (#6537) 2021-04-21 23:48:26 +02:00
iCristalrope
8bb4409a5d
LibGUI: Track selection starting index in AbstractView (#6515)
Modifying the selection while holding the shift button and selecting
with the mouse or the arrow keys no longer results in broken selections.

Fixes #6279.
2021-04-21 17:09:04 +02:00
jakewestrip
b9fc7780ae LibGUI: Remove premature return in Window::handle_key_event 2021-04-21 15:24:57 +02:00
Leandro Pereira
29fd75f22f LibGUI: Make statusbar label flat when displaying override_text
Changing the statusbar appearance when overriding text makes it less
confusing as it's supposed to be something temporary, e.g.  only when
hovering over a toolbar or menu item.

This behavior is present on old Windows systems, although things work
slightly differently there (where only the overridden text is displayed
rather than all the segments).
2021-04-20 09:24:52 +02:00
Conor Byrne
88ecfa164a LibGUI+WindowServer: Add WM_SuperKeyPressed event
This commit adds an event called WM_SuperKeyPressed which is sent to all
windows via WindowManagerServerConnection.
The event is fired from WindowManager when the super key is pressed,
which is the windows key on most keyboards :)
2021-04-19 20:03:25 +02:00
Andreas Kling
7ceb4f5330 LibGUI: Add some more status tips to common actions 2021-04-18 10:58:22 +02:00
Andreas Kling
a2086ad56e LibGUI: Rename Action::long_text to Action::status_tip
This feels a bit more descriptive.
2021-04-18 10:58:22 +02:00
Linus Groh
2b0c361d04 Everywhere: Fix a bunch of typos 2021-04-18 10:30:03 +02:00
Andreas Kling
22ed6a70eb LibGUI: Add "override text" to GUI::Statusbar
Each statusbar segment now has an optional "override text" which can
be set, and if non-null will be displayed instead of the regular text.

This allows programs to display contextual information in the statusbar
temporarily without losing whatever text was already on there.
2021-04-17 20:49:53 +02:00
Andreas Kling
3bf2f7a329 LibGUI: Make GUI::Toolbar buttons generate ActionEnter and ActionLeave
Now you'll get the same event whether you hover an action in a menu
or in a toolbar. :^)
2021-04-17 20:49:53 +02:00
Andreas Kling
7d0b59cb05 LibGUI: Add action enter/leave hooks on GUI::Application
Apps can now hook into these events by assigning a callback to the
on_action_enter and on_action_leave hooks on GUI::Application. :^)
2021-04-17 20:49:53 +02:00
Andreas Kling
4c6f541d5b LibGUI: Add Action* accessors on GUI::Button 2021-04-17 20:49:53 +02:00
Andreas Kling
e7263a7e75 LibGUI: Add a "long text" string to GUI::Action
Actions can now have a longer text description, in addition to its
regular UI string. The longer text will soon be used to display
a more detailed description of hovered actions in statusbars.
2021-04-17 20:49:53 +02:00
Andreas Kling
ba7e1ca2fb WindowServer+LibGUI: Notify GUI clients about menu item enter/leave
We now send out MenuItemEntered and MenuItemLeft messages to the client
when the user hovers/unhovers menu items.

On the client side, these become GUI::ActionEvent, with one of two
types: ActionEnter or ActionLeave. They are sent to the Application.

This will allow GUI applications to react to these events.
2021-04-17 20:49:53 +02:00
Andreas Kling
358697a32f LibGUI: Make sure we depend on the WindowManager IPC endpoints 2021-04-17 15:58:34 +02:00
sin-ack
aa56f9a1e0 LibGUI+WindowServer: Separate window manager IPC from regular IPC
With this patch the window manager related functionality is split out
onto a new endpoint pair named WindowManagerServer/Client.  This allows
window manager functionality to be potentially privilege separated in
the future.  To this end, a new client named WMConnectionClient
is used to maintain a window manager connection.  When a process
connects to the endpoint and greets the WindowServer as a window manager
(via Window::make_window_manager(int)), they're subscribed to the events
they requested via the WM event mask.

This patch also removes the hardcoding of the Taskbar WindowType to
receive WM events automatically.  However, being a window manager still
requires having an active window, at the moment.
2021-04-17 13:06:25 +02:00
Andreas Kling
0e4eb62dd8 LibGUI: Make some API's take String instead of StringView 2021-04-17 01:27:30 +02:00
Andreas Kling
050648b270 LibGUI: Make Window::set_title() take a String 2021-04-17 01:27:29 +02:00
Andreas Kling
d33fdc925b LibGUI: Make GUI::Widget::set_tooltip() take a String
There was no reason for this to take a StringView.
2021-04-17 01:27:29 +02:00
James Triantafylos
c9196995be LibGUI: Allow arbitrary font size in FontPicker
This commit adds a SpinBox to the FontPicker dialog to allow users to
set arbitrary font sizes (1 to 255 inclusive) for TTF fonts.
The SpinBox is only visible when the user is selecting a TTF font.
2021-04-16 23:54:03 +02:00
Linus Groh
ba3bc6fef2 LibGUI+WindowServer: Fix some misaligned CMakeLists.txt SOURCES entries 2021-04-16 21:30:53 +02:00
Andreas Kling
a2baab38fd Everywhere: It's now "Foobar", not "FooBar", and not "foo bar"
I hereby declare these to be full nouns that we don't split,
neither by space, nor by underscore:

- Breadcrumbbar
- Coolbar
- Menubar
- Progressbar
- Scrollbar
- Statusbar
- Taskbar
- Toolbar

This patch makes everything consistent by replacing every other variant
of these with the proper one. :^)
2021-04-13 16:58:15 +02:00
Itamar
f52c3cabcf HackStudio: Add ClassView tab for viewing classes in a tree structure
This enables the user to view and navigate classes with a TreeView that
is updated by the LanguageServer as it parses the code.

It offers a new neat way to view the project's structure :^)
2021-04-13 15:16:27 +02:00
Itamar
b87791cada LibCpp: Add 'Namespace' and 'Member' declaration types 2021-04-13 15:16:27 +02:00
FalseHonesty
2ed5d19407 LibGUI+HackStudio: Add way to tell FilePicker to open a folder
This now means that when trying to open a folder, one can click on
the folder and press open instead of having to actually step into
the desired folder. Of course, it also means it won't let you open
non-directories anymore.
2021-04-13 15:16:07 +02:00
Andreas Kling
1ca22b46f9 LibGUI: Allow GUI::ProgressBar to have min() == max() 2021-04-13 10:12:50 +02:00
Andreas Kling
a2686f9bec LibGUI: Avoid unnecessary Gfx::Bitmap cloning in FileIconProvider 2021-04-11 12:52:42 +02:00
Andreas Kling
0c02dfcad5 LibGUI: Add convenient helpers for getting the sibling of a ModelIndex 2021-04-11 12:52:42 +02:00
Brian Gianforcaro
dc98c417ca LibGUI: Remove an unused AK/Debug.h include 2021-04-11 12:50:33 +02:00
thankyouverycool
25bd4b33a7 LibGUI: Move FontPickerWeightModel and helpers to their own header
Avoids maintaining multiple weight-name lists
2021-04-11 01:16:34 +02:00
Andreas Kling
a4992b5ece LibGUI+LibGfx: Collapse the '&' from Alt shortcuts in tooltip texts
Also resolve a FIXME about using GUI::Label auto-sizing since we're
changing this code and it simplifies what we're doing.

Fixes #6219.
2021-04-11 01:11:09 +02:00
Jelle Raaijmakers
06353077b7 LibGUI/ScrollBar: Only paint buttons as pressed when also hovered
Fixes #6185
2021-04-10 22:28:00 +02:00
AnotherTest
a6e4482080 AK+Everywhere: Make StdLibExtras templates less wrapper-y
This commit makes the user-facing StdLibExtras templates and utilities
arguably more nice-looking by removing the need to reach into the
wrapper structs generated by them to get the value/type needed.
The C++ standard library had to invent `_v` and `_t` variants (likely
because of backwards compat), but we don't need to cater to any codebase
except our own, so might as well have good things for free. :^)
2021-04-10 21:01:31 +02:00
Andreas Kling
d0813be65a LibGUI: Ignore right-clicks on HeaderViews
This prevents right-clicking a column header from making it appear
depressed right before the context menu is shown.
2021-04-10 16:50:43 +02:00
Andreas Kling
48eb58230b LibGUI: List directories before files in FileSystemModel
Instead of mixing directories and files, sorting a FileSystemModel by
the Name column will now give you all the directories first, followed
by all the files.
2021-04-10 13:58:13 +02:00
Andreas Kling
088ae37541 LibGUI: Reflow+update TextEditor widget after ruler visibility change 2021-04-10 00:09:44 +02:00
Andreas Kling
58106f57de LibGUI: Remove 2px of vertical space around FilePicker common places
The extra margin is not needed with the new "Tray" look. :^)
2021-04-09 23:58:04 +02:00
Andreas Kling
42ec6718f2 Base+LibGUI: Add an familiar-looking icon for the desktop directory 2021-04-09 23:45:21 +02:00
Andreas Kling
2de1f32433 LibGUI: Yet another FilePicker UI tweak
Make sure the "Look in:" label is vertically centered within its
corresponding location box.
2021-04-09 23:09:52 +02:00
Andreas Kling
8db4819271 LibGUI: Allow navigating into symlinked directories in FilePicker
If you double-click on a symlink to a directory while browsing with
a FilePicker, you most likely want to open the directory the symlink
points to, not open the symlink itself. So let's do that. :^)
2021-04-09 23:04:04 +02:00
Andreas Kling
bcd05e199b LibGUI: Fix uniform TabWidget tabs bleeding outside the widget
The last uniform-sized tab button would bleed outside the tab bar area
due to us not taking the bar margin into account.
2021-04-09 22:30:41 +02:00
Andreas Kling
c8ff507534 LibGUI: Add TabWidget::on_tab_count_change hook 2021-04-09 22:23:14 +02:00
Andreas Kling
2aaf12e9cd LibGUI: More tweaks for the FilePicker UI layout 2021-04-09 21:53:43 +02:00
Andreas Kling
da7dbc116e LibGUI: Use "Tray" look & feel for the common locations frame :^) 2021-04-09 21:53:43 +02:00
Andreas Kling
3e43b1f173 LibGUI: Tweak FilePickerDialog UI layout 2021-04-09 21:53:43 +02:00
Andreas Kling
afb6e3a79d LibGUI: Give Alt shortcuts to all the CommonActions :^) 2021-04-09 17:08:49 +02:00
AnotherTest
a42886d8ff LibGUI: Update the autocomplete suggestions after processing keys
Previously, this was updating the suggestions before processing the keys
and whatever changes they caused, making the suggestions stale until the
periodic auto-autocomplete timer fired (if enabled).
2021-04-07 08:48:50 +02:00
thankyouverycool
e8c1288e2c LibGUI: Add autosize to CheckBox 2021-04-06 22:24:05 +02:00
thankyouverycool
8afe013069 LibGUI:: Let open/save specify starting directory in FilePicker 2021-04-06 22:24:05 +02:00
Itamar
9545c156b5 LibGUI: Fix typo in AutocompleteBox::show 2021-04-06 21:51:58 +02:00
Andreas Kling
c28a3a385b LibGUI: Tweak order of common location buttons in FilePicker
Let's put the root directory up top so the buttons are in order of
directory specificity.
2021-04-06 21:07:04 +02:00
Andreas Kling
33d9b592cd LibGUI: Make FilePicker's common location buttons checkable
We now use the checked state of these buttons to indicate that you are
in that specific folder. The checked state is updated automagically
no matter how you navigate the file system. :^)
2021-04-06 21:07:04 +02:00
Andreas Kling
25de655d43 LibGUI: Add shortcuts to common locations in GUI::FilePicker
This patch adds a handy set of buttons on the left hand side that can
take you to common locations such as:

- Your home directory
- Your desktop directory
- The root directory
2021-04-06 21:07:04 +02:00
Andreas Kling
15349a3712 LibGUI: Add ability to assign a menu to a GUI::Button
When a button has a menu, it opens the menu on mousedown and the
menu gains input focus immediately. While the menu is open, the
button is painted in a pressed state.
2021-04-05 18:09:04 +02:00
Andreas Kling
9b740f218b WindowServer+LibGUI: Notify clients when menus become visible/hidden
This will allow clients to react to these events.
2021-04-05 18:09:04 +02:00
Maciej Zygmanowski
8646f8f4ad LibGUI: Use normalized TextRange for early empty string check
Fixes #6141. Allows to copy "backward" selections.
2021-04-05 17:06:07 +02:00
Andreas Kling
52de9b1753 LibGUI: Do AbstractView::set_column_hidden() => set_column_visible()
This API felt backwards, so let's change it.
2021-04-05 11:57:47 +02:00
Andreas Kling
eff7ea5b84 LibGUI: Add GUI::CommonActions::make_properties_action()
Many apps want a "Properties" action with the same icon and shortcut.
2021-04-04 22:43:43 +02:00
Andreas Kling
0069020e6c WindowServer+LibGUI: Rename WindowType::MenuApplet => Applet 2021-04-04 17:55:50 +02:00
Linus Groh
96b26ec125 Everywhere: Replace uses of GUI::Desktop's on_rect_change and remove it 2021-04-04 00:37:54 +02:00
Linus Groh
5367bbb82c LibGUI: Add ScreenRectChangeEvent and deliver it to windows and widgets
Having to rely on GUI::Desktop's on_rect_change is quite limiting and a
bit awkward (continuing to use it would mean having to setup the
callback in every application using a webview) - we need a better way of
letting widgets know of a screen rect change automatically.

The specific use case will be IPWV/OOPWV which need to keep track of the
screen rect and notify the WebContent service of any change (which on
its own deliberately can't interact with WindowServer at all).

It'll also be useful for notification windows and the taskbar, which
currently both rely on the GUI::Desktop callback but will now be able to
listen and react to the event themselves.
2021-04-04 00:37:54 +02:00
Andreas Kling
64d4921f35 LibGUI: Don't try to paint items in model-less IconView :^)
Fixes #6079.
2021-04-03 20:36:43 +02:00
Andreas Kling
6ba00ae5b9 LibGUI: Subtract layout margin when placing items along secondary axis
While space distribution along the primary axis of a BoxLayout is
pretty sophisticated, the secondary axis is very simple: we simply
center the widget.

However, this doesn't always look very nice if we don't take margins
into account, so make sure we subtract them from the rect we do all
the centering within.
2021-04-02 23:33:17 +02:00
thankyouverycool
dc6db819f9 LibGUI: Always outline selected date and paint today's date bold
Fixes selected dates and today's date not painting correctly when
viewed from adjacent months
2021-04-02 22:23:21 +02:00
thankyouverycool
14e074cd24 LibGUI+Calendar: Inherit from Frame class
Fixes incorrect painting with variable thickness and cuts down
on some layout boilerplate.
2021-04-02 22:23:21 +02:00
Andreas Kling
0cd60a28ba WindowServer+LibGUI: Plumb mouse/enter/leave events to applet windows
Since applet windows live in the applet area window, the AppletManager
has to keep track of which applet is hovered and send the appropriate
enter/leave events to the applet windows.

This makes applet tooltips work again. :^)
2021-03-30 23:43:24 +02:00
Andreas Kling
9bbc1c9c93 WindowServer+Taskbar: Show applets in taskbar :^)
WindowServer now collects applet windows into an "applet area" which is
really just a window that a WM (window management) client can position
via IPC.

This is rather hackish, and I think we should come up with a better
architecture eventually, but this brings back the missing applets since
the global menu where they used to live is gone.
2021-03-30 23:43:24 +02:00
one-some
279599cbed EditingEngine: Don't jump to the beginning or end of a non-existant word
Previously, when jumping to the next word on the last column of a line,
or when jumping to the previous word on the first column, it would
crash. This checks if that is the case, and if so, will do nothing.
2021-03-30 11:32:59 +02:00
thankyouverycool
4465b37897 LibGUI+Calendar: Add new month and year views to Calendar
And overhaul resize and paint events to fix layout edge cases in
which Calendar wasn't filling its parent widget completely. Ensures
month views always display prior month days for click navigation.
Converts Calendar app layout to GML.
2021-03-30 10:34:34 +02:00
thankyouverycool
fec9c8034d LibGUI: Don't inflate icon text rects beyond available width
Fixes wrapped text candidates not first eliding
2021-03-30 10:33:08 +02:00
Andreas Kling
50a8e0e495 LibGUI+WindowServer: Keep canonical WindowType enum in WindowServer
Having the same enum in two places was annoying. Let's just "using"
the WindowServer::WindowType enum into the GUI namespace.
2021-03-29 22:39:18 +02:00
Timothy Flynn
b88de8a91f LibGUI: Add transient option to show dotfiles in FilePicker
This is particularly useful when wanting to open files in ~/.config
from the Text Editor. The option is currently not persistent, but could
be hooked into File Manager's configuration.
2021-03-29 19:36:38 +02:00
Itamar
f6cc382403 TextEditor: Adjust AutoCompleteBox's position to the scroll height 2021-03-29 18:05:46 +02:00
Edgar Araújo
532e0090fc LibGUI: Enable the use of font properties through GML
You can now specify the font, font_size, font_weight
and font_type (fixed_width/normal) through GML
2021-03-29 09:10:23 +02:00
Edgar Araújo
e23b9907e7 LibGUI: Remove the necessity to have empty {} on GML objects
This simplifies GML syntax when the object doesn't have
any childs or properties
2021-03-29 09:10:23 +02:00
Tom
ee3ac88c2d LibGUI: Fix IconView selection with FlowDirection::TopToBottom
While iterating the items contained by the rubberband we need to skip
the correct number of items either vertically or horizontally, depending
on which direction the items flow.

Fixes #5993
2021-03-29 09:07:25 +02:00
AnotherTest
bbf6847d50 LibGUI: Register GUI::StackWidget with GML 2021-03-28 11:46:47 +02:00
Andreas Kling
247717431d LibGUI: Make GUI::Widget::event() protected 2021-03-28 11:25:40 +02:00
Linus Groh
e8aa998cdc LibGUI: Return symlink fallback icon if target icon cannot be determined
This is the case for symlinks that point to themselves, for example -
previously the returned icon would be empty.

Fixes #5978.
Fixes #5979.
2021-03-27 19:43:36 +01:00
Federico Guerinoni
49a062f81d LibGUI: Show human readable size in filemanager
The size is visible only in TableView mode of the filemanager.
2021-03-26 22:59:09 +01:00
Timothy Flynn
990e362a17 LibGUI: Allow assigning a value to a specific index in JsonArrayModel 2021-03-26 22:58:31 +01:00
Andreas Kling
e9db10e3a9 WindowServer+LibGUI: Remove the global menubar :^)
This leaves menu applets running but invisible, and that's a regression
we need to take care of obviously. But not today, because it's getting
too late.
2021-03-25 23:27:11 +01:00
Andreas Kling
32c6e31f4c LibGUI: Make it possible to tweak icon spacing on a GUI::Button
This is the space between the icon and the text on buttons that have
both icon and text.
2021-03-25 22:41:40 +01:00
Andreas Kling
78b12e1521 Userland: Turn all application menus into window menus :^) 2021-03-25 22:14:09 +01:00