summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/Size.h
AgeCommit message (Collapse)Author
2023-01-04LibIPC+Everywhere: Change IPC::encode's return type to ErrorOrTimothy Flynn
In doing so, this removes all uses of the Encoder's stream operator, except for where it is currently still used in the generated IPC code. So the stream operator currently discards any errors, which is the existing behavior. A subsequent commit will propagate the errors.
2022-12-28LibGfx+Overall: Remove `is_null` from `Point`, `Rect` and `Size`Jelle Raaijmakers
Having a `Point`, `Rect` or `Size` claim it's `null` is silly. We have `Optional<T>` for that. For `Point`, rename `is_null` to `is_zero` to better reflect what we're testing. For `Rect` and `Size`, `is_null` is removed outright. Also, remove `is_empty` from `Point`. Points can't be empty.
2022-12-26LibIPC+Everywhere: Change IPC decoders to construct values in-placeTimothy Flynn
Currently, the generated IPC decoders will default-construct the type to be decoded, then pass that value by reference to the concrete decoder. This, of course, requires that the type is default-constructible. This was an issue for decoding Variants, which had to require the first type in the Variant list is Empty, to ensure it is default constructible. Further, this made it possible for values to become uninitialized in user-defined decoders. This patch makes the decoder interface such that the concrete decoders themselves contruct the decoded type upon return from the decoder. To do so, the default decoders in IPC::Decoder had to be moved to the IPC namespace scope, as these decoders are now specializations instead of overloaded methods (C++ requires specializations to be in a namespace scope).
2022-12-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
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-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
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-03Everywhere: Run clang-formatLinus Groh
2022-11-26LibGfx: Prevent calling `to_type<T>()` on `Line/Point/Rect/Size<T>`Sam Atkins
Also, add `Line::to_type<T>()` since that was missing. Calling to_type() with the same type as the existing object accomplishes nothing except wasting some cycles and making the code more verbose, and it is hard to spot. Nobody does this in the code currently (yay!) but I made this mistake repeatedly when doing my step-by-step CSS Pixels conversion, so let's make it easier to catch them.
2022-11-25LibGfx: Add Size::match_aspect_ratiokleines Filmröllchen
This will create a size that matches the given aspect ratio while preserving one of the two dimensions.
2022-11-25LibGfx: Add Size::aspect_ratiokleines Filmröllchen
This can compute the aspect ratio of the size. It can use another type for these computations, which is important for integer sizes.
2022-11-15Userland: Properly define IPC::encode and IPC::decode specializationsTimothy Flynn
In order to avoid the base encode/decode methods from being used (and failing a static assertion), we must be sure to declare/define the custom type implementations as template specializations. After this, LibIPC is no longer sensitive to include order.
2022-11-06Everywhere: Remove redundant inequality comparison operatorsDaniel Bertalan
C++20 can automatically synthesize `operator!=` from `operator==`, so there is no point in writing such functions by hand if all they do is call through to `operator==`. This fixes a compile error with compilers that implement P2468 (Clang 16 currently). This paper restores the C++17 behavior that if both `T::operator==(U)` and `T::operator!=(U)` exist, `U == T` won't be rewritten in reverse to call `T::operator==(U)`. Removing `!=` operators makes the rewriting possible again. See https://reviews.llvm.org/D134529#3853062
2022-10-27LibGfx: Make formatting of spatial types work with non-int/floatsSam Atkins
Line, Point, Rect, and Size now all have Formatters that will work with any type that itself has a Formatter.
2022-08-08LibGfx: Add Size<T>::to_rounded<I>()MacDue
Currently this is only specialized for rounding to integer types.
2022-03-04LibGfx: Make Size constexpr-capableLenny Maiorani
There is nothing in the `Size` class which cannot be `constexpr`, but without it being `constexpr` it prevents other things from being `constexpr`-capable.
2021-11-28LibIPC+IPCCompiler+AK: Make IPC value decoders return ErrorOr<void>Andreas Kling
This allows us to use TRY() in decoding helpers, leading to a nice reduction in line count.
2021-11-17AK: Convert AK::Format formatting helpers to returning ErrorOr<void>Andreas Kling
This isn't a complete conversion to ErrorOr<void>, but a good chunk. The end goal here is to propagate buffer allocation failures to the caller, and allow the use of TRY() with formatting functions.
2021-06-16LibGfx: Add a bunch of [[nodiscard]] to SizeAndreas Kling
2021-06-16LibGfx: Convert Size to east-const styleAndreas Kling
2021-05-02LibGfx: Unify Rect, Point, and SizeMatthew Olsson
This commit unifies methods and method/param names between the above classes, as well as adds [[nodiscard]] and ALWAYS_INLINE where appropriate. It also renamed the various move_by methods to translate_by, as that more closely matches the transformation terminology.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-03-12Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)Andreas Kling
Good-bye LogStream. Long live AK::Format!
2021-01-22LibGfx: Allow comparing Points, Sizes, and Rects of different typeNico Weber
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling