Commit Graph

374 Commits

Author SHA1 Message Date
Tobias Christiansen
57772f9708 PixelPaint: Add a mask thumbnail to the LayerListWidget 2022-03-08 22:07:12 +01:00
Tobias Christiansen
f972f8e7a8 PixelPaint: Use the currently_edited_bitmap in the Tools
This way, you can actually edit the mask of a Layer!
2022-03-08 22:07:12 +01:00
Tobias Christiansen
96829565d8 PixelPaint: Keep track of and expose the type of the edited bitmap
This can be either the content bitmap or the mask bitmap.
2022-03-08 22:07:12 +01:00
Tobias Christiansen
a180b5f442 PixelPaint: Respect Mask when generating the display bitmap 2022-03-08 22:07:12 +01:00
Tobias Christiansen
82bfdec790 PixelPaint: Add mask Bitmap to Layer and expose it 2022-03-08 22:07:12 +01:00
Tobias Christiansen
31a9196bfe PixelPaint: Split bitmap() of Layer into {content, display}_bitmap
This is in preparation to support masking of Layers. We now distinguish
between the "display_bitmap" which will be the whole Layer with every
effect applied and the "content_bitmap" which contains the actual
unmodified pixels in the Layer.
2022-03-08 22:07:12 +01:00
Idan Horowitz
feb00b7105 Everywhere: Make JSON serialization fallible
This allows us to eliminate a major source of infallible allocation in
the Kernel, as well as lay down the groundwork for OOM fallibility in
userland.
2022-02-27 20:37:57 +01:00
electrikmilk
97ce19bc68 Base+PixelPaint: Use Merge Active Layer Up/Down Icons
The icons for these actions were added in a previous commit but never
used, now they are.
2022-02-15 10:40:49 +01:00
electrikmilk
7e5b3ce26b PixelPaint: Implement Merge Active Layer Up
Implements 'Merge Active Layer Up' and adds it to the 'Layer' menu.
2022-02-15 10:40:49 +01: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
c3e4123ed7 PixelPaint: Change menu shortcut for "Fit Image to View"
This makes it consistent with `ImageViewer`, where `F` was unavailable
for use as a shortcut. A small change, but it's nice having the same
keyboard shortcuts where we can :^)
2022-02-14 11:49:21 +01:00
Mustafa Quraish
5c763e9832 LibGUI+PixelPaint: Move fit_image_to_view to AbstractZoomPanWidget
We often want to zoom and fit the content of the widget into the
visible frame (or some rect within the frame), and it makes sense to
move this functionality into the AbstractZoomPanWidget to minimize
the amount of coordinate math derived classes need to do.

This commit moves the code that implements this functionality from
`PixelPaint::ImageEditor` into `AbstractZoomPanWidget` so that we
can also use it for other applications (such as ImageViewer!)
2022-02-14 11:49:21 +01:00
electrikmilk
8c32b42bdf Base+PixelPaint: Add more icons 2022-02-13 10:18:37 +01:00
Idan Horowitz
c8ab45e79f Userland: Run gml-format
This brings the existing GML files up to spec with the new requirements
2022-02-13 02:36:35 +02:00
Andreas Kling
3c108e20a7 PixelPaint: Run gml-format on FilterGallery.gml 2022-02-12 22:30:50 +01:00
snooze
e9d3f3793c PixelPaint: Add a preview in FilterGallery
Now FilterGallery shows the preview of the currently selected filter
applied on the currently active layer
2022-02-12 12:21:35 +01:00
electrikmilk
dece108f9a PixelPaint: Implement IconBag to organize icons
Implement IconBag method of organizing menubar icons from Browser.
2022-02-12 11:24:00 +01:00
Vitaly Dyachkov
32b8795091 LibConfig: Rename pledge_domains(String) => pledge_domain(String)
pledge_domains() that takes only one String argument was specifically
added as a shortcut for pledging a single domain. So, it makes sense to
use singular here.
2022-02-11 18:06:39 +01:00
kleines Filmröllchen
6ee597369d Meta+Userland: Run the GML formatter on CI and pre-commit
Now that the GML formatter is both perserving comments and also mostly
agrees to the existing GML style, it can be used to auto-format all the
GML files in the system. This commit does not only contain the scripts
for running the formatting on CI and the pre-commit hook, but also
initially formats all the existing GML files so that the hook is
successfull.
2022-02-07 18:39:50 +01:00
Hendiadyoin1
3e135f347f Userland: Use AK::pow<I> where applicable 2022-02-06 17:52:33 +00:00
Matthias-Sleurink
032ffbcf64 PixelPaint: Don't overwrite images with project file on save
The ImageEditor tracks whether it was loaded from an image
(the alternative being a project file.) If it was loaded from an image
file we redirect save project actions to save as instead.
2022-02-06 07:22:57 +00:00
Jagger De Leo
d5183cb7ac PixelPaint: Use Escape to clear rectangular selections
Now while dragging a new rectangular selection you can cancel it by
hitting Escape. Existing selections are cleared by Escape as well if the
RectangularSelectTool is active.
2022-02-04 16:11:48 +01:00
Jagger De Leo
a96b15d2bc PixelPaint: Remove conflicting action hotkey
The new CommandPalette feature conflicts with PixelPaint's Clear
Selection action keyboard shortcut (Ctrl + Shift + A).

Fixes: #12222
2022-02-04 16:11:48 +01:00
Andreas Kling
a599f68cfe PixelPaint: Paint layer thumbnails with correct aspect ratio 2022-02-01 10:49:13 +01:00
kleines Filmröllchen
145eeb57ab Userland: Remove a bunch of unnecessary Vector imports
How silly :^)
2022-01-28 23:40:25 +01:00
Sam Atkins
c388a879d7 AK+Userland: Make AK::decode_base64 return ErrorOr 2022-01-24 22:36:09 +01:00
Mustafa Quraish
1c3e93c6e0 PixelPaint: Use FileSystemAccessClient::try_* APIs 2022-01-20 10:39:12 +01:00
Dmitry Petrov
1662213737 Userland: Add horizontal mouse scroll support 2022-01-20 10:37:52 +01:00
Olivier De Cannière
d3dfb957a6 PixelPaint: Add delete selection behavior
The delete key can now be used to erase the pixels on the active layer
contained within the selection rectangle.

Closes #11861
2022-01-15 23:38:00 +01:00
Mateusz Krajewski
ae71d2b70e PixelPaint: Restrict "crop to selection" to image boundaries 2022-01-15 21:55:41 +01:00
sin-ack
2e1bbcb0fa LibCore+LibIPC+Everywhere: Return Stream::LocalSocket from LocalServer
This change unfortunately cannot be atomically made without a single
commit changing everything.

Most of the important changes are in LibIPC/Connection.cpp,
LibIPC/ServerConnection.cpp and LibCore/LocalServer.cpp.

The notable changes are:
- IPCCompiler now generates the decode and decode_message functions such
  that they take a Core::Stream::LocalSocket instead of the socket fd.
- IPC::Decoder now uses the receive_fd method of LocalSocket instead of
  doing system calls directly on the fd.
- IPC::ConnectionBase and related classes now use the Stream API
  functions.
- IPC::ServerConnection no longer constructs the socket itself; instead,
  a convenience macro, IPC_CLIENT_CONNECTION, is used in place of
  C_OBJECT and will generate a static try_create factory function for
  the ServerConnection subclass. The subclass is now responsible for
  passing the socket constructed in this function to its
  ServerConnection base; the socket is passed as the first argument to
  the constructor (as a NonnullOwnPtr<Core::Stream::LocalServer>) before
  any other arguments.
- The functionality regarding taking over sockets from SystemServer has
  been moved to LibIPC/SystemServerTakeover.cpp. The Core::LocalSocket
  implementation of this functionality hasn't been deleted due to my
  intention of removing this class in the near future and to reduce
  noise on this (already quite noisy) PR.
