Commit Graph

104 Commits

Author SHA1 Message Date
sin-ack
ca2c81251a Everywhere: Replace Model::update() with Model::invalidate()
Most of the models were just calling did_update anyway, which is
pointless since it can be unified to the base Model class. Instead, code
calling update() will now call invalidate(), which functions identically
and is more obvious in what it does.

Additionally, a default implementation is provided, which removes the
need to add empty implementations of update() for each model subclass.

Co-Authored-By: Ali Mohammad Pur <ali.mpfard@gmail.com>
2021-08-06 19:14:31 +02:00
Timothy
73c1b1617a Everywhere: Replace most cases of exit() with Application::quit()
Application::quit() is nicer for most cases where exit() is used. Cases
where exit() is used intentionally for early termination are left
intact.
2021-08-03 18:55:52 +02:00
Brian Gianforcaro
4374e1e213 Demos: Remove unused header includes 2021-08-01 08:10:16 +02:00
Andreas Kling
687a12d7fb Userland: Add GUI::Window::add_menu() and use it everywhere
Applications previously had to create a GUI::Menubar object, add menus
to it, and then call GUI::Window::set_menubar().

This patch introduces GUI::Window::add_menu() which creates the menubar
automatically and adds items to it. Application code becomes slightly
simpler as a result. :^)
2021-07-21 21:24:26 +02:00
Andreas Kling
c7d891765c LibGfx: Use "try_" prefix for static factory functions
Also mark them as [[nodiscard]].
2021-07-21 18:02:15 +02:00
Hendiadyoin1
ed46d52252 Everywhere: Use AK/Math.h if applicable
AK's version should see better inlining behaviors, than the LibM one.
We avoid mixed usage for now though.

Also clean up some stale math includes and improper floatingpoint usage.
2021-07-19 16:34:21 +04:30
Marcus Nilsson
22611ca136 WidgetGallery: Pledge thread
This is needed to use the file picker dialog.
2021-07-17 23:30:58 +02:00
Marcus Nilsson
57fc6eb9be WidgetGallery: Remove unused include 2021-07-17 23:30:58 +02:00
Daniel Bertalan
c6fafd3e90 AK+Userland: Add generic AK::abs() function and use it
Previously, in LibGFX's `Point` class, calculated distances were passed
to the integer `abs` function, even if the stored type was a float. This
caused the value to unexpectedly be truncated. Luckily, this API was not
used with floating point types, but that can change in the future, so
why not fix it now :^)

Since we are in C++, we can use function overloading to make things
easy, and to automatically use the right version.

This is even better than the LibC/LibM functions, as using a bit of
hackery, they are able to be constant-evaluated. They use compiler
intrinsics, so they do not depend on external code and the compiler can
emit the most optimized code by default.

Since we aren't using the C++ standard library's trick of importing
everything into the `AK` namespace, this `abs` function cannot be
exported to the global namespace, as the names would clash.
2021-07-08 10:11:00 +02:00
Andreas Kling
36cc011ae4 Fire: Make the main widget a GUI::Frame 2021-07-05 02:38:31 +02:00
Andreas Kling
782a5c88ce WindowServer: Make most remaining WindowServer IPC calls async
The only remaining sync call from client to server is now the call
that switches a window's backing store. That one actually relies on
the synchronization to hand over ownership of the backing stores,
so it has to stay synchronous for now.
2021-07-04 23:15:16 +02:00
Gunnar Beutner
631d36fd98 Everywhere: Add component declarations
This adds component declarations so that users can select to not build
certain parts of the OS.
2021-06-17 11:03:51 +02:00
Brian Gianforcaro
06ea31d0d5 CatDog: Enhance the speech bubble artificial intelligence
Enable cat dog to greet you, and help you with yak shave sessions.
2021-06-07 21:52:16 +02:00
Ali Mohammad Pur
51c2c69357 AK+Everywhere: Disallow constructing Functions from incompatible types
Previously, AK::Function would accept _any_ callable type, and try to
call it when called, first with the given set of arguments, then with
zero arguments, and if all of those failed, it would simply not call the
function and **return a value-constructed Out type**.
This lead to many, many, many hard to debug situations when someone
forgot a `const` in their lambda argument types, and many cases of
people taking zero arguments in their lambdas to ignore them.
This commit reworks the Function interface to not include any such
surprising behaviour, if your function instance is not callable with
the declared argument set of the Function, it can simply not be
assigned to that Function instance, end of story.
2021-06-06 00:27:30 +04:30
Stephan Unverwerth
10ceeb092f Everywhere: Use s.unverwerth@serenityos.org :^) 2021-05-29 12:30:08 +01:00
Linus Groh
d60ebbbba6 Revert "Userland: static vs non-static constexpr variables"
This reverts commit 800ea8ea96.

Booting the system no longer worked after these changes.
2021-05-21 10:30:52 +01:00
Lenny Maiorani
800ea8ea96 Userland: static vs non-static constexpr variables
Problem:
- `static` variables consume memory and sometimes are less
  optimizable.
- `static const` variables can be `constexpr`, usually.
- `static` function-local variables require an initialization check
  every time the function is run.

Solution:
- If a global `static` variable is only used in a single function then
  move it into the function and make it non-`static` and `constexpr`.
- Make all global `static` variables `constexpr` instead of `const`.
- Change function-local `static const[expr]` variables to be just
  `constexpr`.
2021-05-21 10:07:06 +01:00
Linus Groh
9dd3203cc6 LibGfx: Add missing TextAlignment::BottomLeft 2021-05-21 08:04:31 +02:00
Andreas Kling
8a6c37deef LibGfx: Remove Gfx::FontDatabase::default_bold_fixed_width_font()
Ask for a bold_variant() of the default_fixed_width_font() instead.
2021-05-20 20:55:29 +02:00
Andreas Kling
6a012ad79f LibGfx: Remove Gfx::FontDatabase::default_bold_font()
Instead use default_font().bold_variant() in cases where we want a bold
variant of the default font. :^)
2021-05-20 20:55:29 +02:00
Marcus Nilsson
41e74d4d31 CatDog: Don't show context menu when clicking outside of widget
The context menu for CatDog was shown when right clicking anywhere on
the screen because of global cursor tracking being enabled.
Also fix event not being passed by reference.

Fixes #7285
2021-05-19 23:14:07 +02:00
Erik Biederstadt
585e7890cd 3DFileViewer: Move Demos/GLTeapot to Applications/3DFileViewer
Also changes the category to `Graphics`
2021-05-19 19:34:12 +01:00
Erik Biederstadt
132ecfc47b GLTeapot: Adds a help menu to the GLTeapot demo
Having a help menu maintains better consistency with the other GUI apps
 on the system.
2021-05-19 19:34:12 +01:00
Erik Biederstadt
d9dc42fab5 GLTeapot: Adds additional error checking when loading files
- If the 3D file contains no vertices then an error is raised
- If the file is not an OBJ file then an error is raised
2021-05-19 19:34:12 +01:00
Erik Biederstadt
01a5ffdae0 GLTeapot: Add the ability to open 3D files
This change makes it possible for the GLTeapot demo to open any OBJ
file.
2021-05-19 19:34:12 +01:00
Marcus Nilsson
e5367c13d8 CatDog: Remove global menu and add context menu
There was no way to close catdog since it relied on global menus, this
adds a context menu for opening the about dialog and quitting.

