mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
LibGUI: Support using a bitmap as override cursor
This commit is contained in:
parent
4bfe060336
commit
116bb4888f
Notes:
sideshowbarker
2024-07-18 01:42:08 +09:00
Author: https://github.com/mrkct
Commit: 116bb4888f
Pull-request: https://github.com/SerenityOS/serenity/pull/10381
Reviewed-by: https://github.com/BenWiederhake ✅
Reviewed-by: https://github.com/TobyAsE
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/kleinesfilmroellchen
4 changed files with 46 additions and 26 deletions
|
@ -1036,14 +1036,23 @@ Gfx::IntRect Widget::children_clip_rect() const
|
|||
return rect();
|
||||
}
|
||||
|
||||
void Widget::set_override_cursor(Gfx::StandardCursor cursor)
|
||||
void Widget::set_override_cursor(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor)
|
||||
{
|
||||
if (m_override_cursor == cursor)
|
||||
auto const& are_cursors_the_same = [](AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> const& a, AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> const& b) {
|
||||
if (a.has<Gfx::StandardCursor>() != b.has<Gfx::StandardCursor>())
|
||||
return false;
|
||||
if (a.has<Gfx::StandardCursor>())
|
||||
return a.get<Gfx::StandardCursor>() == b.get<Gfx::StandardCursor>();
|
||||
return a.get<NonnullRefPtr<Gfx::Bitmap>>().ptr() == b.get<NonnullRefPtr<Gfx::Bitmap>>().ptr();
|
||||
};
|
||||
|
||||
if (are_cursors_the_same(m_override_cursor, cursor))
|
||||
return;
|
||||
|
||||
m_override_cursor = cursor;
|
||||
if (auto* window = this->window())
|
||||
m_override_cursor = move(cursor);
|
||||
if (auto* window = this->window()) {
|
||||
window->update_cursor({});
|
||||
}
|
||||
}
|
||||
|
||||
bool Widget::load_from_gml(const StringView& gml_string)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue