Commit graph

741 commits

Author SHA1 Message Date
Hüseyin ASLITÜRK
25227ee284 LibGUI: Add MessageBox question icon 2020-05-20 13:54:10 +02:00
Hüseyin ASLITÜRK
d18f6e82eb LibGUI: Replace up and down arrows with emoji 2020-05-20 13:40:24 +02:00
Hüseyin ASLITÜRK
80699a0824 LibGUI: Update copyright character in about dialog 2020-05-20 13:40:24 +02:00
Andreas Kling
6d078a9ec3 LibGUI: Use dbg() instead of dbgprintf() in GUI::Dialog 2020-05-19 17:46:28 +02:00
Andreas Kling
ff8d250cbc LibGUI: Remove some ancient unused debug logging in AbstractButton 2020-05-19 17:46:28 +02:00
Linus Groh
4ab4de7810 LibGUI: Add ability to hide GUI::TabWidget's tab bar 2020-05-19 17:42:48 +02:00
Andreas Kling
bdfd1f1545 LibGUI: Make text selection feel better in single-line editors
We should always stay on the only line when selecting in a single-line
editor, instead of requiring the user to keep the cursor inside the
text when selecting.

This broke with the variable-width font changes.
2020-05-18 17:55:21 +02:00
Andreas Kling
62b7418376 LibGUI: Add 1px of horizontal content padding to TextEditor
This adds a little bit of needed air around the text.
2020-05-18 17:47:01 +02:00
Andreas Kling
558ca65ca5 LibGUI: Grow the "line content rect" slightly in single line text boxes
Previously we would sometimes leave some pixels from an old selection
rect on screen after clearing the selection. It was because the line
content rect was smaller than the visual selection rect, and we were
using the line content rect for invalidations.
2020-05-18 16:48:54 +02:00
Andreas Kling
a6e2125727 LibGUI: Use a variable-width font by default in single-line TextEditors
This makes things like the Browser location bar look way nicer. :^)
2020-05-18 16:48:54 +02:00
Andreas Kling
2e11c16be4 LibGUI: Support variable-width fonts in TextEditor
This patch reworks metric and coordinate computation to iterate over
text content instead of making assumptions about fixed glyph widths.
2020-05-18 16:48:54 +02:00
Andreas Kling
088841202d LibGUI: Remove outdated FIXME in TextEditor 2020-05-18 14:25:57 +02:00
Andreas Kling
014cb1a55b LibGUI: Tweak EmojiInputDialog layout :^) 2020-05-18 09:55:19 +02:00
Andreas Kling
6060c7444b LibGUI: Fix crash in TextDocument::remove(TextRange)
Oops, we can't be appending substrings of a string we just deleted!

Fix this by building up the new line instead of trying to clear and
append in place. This works out nicely as we now do fewer document view
updates when removing a range. :^)
2020-05-17 22:35:25 +02:00
Andreas Kling
604fb278c1 LibGUI: TextEditor now opts in to emoji input by default :^) 2020-05-17 22:35:25 +02:00
Andreas Kling
4173905198 LibGUI: Add a simple emoji input dialog activated by Ctrl+Alt+Space :^)
Widgets can now opt in to emoji input via set_accepts_emoji_input().
If the focused widget accepts emoji input, we'll pop up a simple dialog
with all the available emojis as clickable buttons.

You can press escape if you change your mind and don't want an emoji.

This UI layout definitely will not scale as we add more emojis, but it
works for the moment, and we can adapt it as we go. Pretty cool! :^)
2020-05-17 22:35:25 +02:00
Andreas Kling
1bef057ec3 LibGUI: Make the TextEditor widget store UTF-32 codepoints
A TextDocumentLine is now backed by a non-null-terminated sequence of
Unicode codepoints encoded as UTF-32 (one u32 per codepoint.)

This makes it possible to view and edit arbitrary Unicode text without
strange cursor and selection behavior. You can freely copy and paste
emojis between TextEditor and Terminal now. :^)

Storing UTF-32 is quite space-inefficient, but we should be able to
use the same optimization techniques as LibVT does to reduce it in
the typical case where most text is ASCII.

There are a lot of things that can be cleaned up around this code,
but this works well enough that I'm pretty happy with it.
2020-05-17 22:35:25 +02:00
Shannon Booth
df43e09433 LibGUI+WindowServer: Allow applications to set custom cursor bitmaps
This will allow e.g PaintBrush to use custom cursors for each tool.
2020-05-16 09:44:55 +02:00
Sergey Bugaev
acc107a44f FileManager+LibGUI+Userland: Switch clipboard to MIME types
We will now actually use MIME types for clipboard. The default type is now
"text/plain" (instead of just "text").

