1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 12:37:44 +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

@ -121,7 +121,7 @@ private:
bool m_chord { false };
};
Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, Function<void(Gfx::Size)> on_size_changed)
Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, Function<void(Gfx::IntSize)> on_size_changed)
: m_face_button(face_button)
, m_flag_label(flag_label)
, m_time_label(time_label)
@ -241,7 +241,7 @@ void Field::reset()
for (size_t c = 0; c < columns(); ++c) {
if (!m_squares[i])
m_squares[i] = make<Square>();
Gfx::Rect rect = { frame_thickness() + static_cast<int>(c) * square_size(), frame_thickness() + static_cast<int>(r) * square_size(), square_size(), square_size() };
Gfx::IntRect rect = { frame_thickness() + static_cast<int>(c) * square_size(), frame_thickness() + static_cast<int>(r) * square_size(), square_size(), square_size() };
auto& square = this->square(r, c);
square.field = this;
square.row = r;
@ -329,13 +329,13 @@ void Field::paint_event(GUI::PaintEvent& event)
painter.add_clip_rect(inner_rect);
for (int y = inner_rect.top() - 1; y <= inner_rect.bottom(); y += square_size()) {
Gfx::Point a { inner_rect.left(), y };
Gfx::Point b { inner_rect.right(), y };
Gfx::IntPoint a { inner_rect.left(), y };
Gfx::IntPoint b { inner_rect.right(), y };
painter.draw_line(a, b, palette().threed_shadow1());
}
for (int x = frame_inner_rect().left() - 1; x <= frame_inner_rect().right(); x += square_size()) {
Gfx::Point a { x, inner_rect.top() };
Gfx::Point b { x, inner_rect.bottom() };
Gfx::IntPoint a { x, inner_rect.top() };
Gfx::IntPoint b { x, inner_rect.bottom() };
painter.draw_line(a, b, palette().threed_shadow1());
}
}

View file

@ -60,7 +60,7 @@ class Field final : public GUI::Frame {
friend class Square;
friend class SquareLabel;
public:
Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, Function<void(Gfx::Size)> on_size_changed);
Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, Function<void(Gfx::IntSize)> on_size_changed);
virtual ~Field() override;
size_t rows() const { return m_rows; }
@ -126,5 +126,5 @@ private:
bool m_chord_preview { false };
bool m_first_click { true };
bool m_single_chording { true };
Function<void(Gfx::Size)> m_on_size_changed;
Function<void(Gfx::IntSize)> m_on_size_changed;
};

View file

@ -92,13 +92,13 @@ void SnakeGame::spawn_fruit()
m_fruit_type = rand() % m_fruit_bitmaps.size();
}
Gfx::Rect SnakeGame::score_rect() const
Gfx::IntRect SnakeGame::score_rect() const
{
int score_width = font().width(m_score_text);
return { width() - score_width - 2, height() - font().glyph_height() - 2, score_width, font().glyph_height() };
}
Gfx::Rect SnakeGame::high_score_rect() const
Gfx::IntRect SnakeGame::high_score_rect() const
{
int high_score_width = font().width(m_high_score_text);
return { 2, height() - font().glyph_height() - 2, high_score_width, font().glyph_height() };
@ -197,10 +197,10 @@ void SnakeGame::keydown_event(GUI::KeyEvent& event)
}
}
Gfx::Rect SnakeGame::cell_rect(const Coordinate& coord) const
Gfx::IntRect SnakeGame::cell_rect(const Coordinate& coord) const
{
auto game_rect = rect();
auto cell_size = Gfx::Size(game_rect.width() / m_columns, game_rect.height() / m_rows);
auto cell_size = Gfx::IntSize(game_rect.width() / m_columns, game_rect.height() / m_rows);
return {
coord.column * cell_size.width(),
coord.row * cell_size.height(),
@ -220,10 +220,10 @@ void SnakeGame::paint_event(GUI::PaintEvent& event)
auto rect = cell_rect(part);
painter.fill_rect(rect, Color::from_rgb(0xaaaa00));
Gfx::Rect left_side(rect.x(), rect.y(), 2, rect.height());
Gfx::Rect top_side(rect.x(), rect.y(), rect.width(), 2);
Gfx::Rect right_side(rect.right() - 1, rect.y(), 2, rect.height());
Gfx::Rect bottom_side(rect.x(), rect.bottom() - 1, rect.width(), 2);
Gfx::IntRect left_side(rect.x(), rect.y(), 2, rect.height());
Gfx::IntRect top_side(rect.x(), rect.y(), rect.width(), 2);
Gfx::IntRect right_side(rect.right() - 1, rect.y(), 2, rect.height());
Gfx::IntRect bottom_side(rect.x(), rect.bottom() - 1, rect.width(), 2);
painter.fill_rect(left_side, Color::from_rgb(0xcccc00));
painter.fill_rect(right_side, Color::from_rgb(0x888800));
painter.fill_rect(top_side, Color::from_rgb(0xcccc00));

View file

@ -63,9 +63,9 @@ private:
bool is_available(const Coordinate&);
void queue_velocity(int v, int h);
const Velocity& last_velocity() const;
Gfx::Rect cell_rect(const Coordinate&) const;
Gfx::Rect score_rect() const;
Gfx::Rect high_score_rect() const;
Gfx::IntRect cell_rect(const Coordinate&) const;
Gfx::IntRect score_rect() const;
Gfx::IntRect high_score_rect() const;
int m_rows { 20 };
int m_columns { 20 };

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