mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:27:45 +00:00
Minesweeper: Turn the field into a GFrame for that containery look.
This commit is contained in:
parent
3f37665492
commit
49b63efddb
3 changed files with 8 additions and 5 deletions
|
@ -25,8 +25,11 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
Field::Field(GWidget* parent)
|
Field::Field(GWidget* parent)
|
||||||
: GWidget(parent)
|
: GFrame(parent)
|
||||||
{
|
{
|
||||||
|
set_frame_thickness(2);
|
||||||
|
set_frame_shape(FrameShape::Container);
|
||||||
|
set_frame_shadow(FrameShadow::Sunken);
|
||||||
m_mine_bitmap = GraphicsBitmap::load_from_file("/res/icons/minesweeper/mine.png");
|
m_mine_bitmap = GraphicsBitmap::load_from_file("/res/icons/minesweeper/mine.png");
|
||||||
m_flag_bitmap = GraphicsBitmap::load_from_file("/res/icons/minesweeper/flag.png");
|
m_flag_bitmap = GraphicsBitmap::load_from_file("/res/icons/minesweeper/flag.png");
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
|
@ -77,7 +80,7 @@ void Field::reset()
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (int r = 0; r < rows(); ++r) {
|
for (int r = 0; r < rows(); ++r) {
|
||||||
for (int c = 0; c < columns(); ++c) {
|
for (int c = 0; c < columns(); ++c) {
|
||||||
Rect rect = { c * square_size(), r * square_size(), square_size(), square_size() };
|
Rect rect = { frame_thickness() + c * square_size(), frame_thickness() + r * square_size(), square_size(), square_size() };
|
||||||
auto& square = this->square(r, c);
|
auto& square = this->square(r, c);
|
||||||
square.row = r;
|
square.row = r;
|
||||||
square.column = c;
|
square.column = c;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibGUI/GWidget.h>
|
#include <LibGUI/GFrame.h>
|
||||||
|
|
||||||
class SquareButton;
|
class SquareButton;
|
||||||
class GLabel;
|
class GLabel;
|
||||||
|
@ -16,7 +16,7 @@ struct Square {
|
||||||
GLabel* label { nullptr };
|
GLabel* label { nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
class Field final : public GWidget {
|
class Field final : public GFrame {
|
||||||
public:
|
public:
|
||||||
explicit Field(GWidget* parent);
|
explicit Field(GWidget* parent);
|
||||||
virtual ~Field() override;
|
virtual ~Field() override;
|
||||||
|
|
|
@ -10,7 +10,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto* window = new GWindow;
|
auto* window = new GWindow;
|
||||||
window->set_title("Minesweeper");
|
window->set_title("Minesweeper");
|
||||||
window->set_rect(100, 100, 135, 171);
|
window->set_rect(100, 100, 139, 175);
|
||||||
|
|
||||||
auto* widget = new GWidget;
|
auto* widget = new GWidget;
|
||||||
window->set_main_widget(widget);
|
window->set_main_widget(widget);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue