Commit Graph

182 Commits

Author SHA1 Message Date
Jelle Raaijmakers
f391ccfe53 LibGfx+Everywhere: Change Gfx::Rect to be endpoint exclusive
Previously, calling `.right()` on a `Gfx::Rect` would return the last
column's coordinate still inside the rectangle, or `left + width - 1`.
This is called 'endpoint inclusive' and does not make a lot of sense for
`Gfx::Rect<float>` where a rectangle of width 5 at position (0, 0) would
return 4 as its right side. This same problem exists for `.bottom()`.

This changes `Gfx::Rect` to be endpoint exclusive, which gives us the
nice property that `width = right - left` and `height = bottom - top`.
It enables us to treat `Gfx::Rect<int>` and `Gfx::Rect<float>` exactly
the same.

All users of `Gfx::Rect` have been updated accordingly.
2023-05-23 12:35:42 +02:00
Lucas CHOLLET
1a97382305 LibGUI: Make Application's construction fallible
The pattern to construct `Application` was to use the `try_create`
method from the `C_OBJECT` macro. While being safe from an OOM
perspective, this method doesn't propagate errors from the constructor.
This patch make `Application` use the `C_OBJECT_ABSTRACT` and manually
define a `create` method that can bubble up errors from the
construction stage.

This commit also removes the ability to use `argc` and `argv` to
create an `Application`, only `Main`'s `Arguments` can be used.

From a user point of view, the patch renames `try_create` => `create`,
hence the huge number of modified files.
2023-05-05 16:41:21 +01:00
thankyouverycool
f7e034d4b2 LibGfx+Userland: Merge FrameShape and FrameShadow into FrameStyle
Previously, Frames could set both these properties along with a
thickness to confusing effect: Most shapes of the same shadowing only
differentiated at a thickness >= 2, and some not at all. This led
to a lot of creative but ultimately superfluous choices in the code.

Instead let's streamline our options, automate thickness, and get
the right look without so much guesswork.

Plain shadowing has been consolidated into a single Plain style,
and 0 thickness can be had by setting style to NoFrame.
2023-04-30 05:49:46 +02:00
thankyouverycool
91bafc2653 LibGUI+Userland: Port Labels to String 2023-04-30 05:48:14 +02:00
Karol Kosek
51bd9ca037 LibGUI+Userland: Make Menu::*add_submmenu take name using new string 2023-04-19 07:59:54 +02:00
Karol Kosek
956f4d9205 Userland: Construct Menus with name using the non-deprecated String 2023-04-19 07:59:54 +02:00
thankyouverycool
55423b4ed0 LibGfx+Userland: Add width_rounded_up() helper 2023-04-15 15:24:50 +02:00
MacDue
35612c6a7f AK+Everywhere: Change URL::path() to serialize_path()
This now defaults to serializing the path with percent decoded segments
(which is what all callers expect), but has an option not to. This fixes
`file://` URLs with spaces in their paths.

