summaryrefslogtreecommitdiff
path: root/Games/Solitaire
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-06-10 10:57:59 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-10 10:59:04 +0200
commit116cf92156090bb3f5c15d5be145f1283884d65d (patch)
tree4496ab3e8c90add1c40da2eceee71324369ec0c6 /Games/Solitaire
parent656b01eb0fb659fb2d3ee4e6e4413a82543414e3 (diff)
downloadserenity-116cf92156090bb3f5c15d5be145f1283884d65d.zip
LibGfx: Rename Rect,Point,Size => IntRect,IntPoint,IntSize
This fits nicer with FloatRect,FloatPoint,FloatSize and gives a much better visual clue about what type of metric is being used.
Diffstat (limited to 'Games/Solitaire')
-rw-r--r--Games/Solitaire/Card.cpp6
-rw-r--r--Games/Solitaire/Card.h12
-rw-r--r--Games/Solitaire/CardStack.cpp6
-rw-r--r--Games/Solitaire/CardStack.h14
-rw-r--r--Games/Solitaire/SolitaireWidget.h2
5 files changed, 20 insertions, 20 deletions
diff --git a/Games/Solitaire/Card.cpp b/Games/Solitaire/Card.cpp
index 4db2e28bf4..980b48bdf5 100644
--- a/Games/Solitaire/Card.cpp
+++ b/Games/Solitaire/Card.cpp
@@ -79,13 +79,13 @@ static const NonnullRefPtr<Gfx::CharacterBitmap> s_club = Gfx::CharacterBitmap::
static RefPtr<Gfx::Bitmap> s_background;
Card::Card(Type type, uint8_t value)
- : m_rect(Gfx::Rect({}, { width, height }))
+ : m_rect(Gfx::IntRect({}, { width, height }))
, m_front(*Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, { width, height }))
, m_type(type)
, m_value(value)
{
ASSERT(value < card_count);
- Gfx::Rect paint_rect({ 0, 0 }, { width, height });
+ Gfx::IntRect paint_rect({ 0, 0 }, { width, height });
if (s_background.is_null()) {
s_background = Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, { width, height });
@@ -96,7 +96,7 @@ Card::Card(Type type, uint8_t value)
ASSERT(!image.is_null());
float aspect_ratio = image->width() / static_cast<float>(image->height());
- auto target_size = Gfx::Size(static_cast<int>(aspect_ratio * (height - 5)), height - 5);
+ auto target_size = Gfx::IntSize(static_cast<int>(aspect_ratio * (height - 5)), height - 5);
bg_painter.draw_scaled_bitmap(
{ { (width - target_size.width()) / 2, (height - target_size.height()) / 2 }, target_size },
diff --git a/Games/Solitaire/Card.h b/Games/Solitaire/Card.h
index a2dcab197a..2f3f31084d 100644
--- a/Games/Solitaire/Card.h
+++ b/Games/Solitaire/Card.h
@@ -50,9 +50,9 @@ public:
virtual ~Card() override;
- Gfx::Rect& rect() { return m_rect; }
- Gfx::Point position() const { return m_rect.location(); }
- const Gfx::Point& old_positon() const { return m_old_position; }
+ Gfx::IntRect& rect() { return m_rect; }
+ Gfx::IntPoint position() const { return m_rect.location(); }
+ const Gfx::IntPoint& old_positon() const { return m_old_position; }
uint8_t value() const { return m_value; };
Type type() const { return m_type; }
@@ -61,7 +61,7 @@ public:
bool is_upside_down() const { return m_upside_down; }
Gfx::Color color() const { return (m_type == Diamonds || m_type == Hearts) ? Color::Red : Color::Black; }
- void set_position(const Gfx::Point p) { m_rect.set_location(p); }
+ void set_position(const Gfx::IntPoint p) { m_rect.set_location(p); }
void set_moving(bool moving) { m_moving = moving; }
void set_upside_down(bool upside_down) { m_upside_down = upside_down; }
@@ -74,9 +74,9 @@ public:
private:
Card(Type type, uint8_t value);
- Gfx::Rect m_rect;
+ Gfx::IntRect m_rect;
NonnullRefPtr<Gfx::Bitmap> m_front;
- Gfx::Point m_old_position;
+ Gfx::IntPoint m_old_position;
Type m_type;
uint8_t m_value;
bool m_old_position_valid { false };
diff --git a/Games/Solitaire/CardStack.cpp b/Games/Solitaire/CardStack.cpp
index a13fec527b..dfac4b9347 100644
--- a/Games/Solitaire/CardStack.cpp
+++ b/Games/Solitaire/CardStack.cpp
@@ -36,7 +36,7 @@ CardStack::CardStack()
{
}
-CardStack::CardStack(const Gfx::Point& position, Type type, uint8_t shift_x, uint8_t shift_y, uint8_t step)
+CardStack::CardStack(const Gfx::IntPoint& position, Type type, uint8_t shift_x, uint8_t shift_y, uint8_t step)
: m_position(position)
, m_type(type)
, m_shift_x(shift_x)
@@ -110,7 +110,7 @@ void CardStack::rebound_cards()
card.set_position(m_stack_positions.at(card_index++));
}
-void CardStack::add_all_grabbed_cards(const Gfx::Point& click_location, NonnullRefPtrVector<Card>& grabbed)
+void CardStack::add_all_grabbed_cards(const Gfx::IntPoint& click_location, NonnullRefPtrVector<Card>& grabbed)
{
ASSERT(grabbed.is_empty());
@@ -218,7 +218,7 @@ NonnullRefPtr<Card> CardStack::pop()
void CardStack::calculate_bounding_box()
{
- m_bounding_box = Gfx::Rect(m_position, { Card::width, Card::height });
+ m_bounding_box = Gfx::IntRect(m_position, { Card::width, Card::height });
if (m_stack.is_empty())
return;
diff --git a/Games/Solitaire/CardStack.h b/Games/Solitaire/CardStack.h
index f8721a219c..e4cb2be77b 100644
--- a/Games/Solitaire/CardStack.h
+++ b/Games/Solitaire/CardStack.h
@@ -40,7 +40,7 @@ public:
};
CardStack();
- CardStack(const Gfx::Point& position, Type type, uint8_t shift_x, uint8_t shift_y, uint8_t step = 1);
+ CardStack(const Gfx::IntPoint& position, Type type, uint8_t shift_x, uint8_t shift_y, uint8_t step = 1);
bool is_dirty() const { return m_dirty; }
bool is_empty() const { return m_stack.is_empty(); }
@@ -49,7 +49,7 @@ public:
size_t count() const { return m_stack.size(); }
const Card& peek() const { return m_stack.last(); }
Card& peek() { return m_stack.last(); }
- const Gfx::Rect& bounding_box() const { return m_bounding_box; }
+ const Gfx::IntRect& bounding_box() const { return m_bounding_box; }
void set_focused(bool focused) { m_focused = focused; }
void set_dirty() { m_dirty = true; };
@@ -59,7 +59,7 @@ public:
void rebound_cards();
bool is_allowed_to_push(const Card&) const;
- void add_all_grabbed_cards(const Gfx::Point& click_location, NonnullRefPtrVector<Card>& grabbed);
+ void add_all_grabbed_cards(const Gfx::IntPoint& click_location, NonnullRefPtrVector<Card>& grabbed);
void draw(GUI::Painter&, const Gfx::Color& background_color);
void clear();
@@ -67,14 +67,14 @@ private:
void calculate_bounding_box();
NonnullRefPtrVector<Card> m_stack;
- Vector<Gfx::Point> m_stack_positions;
- Gfx::Point m_position;
- Gfx::Rect m_bounding_box;
+ Vector<Gfx::IntPoint> m_stack_positions;
+ Gfx::IntPoint m_position;
+ Gfx::IntRect m_bounding_box;
Type m_type { Invalid };
uint8_t m_shift_x { 0 };
uint8_t m_shift_y { 0 };
uint8_t m_step {};
bool m_focused { false };
bool m_dirty { false };
- Gfx::Rect m_base;
+ Gfx::IntRect m_base;
};
diff --git a/Games/Solitaire/SolitaireWidget.h b/Games/Solitaire/SolitaireWidget.h
index 4f5207b5ca..ac9bbd109c 100644
--- a/Games/Solitaire/SolitaireWidget.h
+++ b/Games/Solitaire/SolitaireWidget.h
@@ -124,7 +124,7 @@ private:
Animation m_animation;
CardStack* m_focused_stack { nullptr };
CardStack m_stacks[StackLocation::__Count];
- Gfx::Point m_mouse_down_location;
+ Gfx::IntPoint m_mouse_down_location;
bool m_mouse_down { false };
bool m_repaint_all { true };
bool m_has_to_repaint { true };