Commit graph

32 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
thankyouverycool
91bafc2653 LibGUI+Userland: Port Labels to String 2023-04-30 05:48:14 +02:00
Tim Ledbetter
5b84fafbca PixelPaint: Include possible errno description in error messages
In the case where an error is created from an errno, calling
string_literal() will print nothing. Using Error's formatter
instead gives a more descriptive error message.
2023-03-26 00:47:29 +01:00
Tim Ledbetter
bdaad815a1 PixelPaint: Rename Layer::resize() to Layer::scale()
This name more accurately describes the transform being performed.
2023-03-16 10:00:26 +01:00
Linus Groh
09d40bfbb2 Everywhere: Use _{short_,}string to create Strings from literals 2023-02-25 20:51:49 +01:00
Andreas Kling
df07416171 PixelPaint: Store tool cursors as NNRP<Gfx::Bitmap const> 2023-02-21 00:54:04 +01:00
Karol Kosek
be717edd33 PixelPaint: Propagate errors from making tool property widgets 2023-02-16 23:36:58 +00:00
Karol Kosek
e39adc4772 Userland: Set Button text using the new String class 2023-02-13 00:45:09 +00:00
Tim Ledbetter
4b604f702e PixelPaint: Correct move tool alignment with the layer boundary
Previously, the move tool outline could "wobble" relative to the layer
boundary. This caused the layer boundary to appear and disappear when
zooming. With this commit, the layer boundary is always drawn behind
the move tool outline.
2023-02-08 20:29:48 +01:00
Tim Ledbetter
9115e99e4b PixelPaint: Scale move tool resize anchors
The areas where the user must click to resize the image are now
scaled to ensure they do not overlap. This allows us to display the
correct cursor when zoomed out, as well as making the
borders look nicer.
2023-02-02 14:40:17 +01:00
Tim Ledbetter
c82825379a PixelPaint: Show resize anchors when using the move tool
This commit adds a two color border around areas that the user must
drag to resize, when using the move tool.
2023-02-02 14:40:17 +01:00
Tim Ledbetter
4c617d370e PixelPaint: Highlight active layer when using the move tool
This commit adds a two color border around the currently selected
layer when using the move tool.
2023-02-02 14:40:17 +01:00
Tim Ledbetter
7b3bc883f1 PixelPaint: Set initial position correctly when using the move tool
This fixes an issue, where single clicking in the corner of the image
without moving the mouse would cause the layer to jump to the top left
corner of the canvas.
2023-02-02 14:40:17 +01: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
Tim Ledbetter
77e15ff4da PixelPaint: Let the move tool optionally select the active layer
Previously, the move tool would always select the topmost layer before
performing a move operation. This commit adds an option for the move
tool to always select the active layer, even if it is behind another.
2023-01-26 14:00:14 +01:00
Tim Ledbetter
dd582e4ae3 PixelPaint: Hold shift to increase move tool speed with the arrow keys
Holding shift while using the move tool with the arrow keys now moves
the selected layer in 10 pixel increments.
2023-01-15 19:11:25 +01:00
Tim Ledbetter
569ef94228 PixelPaint: Don't allow the move tool to resize to zero pixels
This prevents an error message appearing when we attempt to scale
a layer to zero pixels using the move tool.
2023-01-13 15:45:28 +01:00
Tim Ledbetter
6b3688147f PixelPaint: Fix typo in variable name 2023-01-06 15:09:56 +00:00
Tim Ledbetter
a30b956e94 PixelPaint: Allow move tool to scale in all directions
It is now possible to scale the current layer using the move tool from
all four corners of the layer boundary. Previously scaling was only
possible from the bottom right of the image.
2023-01-06 15:09:56 +00:00
Baitinq
e89c649be1 PixelPaint: Propagate errors in {flip,crop,rotate,resize} functions
We now propagate errors when using the {Layer,Image}::flip(),
{Layer,Image}::crop(), {Layer,Image}::rotate() and
{Layer,Image}::resize() functions.

We handle these errors by show an error DialogBox with the error's
message.

This removes 8 FIXMEs:))
2023-01-03 09:58:02 +00:00
Tim Ledbetter
213d82f39b PixelPaint: Fix move tool scaling function when zoomed
The move tool enters scaling mode when the user mouses within 10
pixels either side of the the bottom right of the active layer
boundary.

Previously, the bounding box used to determine whether the mouse was
at the bottom right of the layer used coordinates that were scaled to
the size of the image. This made the size of the area
you need to enter proportional the current zoom level.

This commit fixes the issue by using non-scaled coordinates to
calculate the bounding box, meaning its size is unaffected by the
current zoom level.
2022-12-16 10:24:34 +00:00
Tim Ledbetter
5ba0b551f4 PixelPaint: Display a preview image when scaling with the move tool
A preview of the scaled image and an outline of the updated layer
boundary are now shown when scaling with the move tool.
2022-12-16 10:24:34 +00:00
Timothy Slater
296b76095f PixelPaint: Change tool keydown handle to non-const
This was changed to const in PR #15788 but presents problems for tools
that may need to forward this event to non-const event handlers.
2022-12-16 10:14:20 +00:00
MacDue
7be0b27dd3 Meta+Userland: Pass Gfx::IntPoint by value
This is just two ints or 8 bytes or the size of the reference on
x86_64 or AArch64.
2022-12-07 11:48:27 +01:00
Zaggy1024
7ce346e50e PixelPaint: Allow keydown events to bubble from ImageEditor
Previously, all keydown KeyEvents were accepted, causing parent widgets
not to receive them. With the addition of shortcut handling to keydown,
shortcuts were not called when the ImageEditor was focused.
2022-11-14 16:08:11 +00:00
Tommaso Peduzzi
f547b9be7b PixelPaint: Scale layer and preserve aspect ratio
This patch adds the ability to scale a layer and
preserve the aspect ratio.
When the Shift key is pressed, the aspect ratio is preserved.
2022-09-16 22:53:07 +02:00
Tommaso Peduzzi
293ab2cdc9 PixelPaint: Add scaling function to move tool
This patch adds scaling function to the move tool.
When the cursor is over the lower right corner of the layer, it changes.
This is to signify that the layer can be scaled by dragging the mouse.

There is currently no preview of the scaling.
Doing a resize every time the mouse moves leads to unexpected behavior.
2022-09-16 22:53:07 +02:00
Andreas Kling
bf25b0a0b5 PixelPaint: Show more specific Undo/Redo action text
The Undo/Redo actions now tell you what kind of action will be
undone/redone. This is achieved by adding an "action text" field to the
ImageUndoCommand and having everyone who calls did_complete_action()
provide this text.
2022-08-21 20:33:03 +02:00
Lenny Maiorani
160bda7228 Applications: Use default constructors/destructors
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-02-14 22:06:55 +00:00
Mustafa Quraish
7974fee800 PixelPaint: Inherit from AbstractZoomPanWidget 2022-01-14 01:02:34 +01:00
Filiph Sandström
d6a0726302 Everywhere: Rename left/right-click to primary/secondary
This resolves #10641.
2021-10-27 22:05:58 +03:00
Marcus Nilsson
f9e0815c3b PixelPaint: Move Tools to it's own subdirectory
The PixelPaint source directory was getting a bit large, let's move all
the Tools to it's own subdirectory. Also remove some unused includes.
2021-09-20 03:04:24 +00:00
Renamed from Userland/Applications/PixelPaint/MoveTool.cpp (Browse further)