The name has been changed to serialize_path() path to make it more clear
that this method will generate a new string each call (except for the
cannot_be_a_base_url() case). A few callers have then been updated to
avoid repeatedly calling this function.
2023-04-15 06:37:04 +02:00
MacDue
43529ea25e Taskbar: Use Process::spawn_or_show_error() for shutdown actions 2023-03-24 22:06:38 +00:00
MacDue
e46b9c189e Taskbar: Use Process::spawn_or_show_error() to open the "Run" dialog 2023-03-24 22:06:38 +00:00
MacDue
c9043280ec Taskbar: Use GUI::Process::spawn_or_show_error() to launch apps
And while here make a partial fix for launching terminal apps that
require root and contain spaces in their name/path.
2023-03-24 22:06:38 +00:00
implicitfield
e9e4baee77 Everywhere: Support overriding the system color scheme 2023-03-10 22:03:49 +01:00
Andreas Kling
b71c7a6e44 Userland: Use Font::pixel_size_rounded_up() instead of glyph_height()
The only remaining clients of this API are specific to bitmap fonts and
editing thereof.
2023-03-04 00:29:38 +01:00
Linus Groh
09d40bfbb2 Everywhere: Use _{short_,}string to create Strings from literals 2023-02-25 20:51:49 +01:00
Sam Atkins
6b66e39df4 LibGUI+Userland: Stop returning Layout from Widget::(try_)set_layout()
Nobody uses this return value any more. It also lets us remove a whole
bunch of `(void)` casts. :^)
2023-02-18 16:56:56 +00:00
Sam Atkins
77ad0fdb07 Userland: Specify margins and spacing in the GUI::Layout constructor 2023-02-18 16:56:56 +00:00
Sam Atkins
9561ec15f4 Userland: Use Widget::add_spacer() everywhere 2023-02-18 16:56:56 +00:00
Karol Kosek
e39adc4772 Userland: Set Button text using the new String class 2023-02-13 00:45:09 +00:00
Karol Kosek
b5cb9a9ebb LibGUI+TaskBar: Make Calendar::formatted_date() return ErrorOr<String>
This commit introduces no error propagation.
2023-02-13 00:45:09 +00:00
Karol Kosek
d32d4029d3 Userland: Replace usages of AbstractButton::text_deprecated with text() 2023-02-13 00:45:09 +00:00
Karol Kosek
d32b052f22 LibGUI+Userland: Add _deprecated suffix to AbstractButton::{set_,}text 2023-02-13 00:45:09 +00:00
Sam Atkins
ca85ce6db3 Taskbar: Remove declarations for non-existent methods 2023-01-27 20:33:18 +00:00
Tim Schumacher
82a152b696 LibGfx: Remove try_ prefix from bitmap creation functions
Those don't have any non-try counterpart, so we might as well just omit
it.
2023-01-26 20:24:37 +00:00
Sam Atkins
6edc0cf5ab LibCore+Userland: Don't auto-start new Core::Timers
This was unintuitive, and only useful in a few cases. In the majority,
users had to immediately call `stop()`, and several who did want the
timer started would call `start()` on it immediately anyway. Case in
point: There are only two places I had to add a manual `start()`.
2023-01-12 11:25:51 +01:00
Sam Atkins
0c24522635 LibGUI+Everywhere: Use fallible Window::set_main_widget() everywhere :^)
Rip that bandaid off!

This does the following, in one big, awkward jump:
- Replace all uses of `set_main_widget<Foo>()` with the `try` version.
- Remove `set_main_widget<Foo>()`.
- Rename the `try` version to just be `set_main_widget` because it's now
  the only one.

The majority of places that call `set_main_widget<Foo>()` are inside
constructors, so this unfortunately gives us a big batch of new
`release_value_but_fixme_should_propagate_errors()` calls.
2023-01-06 13:36:02 -07:00
Timothy Flynn
3d6b0e60ca LibDesktop+Taskbar: Add an option to exclude apps from the system menu
We currently hard-code excluding Settings apps from the system menu.
This adds an "ExcludeFromSystemMenu" option to the AppFile configuration
to selectively exclude these apps, which all Settings app now set.

This is to allow selectively excluding a few Demo apps in a future
commit.
2023-01-03 17:56:55 +01:00
Andreas Kling
3407ab0fd1 LibGfx: Make Font::width() return a float 2023-01-03 15:25:02 +01:00
Ben Wiederhake
b83cb09db1 Everywhere: Fix badly-formatted includes
In 7c5e30daaa, the focus was "only" on
Userland/Libraries/, whereas this commit cleans up the remaining
headers in the repo, and any new badly-formatted include.
2023-01-02 11:06:15 -05:00
thankyouverycool
352c1fec2d Taskbar: Propagate more errors on widget population 2022-12-27 09:28:16 -05:00
thankyouverycool
10626e6c6c Taskbar: Load Assistant's AppFile on window creation
Fixes crashing when spawning Assistant by shortcut
2022-12-27 09:28:16 -05:00
Arda Cinar
4fec9540ec Taskbar: Handle errors when adding/changing quick launch entries
This patch removes 2 FIXMEs :^)
2022-12-26 09:31:44 +01:00
Arda Cinar
1acc788500 Taskbar: Add a factory function for TaskbarWindow
This means the errors all the way from Individual widgets get propagated
up.
2022-12-26 09:31:44 +01:00
Arda Cinar
f40cb8d771 Taskbar: Add a factory function for QuickLaunchWidget
This helps propagate errors that might happen when constructing the
quick launch menu. However, the errors are not propagated all the way
yet.
2022-12-26 09:31:44 +01:00
ericLemanissier
7fa78b2456 Taskbar: Propagate errors while loading bmp 2022-12-23 12:23:05 +00:00
Cygnix Proto
806a55eda1 LibGfx+Userland: Make Gfx::SystemTheme propagate errors
This patch introduces error propagation to Gfx::SystemTheme to remove
instances of release_value_but_fixme_should_propagate_errors().

Userland applications that have been affected by this change have been
updated to utilise this propagation and as a result 4 such instances of
the aforementioned method have been removed.
2022-12-14 18:25:28 +00:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Jelle Raaijmakers
45a59b4d7e Taskbar: Unbreak SDL2 port by changing include path
Ports would not be able to find `QuickLaunchWidget.h` this way.
2022-11-26 10:34:19 +01:00
Arda Cinar
7f20e7324c Taskbar: Removed the awkward window reference struct 2022-11-26 09:51:11 +01:00
Arda Cinar
7afb7e65d5 Taskbar: Made it possible to add a system menu to taskbar later
This makes it possible to construct the taskbar before the system
menu and remove the awkward reference in Taskbar/main.cpp
2022-11-26 09:51:11 +01:00
Arda Cinar
7456a84e68 Taskbar: Rename start_menu to system_menu
The main menu in GUI (the one in the lower left side of screen by
default) was called start_menu in some parts of the code and system_menu
in others. In the documentation, it was referred to as "system menu".
So, in order to be consistent, these variables are all renamed to
system_menu
2022-11-26 09:51:11 +01:00
thankyouverycool
4aa608aa71 LibGUI+Taskbar+Applets+Applications: Set various windows as Popups
Makes the Audio applet, Taskbar clock, CommandPalette, EmojiPicker,
and Assistant work as Popup windows. Popups are frameless, unmovable,
and unresizable by default, in addition to their preemptive function.
Also sets Assistant not to obey widget min size so its search result
area resizes correctly
2022-11-19 16:04:42 +01:00
thankyouverycool
24d299c9c8 LibGUI+WindowServer+Applets+Taskbar: Remove active input concepts
and the CaptureInput mode. They are a source of unneeded complexity
in WindowServer and have proven prone to regressions, so this patch
replaces them with a simple input preemption scheme using Popups.

Popup windows now have ergonomics similar to menus: When open,
a popup preempts all mouse and key events for the entire window
stack; however, they are fragile and will close after WindowServer
swallows the first event outside them. This is similar to how combo
box windows and popups work in the classic Windows DE and has the
added benefit of letting the user click anywhere to dismiss a popup
without having to worry about unwanted interactions with other
widgets.
2022-11-19 16:04:42 +01:00
Samuel Bowman
d947555527 Taskbar: Support launching apps that require root
If an app file has RequiresRoot=true, launch the app with the requsite
setuid binary. For GUI apps, this is Escalator. For app files with
RunInTerminal=true, this is pls.
2022-11-14 14:58:10 +00:00
Karol Kosek
0b7f5bbdfb Userland: Accept drag_enter events for widgets supporting file drops
This patch will switch cursor to DragCopy when a user enters a widget
while dragging file(s), giving them a visual clue that it *might* be
dropped into this widget.

This is a rather naive approach, as the cursor icon will change for any
kind of file, as currently programs don't know the drag contents before
dropping it. But after all I think it's better than nothing. :^)
2022-11-13 16:13:03 -07:00
Tim Schumacher
ce2f1b845f Everywhere: Mark dependencies of most targets as PRIVATE
Otherwise, we end up propagating those dependencies into targets that
link against that library, which creates unnecessary link-time
dependencies.

Also included are changes to readd now missing dependencies to tools
that actually need them.
2022-11-01 14:49:09 +00:00
cflip
05e7b338ad LibDesktop+Taskbar: Add 'WorkingDirectory' property to app files 2022-10-17 01:37:58 +02:00
implicitfield
0b72d237c1 Taskbar: Display an icon for removing a widget 2022-10-09 10:20:47 +02:00
implicitfield
3353f89e22 Calendar: Only accept Calendar notifications
Previously, changing the time format caused Taskbar to crash.

This commit also simplifies TaskbarWindow::config_string_did_change()
so that it is in line with the changes made to
Calendar::config_string_did_change().

Fixes #15384
2022-09-29 08:48:06 -04:00
Timothy Flynn
73fcaaeda4 Taskbar: Add a context menu to open clock settings from the clock widget 2022-09-22 11:46:53 +01:00