Commit Graph

1868 Commits

Author SHA1 Message Date
Sam Atkins
3695344d6f LibGUI: Add tooltips to DynamicWidgetContainer control buttons 2024-05-04 14:01:57 +02:00
Ali Mohammad Pur
eaa2d69d73 LibGUI+Everywhere: Rename the 'style' frame property to 'frame_style'
'set_frame_style' is what Frame itself uses to set the value, and a
significant number of GML files use 'frame_style' instead of just
'style', so let's switch to it and use it everywhere consistently.
2024-04-30 17:46:41 -06:00
Ali Mohammad Pur
f3a4118aee GMLCompiler+LibGUI: Add support for object properties and undo hack
Previously the GML compiler did not support object properties such as
`content_widget: @GUI::Widget{}` for GUI::ScrollableContainerWidget;
this commit adds support for such properties by simply calling
`set_<key>(<TProperty>&)` on the object.
This commit also removes the previous hack where
ScrollableContainerWidget was special-cased to have its singular child
used as the content widget; the only GML file using this behaviour was
also changed to be in line with 'proper' GML as handled by the GML
Playground.
2024-04-30 17:46:41 -06:00
Andreas Kling
db335f5f40 LibGfx+LibGUI: Move Bitmap volatility stuff to GUI::WindowBackingStore
This is only used by LibGUI to manage the volatility of window backing
stores, so let's move it out of Gfx::Bitmap.
2024-04-29 09:49:28 +02:00
Dan Klishch
7b88363490 Meta+Userland: Make LibELF a proper library on Serenity
Dynamically loaded LibC doesn't need LibELF definitions, so let's not
put them there.
2024-04-26 19:08:13 -06:00
Timothy Flynn
ec492a1a08 Everywhere: Run clang-format
The following command was used to clang-format these files:

    clang-format-18 -i $(find . \
        -not \( -path "./\.*" -prune \) \
        -not \( -path "./Base/*" -prune \) \
        -not \( -path "./Build/*" -prune \) \
        -not \( -path "./Toolchain/*" -prune \) \
        -not \( -path "./Ports/*" -prune \) \
        -type f -name "*.cpp" -o -name "*.mm" -o -name "*.h")

There are a couple of weird cases where clang-format now thinks that a
pointer access in an initializer list, e.g. `m_member(ptr->foo)`, is a
lambda return statement, and it puts spaces around the `->`.
2024-04-24 16:50:01 -04:00
Andrew Kaster
1c3f11a5a6 Userland: Remove remaining callers of synchronous ImageDecoder API
Most of these now just await the image decoding, equivalent (ish) to
the old behavior. A more async-aware refactor should happen some time
in the future.
2024-04-23 12:32:04 -06:00
Andrew Kaster
6d4ba21832 LibIPC+Userland: Make IPC::File always own its file descriptor
Add factory functions to distinguish between when the owner of the File
wants to transfer ownership to the new IPC object (adopt) or to send a
copy of the same fd to the IPC peer (clone).

This behavior is more intuitive than the previous behavior. Previously,
an IPC::File would default to a shallow clone of the file descriptor,
only *actually* calling dup(2) for the fd when encoding or it into an
IPC MessageBuffer. Now the dup(2) for the fd is explicit in the clone_fd
factory function.
2024-04-19 06:34:07 -04:00
Dan Klishch
5ed7cd6e32 Everywhere: Use east const in more places
These changes are compatible with clang-format 16 and will be mandatory
when we eventually bump clang-format version. So, since there are no
real downsides, let's commit them now.
2024-04-19 06:31:19 -04:00
Daniel Bertalan
8366c9f55a LibGUI+PixelPaint: Move virtual destructors out-of-line for Clang 17 2024-04-18 13:14:33 -06:00
Andreas Kling
1cb5385a29 LibCore: Stop obsessing about tiny OOMs in Core::Timer
Work towards #20405
2024-04-17 07:16:52 +02:00
Aryan Baburajan
3336d00241 IncrementalSearchBanner: Port to GML compilation 2024-04-15 14:01:13 +02:00
Aryan Baburajan
b2587cb11b EmojiInputDialog: Port to GML compilation 2024-04-15 14:01:13 +02:00
Aryan Baburajan
e488928509 FontPickerDialog: Port to GML compilation 2024-04-15 14:01:13 +02:00
Aryan Baburajan
3ab05dbbb9 FilePickerDialog: Port to GML compilation 2024-04-15 14:01:13 +02:00
Aryan Baburajan
ddbed25bb5 PasswordInputDialog: Port to GML compilation 2024-04-15 14:01:13 +02:00
Matthew Olsson
ff00d21d58 Everywhere: Mark a bunch of function parameters as NOESCAPE
This fixes the relevant warnings when running LibJSGCVerifier. Note that
the analysis is only performed over LibJS-adjacent code, but could be
performed over the entire codebase. That will have to wait for a future
commit.
2024-04-09 09:10:44 +02:00
Kyle Lanmon
8b4e2e2099 LibGUI: Call on_change when set text is called
If there is an on_change callback, and we found at least one match,
call the callback.
2024-04-08 09:35:55 -06:00
Timothy Flynn
c23060e21b Userland: Avoid some now-unneeded explicit conversions to Bytes 2024-04-04 11:23:21 +02:00
Timothy Flynn
099f18faff LibGUI: Add initial support for an action icon in the tab widget bar
An action icon will be a button-like component to the left of the tab
icon. This initial patch just adds support for rendering an icon. In
the future, we will want to accept an action to be triggered when the
action icon is clicked, and to paint the icon like a button.
2024-03-28 21:08:23 +01:00
Nico Weber
1ab28276f6 LibGfx: Add the start of a JPEG2000 loader
JPEG2000 is the last image format used in PDF filters that we
don't have a loader for. Let's change that.