This also fixes some issues in copy(1) and paste(1).
2020-05-16 09:11:46 +02:00
Andreas Kling
7cc442dc44 LibGUI: Fix build (LibGUI depends on Clipboard IPC classes) 2020-05-15 09:46:55 +02:00
Andreas Kling
244efe050a Clipboard: Move the system clipboard to a dedicated service process :^)
This commit moves the clipboard from WindowServer into a new Clipboard
service program. Clipboard runs as the unprivileged "clipboard" user
and with a much tighter pledge than WindowServer.

To keep things working as before, all GUI::Application users now make
a connection to Clipboard after making the connection to WindowServer.
It could be interesting to connect to Clipboard on demand, but right
now that would necessitate expanding every GUI app's pledge to include
"unix" and also unveiling the clipboard portal, which I prefer not to.
2020-05-14 22:53:58 +02:00
Sergey Bugaev
450a2a0f9c Build: Switch to CMake :^)
Closes https://github.com/SerenityOS/serenity/issues/2080
2020-05-14 20:15:18 +02:00
Andreas Kling
3fe5dc35f2 LibGUI: Add AbstractTableView::move_selection(int steps)
This allows embedders to step the selection up/down and also simplifies
AbstractTableView by sharing code between Key_Up and Key_Down. :^)
2020-05-13 21:24:27 +02:00
Andreas Kling
14aa7f2d44 LibGUI: Add GUI::MessageBox::show_error() convenience function
This is just a wrapper around show() that puts up a standard-looking
error message.
2020-05-13 21:11:49 +02:00
Andreas Kling
c2b5519ce2 LibGUI+WindowServer: Allow apps to use the "move" cursor :^) 2020-05-13 00:16:40 +02:00
Andreas Kling
7dd8f1b921 LibGUI: Add missing Vector.h include to Event.h 2020-05-12 23:28:08 +02:00
Andreas Kling
977863ea07 LibGUI: Include keyboard modifier state with button on_click calls
This will allow you us to implement special behavior when Ctrl+clicking
a button.
2020-05-12 20:31:16 +02:00
Andreas Kling
8c51063a88 LibGUI: Actually check widgets in focus chain for keyboard shortcuts
We were iterating the ancestor chain of the focused widget when looking
for a matching keyboard shortcut, but we didn't actually look at the
ancestors at each step.

With this fix, we now correctly activate actions found in the ancestor
chain of the focused widgets. :^)
2020-05-12 17:05:00 +02:00
Andreas Kling
479f16bb6c LibGUI: Add KeyEvent::to_string()
This makes it way easier to debug key events.
2020-05-12 17:03:17 +02:00
Andreas Kling
90eec0a3d7 LibGUI: Use KeyCode stringification helper in Shortcut::to_string() 2020-05-12 17:02:33 +02:00
Andreas Kling
39d55d1d76 LibGUI: Add a way to highlight the focused widget for debugging
You can now pass --gui-focus-debug to any GUI::Application and it will
draw a cyan rectangle around the currently focused widget.
2020-05-12 15:48:31 +02:00
Andreas Kling
e064999e0d LibGUI: Allow scrolling through a ComboBox with the mouse wheel 2020-05-12 15:11:06 +02:00
Andreas Kling
575b674081 LibGUI: Add missing window() null check when widget's child is removed
Before notifying our window that a child was removed, we should first
check that we actually have a window! :^)
2020-05-12 14:06:25 +02:00
Andreas Kling
9d6c85e6a6 LibGUI: Remove ancient code for debugging widget underdraw 2020-05-12 13:43:37 +02:00
Andreas Kling
9e74793ce2 LibGUI+LibGfx: Paint scollbar tracks with a dithered pattern
Instead of a solid color, we now paint the track/gutter of scrollbars
using a 2-color dither pattern for a pleasant millennium feel. :^)
2020-05-10 01:02:06 +02:00
FalseHonesty
bb6258229a LibGUI: Add hook when a tab is middle clicked 2020-05-09 23:54:20 +02:00
Andreas Kling
cf3b58fbe8 Services: Renamed from Servers
It didn't feel right to have a "DHCPClient" in a "Servers" directory.
Rename this to Services to better reflect the type of programs we'll
be putting in there.
2020-05-08 21:57:44 +02:00
Andreas Kling
03c91fce74 LibGUI: Highlight interactive area of hovered CheckBox and RadioButton
This is consistent what we do for regular Buttons and gives a pleasant
visual cue when you're over a clickable area.
2020-05-08 21:12:16 +02:00
Andreas Kling
0f0d73d1b5 LibGUI: Make the "enabled" widget state propagate to child widgets
This simplifies building composite widgets by not having to worry about
updating widget subtrees.
2020-05-08 13:49:58 +02:00
Hüseyin ASLITÜRK
f0f98de5d8 LibGUI: Fix for disable state of SpinBox 2020-05-08 09:49:41 +02:00
DexesTTP
b478c5f86c LibGUI: Properly draw the background of the selected TreeView line
In the TreeView, the background of the selected line (or any background,
really) was only drawn until the frame's width. When the text was larger
than the frame's width, this caused the end of the text to be displayed
without background, making it unreadable if it was white (which is the
default text color for selected lines).

To compute the background width, we have a choice between :
- The inner frame width (the current behaviour which causes the issue)
- The total width of all columns (which causes the background to end
  early if the columns don't cover the full width)

The new algorithm uses the biggest of the above values, which gives us
exactly what we want in all cases :^)

Fixes #2134
2020-05-07 22:13:25 +02:00
Linus Groh
7571e9e460 LibGUI: Rename SyntaxLanguage::{Javascript -> JavaScript} 2020-05-07 22:04:56 +02:00
Linus Groh
9dbab2d05e Misc: Replace "String(string_view)" with "string_view.to_string()"
StringView::to_string() was added in 917ccb1 but not actually used
anywhere yet.
2020-05-06 19:28:59 +02:00
Linus Groh
a2e1f1a872 LibJS: Implement exponentiation assignment operator (**=) 2020-05-05 11:12:27 +02:00
Linus Groh
3e754a15d4 LibJS: Implement bitwise assignment operators (&=, |=, ^=) 2020-05-05 11:12:27 +02:00
Andreas Kling
8fae4ee931 LibGUI: Add ScrollableWidget::viewport_rect_in_content_coordinates() 2020-05-04 22:33:20 +02:00
mattco98
adb4accab3 LibJS: Add template literals
Adds fully functioning template literals. Because template literals
contain expressions, most of the work has to be done in the Lexer rather
than the Parser. And because of the complexity of template literals
(expressions, nesting, escapes, etc), the Lexer needs to have some
template-related state.

When entering a new template literal, a TemplateLiteralStart token is
emitted. When inside a literal, all text will be parsed up until a '${'
or '`' (or EOF, but that's a syntax error) is seen, and then a
TemplateLiteralExprStart token is emitted. At this point, the Lexer
proceeds as normal, however it keeps track of the number of opening
and closing curly braces it has seen in order to determine the close
of the expression. Once it finds a matching curly brace for the '${',
a TemplateLiteralExprEnd token is emitted and the state is updated
accordingly.

When the Lexer is inside of a template literal, but not an expression,
and sees a '`', this must be the closing grave: a TemplateLiteralEnd
token is emitted.

The state required to correctly parse template strings consists of a
vector (for nesting) of two pieces of information: whether or not we
are in a template expression (as opposed to a template string); and
the count of the number of unmatched open curly braces we have seen
(only applicable if the Lexer is currently in a template expression).

TODO: Add support for template literal newlines in the JS REPL (this will
cause a syntax error currently):

    > `foo
    > bar`
    'foo
    bar'
2020-05-04 16:46:31 +02:00
Andreas Kling
67b92a7d5f WindowServer+LibGUI: Support the 4th and 5th mouse buttons
We'll call the "Back" and "Forward" since that's what they are normally
mapped to in some other systems.
2020-05-02 22:07:43 +02:00
Emilio Cobos Álvarez
e347d6bdb8 LibGUI: Properly remove auto-destroyed child windows from reified_windows.
I just spotted this while I saw you writing this code :-)
2020-05-02 20:27:07 +02:00
Ben Wiederhake
cfbc49b5fc LibGUI: FilePicker: Set initial sort to name instead of undefined
Well, technically the initial sort order is 'ascending inode'.
However, that is unpredictable for the user.
In the rare case it is desired, it can be re-enabled by revealing the
inode column, and then sorting by it, in the TableView.
2020-05-02 14:12:36 +02:00