mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 20:33:10 +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
|
@ -163,6 +163,7 @@ private:
|
||||||
// With the same preview size as we use for card games, a nice fit is 2 ranks of 6.
|
// 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. ;^)
|
// There are definitely better ways of doing this, but it'll do. ;^)
|
||||||
auto square_size = 61;
|
auto square_size = 61;
|
||||||
|
auto square_margin = square_size / 10;
|
||||||
|
|
||||||
auto rect_for_square = [&](Chess::Square const& square) {
|
auto rect_for_square = [&](Chess::Square const& square) {
|
||||||
return Gfx::IntRect {
|
return Gfx::IntRect {
|
||||||
|
@ -196,7 +197,7 @@ private:
|
||||||
auto draw_piece = [&](Chess::Piece const& piece, Chess::Square const& square) {
|
auto draw_piece = [&](Chess::Piece const& piece, Chess::Square const& square) {
|
||||||
auto& bitmap = *m_piece_images.get(piece).value();
|
auto& bitmap = *m_piece_images.get(piece).value();
|
||||||
painter.draw_scaled_bitmap(
|
painter.draw_scaled_bitmap(
|
||||||
rect_for_square(square),
|
rect_for_square(square).shrunken(square_margin, square_margin, square_margin, square_margin),
|
||||||
bitmap,
|
bitmap,
|
||||||
bitmap.rect(),
|
bitmap.rect(),
|
||||||
1.0f,
|
1.0f,
|
||||||
|
|
|
@ -41,6 +41,7 @@ void ChessWidget::paint_event(GUI::PaintEvent& event)
|
||||||
|
|
||||||
auto square_width = min_size / 8;
|
auto square_width = min_size / 8;
|
||||||
auto square_height = 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;
|
int coord_rank_file = (side() == Chess::Color::White) ? 0 : 7;
|
||||||
|
|
||||||
Chess::Board& active_board = (m_playback ? board_playback() : board());
|
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)) {
|
if (!(m_dragging_piece && sq == m_moving_square)) {
|
||||||
auto bmp = m_pieces.get(active_board.get_piece(sq));
|
auto bmp = m_pieces.get(active_board.get_piece(sq));
|
||||||
if (bmp.has_value()) {
|
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