This adds all the scaffolding, but no actual implementation yet.
2024-03-25 20:35:00 +01:00
Shannon Booth
e800605ad3 AK+LibURL: Move AK::URL into a new URL library
This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
2024-03-18 14:06:28 -04:00
Timothy Flynn
feac88f3cb LibGUI: Add FileTypeFilter factories for common audio and video types 2024-03-16 08:42:33 +01:00
Nico Weber
58838db445 LibGfx: Add the start of a JBIG2 loader
JBIG2 is infamous for two things:

1. It's used in xerox scanners were it falsifies scanned numbers:

https://www.dkriesel.com/en/blog/2013/0802_xerox-workcentres_are_switching_written_numbers_when_scanning

2. It was allegedly used in an iOS zero day, in a very cool way:

https://googleprojectzero.blogspot.com/2021/12/a-deep-dive-into-nso-zero-click.html

Needless to say, we need support for it in Serenity. (...because it's
used in PDF files.)

This adds all the scaffolding, but no actual implementation yet.

It's enough for `file` to print the mime type of .jb2 files, but `image`
can't do anything with the files yet.
2024-03-09 16:01:22 +01:00
Timothy Flynn
2a021a35fc LibGUI: Consider carriage returns when counting lines in a label
We create labels in the Browser from text on web documents, which may
use carriage returns. LibGfx will split lines on CR already, but LibGUI
would not consider CRs when computing the height of the containing
widget. The result was text that would not fit in the label's box.
2024-03-08 14:43:33 -05:00
Nico Weber
2e2cae26c6 LibGfx+Fallout: Make ImageDecoder return ErrorOr
...from try_create_for_raw_bytes().

If a plugin returns `true` from sniff but then fails when calling
its `create()` method, we now no longer swallow that error.

Allows `image` (and other places in the system) to print a more
actionable error if early image headers are invalid.

(We now no longer try to find another plugin that can also handle
the image.)

Fixes a regression from #20063 / #19893 -- before then, we didn't
do fallible work this early.
2024-03-07 11:20:06 -05:00
Timothy Flynn
f2204e2b3a LibGUI: Define bitwise operations for GUI::MouseButton
This type is designed to be use as a flag. Define bitwise operations for
convenience.

(clang-format-17 caught an east-const conversion here as well).
2024-03-06 07:46:18 +01:00
Hendiadyoin1
2537efaf64 LibGUI: Use HashMap::keys() to hand out the available sizes of icons 2024-03-01 14:05:53 -07:00
Aarushi Chauhan
564e619f57 AboutDialog: Port to GML Complier 2024-02-26 13:20:42 -07:00
Domenico Iezzi
71a784741f LibGUI: Add Calendar property for mode
If a user selects Year as the default view mode for Calendar app, then
all apps using Calendar widget will default to this view if not
manually overridden with a Calendar::toggle_mode call.

This commit introduces a "mode" property that allows the selection of
the default mode for the calendar widget in GML files. In this way
there is no need to manually call toggle_mode when constructing
UIs with Calendar widget.
2024-02-24 18:54:51 -07:00
Domenico Iezzi
1153068407 LibGUI: Remove redundant Widget::update calls from DatePicker
In DatePicker constructor, calling to Widget::update after
Calendar::update_tiles is redundant since it is already called
internally by update_tiles.

This commit also remove unused header files from DatePicker header.
2024-02-24 18:54:51 -07:00
Domenico Iezzi
bc9bba1d9b LibGUI: Explicitly fire a resize event when toggling Calendar mode
Calendar::toggle_mode function performed a call to Widget::resize with
swapped width and height parameters as a quick way to trigger a
resize_event (resize event is generated only when the new rect size is
different from the old one, hence the swapped parameters).

This method does not work when width and height are equal, such as in
the DatePicker widget where width and height are fixed to 200x200. In
such case, calls to Calendar::toggle_mode would not generate a resize
event, leaving tiles uninitialized, therefore the widget was not able
to properly paint the Month view.

