diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-13 14:22:25 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-13 14:22:40 +0200 |
commit | 49b63efddbecddac49fc0c451a77352fbcff3071 (patch) | |
tree | ee281aeba505b68346c703dcc9f2e4c3631a2c70 | |
parent | 3f37665492e8ebf5bde53176daf266f18baac18e (diff) | |
download | serenity-49b63efddbecddac49fc0c451a77352fbcff3071.zip |
Minesweeper: Turn the field into a GFrame for that containery look.
-rw-r--r-- | Games/Minesweeper/Field.cpp | 7 | ||||
-rw-r--r-- | Games/Minesweeper/Field.h | 4 | ||||
-rw-r--r-- | Games/Minesweeper/main.cpp | 2 |
3 files changed, 8 insertions, 5 deletions
diff --git a/Games/Minesweeper/Field.cpp b/Games/Minesweeper/Field.cpp index 9ae543bd49..92714174d4 100644 --- a/Games/Minesweeper/Field.cpp +++ b/Games/Minesweeper/Field.cpp @@ -25,8 +25,11 @@ public: }; 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_flag_bitmap = GraphicsBitmap::load_from_file("/res/icons/minesweeper/flag.png"); for (int i = 0; i < 8; ++i) @@ -77,7 +80,7 @@ void Field::reset() int i = 0; for (int r = 0; r < rows(); ++r) { 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); square.row = r; square.column = c; diff --git a/Games/Minesweeper/Field.h b/Games/Minesweeper/Field.h index 9395bd1287..1a7d8b8de6 100644 --- a/Games/Minesweeper/Field.h +++ b/Games/Minesweeper/Field.h @@ -1,6 +1,6 @@ #pragma once -#include <LibGUI/GWidget.h> +#include <LibGUI/GFrame.h> class SquareButton; class GLabel; @@ -16,7 +16,7 @@ struct Square { GLabel* label { nullptr }; }; -class Field final : public GWidget { +class Field final : public GFrame { public: explicit Field(GWidget* parent); virtual ~Field() override; diff --git a/Games/Minesweeper/main.cpp b/Games/Minesweeper/main.cpp index 4e5c89b7a1..ef623d278b 100644 --- a/Games/Minesweeper/main.cpp +++ b/Games/Minesweeper/main.cpp @@ -10,7 +10,7 @@ int main(int argc, char** argv) auto* window = new GWindow; window->set_title("Minesweeper"); - window->set_rect(100, 100, 135, 171); + window->set_rect(100, 100, 139, 175); auto* widget = new GWidget; window->set_main_widget(widget); |