mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibGfx: Add ImageCursor type and Cursor variant
Besides standard cursors, we also need to support custom images. For now, everything still uses StandardCursor.
This commit is contained in:
parent
6a4a60cbd5
commit
1990b2fc52
Notes:
github-actions[bot]
2025-02-28 12:52:16 +00:00
Author: https://github.com/AtkinsSJ
Commit: 1990b2fc52
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3644
8 changed files with 104 additions and 39 deletions
40
Libraries/LibGfx/Cursor.cpp
Normal file
40
Libraries/LibGfx/Cursor.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibGfx/Cursor.h>
|
||||
#include <LibIPC/Decoder.h>
|
||||
#include <LibIPC/Encoder.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
bool ImageCursor::operator==(ImageCursor const& other) const
|
||||
{
|
||||
return hotspot == other.hotspot
|
||||
&& bitmap.bitmap() == other.bitmap.bitmap();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace IPC {
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder& encoder, Gfx::ImageCursor const& image_cursor)
|
||||
{
|
||||
TRY(encoder.encode(image_cursor.bitmap));
|
||||
TRY(encoder.encode(image_cursor.hotspot));
|
||||
return {};
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<Gfx::ImageCursor> decode(Decoder& decoder)
|
||||
{
|
||||
Gfx::ImageCursor result;
|
||||
result.bitmap = TRY(decoder.decode<Gfx::ShareableBitmap>());
|
||||
result.hotspot = TRY(decoder.decode<Gfx::IntPoint>());
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue