mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:17:35 +00:00
2048: Give the board view a nice GUI::Frame look :^)
This commit is contained in:
parent
45d4bf156d
commit
3bb36dbd3f
2 changed files with 11 additions and 6 deletions
|
@ -177,11 +177,16 @@ Gfx::Color BoardView::text_color_for_cell(u32 value)
|
||||||
return Color::from_rgb(0xf9f6f2);
|
return Color::from_rgb(0xf9f6f2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoardView::paint_event(GUI::PaintEvent&)
|
void BoardView::paint_event(GUI::PaintEvent& event)
|
||||||
{
|
{
|
||||||
|
Frame::paint_event(event);
|
||||||
|
|
||||||
Color background_color = Color::from_rgb(0xbbada0);
|
Color background_color = Color::from_rgb(0xbbada0);
|
||||||
|
|
||||||
GUI::Painter painter(*this);
|
GUI::Painter painter(*this);
|
||||||
|
painter.add_clip_rect(event.rect());
|
||||||
|
painter.add_clip_rect(frame_inner_rect());
|
||||||
|
painter.translate(frame_thickness(), frame_thickness());
|
||||||
|
|
||||||
if (!m_board) {
|
if (!m_board) {
|
||||||
painter.fill_rect(rect(), background_color);
|
painter.fill_rect(rect(), background_color);
|
||||||
|
|
|
@ -27,20 +27,20 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include <LibGUI/Widget.h>
|
#include <LibGUI/Frame.h>
|
||||||
|
|
||||||
class BoardView final : public GUI::Widget {
|
class BoardView final : public GUI::Frame {
|
||||||
C_OBJECT(BoardView)
|
C_OBJECT(BoardView);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BoardView(const Game::Board*);
|
|
||||||
virtual ~BoardView() override;
|
virtual ~BoardView() override;
|
||||||
|
|
||||||
void set_board(const Game::Board* board);
|
void set_board(const Game::Board* board);
|
||||||
|
|
||||||
Function<void(Game::Direction)> on_move;
|
Function<void(Game::Direction)> on_move;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
explicit BoardView(const Game::Board*);
|
||||||
|
|
||||||
virtual void resize_event(GUI::ResizeEvent&) override;
|
virtual void resize_event(GUI::ResizeEvent&) override;
|
||||||
virtual void paint_event(GUI::PaintEvent&) override;
|
virtual void paint_event(GUI::PaintEvent&) override;
|
||||||
virtual void keydown_event(GUI::KeyEvent&) override;
|
virtual void keydown_event(GUI::KeyEvent&) override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue