blob: 51c0430ee5d1544731d04906a74013a1607d425f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
/*
* Copyright (c) 2020, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "Game.h"
#include <LibGUI/Frame.h>
class BoardView final : public GUI::Frame {
C_OBJECT(BoardView);
public:
virtual ~BoardView() override;
void set_board(const Game::Board* board);
Function<void(Game::Direction)> on_move;
private:
explicit BoardView(const Game::Board*);
virtual void resize_event(GUI::ResizeEvent&) override;
virtual void paint_event(GUI::PaintEvent&) override;
virtual void keydown_event(GUI::KeyEvent&) override;
size_t rows() const;
size_t columns() const;
void pick_font();
void resize();
Color background_color_for_cell(u32 value);
Color text_color_for_cell(u32 value);
float m_padding { 0 };
float m_cell_size { 0 };
const Game::Board* m_board { nullptr };
};
|