mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
Chess+GamesSettings: Give chess pieces some breathing room
Draw pieces around 80% of the size of a square, instead of 100%, so that there is a nice gap around them. This feels more comfy, and makes it actually possible to read the coordinates while a piece is on their square.
This commit is contained in:
parent
7e4186de63
commit
0f2936d8cd
Notes:
sideshowbarker
2024-07-17 08:43:11 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/0f2936d8cd Pull-request: https://github.com/SerenityOS/serenity/pull/17281
2 changed files with 4 additions and 2 deletions
|
@ -163,6 +163,7 @@ private:
|
|||
// With the same preview size as we use for card games, a nice fit is 2 ranks of 6.
|
||||
// There are definitely better ways of doing this, but it'll do. ;^)
|
||||
auto square_size = 61;
|
||||
auto square_margin = square_size / 10;
|
||||
|
||||
auto rect_for_square = [&](Chess::Square const& square) {
|
||||
return Gfx::IntRect {
|
||||
|
@ -196,7 +197,7 @@ private:
|
|||
auto draw_piece = [&](Chess::Piece const& piece, Chess::Square const& square) {
|
||||
auto& bitmap = *m_piece_images.get(piece).value();
|
||||
painter.draw_scaled_bitmap(
|
||||
rect_for_square(square),
|
||||
rect_for_square(square).shrunken(square_margin, square_margin, square_margin, square_margin),
|
||||
bitmap,
|
||||
bitmap.rect(),
|
||||
1.0f,
|
||||
|
|
|
@ -41,6 +41,7 @@ void ChessWidget::paint_event(GUI::PaintEvent& event)
|
|||
|
||||
auto square_width = min_size / 8;
|
||||
auto square_height = min_size / 8;
|
||||
auto square_margin = square_width / 10;
|
||||
int coord_rank_file = (side() == Chess::Color::White) ? 0 : 7;
|
||||
|
||||
Chess::Board& active_board = (m_playback ? board_playback() : board());
|
||||
|
@ -84,7 +85,7 @@ void ChessWidget::paint_event(GUI::PaintEvent& event)
|
|||
if (!(m_dragging_piece && sq == m_moving_square)) {
|
||||
auto bmp = m_pieces.get(active_board.get_piece(sq));
|
||||
if (bmp.has_value()) {
|
||||
painter.draw_scaled_bitmap(tile_rect, *bmp.value(), bmp.value()->rect(), 1.0f, Gfx::Painter::ScalingMode::BilinearBlend);
|
||||
painter.draw_scaled_bitmap(tile_rect.shrunken(square_margin, square_margin, square_margin, square_margin), *bmp.value(), bmp.value()->rect(), 1.0f, Gfx::Painter::ScalingMode::BilinearBlend);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue