From bab8bd143f964c5a0ed3c831aad3e7fef1ab1d58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Louren=C3=A7o?= Date: Thu, 25 Aug 2022 22:10:54 -0300 Subject: [PATCH] Chess: Highlight piece origin square when dragging piece --- Userland/Games/Chess/ChessWidget.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Userland/Games/Chess/ChessWidget.cpp b/Userland/Games/Chess/ChessWidget.cpp index 57f4b3904b5..939645905cb 100644 --- a/Userland/Games/Chess/ChessWidget.cpp +++ b/Userland/Games/Chess/ChessWidget.cpp @@ -157,6 +157,14 @@ void ChessWidget::paint_event(GUI::PaintEvent& event) } } + Gfx::IntRect origin_square; + if (side() == Chess::Color::White) { + origin_square = { m_moving_square.file * tile_width, (7 - m_moving_square.rank) * tile_height, tile_width, tile_height }; + } else { + origin_square = { (7 - m_moving_square.file) * tile_width, m_moving_square.rank * tile_height, tile_width, tile_height }; + } + painter.fill_rect(origin_square, m_move_highlight_color); + auto bmp = m_pieces.get(active_board.get_piece(m_moving_square)); if (bmp.has_value()) { auto center = m_drag_point - Gfx::IntPoint(tile_width / 2, tile_height / 2);