This commit replaces Widget::resize call with a manual triggering of
the event.
2024-02-24 18:54:51 -07:00
Kemal Zebari
111e4162d0 LibGUI/Application: Resize recent files list to max open file size
Since it's possible to have the actual recently opened files <
max_recently_open_files(), which causes us to crash when we try to
access new_recent_files_list where index >= the list's size.
2024-02-23 09:51:42 +01:00
Tim Ledbetter
1a223d07e1 LibGUI: Assert that most recently open file path isn't empty
Attempting to do this causes a crash. It's better to fail early in this
case, so that the cause of the failure is clear.
2024-02-21 22:37:34 +01:00
Bastiaan van der Plaat
5a8e82e6ea Base: Create user default Music and Pictures directories 2024-02-05 16:30:52 +01:00
Bastiaan van der Plaat
350affe406 LibGUI+WindowServer: Add menu minimum width support 2024-01-29 05:29:41 -07:00
kleines Filmröllchen
dec066fa5c GMLCompiler: Add common pattern for a user-defined fallible initializer
Many widget classes need to run substantial initialization code after
they have been setup from GML. With this change, an
initialize_fallibles() function is called if available, allowing the
initialization to be invoked from the GML setup automatically. This
means that the GML-generated creation function can now be used directly
for many more cases, and reduces code duplication.
2024-01-29 05:21:48 -07:00
Nico Weber
187862ebe0 LibGfx: Add a .pam loader
.pam is a "portrable arbitrarymap" as documented at
https://netpbm.sourceforge.net/doc/pam.html

It's very similar to .pbm, .pgm, and .ppm, so this uses the
PortableImageMapLoader framework. The header is slightly different,
so this has a custom header parsing function.

Also, .pam only exixts in binary form, so the ascii form support
becomes optional.
2024-01-26 07:36:53 +01:00
Sam Atkins
343de324db LibGUI: Don't update the recent files if we haven't created them yet
We previously assumed that `set_most_recently_open_file()` would only be
called after `Menu::add_recent_files_list()` had been called, and would
crash if we hadn't called it yet. This stops the crash. We're fine to
do this, because we always call `update_recent_file_actions()` in
`register_recent_file_actions()` so it's guaranteed to be up to date
when we do need it.
2024-01-24 11:07:03 +00:00
Sam Atkins
f8fe6d11b2 LibGUI: Allow creating a recent-files list without a trailing separator
This is useful in situations where we want this list in a submenu.
2024-01-24 11:07:03 +00:00
Sam Atkins
9657f4cabb LibGUI+Userland: Take ByteString in set_most_recently_open_file() 2024-01-24 11:07:03 +00:00
Dan Klishch
b5f1a48a7c AK+Everywhere: Remove JsonValue APIs with implicit default values 2024-01-21 15:47:53 -07:00
Dan Klishch
0388c828be LibGUI: Remove GUI::Variant::Variant(JsonValue const&)
Let's force callers of Variant constructor to know the type of the
object they are constructing.
2024-01-21 15:47:53 -07:00
Sam Atkins
8d80841e9c LibFileSystem+Everywhere: Return ByteString from read_link() 2024-01-16 08:42:34 +00:00
Sam Atkins
56c5ffe398 LibFileSystem+Userland: Return ByteString from real_path() 2024-01-16 08:42:34 +00:00
Tim Ledbetter
1eb1f7bde9 LibGUI: Allow HeaderView column selectability to be toggled
Previously, any TableView column could be made visible through a
context menu shown by right clicking on the table header. This change
allows columns to be marked as non-selectable, so their visibility
cannot be toggled in this way.
2024-01-14 15:01:47 -07:00
Lucas CHOLLET
66f52d6db9 LibGUI: Use BoxSampling to draw thumbnails 2024-01-14 21:26:36 +01:00
Sam Atkins
e0fd5beb36 LibGUI+Applications: Default the SpinBox min/max to the full int range
By default, a SpinBox's value should be unlimited, (or as close as we
can get to that,) and then the GML or code can impose a limit if
needed. This saves the developer from entering an arbitrary "big" max
value when they want the value to have no maximum.

I've audited the use of SpinBox and added `min: 0`, and removed a `max`,
where appropriate. All existing SpinBoxes constructed in code have a
range set explicitly as far as I can tell.
2024-01-14 13:46:14 +00:00
Dan Klishch
ccd701809f Everywhere: Add deprecated_ prefix to JsonValue::to_byte_string
`JsonValue::to_byte_string` has peculiar type-erasure semantics which is
not usually intended. Unfortunately, it also has a very stereotypical
name which does not warn about unexpected behavior. So let's prefix it
with `deprecated_` to make new code use `as_string` if it just wants to
get string value or `serialized<StringBuilder>` if it needs to do proper
serialization.
2024-01-12 17:41:34 -07:00
Sam Atkins
5f0230a57e LibGUI: Make NumericInput work well in GML
- Register the widget
- Register property getters and setters
- Rename getters and setters to match the property names, as required by
  the GML compiler. The names min/max/value are chosen to match SpinBox.
- Prevent a crash when the minimum is less than the maximum (which can
  happen while editing the GML).
2024-01-10 13:13:27 +00:00