Fixes #7252
2021-05-18 18:59:18 +01:00
Gunnar Beutner
92879383fb Mandelbrot: Export images in a fixed resolution
This makes the exported image independent from the current window size
and just always exports it at 1920x1080.
2021-05-18 16:01:32 +02:00
Gunnar Beutner
f2f728d39a Mandelbrot: Keep the aspect ratio when (re-)sizing the window
Previously the initial aspect ratio was incorrect and there was
nothing to ensure that the aspect ratio is kept when resizing the
window.
2021-05-18 16:01:32 +02:00
Gunnar Beutner
77bd3f75ce Mandelbrot: Add support for exporting the current image
Unfortunately this means unveil() won't work - at least until we get
something like FilePickerServer.
2021-05-18 16:01:32 +02:00
Gunnar Beutner
b429ee88f8 Mandelbrot: Implement color smoothing with gradients
This removes the color banding that happens for some of the
"outer" areas which all have the same iteration count.
2021-05-18 16:01:32 +02:00
Gunnar Beutner
c961616e6d Mandelbrot: Maintain aspect ratio when selecting a region
This makes sure the aspect ratio of the widget and the selection
match. Otherwise you'd end up with distorted images when zooming
in.
2021-05-18 16:01:32 +02:00
Gunnar Beutner
51db8085f8 Demos: Add Mandelbrot demo
This adds a very rudimentary Mandelbrot viewer. It supports zooming
and pretty much nothing else. Not even color smoothing or super
sampling.
2021-05-17 13:35:39 +02:00
Erik Biederstadt
2eb9dca782
GLTeapot: Add support for loading OBJ files containing extra information
If the OBJ loader encounters a file with vertex normals or texture
coordinates then it will no longer crash.
2021-05-16 22:48:23 +01:00
Andreas Kling
31d4bcf5bf Userland: Tighten a *lot* of pledges! :^)
Since applications using Core::EventLoop no longer need to create a
socket in /tmp/rpc/, and also don't need to listen for incoming
connections on this socket, we can remove a whole bunch of pledges!
2021-05-13 23:28:40 +02:00
Stephan Unverwerth
c2d84efaae LibGfx+Demos: Make Matrix4x4 a true alias for Matrix<4,T>
Matrix4x4 was defined as a derived class of Matrix<N,T> before.
Furthermore, some code was duplicated and it was overall just messy.
This commit turns Matrix4x4 into a simple alias for Matrix<4,T>.
2021-05-13 22:24:42 +02:00
Stephan Unverwerth
0833db0874 LibGfx: Make Matrix class consistently row-major
Matrix elements were interpreted in different ways.
This makes it definitely row-major, allowing initialization via
initializer list in a standard scientific order. Also matrix
multiplication now happens in the correct order and accessing
elements happens as m_elements[row][column].
2021-05-13 22:24:42 +02:00
Linus Groh
91eda22208 Everywhere: Add Alt shortcuts to remaining top-level menus
Not sure why some menus did have one and others didn't, even in the
same application - now they all do. :^)
I added character shortcuts to some menu actions as well.
2021-05-12 18:09:42 +01:00
Linus Groh
ff1d3f53c4 Everywhere: Rename app_menu to file_menu, continued
These were missed in 4b0098e.
2021-05-12 17:50:48 +01:00
Ali Mohammad Pur
a91a49337c LibCore+Everywhere: Move OpenMode out of IODevice
...and make it an enum class so people don't omit "OpenMode".
2021-05-12 11:00:45 +01:00
Ali Mohammad Pur
d42d984a2d GLTeapot: Use glGenLists() a bit to demonstrate that it works 2021-05-11 14:09:17 +01:00
Mathieu Gaillard
cf93512abe Demos: Implement basic Lambertian lighting for the GLTeapot
The teapot now looks more realistic
2021-05-09 16:14:15 +01:00
Mathieu Gaillard
7426c2fe45 Demos: Add indexed meshes in GLTeapot Demos
Improved the basic Wavefront OBJ loader to index vertices.
Uses less memory for the same mesh.
2021-05-09 16:14:15 +01:00
Stephan Unverwerth
e4db18e644 Demos: GLTeapot: Enable depth testing in demo 2021-05-09 15:58:35 +02:00
Gunnar Beutner
e0fe38ea25 CatDog: Help the user debug their programs
This adds helpful speech bubbles to CatDog. CatDog just wants to
help, that's all.
2021-05-09 15:21:23 +02:00
Gunnar Beutner
da5923bc54 CatDog: Rename root_widget to catdog_widget 2021-05-09 15:21:23 +02:00
Gunnar Beutner
e229914a74 CatDog: Move the main widget into its own file 2021-05-09 15:21:23 +02:00
Andreas Kling
41dc73adc4 Demos: Fix a bunch of incorrect use of GUI::PaintEvent::rect()
A bunch of programs were using the paint event rect as the rect
to draw into. Since the event rect could be any invalidated part
of the widget, we need to be passing the full Widget::rect().
2021-05-09 10:11:30 +02:00
Jesse Buhagiar
834f3c64f0 Demos: Add OpenGL teapot demo :^)
Every GL library needs an implementation of this!
Currently drawn with "pixel vomit" colours as we don't
yet support lighting via the GL library.

This also ships with a super basic Wavefront OBJ loader.
2021-05-08 10:13:22 +02:00
Andreas Kling
e2ffd14e4e WidgetGallery: Convert StringBuilder::appendf() => AK::Format 2021-05-07 21:12:09 +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