mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:17:35 +00:00
LibGUI+WindowServer: Allow specifying an optional drag bitmap
This bitmap is displayed alongside the dragged text underneath the mouse cursor while dragging. This will be a perfect fit for dragging e.g files around. :^)
This commit is contained in:
parent
183ee5847c
commit
f5dfb29607
5 changed files with 36 additions and 6 deletions
|
@ -424,11 +424,16 @@ void WSCompositor::draw_cursor()
|
|||
|
||||
if (wm.dnd_client()) {
|
||||
auto dnd_rect = wm.dnd_rect();
|
||||
m_back_painter->fill_rect(dnd_rect, Color(110, 34, 9, 200));
|
||||
if (!wm.dnd_text().is_empty()) {
|
||||
m_back_painter->fill_rect(dnd_rect, Color(110, 34, 9, 200));
|
||||
m_back_painter->draw_text(dnd_rect, wm.dnd_text(), TextAlignment::Center, Color::White);
|
||||
auto text_rect = dnd_rect;
|
||||
if (wm.dnd_bitmap())
|
||||
text_rect.move_by(wm.dnd_bitmap()->width(), 0);
|
||||
m_back_painter->draw_text(text_rect, wm.dnd_text(), TextAlignment::CenterLeft, Color::White);
|
||||
}
|
||||
if (wm.dnd_bitmap()) {
|
||||
m_back_painter->blit(dnd_rect.top_left(), *wm.dnd_bitmap(), wm.dnd_bitmap()->rect());
|
||||
}
|
||||
// FIXME: Also do the drag_bitmap if present
|
||||
m_last_dnd_rect = dnd_rect;
|
||||
} else {
|
||||
m_last_dnd_rect = {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue