Commit graph

815 commits

Author SHA1 Message Date
Andreas Kling
0b9efc04b5 LibGUI: Sort FileSystemModel alphabetically internally
This just makes everything nicer.
2020-07-04 20:33:23 +02:00
Andreas Kling
998b3f6d87 LibGUI: Fix glitchy behavior in ScrollableWidget::scroll_into_view()
This function relies on visible_content_rect() which could previously
return rectangles with negative size. This was causing TableViews to
scroll down a little bit when assigning a model to them.

Also tweak the logic so we scroll a 0x0 rect into view, giving a
slightly nicer final position.
2020-07-04 20:18:57 +02:00
Andreas Kling
a5799ed462 LibGUI: Add SortingProxyModel::sort_role()
This allows you to specify a role to sort by. Defaults to Role::Sort.
Also reordered the Role enum so that Role::Custom is last.
2020-07-04 18:40:21 +02:00
Andreas Kling
d851863704 Userspace: Remove a bunch of unnecessary Kernel/API/KeyCode.h includes 2020-07-04 17:25:31 +02:00
Andreas Kling
11c4a28660 Kernel: Move headers intended for userspace use into Kernel/API/ 2020-07-04 17:22:23 +02:00
Andreas Kling
ca93c22ae2 LibGUI: Turn GUI::Application::the() into a pointer
During app teardown, the Application object may be destroyed before
something else, and so having Application::the() return a reference was
obscuring the truth about its lifetime.

This patch makes the API more honest by returning a pointer. While
this makes call sites look a bit more sketchy, do note that the global
Application pointer only becomes null during app teardown.
2020-07-04 16:54:55 +02:00
Andreas Kling
1dd1595043 LibGUI: Make GUI::Application a Core::Object
Having this on the stack makes whole-program teardown iffy. Turning it
into a Core::Object allows anyone who needs it to extends its lifetime.
2020-07-04 14:05:57 +02:00
Andreas Kling
c6c71b0fcc LibGUI: Respect per-index font when computing TreeView item rects
This makes the selected (currently shown in bold) item in HackStudio's
project file view show up at the correct position.
2020-07-04 11:01:43 +02:00
Andreas Kling
eec22acb8e LibGUI: Add GUI::CommonActions::make_select_all_action() :^) 2020-07-03 21:34:12 +02:00
Linus Groh
33ca151eb0 FilePicker: Add folder icon to location box
It looks good in FileManager so it will also look good here :^)

FileManager commit: b8a50e9
2020-07-03 12:28:12 +02:00
Linus Groh
f8fa495d67 FilePicker: Make the location box 2px taller
This mimics a recent change to the FileManager's location box.

FileManager commit: 3d5233a
2020-07-03 12:28:12 +02:00
Andreas Kling
c6193af269 LibGUI: Make Application::exec() return instead of calling exit()
We were calling exit() here because we didn't want to deal with object
teardown in the long-long-ago before Core::Object was ref-counted.
2020-07-01 20:49:00 +02:00
Jack Karamanian
4dcdad4cc4 LibGUI: Highlight JS Extends and Super tokens 2020-07-01 11:18:44 +02:00
AnotherTest
476ccb2206 LibGUI: Do not recurse into rows with invalid indices
That would cause the traversal to go into an infinite loop.
2020-07-01 11:18:19 +02:00
Linus Groh
2e183e3292 LibGUI: Update FilePicker location textbox when changing directory
Fixes #2662.
2020-06-30 12:20:18 +02:00
Linus Groh
5acc457c06 LibGUI: Only show FilePicker preview pane on demand
FilePicker::set_preview() and FilePicker::clear_preview() now show and
hide the preview pane respectively.
2020-06-30 10:43:46 +02:00
Linus Groh
6b61d4656f LibGUI: Tweak FilePicker layout to remove bottom padding
This makes the "Cancel" and "Open" buttons align with the right sidebar's
bottom edge.
2020-06-30 10:26:11 +02:00
Andreas Kling
f50bc0f314 LibGUI: Add TextEditor::set_icon()
You can now set a 16x16 icon on a single-line TextEditor. If present,
the icon will be painted to the left of the text content.
2020-06-29 20:34:42 +02:00
Benoît Lormeau
951a429268 LibGUI: SpinBox: update the displayed value when set_range() clamps it
Consider the following: upon instanciation of a GUI::SpinBox, its
internal value and displayed value are both 0. When calling `set_min(1)`
on it (same as `set_range(1, max())`), the internal value gets clamped
to 1 correctly, but "0" is still displayed by the widget.

The displayed value is now updated accordingly to the internal value
when it gets clamped.
2020-06-29 14:57:36 +02:00
Hüseyin ASLITÜRK
a8b0ad5cc6 LibGUI: Fix image preview size in FilePicker for large images
Image preview widget overflow to other widgets in FilePicker dialog when image is larger than 160px.  Also change the ImagePreview widget variable name for align to naming standards.
2020-06-27 12:57:30 +02:00
Hüseyin ASLITÜRK
671560a844 LibGUI: Bug fix on GUI::Image when image is nullptr
This bug cause to FilePicker crash when second image selected for preview. FilePicker sets bitmap to "nullptr" clear preview.
2020-06-21 16:42:46 +02:00
Hüseyin ASLITÜRK
12671e38e7 LibGUI: Add a new Window::is_maximized method 2020-06-18 23:18:11 +02:00
Andreas Kling
033da11364 LibGUI: Fix MessageBox width calculation not including the icon width 2020-06-18 22:18:19 +02:00
Hüseyin ASLITÜRK
0a2dc1f5c0 AboutDialog: Replace Label with Image to show banner and app icon 2020-06-18 16:35:57 +02:00
Hüseyin ASLITÜRK
030d0f9937 MessageBox: Replace Label with Image component to show icons 2020-06-18 16:35:57 +02:00
Hüseyin ASLITÜRK
56e82a2c07 FilePicker: Replace Label with Image component to show icons 2020-06-18 16:35:57 +02:00
Hüseyin ASLITÜRK
ccb0d00020 LibGUI: Add a new GUI::Image component for display images
New GUI::Image component for replace Label usage for icons and images.
2020-06-18 16:35:57 +02:00
Sergey Bugaev
0674d9362b LibGUI: Use Core::File::read_link() 2020-06-17 15:02:03 +02:00
Hüseyin ASLITÜRK
53227f400c LibGUI: Replace text attribute on KeyEvent with code_point attribute 2020-06-16 13:15:17 +02:00
Hüseyin ASLITÜRK
0799835e15 LibGUI: Use new Bitmap::is_path_a_supported_image_format method 2020-06-15 22:42:23 +02:00
Kevin Meyer
17aa917073 LibGUI: Don't update cursor, if visual data out-of-date
This fixes https://github.com/SerenityOS/serenity/issues/2498
A nullptr dereference was caused by the visual data beeing out of sync
with the line data, due to a deferred recompute.
2020-06-15 22:32:18 +02:00
Matthew Olsson
e8e728454c AK: JsonParser improvements
- Parsing invalid JSON no longer asserts
    Instead of asserting when coming across malformed JSON,
    JsonParser::parse now returns an Optional<JsonValue>.
- Disallow trailing commas in JSON objects and arrays
- No longer parse 'undefined', as that is a purely JS thing
- No longer allow non-whitespace after anything consumed by the initial
  parse() call. Examples of things that were valid and no longer are:
    - undefineddfz
    - {"foo": 1}abcd
    - [1,2,3]4
- JsonObject.for_each_member now iterates in original insertion order
2020-06-13 12:43:22 +02:00
Andreas Kling
fdfda6dec2 AK: Make string-to-number conversion helpers return Optional
Get rid of the weird old signature:

- int StringType::to_int(bool& ok) const

And replace it with sensible new signature:

- Optional<int> StringType::to_int() const
2020-06-12 21:28:55 +02:00
Andreas Kling
2ce2c4810a LibIPC+WindowServer+LibGUI: Detect and highlight unresponsive GUI apps
IPC::ClientConnection now tracks the time since the last time we got
a message from the client and calls a virtual function on itself after
3 seconds: may_have_become_unresponsive().

Subclasses of ClientConnection can then react to this if they like.

We use this mechanism in WindowServer to send out a friendly Ping
message to the client. If he doesn't Pong within 1 second, we mark
the client as "unresponsive" and recompose all of his windows with
a darkened appearance and amended title until he Pongs us.

This is a little on the aggressive side and we should figure out a way
to wake up less often. Perhaps this could only be done to windows the
user is currently interacting with, for example.

Anyways, this is pretty cool! :^)
2020-06-11 22:46:49 +02:00
Andreas Kling
116cf92156 LibGfx: Rename Rect,Point,Size => IntRect,IntPoint,IntSize
This fits nicer with FloatRect,FloatPoint,FloatSize and gives a much
better visual clue about what type of metric is being used.
2020-06-10 10:59:04 +02:00
Andreas Kling
b81b2a85c4 LibGUI: Don't scroll cursor into view while reflows are deferred
We don't have up-to-date visual line rects until after reflow, and we
already do a "scroll cursor into view" when deferral ends anyway.

Fixes #2524.
2020-06-07 21:05:05 +02:00
Linus Groh
0ff9d7e189 LibJS: Add BigInt 2020-06-07 19:29:40 +02:00
Matthew Olsson
61ac1d3ffa LibJS: Lex and parse regex literals, add RegExp objects
This adds regex parsing/lexing, as well as a relatively empty
RegExpObject. The purpose of this patch is to allow the engine to not
get hung up on parsing regexes. This will aid in finding new syntax
errors (say, from google or twitter) without having to replace all of
their regexes first!
2020-06-07 19:06:55 +02:00
Andreas Kling
984a6ff97b LibGUI: Fix broken clip rect when scrolling a TextEditor 2020-06-07 18:02:43 +02:00
Andreas Kling
5c485d4a1e LibGUI: Fix TextEditor painting glitch after add_clip_rect() change 2020-06-06 19:37:03 +02:00
Andreas Kling
5be613c9c8 LibGUI: Fix bad KeyEvent::m_key initializer to unbreak SDL2 port 2020-06-04 16:02:40 +02:00
Hüseyin ASLITÜRK
c6f1962919 LibGUI: Add scancode value to KeyEvent 2020-06-03 21:52:40 +02:00
Hüseyin ASLITÜRK
eead3878a1 LibGUI: Add save action to CommonActions list 2020-06-03 21:52:40 +02:00
Andreas Kling
517cf65c99 LibGUI: Tweak AboutDialog a bit, remove big Buggie from system variant
One Buggie is enough, it looks a lot less confused without the big one.
Also make the dialog a bit shorter since there was a lot of dead space.
2020-06-01 18:50:28 +02:00
Andreas Kling
1d6ec51bee WindowServer+LibGUI: Add per-window progress
Each window now has an associated progress integer that can be updated
via the SetWindowProgress IPC call.

This can be used by clients to indicate the progress of ongoing tasks.
Any number in the range 0 through 100 indicate a progress percentage.
Any other number means "no progress"
2020-05-30 23:00:35 +02:00
FalseHonesty
12fe546be9 LibGUI+HackStudio: Fix cursor appearance and crash while debugging
HackStudio uses a TreeView to display the list of current variables
while debugging, and when the program completes, it sets that view's
model to a null model. This would trip an assertion if the TreeView
had something selected at the time, so this patch lessens the
assertion into a simple null check.

Additionally, the cursor would look laggy when moving about the
editor because the code was waiting for a window repaint to update
the cursor's look when it makes more sense to update the cursor
when it actually moves. This change also requires the base
GUI::TextEditor to expose a getter to tell if its currently in a drag
selection.

Finally, requesting a context menu in the line ruler on the side of
the editor would also place/remove breakpoints, which was counter
intuitive, so this requires a left click to modify breakpoint placement.
2020-05-30 10:18:14 +02:00
FalseHonesty
061938206a LibGUI: Fix cursor being out of view after typing
Previously, if the cursor moved out of the visible area while text
was being inserted, the text editor would never scroll the cursor
back into view until the arrow keys were pressed to move the cursor.
This was caused by the TextEditor's reflow deferral system stopping
visual line recomputation until the end of text insertion, so now
when reflow deferral is completed, the TextEditor will make sure
the cursor is visible.
2020-05-29 22:14:45 +02:00
FalseHonesty
b0b03c52af LibGUI: Fix TextEditor crashing when selecting a blank line
Previously, the TextEditor would crash when selecting a line with
no codepoints due to a null dereference, so this patch makes sure
there is actually any text to render before giving it to the painter.
2020-05-29 20:17:53 +02:00
Emanuele Torre
937d0be762 Meta: Add a script check the presence of "#pragma once" in header files
.. and make travis run it.

I renamed check-license-headers.sh to check-style.sh and expanded it so
that it now also checks for the presence of "#pragma once" in .h files.

It also checks the presence of a (single) blank line above and below the
"#pragma once" line.

I also added "#pragma once" to all the files that need it: even the ones
we are not check.
I also added/removed blank lines in order to make the script not fail.

I also ran clang-format on the files I modified.
2020-05-29 07:59:45 +02:00
Andreas Kling
49f3323fa8 LibGUI: Don't show big Buggie in app about dialogs
It was getting to crowded between two Buggies and the app icon.
2020-05-28 11:45:01 +02:00