2022-01-15 13:29:48 +03:30
Colin
dc89ac1463 PixelPaint: Update SelectedColorWidget::m_color consistently 2022-01-14 21:33:32 +01:00
Mustafa Quraish
7974fee800 PixelPaint: Inherit from AbstractZoomPanWidget 2022-01-14 01:02:34 +01:00
electrikmilk
64ae8eac0e Base+PixelPaint: Add more menu icons
Adding icons missing from Pixel Paint menus.
2022-01-12 10:55:13 +01:00
Marcus Nilsson
876424923a PixelPaint: Verify that we have an ImageEditor instead of returning
We should never be in a state where an action requiring an ImageEditor
is enabled if all tabs are closed.
2022-01-09 20:24:02 +01:00
Marcus Nilsson
ae958d97b2 PixelPaint: Disable actions when no ImageEditor is open
Disable all actions when the last tab is closed and enable them when a
new ImageEditor is created.
2022-01-09 20:24:02 +01:00
Marcus Nilsson
18e6da6d4d PixelPaint: Keep a RefPtr to layer in LayerPropertiesWidget
Using a WeakPtr to keep a reference to the active layer caused it to
be destroyed when the last tab was closed, which made the
m_layer == layer check in set_layer() return early since it was
already null. Because of this the LayerPropertiesWidget was never
disabled.
2022-01-09 20:24:02 +01:00
Marcus Nilsson
7ca4d045bd PixelPaint: Make PaletteWidget::set_image_editor take a ImageEditor*
After closing the last open ImageEditor, selecting a color would try to
dereference it causing a crash. Instead make set_image_editor() take a
pointer to it and set it to nullptr when closing the last tab like we
do with LayerListWidget and LayerPropertiesWidget.
2022-01-09 20:24:02 +01:00
Mustafa Quraish
0e6576b376 PixelPaint: Move out common logic from Filters into base class
Now, each new filter only has to describe how to actually change
the bitmaps, and the common logic of pulling out the bitmap from the
layer, and marking the action as done, etc is all handled in the
`Filter` base class.

This also makes it possible to apply filters to external bitmaps,
which are not embedded in a `Layer` (which we can use to preview
filters in the future!)
2022-01-09 12:26:07 +01:00
creator1creeper1
45e68b2aa4 PixelPaint: Propagate errors using try_set_main_widget in main 2022-01-09 00:56:11 +01:00
Mustafa Quraish
c5fb55725e PixelPaint: Only clear LayerListWidget if there are no editors left
Previously, we would clear it if there was still an editor open. This
was not obvious because it was only visible when an inactive tab was
closed, since closing an active tab would trigger an editor change
which would re-fill the layers widget.
2022-01-09 00:19:47 +01:00
Mustafa Quraish
6c60bf7537 PixelPaint: Move request_close_editor() logic inside ImageEditor
This allows us to request any specific editor to close itself. Earlier,
this could only be done for the currently active editor, so trying to
close inactive tabs would not work properly.
2022-01-09 00:19:47 +01:00
Mustafa Quraish
c2b3bab984 PixelPaint: Move save and save_as logic inside ImageEditor
Previously the save logic was hardcoded to only work for the active
editor, so closing editors in the background would not properly
handle the unsaved changes. This patch brings us closer to be able
to fix that problem.
2022-01-09 00:19:47 +01:00
Xavier Defrang
b1a15b02f1 PixelPaint+LibGfx: Add sepia color filter 2022-01-08 12:31:11 +01:00
Marcus Nilsson
cecbed467b LibGUI: Move rotate cw/ccw to CommonActions
The rotate clockwise/rotate counterclockwise actions can be added to
CommonActions since they are repeated in FontEditor, ImageViewer and
PixelPaint. This keeps the shortcuts and icons consistent across
applications.
2022-01-06 21:25:02 +01:00
Tobias Christiansen
923979ca93 PixelPaint: Unveil FileIconProvider.ini
This is used by the Filter Gallery and previously complained in the
debug log that it was not unveiled.
2022-01-06 15:13:05 +01:00
Mustafa Quraish
7c69830169 PixelPaint: Add new icon for New Image from Clipboard
This is just a slight variation of `/res/icons/16x16/paste.png`, I've
removed the lines on the paper to make it look consistent with the
"New Image" icon, which is an empty piece of paper.
2022-01-05 12:08:20 +01:00
Mustafa Quraish
e2c73a114d PixelPaint: Use 'save' action in toolbar instead of 'save as'
I think this is likely the more common operation and makes more sense
in the toolbar. It calls the 'save as' action internally anyway if there
is no associated file.
2022-01-05 12:08:20 +01:00
Mustafa Quraish
c03f271bbf PixelPaint: Ask about unsaved changes for all tabs on close
Now, when trying to close the application, there is a separate prompt
for each open tab with unsaved changes. Each tab is closed after it is
handled appropriately (assuming the user didn't Cancel), this makes it
so that the message box is always asking about the currently active tab,
allowing the user to see that the image contains.

If at any point the user presses "Cancel", all remaining tabs are kept
open.
2022-01-05 12:08:20 +01:00
Mustafa Quraish
915211252d PixelPaint: Mark editor as unmodified when creating a default image
This is similar to opening an empty text file in TextEditor, the user
is only asked to saved changes if they have made any changes to it.
2022-01-05 12:08:20 +01:00