1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 05:27:45 +00:00

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.
This commit is contained in:
Andreas Kling 2020-06-10 10:57:59 +02:00
parent 656b01eb0f
commit 116cf92156
212 changed files with 1144 additions and 1144 deletions

View file

@ -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 },

View file

@ -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 };

View file

@ -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;

View file

@ -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;
};

View file

@ -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 };