diff options
author | Andreas Kling <kling@serenityos.org> | 2020-06-10 10:57:59 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-10 10:59:04 +0200 |
commit | 116cf92156090bb3f5c15d5be145f1283884d65d (patch) | |
tree | 4496ab3e8c90add1c40da2eceee71324369ec0c6 /Libraries | |
parent | 656b01eb0fb659fb2d3ee4e6e4413a82543414e3 (diff) | |
download | serenity-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 'Libraries')
106 files changed, 693 insertions, 693 deletions
diff --git a/Libraries/LibGUI/AbstractButton.cpp b/Libraries/LibGUI/AbstractButton.cpp index d13cb7843c..a4114bc1b8 100644 --- a/Libraries/LibGUI/AbstractButton.cpp +++ b/Libraries/LibGUI/AbstractButton.cpp @@ -155,7 +155,7 @@ void AbstractButton::keydown_event(KeyEvent& event) Widget::keydown_event(event); } -void AbstractButton::paint_text(Painter& painter, const Gfx::Rect& rect, const Gfx::Font& font, Gfx::TextAlignment text_alignment) +void AbstractButton::paint_text(Painter& painter, const Gfx::IntRect& rect, const Gfx::Font& font, Gfx::TextAlignment text_alignment) { auto clipped_rect = rect.intersected(this->rect()); diff --git a/Libraries/LibGUI/AbstractButton.h b/Libraries/LibGUI/AbstractButton.h index d925a451e7..1fc701bf7d 100644 --- a/Libraries/LibGUI/AbstractButton.h +++ b/Libraries/LibGUI/AbstractButton.h @@ -73,7 +73,7 @@ protected: virtual void save_to(JsonObject&) override; virtual bool set_property(const StringView& name, const JsonValue& value) override; - void paint_text(Painter&, const Gfx::Rect&, const Gfx::Font&, Gfx::TextAlignment); + void paint_text(Painter&, const Gfx::IntRect&, const Gfx::Font&, Gfx::TextAlignment); private: virtual bool is_abstract_button() const final { return true; } diff --git a/Libraries/LibGUI/AbstractTableView.cpp b/Libraries/LibGUI/AbstractTableView.cpp index d67d489efb..d05ee42f1d 100644 --- a/Libraries/LibGUI/AbstractTableView.cpp +++ b/Libraries/LibGUI/AbstractTableView.cpp @@ -109,7 +109,7 @@ void AbstractTableView::update_content_size() set_size_occupied_by_fixed_elements({ 0, header_height() }); } -Gfx::Rect AbstractTableView::header_rect(int column_index) const +Gfx::IntRect AbstractTableView::header_rect(int column_index) const { if (!model()) return {}; @@ -147,7 +147,7 @@ void AbstractTableView::paint_headers(Painter& painter) continue; int column_width = this->column_width(column_index); bool is_key_column = model()->key_column() == column_index; - Gfx::Rect cell_rect(x_offset, 0, column_width + horizontal_padding() * 2, header_height()); + Gfx::IntRect cell_rect(x_offset, 0, column_width + horizontal_padding() * 2, header_height()); bool pressed = column_index == m_pressed_column_header_index && m_pressed_column_header_is_pressed; bool hovered = column_index == m_hovered_column_header_index && model()->is_column_sortable(column_index); Gfx::StylePainter::paint_button(painter, cell_rect, palette(), Gfx::ButtonStyle::Normal, pressed, hovered); @@ -224,7 +224,7 @@ void AbstractTableView::set_cell_painting_delegate(int column, OwnPtr<TableCellP void AbstractTableView::update_headers() { - Gfx::Rect rect { 0, 0, frame_inner_rect().width(), header_height() }; + Gfx::IntRect rect { 0, 0, frame_inner_rect().width(), header_height() }; rect.move_by(frame_thickness(), frame_thickness()); update(rect); } @@ -236,7 +236,7 @@ AbstractTableView::ColumnData& AbstractTableView::column_data(int column) const return m_column_data.at(column); } -Gfx::Rect AbstractTableView::column_resize_grabbable_rect(int column) const +Gfx::IntRect AbstractTableView::column_resize_grabbable_rect(int column) const { if (!model()) return {}; @@ -257,7 +257,7 @@ void AbstractTableView::mousemove_event(MouseEvent& event) return AbstractView::mousemove_event(event); auto adjusted_position = this->adjusted_position(event.position()); - Gfx::Point horizontally_adjusted_position(adjusted_position.x(), event.position().y()); + Gfx::IntPoint horizontally_adjusted_position(adjusted_position.x(), event.position().y()); if (m_in_column_resize) { auto delta = adjusted_position - m_column_resize_origin; @@ -315,7 +315,7 @@ void AbstractTableView::mousemove_event(MouseEvent& event) void AbstractTableView::mouseup_event(MouseEvent& event) { auto adjusted_position = this->adjusted_position(event.position()); - Gfx::Point horizontally_adjusted_position(adjusted_position.x(), event.position().y()); + Gfx::IntPoint horizontally_adjusted_position(adjusted_position.x(), event.position().y()); if (event.button() == MouseButton::Left) { if (m_in_column_resize) { if (!column_resize_grabbable_rect(m_resizing_column).contains(horizontally_adjusted_position)) @@ -352,7 +352,7 @@ void AbstractTableView::mousedown_event(MouseEvent& event) return AbstractView::mousedown_event(event); auto adjusted_position = this->adjusted_position(event.position()); - Gfx::Point horizontally_adjusted_position(adjusted_position.x(), event.position().y()); + Gfx::IntPoint horizontally_adjusted_position(adjusted_position.x(), event.position().y()); if (event.y() < header_height()) { int column_count = model()->column_count(); @@ -386,7 +386,7 @@ void AbstractTableView::mousedown_event(MouseEvent& event) AbstractView::mousedown_event(event); } -ModelIndex AbstractTableView::index_at_event_position(const Gfx::Point& position, bool& is_toggle) const +ModelIndex AbstractTableView::index_at_event_position(const Gfx::IntPoint& position, bool& is_toggle) const { is_toggle = false; if (!model()) @@ -406,7 +406,7 @@ ModelIndex AbstractTableView::index_at_event_position(const Gfx::Point& position return {}; } -ModelIndex AbstractTableView::index_at_event_position(const Gfx::Point& position) const +ModelIndex AbstractTableView::index_at_event_position(const Gfx::IntPoint& position) const { bool is_toggle; auto index = index_at_event_position(position, is_toggle); @@ -489,7 +489,7 @@ void AbstractTableView::leave_event(Core::Event& event) set_hovered_header_index(-1); } -Gfx::Rect AbstractTableView::content_rect(int row, int column) const +Gfx::IntRect AbstractTableView::content_rect(int row, int column) const { auto row_rect = this->row_rect(row); int x = 0; @@ -499,17 +499,17 @@ Gfx::Rect AbstractTableView::content_rect(int row, int column) const return { row_rect.x() + x, row_rect.y(), column_width(column) + horizontal_padding() * 2, item_height() }; } -Gfx::Rect AbstractTableView::content_rect(const ModelIndex& index) const +Gfx::IntRect AbstractTableView::content_rect(const ModelIndex& index) const { return content_rect(index.row(), index.column()); } -Gfx::Rect AbstractTableView::row_rect(int item_index) const +Gfx::IntRect AbstractTableView::row_rect(int item_index) const { return { 0, header_height() + (item_index * item_height()), max(content_size().width(), width()), item_height() }; } -Gfx::Point AbstractTableView::adjusted_position(const Gfx::Point& position) const +Gfx::IntPoint AbstractTableView::adjusted_position(const Gfx::IntPoint& position) const { return position.translated(horizontal_scrollbar().value() - frame_thickness(), vertical_scrollbar().value() - frame_thickness()); } diff --git a/Libraries/LibGUI/AbstractTableView.h b/Libraries/LibGUI/AbstractTableView.h index 8ef3486f1d..2b4cd0c8d0 100644 --- a/Libraries/LibGUI/AbstractTableView.h +++ b/Libraries/LibGUI/AbstractTableView.h @@ -34,7 +34,7 @@ class TableCellPaintingDelegate { public: virtual ~TableCellPaintingDelegate() {} - virtual void paint(Painter&, const Gfx::Rect&, const Gfx::Palette&, const Model&, const ModelIndex&) = 0; + virtual void paint(Painter&, const Gfx::IntRect&, const Gfx::Palette&, const Model&, const ModelIndex&) = 0; }; class AbstractTableView : public AbstractView { @@ -56,16 +56,16 @@ public: int horizontal_padding() const { return m_horizontal_padding; } - Gfx::Point adjusted_position(const Gfx::Point&) const; + Gfx::IntPoint adjusted_position(const Gfx::IntPoint&) const; - virtual Gfx::Rect content_rect(const ModelIndex&) const override; - Gfx::Rect content_rect(int row, int column) const; - Gfx::Rect row_rect(int item_index) const; + virtual Gfx::IntRect content_rect(const ModelIndex&) const override; + Gfx::IntRect content_rect(int row, int column) const; + Gfx::IntRect row_rect(int item_index) const; void scroll_into_view(const ModelIndex&, Orientation); - virtual ModelIndex index_at_event_position(const Gfx::Point&, bool& is_toggle) const; - virtual ModelIndex index_at_event_position(const Gfx::Point&) const override; + virtual ModelIndex index_at_event_position(const Gfx::IntPoint&, bool& is_toggle) const; + virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override; virtual void select_all() override; @@ -86,7 +86,7 @@ protected: virtual void toggle_index(const ModelIndex&) {} void paint_headers(Painter&); - Gfx::Rect header_rect(int column) const; + Gfx::IntRect header_rect(int column) const; static const Gfx::Font& header_font(); void update_headers(); @@ -106,7 +106,7 @@ protected: Menu& ensure_header_context_menu(); RefPtr<Menu> m_header_context_menu; - Gfx::Rect column_resize_grabbable_rect(int) const; + Gfx::IntRect column_resize_grabbable_rect(int) const; int column_width(int) const; void update_content_size(); virtual void update_column_sizes(); @@ -117,7 +117,7 @@ private: bool m_in_column_resize { false }; bool m_alternating_row_colors { true }; int m_horizontal_padding { 5 }; - Gfx::Point m_column_resize_origin; + Gfx::IntPoint m_column_resize_origin; int m_column_resize_original_width { 0 }; int m_resizing_column { -1 }; int m_pressed_column_header_index { -1 }; diff --git a/Libraries/LibGUI/AbstractView.h b/Libraries/LibGUI/AbstractView.h index 4d431b6aa2..de48234e65 100644 --- a/Libraries/LibGUI/AbstractView.h +++ b/Libraries/LibGUI/AbstractView.h @@ -51,8 +51,8 @@ public: virtual void did_update_model(unsigned flags); virtual void did_update_selection(); - virtual Gfx::Rect content_rect(const ModelIndex&) const { return {}; } - virtual ModelIndex index_at_event_position(const Gfx::Point&) const = 0; + virtual Gfx::IntRect content_rect(const ModelIndex&) const { return {}; } + virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const = 0; void begin_editing(const ModelIndex&); void stop_editing(); @@ -92,9 +92,9 @@ protected: bool m_editable { false }; ModelIndex m_edit_index; RefPtr<Widget> m_edit_widget; - Gfx::Rect m_edit_widget_content_rect; + Gfx::IntRect m_edit_widget_content_rect; - Gfx::Point m_left_mousedown_position; + Gfx::IntPoint m_left_mousedown_position; bool m_might_drag { false }; ModelIndex m_hovered_index; diff --git a/Libraries/LibGUI/Application.cpp b/Libraries/LibGUI/Application.cpp index 7f7148b754..fd3a15bd19 100644 --- a/Libraries/LibGUI/Application.cpp +++ b/Libraries/LibGUI/Application.cpp @@ -141,7 +141,7 @@ private: RefPtr<Label> m_label; }; -void Application::show_tooltip(const StringView& tooltip, const Gfx::Point& screen_location) +void Application::show_tooltip(const StringView& tooltip, const Gfx::IntPoint& screen_location) { if (!m_tooltip_window) { m_tooltip_window = TooltipWindow::construct(); @@ -149,10 +149,10 @@ void Application::show_tooltip(const StringView& tooltip, const Gfx::Point& scre } m_tooltip_window->set_tooltip(tooltip); - Gfx::Rect desktop_rect = Desktop::the().rect(); + Gfx::IntRect desktop_rect = Desktop::the().rect(); const int margin = 30; - Gfx::Point adjusted_pos = screen_location; + Gfx::IntPoint adjusted_pos = screen_location; if (adjusted_pos.x() + m_tooltip_window->width() >= desktop_rect.width() - margin) { adjusted_pos = adjusted_pos.translated(-m_tooltip_window->width(), 0); } diff --git a/Libraries/LibGUI/Application.h b/Libraries/LibGUI/Application.h index cfb63985d9..b5e84a2129 100644 --- a/Libraries/LibGUI/Application.h +++ b/Libraries/LibGUI/Application.h @@ -51,7 +51,7 @@ public: void register_global_shortcut_action(Badge<Action>, Action&); void unregister_global_shortcut_action(Badge<Action>, Action&); - void show_tooltip(const StringView&, const Gfx::Point& screen_location); + void show_tooltip(const StringView&, const Gfx::IntPoint& screen_location); void hide_tooltip(); bool quit_when_last_window_deleted() const { return m_quit_when_last_window_deleted; } diff --git a/Libraries/LibGUI/BoxLayout.cpp b/Libraries/LibGUI/BoxLayout.cpp index 5d48fd2dd5..ce49657a1f 100644 --- a/Libraries/LibGUI/BoxLayout.cpp +++ b/Libraries/LibGUI/BoxLayout.cpp @@ -51,7 +51,7 @@ void BoxLayout::run(Widget& widget) if (m_entries.is_empty()) return; - Gfx::Size available_size = widget.size(); + Gfx::IntSize available_size = widget.size(); int number_of_entries_with_fixed_size = 0; int number_of_visible_entries = 0; @@ -99,8 +99,8 @@ void BoxLayout::run(Widget& widget) if (should_log) dbgprintf("BoxLayout: available_size=%s, fixed=%d, fill=%d\n", available_size.to_string().characters(), number_of_entries_with_fixed_size, number_of_entries_with_automatic_size); - Gfx::Size automatic_size; - Gfx::Size automatic_size_for_last_entry; + Gfx::IntSize automatic_size; + Gfx::IntSize automatic_size_for_last_entry; if (number_of_entries_with_automatic_size) { if (m_orientation == Orientation::Horizontal) { @@ -135,7 +135,7 @@ void BoxLayout::run(Widget& widget) continue; if (!entry.widget->is_visible()) continue; - Gfx::Rect rect(current_x, current_y, 0, 0); + Gfx::IntRect rect(current_x, current_y, 0, 0); if (entry.layout) { // FIXME: Implement recursive layout. ASSERT_NOT_REACHED(); diff --git a/Libraries/LibGUI/Button.cpp b/Libraries/LibGUI/Button.cpp index 7ff306890d..9621490180 100644 --- a/Libraries/LibGUI/Button.cpp +++ b/Libraries/LibGUI/Button.cpp @@ -58,7 +58,7 @@ void Button::paint_event(PaintEvent& event) return; auto content_rect = rect().shrunken(8, 2); - auto icon_location = m_icon ? content_rect.center().translated(-(m_icon->width() / 2), -(m_icon->height() / 2)) : Gfx::Point(); + auto icon_location = m_icon ? content_rect.center().translated(-(m_icon->width() / 2), -(m_icon->height() / 2)) : Gfx::IntPoint(); if (m_icon && !text().is_empty()) icon_location.set_x(content_rect.x()); if (is_being_pressed() || is_checked()) @@ -79,7 +79,7 @@ void Button::paint_event(PaintEvent& event) content_rect.set_width(content_rect.width() - m_icon->width() - 4); } - Gfx::Rect text_rect { 0, 0, font.width(text()), font.glyph_height() }; + Gfx::IntRect text_rect { 0, 0, font.width(text()), font.glyph_height() }; if (text_rect.width() > content_rect.width()) text_rect.set_width(content_rect.width()); text_rect.align_within(content_rect, text_alignment()); diff --git a/Libraries/LibGUI/CheckBox.cpp b/Libraries/LibGUI/CheckBox.cpp index f2cdf40897..b6d8d6c658 100644 --- a/Libraries/LibGUI/CheckBox.cpp +++ b/Libraries/LibGUI/CheckBox.cpp @@ -78,7 +78,7 @@ void CheckBox::paint_event(PaintEvent& event) if (is_enabled() && is_hovered()) painter.fill_rect(rect(), palette().hover_highlight()); - Gfx::Rect box_rect { + Gfx::IntRect box_rect { 0, height() / 2 - s_box_height / 2 - 1, s_box_width, s_box_height }; diff --git a/Libraries/LibGUI/ColorInput.cpp b/Libraries/LibGUI/ColorInput.cpp index f4a289aedb..b68d4b3862 100644 --- a/Libraries/LibGUI/ColorInput.cpp +++ b/Libraries/LibGUI/ColorInput.cpp @@ -46,7 +46,7 @@ ColorInput::~ColorInput() { } -Gfx::Rect ColorInput::color_rect() const +Gfx::IntRect ColorInput::color_rect() const { auto color_box_padding = 3; auto color_box_size = height() - color_box_padding - color_box_padding; diff --git a/Libraries/LibGUI/ColorInput.h b/Libraries/LibGUI/ColorInput.h index cebefbe0dc..1ab774efcf 100644 --- a/Libraries/LibGUI/ColorInput.h +++ b/Libraries/LibGUI/ColorInput.h @@ -57,7 +57,7 @@ protected: private: ColorInput(); - Gfx::Rect color_rect() const; + Gfx::IntRect color_rect() const; void set_color_without_changing_text(Color); Color m_color; diff --git a/Libraries/LibGUI/ColorPicker.cpp b/Libraries/LibGUI/ColorPicker.cpp index b897d9ed93..db5279dfc5 100644 --- a/Libraries/LibGUI/ColorPicker.cpp +++ b/Libraries/LibGUI/ColorPicker.cpp @@ -73,7 +73,7 @@ private: RefPtr<Gfx::Bitmap> m_custom_colors; bool m_being_pressed { false }; - Gfx::Point m_last_position; + Gfx::IntPoint m_last_position; void pick_color_at_position(GUI::MouseEvent& event); diff --git a/Libraries/LibGUI/ColumnsView.cpp b/Libraries/LibGUI/ColumnsView.cpp index ae2d14a1fa..29a2ca9117 100644 --- a/Libraries/LibGUI/ColumnsView.cpp +++ b/Libraries/LibGUI/ColumnsView.cpp @@ -122,11 +122,11 @@ void ColumnsView::paint_event(PaintEvent& event) text_color = palette().selection_text(); } - Gfx::Rect row_rect { column_x, row * item_height(), column.width, item_height() }; + Gfx::IntRect row_rect { column_x, row * item_height(), column.width, item_height() }; painter.fill_rect(row_rect, background_color); auto icon = model()->data(index, Model::Role::Icon); - Gfx::Rect icon_rect = { column_x + icon_spacing(), 0, icon_size(), icon_size() }; + Gfx::IntRect icon_rect = { column_x + icon_spacing(), 0, icon_size(), icon_size() }; icon_rect.center_vertically_within(row_rect); if (icon.is_icon()) { if (auto* bitmap = icon.as_icon().bitmap_for_size(icon_size())) { @@ -137,7 +137,7 @@ void ColumnsView::paint_event(PaintEvent& event) } } - Gfx::Rect text_rect = { + Gfx::IntRect text_rect = { icon_rect.right() + 1 + icon_spacing(), row * item_height(), column.width - icon_spacing() - icon_size() - icon_spacing() - icon_spacing() - s_arrow_bitmap_width - icon_spacing(), item_height() }; @@ -146,7 +146,7 @@ void ColumnsView::paint_event(PaintEvent& event) bool expandable = model()->row_count(index) > 0; if (expandable) { - Gfx::Rect arrow_rect = { + Gfx::IntRect arrow_rect = { text_rect.right() + 1 + icon_spacing(), 0, s_arrow_bitmap_width, s_arrow_bitmap_height }; @@ -214,7 +214,7 @@ void ColumnsView::update_column_sizes() set_content_size({ total_width, total_height }); } -ModelIndex ColumnsView::index_at_event_position(const Gfx::Point& a_position) const +ModelIndex ColumnsView::index_at_event_position(const Gfx::IntPoint& a_position) const { if (!model()) return {}; diff --git a/Libraries/LibGUI/ColumnsView.h b/Libraries/LibGUI/ColumnsView.h index a93ffd2b4b..49327b1898 100644 --- a/Libraries/LibGUI/ColumnsView.h +++ b/Libraries/LibGUI/ColumnsView.h @@ -37,7 +37,7 @@ public: int model_column() const { return m_model_column; } void set_model_column(int column) { m_model_column = column; } - virtual ModelIndex index_at_event_position(const Gfx::Point&) const override; + virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override; private: ColumnsView(); diff --git a/Libraries/LibGUI/ComboBox.cpp b/Libraries/LibGUI/ComboBox.cpp index 56dfae1b68..7516760261 100644 --- a/Libraries/LibGUI/ComboBox.cpp +++ b/Libraries/LibGUI/ComboBox.cpp @@ -144,12 +144,12 @@ void ComboBox::open() auto item_text = model()->data(index).to_string(); longest_item_width = max(longest_item_width, m_list_view->font().width(item_text)); } - Gfx::Size size { + Gfx::IntSize size { max(width(), longest_item_width + m_list_view->width_occupied_by_vertical_scrollbar() + m_list_view->frame_thickness() * 2 + m_list_view->horizontal_padding()), model()->row_count() * m_list_view->item_height() + m_list_view->frame_thickness() * 2 }; - Gfx::Rect list_window_rect { my_screen_rect.bottom_left(), size }; + Gfx::IntRect list_window_rect { my_screen_rect.bottom_left(), size }; list_window_rect.intersect(Desktop::the().rect().shrunken(0, 128)); m_list_window->set_rect(list_window_rect); diff --git a/Libraries/LibGUI/Desktop.cpp b/Libraries/LibGUI/Desktop.cpp index 7fbe91aae6..f68613a5de 100644 --- a/Libraries/LibGUI/Desktop.cpp +++ b/Libraries/LibGUI/Desktop.cpp @@ -45,7 +45,7 @@ Desktop::Desktop() { } -void Desktop::did_receive_screen_rect(Badge<WindowServerConnection>, const Gfx::Rect& rect) +void Desktop::did_receive_screen_rect(Badge<WindowServerConnection>, const Gfx::IntRect& rect) { if (m_rect == rect) return; diff --git a/Libraries/LibGUI/Desktop.h b/Libraries/LibGUI/Desktop.h index e6b041a156..5b90accafa 100644 --- a/Libraries/LibGUI/Desktop.h +++ b/Libraries/LibGUI/Desktop.h @@ -45,13 +45,13 @@ public: String wallpaper() const; bool set_wallpaper(const StringView& path); - Gfx::Rect rect() const { return m_rect; } - void did_receive_screen_rect(Badge<WindowServerConnection>, const Gfx::Rect&); + Gfx::IntRect rect() const { return m_rect; } + void did_receive_screen_rect(Badge<WindowServerConnection>, const Gfx::IntRect&); - Function<void(const Gfx::Rect&)> on_rect_change; + Function<void(const Gfx::IntRect&)> on_rect_change; private: - Gfx::Rect m_rect; + Gfx::IntRect m_rect; }; } diff --git a/Libraries/LibGUI/DragOperation.cpp b/Libraries/LibGUI/DragOperation.cpp index 462a9822f7..f0355eaddb 100644 --- a/Libraries/LibGUI/DragOperation.cpp +++ b/Libraries/LibGUI/DragOperation.cpp @@ -50,7 +50,7 @@ DragOperation::Outcome DragOperation::exec() ASSERT(!m_event_loop); int bitmap_id = -1; - Gfx::Size bitmap_size; + Gfx::IntSize bitmap_size; RefPtr<Gfx::Bitmap> shared_bitmap; if (m_bitmap) { shared_bitmap = m_bitmap->to_bitmap_backed_by_shared_buffer(); diff --git a/Libraries/LibGUI/Event.cpp b/Libraries/LibGUI/Event.cpp index f511c8c06b..3274185eb5 100644 --- a/Libraries/LibGUI/Event.cpp +++ b/Libraries/LibGUI/Event.cpp @@ -31,7 +31,7 @@ namespace GUI { -DropEvent::DropEvent(const Gfx::Point& position, const String& text, NonnullRefPtr<Core::MimeData> mime_data) +DropEvent::DropEvent(const Gfx::IntPoint& position, const String& text, NonnullRefPtr<Core::MimeData> mime_data) : Event(Event::Drop) , m_position(position) , m_text(text) diff --git a/Libraries/LibGUI/Event.h b/Libraries/LibGUI/Event.h index 12e0f3ba4d..a37250ae84 100644 --- a/Libraries/LibGUI/Event.h +++ b/Libraries/LibGUI/Event.h @@ -111,7 +111,7 @@ public: class WMWindowStateChangedEvent : public WMEvent { public: - WMWindowStateChangedEvent(int client_id, int window_id, const StringView& title, const Gfx::Rect& rect, bool is_active, WindowType window_type, bool is_minimized, bool is_frameless, int progress) + WMWindowStateChangedEvent(int client_id, int window_id, const StringView& title, const Gfx::IntRect& rect, bool is_active, WindowType window_type, bool is_minimized, bool is_frameless, int progress) : WMEvent(Event::Type::WM_WindowStateChanged, client_id, window_id) , m_title(title) , m_rect(rect) @@ -124,7 +124,7 @@ public: } String title() const { return m_title; } - Gfx::Rect rect() const { return m_rect; } + Gfx::IntRect rect() const { return m_rect; } bool is_active() const { return m_active; } WindowType window_type() const { return m_window_type; } bool is_minimized() const { return m_minimized; } @@ -133,7 +133,7 @@ public: private: String m_title; - Gfx::Rect m_rect; + Gfx::IntRect m_rect; WindowType m_window_type; bool m_active; bool m_minimized; @@ -143,21 +143,21 @@ private: class WMWindowRectChangedEvent : public WMEvent { public: - WMWindowRectChangedEvent(int client_id, int window_id, const Gfx::Rect& rect) + WMWindowRectChangedEvent(int client_id, int window_id, const Gfx::IntRect& rect) : WMEvent(Event::Type::WM_WindowRectChanged, client_id, window_id) , m_rect(rect) { } - Gfx::Rect rect() const { return m_rect; } + Gfx::IntRect rect() const { return m_rect; } private: - Gfx::Rect m_rect; + Gfx::IntRect m_rect; }; class WMWindowIconBitmapChangedEvent : public WMEvent { public: - WMWindowIconBitmapChangedEvent(int client_id, int window_id, int icon_buffer_id, const Gfx::Size& icon_size) + WMWindowIconBitmapChangedEvent(int client_id, int window_id, int icon_buffer_id, const Gfx::IntSize& icon_size) : WMEvent(Event::Type::WM_WindowIconBitmapChanged, client_id, window_id) , m_icon_buffer_id(icon_buffer_id) , m_icon_size(icon_size) @@ -165,79 +165,79 @@ public: } int icon_buffer_id() const { return m_icon_buffer_id; } - const Gfx::Size& icon_size() const { return m_icon_size; } + const Gfx::IntSize& icon_size() const { return m_icon_size; } private: int m_icon_buffer_id; - Gfx::Size m_icon_size; + Gfx::IntSize m_icon_size; }; class MultiPaintEvent final : public Event { public: - explicit MultiPaintEvent(const Vector<Gfx::Rect, 32>& rects, const Gfx::Size& window_size) + explicit MultiPaintEvent(const Vector<Gfx::IntRect, 32>& rects, const Gfx::IntSize& window_size) : Event(Event::MultiPaint) , m_rects(rects) , m_window_size(window_size) { } - const Vector<Gfx::Rect, 32>& rects() const { return m_rects; } - Gfx::Size window_size() const { return m_window_size; } + const Vector<Gfx::IntRect, 32>& rects() const { return m_rects; } + Gfx::IntSize window_size() const { return m_window_size; } private: - Vector<Gfx::Rect, 32> m_rects; - Gfx::Size m_window_size; + Vector<Gfx::IntRect, 32> m_rects; + Gfx::IntSize m_window_size; }; class PaintEvent final : public Event { public: - explicit PaintEvent(const Gfx::Rect& rect, const Gfx::Size& window_size = {}) + explicit PaintEvent(const Gfx::IntRect& rect, const Gfx::IntSize& window_size = {}) : Event(Event::Paint) , m_rect(rect) , m_window_size(window_size) { } - Gfx::Rect rect() const { return m_rect; } - Gfx::Size window_size() const { return m_window_size; } + Gfx::IntRect rect() const { return m_rect; } + Gfx::IntSize window_size() const { return m_window_size; } private: - Gfx::Rect m_rect; - Gfx::Size m_window_size; + Gfx::IntRect m_rect; + Gfx::IntSize m_window_size; }; class ResizeEvent final : public Event { public: - explicit ResizeEvent(const Gfx::Size& old_size, const Gfx::Size& size) + explicit ResizeEvent(const Gfx::IntSize& old_size, const Gfx::IntSize& size) : Event(Event::Resize) , m_old_size(old_size) , m_size(size) { } - const Gfx::Size& old_size() const { return m_old_size; } - const Gfx::Size& size() const { return m_size; } + const Gfx::IntSize& old_size() const { return m_old_size; } + const Gfx::IntSize& size() const { return m_size; } private: - Gfx::Size m_old_size; - Gfx::Size m_size; + Gfx::IntSize m_old_size; + Gfx::IntSize m_size; }; class ContextMenuEvent final : public Event { public: - explicit ContextMenuEvent(const Gfx::Point& position, const Gfx::Point& screen_position) + explicit ContextMenuEvent(const Gfx::IntPoint& position, const Gfx::IntPoint& screen_position) : Event(Event::ContextMenu) , m_position(position) , m_screen_position(screen_position) { } - const Gfx::Point& position() const { return m_position; } - const Gfx::Point& screen_position() const { return m_screen_position; } + const Gfx::IntPoint& position() const { return m_position; } + const Gfx::IntPoint& screen_position() const { return m_screen_position; } private: - Gfx::Point m_position; - Gfx::Point m_screen_position; + Gfx::IntPoint m_position; + Gfx::IntPoint m_screen_position; }; class ShowEvent final : public Event { @@ -296,7 +296,7 @@ private: class MouseEvent final : public Event { public: - MouseEvent(Type type, const Gfx::Point& position, unsigned buttons, MouseButton button, unsigned modifiers, int wheel_delta) + MouseEvent(Type type, const Gfx::IntPoint& position, unsigned buttons, MouseButton button, unsigned modifiers, int wheel_delta) : Event(type) , m_position(position) , m_buttons(buttons) @@ -306,7 +306,7 @@ public: { } - Gfx::Point position() const { return m_position; } + Gfx::IntPoint position() const { return m_position; } int x() const { return m_position.x(); } int y() const { return m_position.y(); } MouseButton button() const { return m_button; } @@ -315,7 +315,7 @@ public: int wheel_delta() const { return m_wheel_delta; } private: - Gfx::Point m_position; + Gfx::IntPoint m_position; unsigned m_buttons { 0 }; MouseButton m_button { MouseButton::None }; unsigned m_modifiers { 0 }; @@ -324,33 +324,33 @@ private: class DragEvent final : public Event { public: - DragEvent(Type type, const Gfx::Point& position, const String& data_type) + DragEvent(Type type, const Gfx::IntPoint& position, const String& data_type) : Event(type) , m_position(position) , m_data_type(data_type) { } - const Gfx::Point& position() const { return m_position; } + const Gfx::IntPoint& position() const { return m_position; } const String& data_type() const { return m_data_type; } private: - Gfx::Point m_position; + Gfx::IntPoint m_position; String m_data_type; }; class DropEvent final : public Event { public: - DropEvent(const Gfx::Point&, const String& text, NonnullRefPtr<Core::MimeData> mime_data); + DropEvent(const Gfx::IntPoint&, const String& text, NonnullRefPtr<Core::MimeData> mime_data); ~DropEvent(); - const Gfx::Point& position() const { return m_position; } + const Gfx::IntPoint& position() const { return m_position; } const String& text() const { return m_text; } const Core::MimeData& mime_data() const { return m_mime_data; } private: - Gfx::Point m_position; + Gfx::IntPoint m_position; String m_text; NonnullRefPtr<Core::MimeData> m_mime_data; }; diff --git a/Libraries/LibGUI/FileSystemModel.cpp b/Libraries/LibGUI/FileSystemModel.cpp index d5a2944cbc..0b8603efbf 100644 --- a/Libraries/LibGUI/FileSystemModel.cpp +++ b/Libraries/LibGUI/FileSystemModel.cpp @@ -482,7 +482,7 @@ static RefPtr<Gfx::Bitmap> render_thumbnail(const StringView& path) double scale = min(32 / (double)png_bitmap->width(), 32 / (double)png_bitmap->height()); auto thumbnail = Gfx::Bitmap::create(png_bitmap->format(), { 32, 32 }); - Gfx::Rect destination = Gfx::Rect(0, 0, (int)(png_bitmap->width() * scale), (int)(png_bitmap->height() * scale)); + Gfx::IntRect destination = Gfx::IntRect(0, 0, (int)(png_bitmap->width() * scale), (int)(png_bitmap->height() * scale)); destination.center_within(thumbnail->rect()); Painter painter(*thumbnail); diff --git a/Libraries/LibGUI/Frame.h b/Libraries/LibGUI/Frame.h index 10b48e1cae..5bf43f238a 100644 --- a/Libraries/LibGUI/Frame.h +++ b/Libraries/LibGUI/Frame.h @@ -45,8 +45,8 @@ public: Gfx::FrameShape frame_shape() const { return m_shape; } void set_frame_shape(Gfx::FrameShape shape) { m_shape = shape; } - Gfx::Rect frame_inner_rect_for_size(const Gfx::Size& size) const { return { m_thickness, m_thickness, size.width() - m_thickness * 2, size.height() - m_thickness * 2 }; } - Gfx::Rect frame_inner_rect() const { return frame_inner_rect_for_size(size()); } + Gfx::IntRect frame_inner_rect_for_size(const Gfx::IntSize& size) const { return { m_thickness, m_thickness, size.width() - m_thickness * 2, size.height() - m_thickness * 2 }; } + Gfx::IntRect frame_inner_rect() const { return frame_inner_rect_for_size(size()); } protected: Frame(); diff --git a/Libraries/LibGUI/GroupBox.cpp b/Libraries/LibGUI/GroupBox.cpp index f74db7f20b..1ff52384f9 100644 --- a/Libraries/LibGUI/GroupBox.cpp +++ b/Libraries/LibGUI/GroupBox.cpp @@ -46,13 +46,13 @@ void GroupBox::paint_event(PaintEvent& event) Painter painter(*this); painter.add_clip_rect(event.rect()); - Gfx::Rect frame_rect { + Gfx::IntRect frame_rect { 0, font().glyph_height() / 2, width(), height() - font().glyph_height() / 2 }; Gfx::StylePainter::paint_frame(painter, frame_rect, palette(), Gfx::FrameShape::Box, Gfx::FrameShadow::Sunken, 2); - Gfx::Rect text_rect { 4, 0, font().width(m_title) + 6, font().glyph_height() }; + Gfx::IntRect text_rect { 4, 0, font().width(m_title) + 6, font().glyph_height() }; painter.fill_rect(text_rect, palette().button()); painter.draw_text(text_rect, m_title, Gfx::TextAlignment::Center, palette().button_text()); } diff --git a/Libraries/LibGUI/IconView.cpp b/Libraries/LibGUI/IconView.cpp index a49638ff0e..0e20d899c5 100644 --- a/Libraries/LibGUI/IconView.cpp +++ b/Libraries/LibGUI/IconView.cpp @@ -93,7 +93,7 @@ void IconView::update_content_size() set_content_size({ content_width, content_height }); } -Gfx::Rect IconView::item_rect(int item_index) const +Gfx::IntRect IconView::item_rect(int item_index) const { if (!m_visual_row_count || !m_visual_column_count) return {}; @@ -107,14 +107,14 @@ Gfx::Rect IconView::item_rect(int item_index) const }; } -Vector<int> IconView::items_intersecting_rect(const Gfx::Rect& rect) const +Vector<int> IconView::items_intersecting_rect(const Gfx::IntRect& rect) const { ASSERT(model()); Vector<int> item_indexes; for (int item_index = 0; item_index < item_count(); ++item_index) { - Gfx::Rect item_rect; - Gfx::Rect icon_rect; - Gfx::Rect text_rect; + Gfx::IntRect item_rect; + Gfx::IntRect icon_rect; + Gfx::IntRect text_rect; auto index = model()->index(item_index, model_column()); auto item_text = model()->data(index); get_item_rects(item_index, font_for_index(index), item_text, item_rect, icon_rect, text_rect); @@ -124,16 +124,16 @@ Vector<int> IconView::items_intersecting_rect(const Gfx::Rect& rect) const return item_indexes; } -ModelIndex IconView::index_at_event_position(const Gfx::Point& position) const +ModelIndex IconView::index_at_event_position(const Gfx::IntPoint& position) const { ASSERT(model()); // FIXME: Since all items are the same size, just compute the clicked item index // instead of iterating over everything. auto adjusted_position = this->adjusted_position(position); for (int item_index = 0; item_index < item_count(); ++item_index) { - Gfx::Rect item_rect; - Gfx::Rect icon_rect; - Gfx::Rect text_rect; + Gfx::IntRect item_rect; + Gfx::IntRect icon_rect; + Gfx::IntRect text_rect; auto index = model()->index(item_index, model_column()); auto item_text = model()->data(index); get_item_rects(item_index, font_for_index(index), item_text, item_rect, icon_rect, text_rect); @@ -143,7 +143,7 @@ ModelIndex IconView::index_at_event_position(const Gfx::Point& position) const return {}; } -Gfx::Point IconView::adjusted_position(const Gfx::Point& position) const +Gfx::IntPoint IconView::adjusted_position(const Gfx::IntPoint& position) const { return position.translated(0, vertical_scrollbar().value()); } @@ -218,7 +218,7 @@ void IconView::mousemove_event(MouseEvent& event) auto adjusted_position = this->adjusted_position(event.position()); if (m_rubber_band_current != adjusted_position) { m_rubber_band_current = adjusted_position; - auto rubber_band_rect = Gfx::Rect::from_two_points(m_rubber_band_origin, m_rubber_band_current); + auto rubber_band_rect = Gfx::IntRect::from_two_points(m_rubber_band_origin, m_rubber_band_current); selection().clear(); for (auto item_index : items_intersecting_rect(rubber_band_rect)) { selection().add(model()->index(item_index, model_column())); @@ -236,7 +236,7 @@ void IconView::mousemove_event(MouseEvent& event) AbstractView::mousemove_event(event); } -void IconView::get_item_rects(int item_index, const Gfx::Font& font, const Variant& item_text, Gfx::Rect& item_rect, Gfx::Rect& icon_rect, Gfx::Rect& text_rect) const +void IconView::get_item_rects(int item_index, const Gfx::Font& font, const Variant& item_text, Gfx::IntRect& item_rect, Gfx::IntRect& icon_rect, Gfx::IntRect& text_rect) const { item_rect = this->item_rect(item_index); icon_rect = { 0, 0, 32, 32 }; @@ -258,7 +258,7 @@ void IconView::second_paint_event(PaintEvent& event) painter.translate(frame_thickness(), frame_thickness()); painter.translate(-horizontal_scrollbar().value(), -vertical_scrollbar().value()); - auto rubber_band_rect = Gfx::Rect::from_two_points(m_rubber_band_origin, m_rubber_band_current); + auto rubber_band_rect = Gfx::IntRect::from_two_points(m_rubber_band_origin, m_rubber_band_current); painter.fill_rect(rubber_band_rect, palette().rubber_band_fill()); painter.draw_rect(rubber_band_rect, palette().rubber_band_border()); } @@ -289,14 +289,14 @@ void IconView::paint_event(PaintEvent& event) auto icon = model()->data(model_index, Model::Role::Icon); auto item_text = model()->data(model_index, Model::Role::Display); - Gfx::Rect item_rect; - Gfx::Rect icon_rect; - Gfx::Rect text_rect; + Gfx::IntRect item_rect; + Gfx::IntRect icon_rect; + Gfx::IntRect text_rect; get_item_rects(item_index, font_for_index(model_index), item_text, item_rect, icon_rect, text_rect); if (icon.is_icon()) { if (auto bitmap = icon.as_icon().bitmap_for_size(icon_rect.width())) { - Gfx::Rect destination = bitmap->rect(); + Gfx::IntRect destination = bitmap->rect(); destination.center_within(icon_rect); if (m_hovered_index.is_valid() && m_hovered_index == model_index) { diff --git a/Libraries/LibGUI/IconView.h b/Libraries/LibGUI/IconView.h index 210602caac..ae6e28d178 100644 --- a/Libraries/LibGUI/IconView.h +++ b/Libraries/LibGUI/IconView.h @@ -40,13 +40,13 @@ public: int horizontal_padding() const { return m_horizontal_padding; } void scroll_into_view(const ModelIndex&, Orientation); - Gfx::Size effective_item_size() const { return m_effective_item_size; } + Gfx::IntSize effective_item_size() const { return m_effective_item_size; } int model_column() const { return m_model_column; } void set_model_column(int column) { m_model_column = column; } - virtual ModelIndex index_at_event_position(const Gfx::Point&) const override; - Gfx::Point adjusted_position(const Gfx::Point&) const; + virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override; + Gfx::IntPoint adjusted_position(const Gfx::IntPoint&) const; virtual void select_all() override; private: @@ -63,21 +63,21 @@ private: virtual void drag_move_event(DragEvent&) override; int item_count() const; - Gfx::Rect item_rect(int item_index) const; - Vector<int> items_intersecting_rect(const Gfx::Rect&) const; + Gfx::IntRect item_rect(int item_index) const; + Vector<int> items_intersecting_rect(const Gfx::IntRect&) const; void update_content_size(); - void get_item_rects(int item_index, const Gfx::Font&, const Variant& item_text, Gfx::Rect& item_rect, Gfx::Rect& icon_rect, Gfx::Rect& text_rect) const; + void get_item_rects(int item_index, const Gfx::Font&, const Variant& item_text, Gfx::IntRect& item_rect, Gfx::IntRect& icon_rect, Gfx::IntRect& text_rect) const; int m_horizontal_padding { 5 }; int m_model_column { 0 }; int m_visual_column_count { 0 }; int m_visual_row_count { 0 }; - Gfx::Size m_effective_item_size { 80, 80 }; + Gfx::IntSize m_effective_item_size { 80, 80 }; bool m_rubber_banding { false }; - Gfx::Point m_rubber_band_origin; - Gfx::Point m_rubber_band_current; + Gfx::IntPoint m_rubber_band_origin; + Gfx::IntPoint m_rubber_band_current; Vector<ModelIndex> m_rubber_band_remembered_selection; ModelIndex m_drop_candidate_index; diff --git a/Libraries/LibGUI/ListView.cpp b/Libraries/LibGUI/ListView.cpp index 10b2732c30..2bdfefef64 100644 --- a/Libraries/LibGUI/ListView.cpp +++ b/Libraries/LibGUI/ListView.cpp @@ -83,17 +83,17 @@ void ListView::did_update_model(unsigned flags) update(); } -Gfx::Rect ListView::content_rect(int row) const +Gfx::IntRect ListView::content_rect(int row) const { return { 0, row * item_height(), content_width(), item_height() }; } -Gfx::Rect ListView::content_rect(const ModelIndex& index) const +Gfx::IntRect ListView::content_rect(const ModelIndex& index) const { return content_rect(index.row()); } -ModelIndex ListView::index_at_event_position(const Gfx::Point& point) const +ModelIndex ListView::index_at_event_position(const Gfx::IntPoint& point) const { ASSERT(model()); @@ -106,7 +106,7 @@ ModelIndex ListView::index_at_event_position(const Gfx::Point& point) const return {}; } -Gfx::Point ListView::adjusted_position(const Gfx::Point& position) const +Gfx::IntPoint ListView::adjusted_position(const Gfx::IntPoint& position) const { return position.translated(horizontal_scrollbar().value() - frame_thickness(), vertical_scrollbar().value() - frame_thickness()); } @@ -143,7 +143,7 @@ void ListView::paint_event(PaintEvent& event) } } - Gfx::Rect row_rect(0, y, content_width(), item_height()); + Gfx::IntRect row_rect(0, y, content_width(), item_height()); painter.fill_rect(row_rect, background_color); auto index = model()->index(row_index, m_model_column); auto data = model()->data(index); @@ -169,7 +169,7 @@ void ListView::paint_event(PaintEvent& event) ++painted_item_index; }; - Gfx::Rect unpainted_rect(0, painted_item_index * item_height(), exposed_width, height()); + Gfx::IntRect unpainted_rect(0, painted_item_index * item_height(), exposed_width, height()); if (fill_with_background_color()) painter.fill_rect(unpainted_rect, palette().color(background_role())); } diff --git a/Libraries/LibGUI/ListView.h b/Libraries/LibGUI/ListView.h index f9a7c42319..5194d2bd51 100644 --- a/Libraries/LibGUI/ListView.h +++ b/Libraries/LibGUI/ListView.h @@ -44,10 +44,10 @@ public: void scroll_into_view(const ModelIndex&, Orientation); - Gfx::Point adjusted_position(const Gfx::Point&) const; + Gfx::IntPoint adjusted_position(const Gfx::IntPoint&) const; - virtual ModelIndex index_at_event_position(const Gfx::Point&) const override; - virtual Gfx::Rect content_rect(const ModelIndex&) const override; + virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override; + virtual Gfx::IntRect content_rect(const ModelIndex&) const override; int model_column() const { return m_model_column; } void set_model_column(int column) { m_model_column = column; } @@ -65,7 +65,7 @@ private: virtual void keydown_event(KeyEvent&) override; virtual void resize_event(ResizeEvent&) override; - Gfx::Rect content_rect(int row) const; + Gfx::IntRect content_rect(int row) const; int item_count() const; void update_content_size(); diff --git a/Libraries/LibGUI/Menu.cpp b/Libraries/LibGUI/Menu.cpp index 2e39b88690..ac3516b08a 100644 --- a/Libraries/LibGUI/Menu.cpp +++ b/Libraries/LibGUI/Menu.cpp @@ -89,7 +89,7 @@ void Menu::realize_if_needed() realize_menu(); } -void Menu::popup(const Gfx::Point& screen_position) +void Menu::popup(const Gfx::IntPoint& screen_position) { realize_if_needed(); WindowServerConnection::the().post_message(Messages::WindowServer::PopupMenu(m_menu_id, screen_position)); @@ -129,7 +129,7 @@ int Menu::realize_menu() int icon_buffer_id = -1; if (action.icon()) { ASSERT(action.icon()->format() == Gfx::BitmapFormat::RGBA32); - ASSERT(action.icon()->size() == Gfx::Size(16, 16)); + ASSERT(action.icon()->size() == Gfx::IntSize(16, 16)); if (action.icon()->shbuf_id() == -1) { auto shared_buffer = SharedBuffer::create_with_size(action.icon()->size_in_bytes()); ASSERT(shared_buffer); diff --git a/Libraries/LibGUI/Menu.h b/Libraries/LibGUI/Menu.h index 8770b21b53..2b56e04d35 100644 --- a/Libraries/LibGUI/Menu.h +++ b/Libraries/LibGUI/Menu.h @@ -56,7 +56,7 @@ public: void add_separator(); Menu& add_submenu(const String& name); - void popup(const Gfx::Point& screen_position); + void popup(const Gfx::IntPoint& screen_position); void dismiss(); private: diff --git a/Libraries/LibGUI/RadioButton.cpp b/Libraries/LibGUI/RadioButton.cpp index 422dadc9d4..d8c982145d 100644 --- a/Libraries/LibGUI/RadioButton.cpp +++ b/Libraries/LibGUI/RadioButton.cpp @@ -42,7 +42,7 @@ RadioButton::~RadioButton() { } -Gfx::Size RadioButton::circle_size() +Gfx::IntSize RadioButton::circle_size() { return { 12, 12 }; } @@ -58,12 +58,12 @@ void RadioButton::paint_event(PaintEvent& event) if (is_enabled() && is_hovered()) painter.fill_rect(rect(), palette().hover_highlight()); - Gfx::Rect circle_rect { { 2, 0 }, circle_size() }; + Gfx::IntRect circle_rect { { 2, 0 }, circle_size() }; circle_rect.center_vertically_within(rect()); Gfx::StylePainter::paint_radio_button(painter, circle_rect, palette(), is_checked(), is_being_pressed()); - Gfx::Rect text_rect { circle_rect.right() + 4, 0, font().width(text()), font().glyph_height() }; + Gfx::IntRect text_rect { circle_rect.right() + 4, 0, font().width(text()), font().glyph_height() }; text_rect.center_vertically_within(rect()); paint_text(painter, text_rect, font(), Gfx::TextAlignment::TopLeft); } diff --git a/Libraries/LibGUI/RadioButton.h b/Libraries/LibGUI/RadioButton.h index ec5c7b8400..18a492b5a0 100644 --- a/Libraries/LibGUI/RadioButton.h +++ b/Libraries/LibGUI/RadioButton.h @@ -50,7 +50,7 @@ private: template<typename Callback> void for_each_in_group(Callback); - static Gfx::Size circle_size(); + static Gfx::IntSize circle_size(); }; } diff --git a/Libraries/LibGUI/ScrollBar.cpp b/Libraries/LibGUI/ScrollBar.cpp index 3844ad2330..c5a56e373d 100644 --- a/Libraries/LibGUI/ScrollBar.cpp +++ b/Libraries/LibGUI/ScrollBar.cpp @@ -143,12 +143,12 @@ void ScrollBar::set_value(int value) update(); } -Gfx::Rect ScrollBar::decrement_button_rect() const +Gfx::IntRect ScrollBar::decrement_button_rect() const { return { 0, 0, button_width(), button_height() }; } -Gfx::Rect ScrollBar::increment_button_rect() const +Gfx::IntRect ScrollBar::increment_button_rect() const { if (orientation() == Orientation::Vertical) return { 0, height() - button_height(), button_width(), button_height() }; @@ -156,7 +156,7 @@ Gfx::Rect ScrollBar::increment_button_rect() const return { width() - button_width(), 0, button_width(), button_height() }; } -Gfx::Rect ScrollBar::decrement_gutter_rect() const +Gfx::IntRect ScrollBar::decrement_gutter_rect() const { if (orientation() == Orientation::Vertical) return { 0, button_height(), button_width(), scrubber_rect().top() - button_height() }; @@ -164,7 +164,7 @@ Gfx::Rect ScrollBar::decrement_gutter_rect() const return { button_width(), 0, scrubber_rect().x() - button_width(), button_height() }; } -Gfx::Rect ScrollBar::increment_gutter_rect() const +Gfx::IntRect ScrollBar::increment_gutter_rect() const { auto scrubber_rect = this->scrubber_rect(); if (orientation() == Orientation::Vertical) @@ -193,7 +193,7 @@ int ScrollBar::scrubber_size() const return ::max(pixel_range - value_range, button_size()); } -Gfx::Rect ScrollBar::scrubber_rect() const +Gfx::IntRect ScrollBar::scrubber_rect() const { if (!has_scrubber() || length(orientation()) <= (button_size() * 2) + scrubber_size()) return {}; diff --git a/Libraries/LibGUI/ScrollBar.h b/Libraries/LibGUI/ScrollBar.h index dd943e6a0e..d94df20b70 100644 --- a/Libraries/LibGUI/ScrollBar.h +++ b/Libraries/LibGUI/ScrollBar.h @@ -79,11 +79,11 @@ private: int button_size() const { return length(orientation()) <= (default_button_size() * 2) ? length(orientation()) / 2 : default_button_size(); } int button_width() const { return orientation() == Orientation::Vertical ? width() : button_size(); } int button_height() const { return orientation() == Orientation::Horizontal ? height() : button_size(); } - Gfx::Rect decrement_button_rect() const; - Gfx::Rect increment_button_rect() const; - Gfx::Rect decrement_gutter_rect() const; - Gfx::Rect increment_gutter_rect() const; - Gfx::Rect scrubber_rect() const; + Gfx::IntRect decrement_button_rect() const; + Gfx::IntRect increment_button_rect() const; + Gfx::IntRect decrement_gutter_rect() const; + Gfx::IntRect increment_gutter_rect() const; + Gfx::IntRect scrubber_rect() const; int scrubber_size() const; int scrubbable_range_in_pixels() const; void on_automatic_scrolling_timer_fired(); @@ -97,7 +97,7 @@ private: bool m_scrubbing { false }; int m_scrub_start_value { 0 }; - Gfx::Point m_scrub_origin; + Gfx::IntPoint m_scrub_origin; Gfx::Orientation m_orientation { Gfx::Orientation::Vertical }; Component m_hovered_component { Component::Invalid }; diff --git a/Libraries/LibGUI/ScrollableWidget.cpp b/Libraries/LibGUI/ScrollableWidget.cpp index 3968a4b99e..b9ee984c82 100644 --- a/Libraries/LibGUI/ScrollableWidget.cpp +++ b/Libraries/LibGUI/ScrollableWidget.cpp @@ -84,7 +84,7 @@ void ScrollableWidget::custom_layout() m_corner_widget->set_visible(m_vertical_scrollbar->is_visible() && m_horizontal_scrollbar->is_visible()); if (m_corner_widget->is_visible()) { - Gfx::Rect corner_rect { m_horizontal_scrollbar->relative_rect().right() + 1, m_vertical_scrollbar->relative_rect().bottom() + 1, width_occupied_by_vertical_scrollbar(), height_occupied_by_horizontal_scrollbar() }; + Gfx::IntRect corner_rect { m_horizontal_scrollbar->relative_rect().right() + 1, m_vertical_scrollbar->relative_rect().bottom() + 1, width_occupied_by_vertical_scrollbar(), height_occupied_by_horizontal_scrollbar() }; m_corner_widget->set_relative_rect(corner_rect); } } @@ -95,7 +95,7 @@ void ScrollableWidget::resize_event(ResizeEvent& event) update_scrollbar_ranges(); } -Gfx::Size ScrollableWidget::available_size() const +Gfx::IntSize ScrollableWidget::available_size() const { int available_width = frame_inner_rect().width() - m_size_occupied_by_fixed_elements.width() - width_occupied_by_vertical_scrollbar(); int available_height = frame_inner_rect().height() - m_size_occupied_by_fixed_elements.height() - height_occupied_by_horizontal_scrollbar(); @@ -121,7 +121,7 @@ void ScrollableWidget::update_scrollbar_ranges() m_vertical_scrollbar->set_big_step(visible_content_rect().height() - m_vertical_scrollbar->step()); } -void ScrollableWidget::set_content_size(const Gfx::Size& size) +void ScrollableWidget::set_content_size(const Gfx::IntSize& size) { if (m_content_size == size) return; @@ -129,7 +129,7 @@ void ScrollableWidget::set_content_size(const Gfx::Size& size) update_scrollbar_ranges(); } -void ScrollableWidget::set_size_occupied_by_fixed_elements(const Gfx::Size& size) +void ScrollableWidget::set_size_occupied_by_fixed_elements(const Gfx::IntSize& size) { if (m_size_occupied_by_fixed_elements == size) return; @@ -147,7 +147,7 @@ int ScrollableWidget::width_occupied_by_vertical_scrollbar() const return m_vertical_scrollbar->is_visible() ? m_vertical_scrollbar->width() : 0; } -Gfx::Rect ScrollableWidget::visible_content_rect() const +Gfx::IntRect ScrollableWidget::visible_content_rect() const { return { m_horizontal_scrollbar->value(), @@ -157,14 +157,14 @@ Gfx::Rect ScrollableWidget::visible_content_rect() const }; } -void ScrollableWidget::scroll_into_view(const Gfx::Rect& rect, Orientation orientation) +void ScrollableWidget::scroll_into_view(const Gfx::IntRect& rect, Orientation orientation) { if (orientation == Orientation::Vertical) return scroll_into_view(rect, false, true); return scroll_into_view(rect, true, false); } -void ScrollableWidget::scroll_into_view(const Gfx::Rect& rect, bool scroll_horizontally, bool scroll_vertically) +void ScrollableWidget::scroll_into_view(const Gfx::IntRect& rect, bool scroll_horizontally, bool scroll_vertically) { auto visible_content_rect = this->visible_content_rect(); if (visible_content_rect.contains(rect)) @@ -206,7 +206,7 @@ void ScrollableWidget::scroll_to_bottom() scroll_into_view({ 0, content_height(), 1, 1 }, Orientation::Vertical); } -Gfx::Rect ScrollableWidget::widget_inner_rect() const +Gfx::IntRect ScrollableWidget::widget_inner_rect() const { auto rect = frame_inner_rect(); rect.set_width(rect.width() - width_occupied_by_vertical_scrollbar()); @@ -214,7 +214,7 @@ Gfx::Rect ScrollableWidget::widget_inner_rect() const return rect; } -Gfx::Point ScrollableWidget::to_content_position(const Gfx::Point& widget_position) const +Gfx::IntPoint ScrollableWidget::to_content_position(const Gfx::IntPoint& widget_position) const { auto content_position = widget_position; content_position.move_by(horizontal_scrollbar().value(), vertical_scrollbar().value()); @@ -222,7 +222,7 @@ Gfx::Point ScrollableWidget::to_content_position(const Gfx::Point& widget_positi return content_position; } -Gfx::Point ScrollableWidget::to_widget_position(const Gfx::Point& content_position) const +Gfx::IntPoint ScrollableWidget::to_widget_position(const Gfx::IntPoint& content_position) const { auto widget_position = content_position; widget_position.move_by(-horizontal_scrollbar().value(), -vertical_scrollbar().value()); diff --git a/Libraries/LibGUI/ScrollableWidget.h b/Libraries/LibGUI/ScrollableWidget.h index 28aa6290dc..4783f98d75 100644 --- a/Libraries/LibGUI/ScrollableWidget.h +++ b/Libraries/LibGUI/ScrollableWidget.h @@ -35,28 +35,28 @@ class ScrollableWidget : public Frame { public: virtual ~ScrollableWidget() override; - Gfx::Size content_size() const { return m_content_size; } + Gfx::IntSize content_size() const { return m_content_size; } int content_width() const { return m_content_size.width(); } int content_height() const { return m_content_size.height(); } - Gfx::Rect visible_content_rect() const; + Gfx::IntRect visible_content_rect() const; - Gfx::Rect widget_inner_rect() const; + Gfx::IntRect widget_inner_rect() const; - Gfx::Rect viewport_rect_in_content_coordinates() const + Gfx::IntRect viewport_rect_in_content_coordinates() const { auto viewport_rect = visible_content_rect(); viewport_rect.set_size(widget_inner_rect().size()); return viewport_rect; } - void scroll_into_view(const Gfx::Rect&, Orientation); - void scroll_into_view(const Gfx::Rect&, bool scroll_horizontally, bool scroll_vertically); + void scroll_into_view(const Gfx::IntRect&, Orientation); + void scroll_into_view(const Gfx::IntRect&, bool scroll_horizontally, bool scroll_vertically); void set_scrollbars_enabled(bool); bool is_scrollbars_enabled() const { return m_scrollbars_enabled; } - Gfx::Size available_size() const; + Gfx::IntSize available_size() const; ScrollBar& vertical_scrollbar() { return *m_vertical_scrollbar; } const ScrollBar& vertical_scrollbar() const { return *m_vertical_scrollbar; } @@ -74,8 +74,8 @@ public: void set_should_hide_unnecessary_scrollbars(bool b) { m_should_hide_unnecessary_scrollbars = b; } bool should_hide_unnecessary_scrollbars() const { return m_should_hide_unnecessary_scrollbars; } - Gfx::Point to_content_position(const Gfx::Point& widget_position) const; - Gfx::Point to_widget_position(const Gfx::Point& content_position) const; + Gfx::IntPoint to_content_position(const Gfx::IntPoint& widget_position) const; + Gfx::IntPoint to_widget_position(const Gfx::IntPoint& content_position) const; protected: ScrollableWidget(); @@ -83,8 +83,8 @@ protected: virtual void resize_event(ResizeEvent&) override; virtual void mousewheel_event(MouseEvent&) override; virtual void did_scroll() {} - void set_content_size(const Gfx::Size&); - void set_size_occupied_by_fixed_elements(const Gfx::Size&); + void set_content_size(const Gfx::IntSize&); + void set_size_occupied_by_fixed_elements(const Gfx::IntSize&); private: void update_scrollbar_ranges(); @@ -92,8 +92,8 @@ private: RefPtr<ScrollBar> m_vertical_scrollbar; RefPtr<ScrollBar> m_horizontal_scrollbar; RefPtr<Widget> m_corner_widget; - Gfx::Size m_content_size; - Gfx::Size m_size_occupied_by_fixed_elements; + Gfx::IntSize m_content_size; + Gfx::IntSize m_size_occupied_by_fixed_elements; bool m_scrollbars_enabled { true }; bool m_should_hide_unnecessary_scrollbars { false }; }; diff --git a/Libraries/LibGUI/Slider.cpp b/Libraries/LibGUI/Slider.cpp index f072640fa9..e55cb61fa4 100644 --- a/Libraries/LibGUI/Slider.cpp +++ b/Libraries/LibGUI/Slider.cpp @@ -70,7 +70,7 @@ void Slider::paint_event(PaintEvent& event) Painter painter(*this); painter.add_clip_rect(event.rect()); - Gfx::Rect track_rect; + Gfx::IntRect track_rect; if (orientation() == Orientation::Horizontal) { track_rect = { inner_rect().x(), 0, inner_rect().width(), track_size() }; @@ -84,10 +84,10 @@ void Slider::paint_event(PaintEvent& event) Gfx::StylePainter::paint_button(painter, knob_rect(), palette(), Gfx::ButtonStyle::Normal, false, m_knob_hovered); } -Gfx::Rect Slider::knob_rect() const +Gfx::IntRect Slider::knob_rect() const { auto inner_rect = this->inner_rect(); - Gfx::Rect rect; + Gfx::IntRect rect; rect.set_secondary_offset_for_orientation(orientation(), 0); rect.set_secondary_size_for_orientation(orientation(), knob_secondary_size()); diff --git a/Libraries/LibGUI/Slider.h b/Libraries/LibGUI/Slider.h index 597f3d1e65..cf6ad660fd 100644 --- a/Libraries/LibGUI/Slider.h +++ b/Libraries/LibGUI/Slider.h @@ -62,9 +62,9 @@ public: int knob_secondary_size() const { return 20; } bool knob_dragging() const { return m_dragging; } - Gfx::Rect knob_rect() const; + Gfx::IntRect knob_rect() const; - Gfx::Rect inner_rect() const + Gfx::IntRect inner_rect() const { if (orientation() == Orientation::Horizontal) return rect().shrunken(20, 0); @@ -94,7 +94,7 @@ private: bool m_knob_hovered { false }; bool m_dragging { false }; int m_drag_origin_value { 0 }; - Gfx::Point m_drag_origin; + Gfx::IntPoint m_drag_origin; KnobSizeMode m_knob_size_mode { KnobSizeMode::Fixed }; Orientation m_orientation { Orientation::Horizontal }; }; diff --git a/Libraries/LibGUI/Splitter.cpp b/Libraries/LibGUI/Splitter.cpp index 290f464fe3..c8b9e91ce4 100644 --- a/Libraries/LibGUI/Splitter.cpp +++ b/Libraries/LibGUI/Splitter.cpp @@ -73,7 +73,7 @@ void Splitter::leave_event(Core::Event&) } } -bool Splitter::get_resize_candidates_at(const Gfx::Point& position, Widget*& first, Widget*& second) +bool Splitter::get_resize_candidates_at(const Gfx::IntPoint& position, Widget*& first, Widget*& second) { int x_or_y = position.primary_offset_for_orientation(m_orientation); @@ -117,7 +117,7 @@ void Splitter::recompute_grabbable_rect(const Widget& first, const Widget& secon { auto first_edge = first.content_rect().primary_offset_for_orientation(m_orientation) + first.content_rect().primary_size_for_orientation(m_orientation); auto second_edge = second.content_rect().primary_offset_for_orientation(m_orientation); - Gfx::Rect rect; + Gfx::IntRect rect; rect.set_primary_offset_for_orientation(m_orientation, first_edge); rect.set_primary_size_for_orientation(m_orientation, second_edge - first_edge); rect.set_secondary_offset_for_orientation(m_orientation, first.content_rect().secondary_offset_for_orientation(m_orientation)); diff --git a/Libraries/LibGUI/Splitter.h b/Libraries/LibGUI/Splitter.h index 25de077667..4d048f5b3c 100644 --- a/Libraries/LibGUI/Splitter.h +++ b/Libraries/LibGUI/Splitter.h @@ -50,16 +50,16 @@ protected: private: void recompute_grabbable_rect(const Widget&, const Widget&); - bool get_resize_candidates_at(const Gfx::Point&, Widget*&, Widget*&); + bool get_resize_candidates_at(const Gfx::IntPoint&, Widget*&, Widget*&); Gfx::Orientation m_orientation; bool m_resizing { false }; - Gfx::Point m_resize_origin; + Gfx::IntPoint m_resize_origin; WeakPtr<Widget> m_first_resizee; WeakPtr<Widget> m_second_resizee; - Gfx::Size m_first_resizee_start_size; - Gfx::Size m_second_resizee_start_size; - Gfx::Rect m_grabbable_rect; + Gfx::IntSize m_first_resizee_start_size; + Gfx::IntSize m_second_resizee_start_size; + Gfx::IntRect m_grabbable_rect; }; class VerticalSplitter final : public Splitter { diff --git a/Libraries/LibGUI/TabWidget.cpp b/Libraries/LibGUI/TabWidget.cpp index baf3799c6a..91d1468ba1 100644 --- a/Libraries/LibGUI/TabWidget.cpp +++ b/Libraries/LibGUI/TabWidget.cpp @@ -84,9 +84,9 @@ void TabWidget::resize_event(ResizeEvent& event) m_active_widget->set_relative_rect(child_rect_for_size(event.size())); } -Gfx::Rect TabWidget::child_rect_for_size(const Gfx::Size& size) const +Gfx::IntRect TabWidget::child_rect_for_size(const Gfx::IntSize& size) const { - Gfx::Rect rect; + Gfx::IntRect rect; switch (m_tab_position) { case TabPosition::Top: rect = { { container_padding(), bar_height() + container_padding() }, { size.width() - container_padding() * 2, size.height() - bar_height() - container_padding() * 2 } }; @@ -123,7 +123,7 @@ void TabWidget::child_event(Core::ChildEvent& event) Widget::child_event(event); } -Gfx::Rect TabWidget::bar_rect() const +Gfx::IntRect TabWidget::bar_rect() const { switch (m_tab_position) { case TabPosition::Top: @@ -134,7 +134,7 @@ Gfx::Rect TabWidget::bar_rect() const ASSERT_NOT_REACHED(); } -Gfx::Rect TabWidget::container_rect() const +Gfx::IntRect TabWidget::container_rect() const { switch (m_tab_position) { case TabPosition::Top: @@ -166,7 +166,7 @@ void TabWidget::paint_event(PaintEvent& event) auto paint_tab_icon_if_needed = [&](auto& icon, auto& button_rect, auto& text_rect) { if (!icon) return; - Gfx::Rect icon_rect { button_rect.x(), button_rect.y(), 16, 16 }; + Gfx::IntRect icon_rect { button_rect.x(), button_rect.y(), 16, 16 }; icon_rect.move_by(4, 3); painter.draw_scaled_bitmap(icon_rect, *icon, icon->rect()); text_rect.set_x(icon_rect.right() + 1 + 4); @@ -217,14 +217,14 @@ void TabWidget::set_bar_visible(bool bar_visible) update_bar(); } -Gfx::Rect TabWidget::button_rect(int index) const +Gfx::IntRect TabWidget::button_rect(int index) const { int x_offset = 2; for (int i = 0; i < index; ++i) { auto tab_width = m_uniform_tabs ? uniform_tab_width() : m_tabs[i].width(font()); x_offset += tab_width; } - Gfx::Rect rect { x_offset, 0, m_uniform_tabs ? uniform_tab_width() : m_tabs[index].width(font()), bar_height() }; + Gfx::IntRect rect { x_offset, 0, m_uniform_tabs ? uniform_tab_width() : m_tabs[index].width(font()), bar_height() }; if (m_tabs[index].widget != m_active_widget) { rect.move_by(0, 2); rect.set_height(rect.height() - 2); diff --git a/Libraries/LibGUI/TabWidget.h b/Libraries/LibGUI/TabWidget.h index 3c49acfa5d..5dcef4e222 100644 --- a/Libraries/LibGUI/TabWidget.h +++ b/Libraries/LibGUI/TabWidget.h @@ -99,10 +99,10 @@ protected: virtual void context_menu_event(ContextMenuEvent&) override; private: - Gfx::Rect child_rect_for_size(const Gfx::Size&) const; - Gfx::Rect button_rect(int index) const; - Gfx::Rect bar_rect() const; - Gfx::Rect container_rect() const; + Gfx::IntRect child_rect_for_size(const Gfx::IntSize&) const; + Gfx::IntRect button_rect(int index) const; + Gfx::IntRect bar_rect() const; + Gfx::IntRect container_rect() const; void update_bar(); RefPtr<Widget> m_active_widget; diff --git a/Libraries/LibGUI/TableView.cpp b/Libraries/LibGUI/TableView.cpp index fc426eee12..772c3ef158 100644 --- a/Libraries/LibGUI/TableView.cpp +++ b/Libraries/LibGUI/TableView.cpp @@ -105,7 +105,7 @@ void TableView::paint_event(PaintEvent& event) continue; int column_width = this->column_width(column_index); bool is_key_column = model()->key_column() == column_index; - Gfx::Rect cell_rect(horizontal_padding() + x_offset, y, column_width, item_height()); + Gfx::IntRect cell_rect(horizontal_padding() + x_offset, y, column_width, item_height()); auto cell_rect_for_fill = cell_rect.inflated(horizontal_padding() * 2, 0); if (is_key_column) painter.fill_rect(cell_rect_for_fill, key_column_background_color); @@ -144,7 +144,7 @@ void TableView::paint_event(PaintEvent& event) ++painted_item_index; }; - Gfx::Rect unpainted_rect(0, header_height() + painted_item_index * item_height(), exposed_width, height()); + Gfx::IntRect unpainted_rect(0, header_height() + painted_item_index * item_height(), exposed_width, height()); if (fill_with_background_color()) painter.fill_rect(unpainted_rect, widget_background_color); diff --git a/Libraries/LibGUI/TextEditor.cpp b/Libraries/LibGUI/TextEditor.cpp index 855ba58027..7370484c53 100644 --- a/Libraries/LibGUI/TextEditor.cpp +++ b/Libraries/LibGUI/TextEditor.cpp @@ -135,7 +135,7 @@ void TextEditor::update_content_size() set_size_occupied_by_fixed_elements({ ruler_width(), 0 }); } -TextPosition TextEditor::text_position_at(const Gfx::Point& a_position) const +TextPosition TextEditor::text_position_at(const Gfx::IntPoint& a_position) const { auto position = a_position; position.move_by(horizontal_scrollbar().value(), vertical_scrollbar().value()); @@ -163,7 +163,7 @@ TextPosition TextEditor::text_position_at(const Gfx::Point& a_position) const size_t column_index = 0; switch (m_text_alignment) { case Gfx::TextAlignment::CenterLeft: - for_each_visual_line(line_index, [&](const Gfx::Rect& rect, auto& view, size_t start_of_line) { + for_each_visual_line(line_index, [&](const Gfx::IntRect& rect, auto& view, size_t start_of_line) { if (is_multi_line() && !rect.contains_vertically(position.y())) return IterationDecision::Continue; column_index = start_of_line; @@ -324,7 +324,7 @@ int TextEditor::ruler_width() const return 5 * font().glyph_width('x') + 4; } -Gfx::Rect TextEditor::ruler_content_rect(size_t line_index) const +Gfx::IntRect TextEditor::ruler_content_rect(size_t line_index) const { if (!m_ruler_visible) return {}; @@ -336,12 +336,12 @@ Gfx::Rect TextEditor::ruler_content_rect(size_t line_index) const }; } -Gfx::Rect TextEditor::ruler_rect_in_inner_coordinates() const +Gfx::IntRect TextEditor::ruler_rect_in_inner_coordinates() const { return { 0, 0, ruler_width(), height() - height_occupied_by_horizontal_scrollbar() }; } -Gfx::Rect TextEditor::visible_text_rect_in_inner_coordinates() const +Gfx::IntRect TextEditor::visible_text_rect_in_inner_coordinates() const { return { m_horizontal_content_padding + (m_ruler_visible ? (ruler_rect_in_inner_coordinates().right() + 1) : 0), @@ -396,7 +396,7 @@ void TextEditor::paint_event(PaintEvent& event) } } - Gfx::Rect text_clip_rect { + Gfx::IntRect text_clip_rect { (m_ruler_visible ? (ruler_rect_in_inner_coordinates().right() + frame_thickness() + 1) : frame_thickness()), frame_thickness(), width() - width_occupied_by_vertical_scrollbar() - ruler_width(), @@ -429,7 +429,7 @@ void TextEditor::paint_event(PaintEvent& event) size_t selection_end_column_within_line = selection.end().line() == line_index ? selection.end().column() : line.length(); size_t visual_line_index = 0; - for_each_visual_line(line_index, [&](const Gfx::Rect& visual_line_rect, auto& visual_line_text, size_t start_of_visual_line) { + for_each_visual_line(line_index, [&](const Gfx::IntRect& visual_line_rect, auto& visual_line_text, size_t start_of_visual_line) { if (is_multi_line() && line_index == m_cursor.line()) painter.fill_rect(visual_line_rect, widget_background_color.darkened(0.9f)); #ifdef DEBUG_TEXTEDITOR @@ -440,7 +440,7 @@ void TextEditor::paint_event(PaintEvent& event) auto color = palette().color(is_enabled() ? foreground_role() : Gfx::ColorRole::DisabledText); painter.draw_text(visual_line_rect, visual_line_text, m_text_alignment, color); } else { - Gfx::Rect character_rect = { visual_line_rect.location(), { 0, line_height() } }; + Gfx::IntRect character_rect = { visual_line_rect.location(), { 0, line_height() } }; for (size_t i = 0; i < visual_line_text.length(); ++i) { u32 codepoint = visual_line_text.substring_view(i, 1).codepoints()[0]; const Gfx::Font* font = &this->font(); @@ -489,7 +489,7 @@ void TextEditor::paint_event(PaintEvent& event) ? content_x_for_position({ line_index, (size_t)selection_end_column_within_line }) : visual_line_rect.right() + 1; - Gfx::Rect selection_rect { + Gfx::IntRect selection_rect { selection_left, visual_line_rect.y(), selection_right - selection_left, @@ -948,7 +948,7 @@ int TextEditor::content_x_for_position(const TextPosition& position) const int x_offset = 0; switch (m_text_alignment) { case Gfx::TextAlignment::CenterLeft: - for_each_visual_line(position.line(), [&](const Gfx::Rect&, auto& visual_line_view, size_t start_of_visual_line) { + for_each_visual_line(position.line(), [&](const Gfx::IntRect&, auto& visual_line_view, size_t start_of_visual_line) { size_t offset_in_visual_line = position.column() - start_of_visual_line; if (position.column() >= start_of_visual_line && (offset_in_visual_line <= visual_line_view.length())) { if (offset_in_visual_line == 0) { @@ -971,7 +971,7 @@ int TextEditor::content_x_for_position(const TextPosition& position) const } } -Gfx::Rect TextEditor::content_rect_for_position(const TextPosition& position) const +Gfx::IntRect TextEditor::content_rect_for_position(const TextPosition& position) const { if (!position.is_valid()) return {}; @@ -981,13 +981,13 @@ Gfx::Rect TextEditor::content_rect_for_position(const TextPosition& position) co int x = content_x_for_position(position); if (is_single_line()) { - Gfx::Rect rect { x, 0, 1, font().glyph_height() + 2 }; + Gfx::IntRect rect { x, 0, 1, font().glyph_height() + 2 }; rect.center_vertically_within({ {}, frame_inner_rect().size() }); return rect; } - Gfx::Rect rect; - for_each_visual_line(position.line(), [&](const Gfx::Rect& visual_line_rect, auto& view, size_t start_of_visual_line) { + Gfx::IntRect rect; + for_each_visual_line(position.line(), [&](const Gfx::IntRect& visual_line_rect, auto& view, size_t start_of_visual_line) { if (position.column() >= start_of_visual_line && ((position.column() - start_of_visual_line) <= view.length())) { // NOTE: We have to subtract the horizontal padding here since it's part of the visual line rect // *and* included in what we get from content_x_for_position(). @@ -1004,12 +1004,12 @@ Gfx::Rect TextEditor::content_rect_for_position(const TextPosition& position) co return rect; } -Gfx::Rect TextEditor::cursor_content_rect() const +Gfx::IntRect TextEditor::cursor_content_rect() const { return content_rect_for_position(m_cursor); } -Gfx::Rect TextEditor::line_widget_rect(size_t line_index) const +Gfx::IntRect TextEditor::line_widget_rect(size_t line_index) const { auto rect = line_content_rect(line_index); rect.set_x(frame_thickness()); @@ -1036,11 +1036,11 @@ void TextEditor::scroll_cursor_into_view() scroll_position_into_view(m_cursor); } -Gfx::Rect TextEditor::line_content_rect(size_t line_index) const +Gfx::IntRect TextEditor::line_content_rect(size_t line_index) const { auto& line = this->line(line_index); if (is_single_line()) { - Gfx::Rect line_rect = { content_x_for_position({ line_index, 0 }), 0, font().width(line.view()), font().glyph_height() + 4 }; + Gfx::IntRect line_rect = { content_x_for_position({ line_index, 0 }), 0, font().width(line.view()), font().glyph_height() + 4 }; line_rect.center_vertically_within({ {}, frame_inner_rect().size() }); return line_rect; } @@ -1412,7 +1412,7 @@ void TextEditor::ensure_cursor_is_valid() size_t TextEditor::visual_line_containing(size_t line_index, size_t column) const { size_t visual_line_index = 0; - for_each_visual_line(line_index, [&](const Gfx::Rect&, auto& view, size_t start_of_visual_line) { + for_each_visual_line(line_index, [&](const Gfx::IntRect&, auto& view, size_t start_of_visual_line) { if (column >= start_of_visual_line && ((column - start_of_visual_line) < view.length())) return IterationDecision::Break; ++visual_line_index; @@ -1466,7 +1466,7 @@ void TextEditor::for_each_visual_line(size_t line_index, Callback callback) cons for (auto visual_line_break : visual_data.visual_line_breaks) { auto visual_line_view = Utf32View(line.codepoints() + start_of_line, visual_line_break - start_of_line); - Gfx::Rect visual_line_rect { + Gfx::IntRect visual_line_rect { visual_data.visual_rect.x(), visual_data.visual_rect.y() + ((int)visual_line_index * line_height()), font().width(visual_line_view), diff --git a/Libraries/LibGUI/TextEditor.h b/Libraries/LibGUI/TextEditor.h index 901345b7e9..d8da3a7f59 100644 --- a/Libraries/LibGUI/TextEditor.h +++ b/Libraries/LibGUI/TextEditor.h @@ -151,9 +151,9 @@ protected: virtual void resize_event(ResizeEvent&) override; virtual void theme_change_event(ThemeChangeEvent&) override; virtual void cursor_did_change() {} - Gfx::Rect ruler_content_rect(size_t line) const; + Gfx::IntRect ruler_content_rect(size_t line) const; - TextPosition text_position_at(const Gfx::Point&) const; + TextPosition text_position_at(const Gfx::IntPoint&) const; bool ruler_visible() const { return m_ruler_visible; } private: @@ -192,10 +192,10 @@ private: TextEditor& m_editor; }; - Gfx::Rect line_content_rect(size_t item_index) const; - Gfx::Rect line_widget_rect(size_t line_index) const; - Gfx::Rect cursor_content_rect() const; - Gfx::Rect content_rect_for_position(const TextPosition&) const; + Gfx::IntRect line_content_rect(size_t item_index) const; + Gfx::IntRect line_widget_rect(size_t line_index) const; + Gfx::IntRect cursor_content_rect() const; + Gfx::IntRect content_rect_for_position(const TextPosition&) const; void update_cursor(); const NonnullOwnPtrVector<TextDocumentLine>& lines() const { return document().lines(); } NonnullOwnPtrVector<TextDocumentLine>& lines() { return document().lines(); } @@ -208,8 +208,8 @@ private: void delete_selection(); void did_update_selection(); int content_x_for_position(const TextPosition&) const; - Gfx::Rect ruler_rect_in_inner_coordinates() const; - Gfx::Rect visible_text_rect_in_inner_coordinates() const; + Gfx::IntRect ruler_rect_in_inner_coordinates() const; + Gfx::IntRect visible_text_rect_in_inner_coordinates() const; void recompute_all_visual_lines(); void ensure_cursor_is_valid(); void flush_pending_change_notification_if_needed(); @@ -268,7 +268,7 @@ private: struct LineVisualData { Vector<size_t, 1> visual_line_breaks; - Gfx::Rect visual_rect; + Gfx::IntRect visual_rect; }; NonnullOwnPtrVector<LineVisualData> m_line_visual_data; @@ -276,7 +276,7 @@ private: OwnPtr<SyntaxHighlighter> m_highlighter; RefPtr<Core::Timer> m_automatic_selection_scroll_timer; - Gfx::Point m_last_mousemove_position; + Gfx::IntPoint m_last_mousemove_position; }; } diff --git a/Libraries/LibGUI/TreeView.cpp b/Libraries/LibGUI/TreeView.cpp index 016037d6cb..d21e571db4 100644 --- a/Libraries/LibGUI/TreeView.cpp +++ b/Libraries/LibGUI/TreeView.cpp @@ -65,14 +65,14 @@ TreeView::~TreeView() { } -ModelIndex TreeView::index_at_event_position(const Gfx::Point& a_position, bool& is_toggle) const +ModelIndex TreeView::index_at_event_position(const Gfx::IntPoint& a_position, bool& is_toggle) const { auto position = a_position.translated(0, -header_height()).translated(horizontal_scrollbar().value() - frame_thickness(), vertical_scrollbar().value() - frame_thickness()); is_toggle = false; if (!model()) return {}; ModelIndex result; - traverse_in_paint_order([&](const ModelIndex& index, const Gfx::Rect& rect, const Gfx::Rect& toggle_rect, int) { + traverse_in_paint_order([&](const ModelIndex& index, const Gfx::IntRect& rect, const Gfx::IntRect& toggle_rect, int) { if (toggle_rect.contains(position)) { result = index; is_toggle = true; @@ -165,11 +165,11 @@ void TreeView::traverse_in_paint_order(Callback callback) const auto& metadata = ensure_metadata_for_index(index); int x_offset = tree_column_x_offset + horizontal_padding() + indent_level * indent_width_in_pixels(); auto node_text = model.data(index, Model::Role::Display).to_string(); - Gfx::Rect rect = { + Gfx::IntRect rect = { x_offset, y_offset, icon_size() + icon_spacing() + text_padding() + font().width(node_text) + text_padding(), item_height() }; - Gfx::Rect toggle_rect; + Gfx::IntRect toggle_rect; if (row_count_at_index > 0) { int toggle_x = tree_column_x_offset + horizontal_padding() + (indent_width_in_pixels() * indent_level) - (icon_size() / 2) - 4; toggle_rect = { toggle_x, rect.y(), toggle_size(), toggle_size() }; @@ -223,7 +223,7 @@ void TreeView::paint_event(PaintEvent& event) int painted_row_index = 0; - traverse_in_paint_order([&](const ModelIndex& index, const Gfx::Rect& a_rect, const Gfx::Rect& a_toggle_rect, int indent_level) { + traverse_in_paint_order([&](const ModelIndex& index, const Gfx::IntRect& a_rect, const Gfx::IntRect& a_toggle_rect, int indent_level) { if (!a_rect.intersects_vertically(visible_content_rect)) return IterationDecision::Continue; @@ -265,7 +265,7 @@ void TreeView::paint_event(PaintEvent& event) row_width = frame_inner_rect().width(); } - Gfx::Rect row_rect { 0, rect.y(), row_width, rect.height() }; + Gfx::IntRect row_rect { 0, rect.y(), row_width, rect.height() }; painter.fill_rect(row_rect, background_color); int x_offset = 0; @@ -277,7 +277,7 @@ void TreeView::paint_event(PaintEvent& event) painter.draw_rect(toggle_rect, text_color); if (column_index != tree_column) { - Gfx::Rect cell_rect(horizontal_padding() + x_offset, rect.y(), column_width, item_height()); + Gfx::IntRect cell_rect(horizontal_padding() + x_offset, rect.y(), column_width, item_height()); auto cell_index = model.sibling(index.row(), column_index, index.parent()); if (auto* delegate = column_data(column_index).cell_painting_delegate.ptr()) { @@ -299,7 +299,7 @@ void TreeView::paint_event(PaintEvent& event) } } else { // It's the tree column! - Gfx::Rect icon_rect = { rect.x(), rect.y(), icon_size(), icon_size() }; + Gfx::IntRect icon_rect = { rect.x(), rect.y(), icon_size(), icon_size() }; auto icon = model.data(index, Model::Role::Icon); if (icon.is_icon()) { if (auto* bitmap = icon.as_icon().bitmap_for_size(icon_size())) { @@ -309,7 +309,7 @@ void TreeView::paint_event(PaintEvent& event) painter.blit(icon_rect.location(), *bitmap, bitmap->rect()); } } - Gfx::Rect text_rect = { + Gfx::IntRect text_rect = { icon_rect.right() + 1 + icon_spacing(), rect.y(), rect.width() - icon_size() - icon_spacing(), rect.height() }; @@ -319,16 +319,16 @@ void TreeView::paint_event(PaintEvent& event) for (int i = indent_level; i > 0; --i) { auto parent_of_index_at_indent = index_at_indent.parent(); bool index_at_indent_is_last_in_parent = index_at_indent.row() == model.row_count(parent_of_index_at_indent) - 1; - Gfx::Point a { tree_column_x_offset + horizontal_padding() + indent_width_in_pixels() * i - icon_size() / 2, rect.y() - 2 }; - Gfx::Point b { a.x(), a.y() + item_height() - 1 }; + Gfx::IntPoint a { tree_column_x_offset + horizontal_padding() + indent_width_in_pixels() * i - icon_size() / 2, rect.y() - 2 }; + Gfx::IntPoint b { a.x(), a.y() + item_height() - 1 }; if (index_at_indent_is_last_in_parent) b.set_y(rect.center().y()); if (!(i != indent_level && index_at_indent_is_last_in_parent)) painter.draw_line(a, b, Color::MidGray); if (i == indent_level) { - Gfx::Point c { a.x(), rect.center().y() }; - Gfx::Point d { c.x() + icon_size() / 2, c.y() }; + Gfx::IntPoint c { a.x(), rect.center().y() }; + Gfx::IntPoint d { c.x() + icon_size() / 2, c.y() }; painter.draw_line(c, d, Color::MidGray); } index_at_indent = parent_of_index_at_indent; @@ -357,8 +357,8 @@ void TreeView::scroll_into_view(const ModelIndex& a_index, Orientation orientati { if (!a_index.is_valid()) return; - Gfx::Rect found_rect; - traverse_in_paint_order([&](const ModelIndex& index, const Gfx::Rect& rect, const Gfx::Rect&, int) { + Gfx::IntRect found_rect; + traverse_in_paint_order([&](const ModelIndex& index, const Gfx::IntRect& rect, const Gfx::IntRect&, int) { if (index == a_index) { found_rect = rect; return IterationDecision::Break; @@ -414,7 +414,7 @@ void TreeView::keydown_event(KeyEvent& event) if (event.key() == KeyCode::Key_Up) { ModelIndex previous_index; ModelIndex found_index; - traverse_in_paint_order([&](const ModelIndex& index, const Gfx::Rect&, const Gfx::Rect&, int) { + traverse_in_paint_order([&](const ModelIndex& index, const Gfx::IntRect&, const Gfx::IntRect&, int) { if (index == cursor_index) { found_index = previous_index; return IterationDecision::Break; @@ -432,7 +432,7 @@ void TreeView::keydown_event(KeyEvent& event) if (event.key() == KeyCode::Key_Down) { ModelIndex previous_index; ModelIndex found_index; - traverse_in_paint_order([&](const ModelIndex& index, const Gfx::Rect&, const Gfx::Rect&, int) { + traverse_in_paint_order([&](const ModelIndex& index, const Gfx::IntRect&, const Gfx::IntRect&, int) { if (previous_index == cursor_index) { found_index = index; return IterationDecision::Break; @@ -506,7 +506,7 @@ void TreeView::keydown_event(KeyEvent& event) int TreeView::item_count() const { int count = 0; - traverse_in_paint_order([&](const ModelIndex&, const Gfx::Rect&, const Gfx::Rect&, int) { + traverse_in_paint_order([&](const ModelIndex&, const Gfx::IntRect&, const Gfx::IntRect&, int) { ++count; return IterationDecision::Continue; }); @@ -552,7 +552,7 @@ void TreeView::update_column_sizes() int tree_column_header_width = header_font().width(model.column_name(tree_column)); int tree_column_width = tree_column_header_width; - traverse_in_paint_order([&](const ModelIndex&, const Gfx::Rect& rect, const Gfx::Rect&, int) { + traverse_in_paint_order([&](const ModelIndex&, const Gfx::IntRect& rect, const Gfx::IntRect&, int) { tree_column_width = max(rect.right() - tree_column_x_offset, tree_column_width); return IterationDecision::Continue; }); diff --git a/Libraries/LibGUI/TreeView.h b/Libraries/LibGUI/TreeView.h index 4ec708d4ab..7f712f7147 100644 --- a/Libraries/LibGUI/TreeView.h +++ b/Libraries/LibGUI/TreeView.h @@ -54,7 +54,7 @@ protected: virtual void did_update_model(unsigned flags) override; private: - virtual ModelIndex index_at_event_position(const Gfx::Point&, bool& is_toggle) const override; + virtual ModelIndex index_at_event_position(const Gfx::IntPoint&, bool& is_toggle) const override; int item_height() const { return 16; } int max_item_width() const { return frame_inner_rect().width(); } diff --git a/Libraries/LibGUI/Variant.cpp b/Libraries/LibGUI/Variant.cpp index 88917abac3..3862870ddd 100644 --- a/Libraries/LibGUI/Variant.cpp +++ b/Libraries/LibGUI/Variant.cpp @@ -224,19 +224,19 @@ Variant::Variant(Color color) m_value.as_color = color.value(); } -Variant::Variant(const Gfx::Point& point) +Variant::Variant(const Gfx::IntPoint& point) : m_type(Type::Point) { m_value.as_point = { point.x(), point.y() }; } -Variant::Variant(const Gfx::Size& size) +Variant::Variant(const Gfx::IntSize& size) : m_type(Type::Size) { m_value.as_size = { size.width(), size.height() }; } -Variant::Variant(const Gfx::Rect& rect) +Variant::Variant(const Gfx::IntRect& rect) : m_type(Type::Rect) { m_value.as_rect = (const RawRect&)rect; diff --git a/Libraries/LibGUI/Variant.h b/Libraries/LibGUI/Variant.h index 07b20e3e34..7d0d5ea4fe 100644 --- a/Libraries/LibGUI/Variant.h +++ b/Libraries/LibGUI/Variant.h @@ -46,9 +46,9 @@ public: Variant(const FlyString&); Variant(const Gfx::Bitmap&); Variant(const GUI::Icon&); - Variant(const Gfx::Point&); - Variant(const Gfx::Size&); - Variant(const Gfx::Rect&); + Variant(const Gfx::IntPoint&); + Variant(const Gfx::IntSize&); + Variant(const Gfx::IntRect&); Variant(const Gfx::Font&); Variant(const Gfx::TextAlignment); Variant(const AK::JsonValue&); @@ -184,17 +184,17 @@ public: return m_value.as_float; } - Gfx::Point as_point() const + Gfx::IntPoint as_point() const { return { m_value.as_point.x, m_value.as_point.y }; } - Gfx::Size as_size() const + Gfx::IntSize as_size() const { return { m_value.as_size.width, m_value.as_size.height }; } - Gfx::Rect as_rect() const + Gfx::IntRect as_rect() const { return { as_point(), as_size() }; } diff --git a/Libraries/LibGUI/Widget.cpp b/Libraries/LibGUI/Widget.cpp index 661f77f638..709b6f1e18 100644 --- a/Libraries/LibGUI/Widget.cpp +++ b/Libraries/LibGUI/Widget.cpp @@ -132,10 +132,10 @@ void Widget::child_event(Core::ChildEvent& event) return Core::Object::child_event(event); } -void Widget::set_relative_rect(const Gfx::Rect& a_rect) +void Widget::set_relative_rect(const Gfx::IntRect& a_rect) { // Get rid of negative width/height values. - Gfx::Rect rect = { + Gfx::IntRect rect = { a_rect.x(), a_rect.y(), max(a_rect.width(), 0), @@ -432,7 +432,7 @@ void Widget::update() update(rect()); } -void Widget::update(const Gfx::Rect& rect) +void Widget::update(const Gfx::IntRect& rect) { if (!is_visible()) return; @@ -452,7 +452,7 @@ void Widget::update(const Gfx::Rect& rect) window->update(rect.translated(window_relative_rect().location())); } -Gfx::Rect Widget::window_relative_rect() const +Gfx::IntRect Widget::window_relative_rect() const { auto rect = relative_rect(); for (auto* parent = parent_widget(); parent; parent = parent->parent_widget()) { @@ -461,12 +461,12 @@ Gfx::Rect Widget::window_relative_rect() const return rect; } -Gfx::Rect Widget::screen_relative_rect() const +Gfx::IntRect Widget::screen_relative_rect() const { return window_relative_rect().translated(window()->position()); } -Widget* Widget::child_at(const Gfx::Point& point) const +Widget* Widget::child_at(const Gfx::IntPoint& point) const { for (int i = children().size() - 1; i >= 0; --i) { if (!Core::is<Widget>(children()[i])) @@ -480,7 +480,7 @@ Widget* Widget::child_at(const Gfx::Point& point) const return nullptr; } -Widget::HitTestResult Widget::hit_test(const Gfx::Point& position, ShouldRespectGreediness should_respect_greediness) +Widget::HitTestResult Widget::hit_test(const Gfx::IntPoint& position, ShouldRespectGreediness should_respect_greediness) { if (should_respect_greediness == ShouldRespectGreediness::Yes && is_greedy_for_hits()) return { this, position }; @@ -549,7 +549,7 @@ bool Widget::global_cursor_tracking() const return win->global_cursor_tracking_widget() == this; } -void Widget::set_preferred_size(const Gfx::Size& size) +void Widget::set_preferred_size(const Gfx::IntSize& size) { if (m_preferred_size == size) return; @@ -827,7 +827,7 @@ void Widget::set_content_margins(const Margins& margins) invalidate_layout(); } -Gfx::Rect Widget::content_rect() const +Gfx::IntRect Widget::content_rect() const { auto rect = relative_rect(); rect.move_by(m_content_margins.left(), m_content_margins.top()); diff --git a/Libraries/LibGUI/Widget.h b/Libraries/LibGUI/Widget.h index b7a2cf092a..7b8966c505 100644 --- a/Libraries/LibGUI/Widget.h +++ b/Libraries/LibGUI/Widget.h @@ -113,8 +113,8 @@ public: void set_size_policy(SizePolicy horizontal_policy, SizePolicy vertical_policy); void set_size_policy(Orientation, SizePolicy); - Gfx::Size preferred_size() const { return m_preferred_size; } - void set_preferred_size(const Gfx::Size&); + Gfx::IntSize preferred_size() const { return m_preferred_size; } + void set_preferred_size(const Gfx::IntSize&); void set_preferred_size(int width, int height) { set_preferred_size({ width, height }); } bool has_tooltip() const { return !m_tooltip.is_empty(); } @@ -132,11 +132,11 @@ public: // This is called after children have been painted. virtual void second_paint_event(PaintEvent&); - Gfx::Rect relative_rect() const { return m_relative_rect; } - Gfx::Point relative_position() const { return m_relative_rect.location(); } + Gfx::IntRect relative_rect() const { return m_relative_rect; } + Gfx::IntPoint relative_position() const { return m_relative_rect.location(); } - Gfx::Rect window_relative_rect() const; - Gfx::Rect screen_relative_rect() const; + Gfx::IntRect window_relative_rect() const; + Gfx::IntRect screen_relative_rect() const; int x() const { return m_relative_rect.x(); } int y() const { return m_relative_rect.y(); } @@ -144,11 +144,11 @@ public: int height() const { return m_relative_rect.height(); } int length(Orientation orientation) const { return orientation == Orientation::Vertical ? height() : width(); } - Gfx::Rect rect() const { return { 0, 0, width(), height() }; } - Gfx::Size size() const { return m_relative_rect.size(); } + Gfx::IntRect rect() const { return { 0, 0, width(), height() }; } + Gfx::IntSize size() const { return m_relative_rect.size(); } void update(); - void update(const Gfx::Rect&); + void update(const Gfx::IntRect&); virtual bool accepts_focus() const { return false; } @@ -159,12 +159,12 @@ public: Yes }; struct HitTestResult { Widget* widget { nullptr }; - Gfx::Point local_position; + Gfx::IntPoint local_position; }; - HitTestResult hit_test(const Gfx::Point&, ShouldRespectGreediness = ShouldRespectGreediness::Yes); - Widget* child_at(const Gfx::Point&) const; + HitTestResult hit_test(const Gfx::IntPoint&, ShouldRespectGreediness = ShouldRespectGreediness::Yes); + Widget* child_at(const Gfx::IntPoint&) const; - void set_relative_rect(const Gfx::Rect&); + void set_relative_rect(const Gfx::IntRect&); void set_relative_rect(int x, int y, int width, int height) { set_relative_rect({ x, y, width, height }); } void set_x(int x) { set_relative_rect(x, y(), width(), height()); } @@ -172,13 +172,13 @@ public: void set_width(int width) { set_relative_rect(x(), y(), width, height()); } void set_height(int height) { set_relative_rect(x(), y(), width(), height); } - void move_to(const Gfx::Point& point) { set_relative_rect({ point, relative_rect().size() }); } + void move_to(const Gfx::IntPoint& point) { set_relative_rect({ point, relative_rect().size() }); } void move_to(int x, int y) { move_to({ x, y }); } - void resize(const Gfx::Size& size) { set_relative_rect({ relative_rect().location(), size }); } + void resize(const Gfx::IntSize& size) { set_relative_rect({ relative_rect().location(), size }); } void resize(int width, int height) { resize({ width, height }); } void move_by(int x, int y) { move_by({ x, y }); } - void move_by(const Gfx::Point& delta) { set_relative_rect({ relative_position().translated(delta), size() }); } + void move_by(const Gfx::IntPoint& delta) { set_relative_rect({ relative_position().translated(delta), size() }); } Gfx::ColorRole background_role() const { return m_background_role; } void set_background_role(Gfx::ColorRole); @@ -270,7 +270,7 @@ public: const Margins& content_margins() const { return m_content_margins; } void set_content_margins(const Margins&); - Gfx::Rect content_rect() const; + Gfx::IntRect content_rect() const; void set_accepts_emoji_input(bool b) { m_accepts_emoji_input = b; } bool accepts_emoji_input() const { return m_accepts_emoji_input; } @@ -322,7 +322,7 @@ private: Window* m_window { nullptr }; RefPtr<Layout> m_layout; - Gfx::Rect m_relative_rect; + Gfx::IntRect m_relative_rect; Gfx::ColorRole m_background_role; Gfx::ColorRole m_foreground_role; Color m_background_color; @@ -332,7 +332,7 @@ private: SizePolicy m_horizontal_size_policy { SizePolicy::Fill }; SizePolicy m_vertical_size_policy { SizePolicy::Fill }; - Gfx::Size m_preferred_size; + Gfx::IntSize m_preferred_size; Margins m_content_margins; bool m_fill_with_background_color { false }; diff --git a/Libraries/LibGUI/Window.cpp b/Libraries/LibGUI/Window.cpp index 91d435c68b..5a12b3c69c 100644 --- a/Libraries/LibGUI/Window.cpp +++ b/Libraries/LibGUI/Window.cpp @@ -176,14 +176,14 @@ String Window::title() const return WindowServerConnection::the().send_sync<Messages::WindowServer::GetWindowTitle>(m_window_id)->title(); } -Gfx::Rect Window::rect() const +Gfx::IntRect Window::rect() const { if (!is_visible()) return m_rect_when_windowless; return WindowServerConnection::the().send_sync<Messages::WindowServer::GetWindowRect>(m_window_id)->rect(); } -void Window::set_rect(const Gfx::Rect& a_rect) +void Window::set_rect(const Gfx::IntRect& a_rect) { m_rect_when_windowless = a_rect; if (!is_visible()) { @@ -242,14 +242,14 @@ void Window::event(Core::Event& event) auto& mouse_event = static_cast<MouseEvent&>(event); if (m_global_cursor_tracking_widget) { auto window_relative_rect = m_global_cursor_tracking_widget->window_relative_rect(); - Gfx::Point local_point { mouse_event.x() - window_relative_rect.x(), mouse_event.y() - window_relative_rect.y() }; + Gfx::IntPoint local_point { mouse_event.x() - window_relative_rect.x(), mouse_event.y() - window_relative_rect.y() }; auto local_event = make<MouseEvent>((Event::Type)event.type(), local_point, mouse_event.buttons(), mouse_event.button(), mouse_event.modifiers(), mouse_event.wheel_delta()); m_global_cursor_tracking_widget->dispatch_event(*local_event, this); return; } if (m_automatic_cursor_tracking_widget) { auto window_relative_rect = m_automatic_cursor_tracking_widget->window_relative_rect(); - Gfx::Point local_point { mouse_event.x() - window_relative_rect.x(), mouse_event.y() - window_relative_rect.y() }; + Gfx::IntPoint local_point { mouse_event.x() - window_relative_rect.x(), mouse_event.y() - window_relative_rect.y() }; auto local_event = make<MouseEvent>((Event::Type)event.type(), local_point, mouse_event.buttons(), mouse_event.button(), mouse_event.modifiers(), mouse_event.wheel_delta()); m_automatic_cursor_tracking_widget->dispatch_event(*local_event, this); if (mouse_event.buttons() == 0) @@ -311,7 +311,7 @@ void Window::event(Core::Event& event) set_current_backing_bitmap(*m_back_bitmap, true); if (is_visible()) { - Vector<Gfx::Rect> rects_to_send; + Vector<Gfx::IntRect> rects_to_send; for (auto& r : rects) rects_to_send.append(r); WindowServerConnection::the().post_message(Messages::WindowServer::DidFinishPainting(m_window_id, rects_to_send)); @@ -414,7 +414,7 @@ void Window::force_update() WindowServerConnection::the().post_message(Messages::WindowServer::InvalidateRect(m_window_id, { { 0, 0, rect.width(), rect.height() } }, true)); } -void Window::update(const Gfx::Rect& a_rect) +void Window::update(const Gfx::IntRect& a_rect) { if (!is_visible()) return; @@ -433,7 +433,7 @@ void Window::update(const Gfx::Rect& a_rect) auto rects = move(m_pending_paint_event_rects); if (rects.is_empty()) return; - Vector<Gfx::Rect> rects_to_send; + Vector<Gfx::IntRect> rects_to_send; for (auto& r : rects) rects_to_send.append(r); WindowServerConnection::the().post_message(Messages::WindowServer::InvalidateRect(m_window_id, rects_to_send, false)); @@ -543,7 +543,7 @@ void Window::set_current_backing_bitmap(Gfx::Bitmap& bitmap, bool flush_immediat WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowBackingStore>(m_window_id, 32, bitmap.pitch(), bitmap.shbuf_id(), bitmap.has_alpha_channel(), bitmap.size(), flush_immediately); } -void Window::flip(const Vector<Gfx::Rect, 32>& dirty_rects) +void Window::flip(const Vector<Gfx::IntRect, 32>& dirty_rects) { swap(m_front_bitmap, m_back_bitmap); @@ -565,7 +565,7 @@ void Window::flip(const Vector<Gfx::Rect, 32>& dirty_rects) m_back_bitmap->shared_buffer()->set_volatile(); } -RefPtr<Gfx::Bitmap> Window::create_shared_bitmap(Gfx::BitmapFormat format, const Gfx::Size& size) +RefPtr<Gfx::Bitmap> Window::create_shared_bitmap(Gfx::BitmapFormat format, const Gfx::IntSize& size) { ASSERT(WindowServerConnection::the().server_pid()); ASSERT(!size.is_empty()); @@ -577,7 +577,7 @@ RefPtr<Gfx::Bitmap> Window::create_shared_bitmap(Gfx::BitmapFormat format, const return Gfx::Bitmap::create_with_shared_buffer(format, *shared_buffer, size); } -RefPtr<Gfx::Bitmap> Window::create_backing_bitmap(const Gfx::Size& size) +RefPtr<Gfx::Bitmap> Window::create_backing_bitmap(const Gfx::IntSize& size) { auto format = m_has_alpha_channel ? Gfx::BitmapFormat::RGBA32 : Gfx::BitmapFormat::RGB32; return create_shared_bitmap(format, size); @@ -743,7 +743,7 @@ Action* Window::action_for_key_event(const KeyEvent& event) return found_action; } -void Window::set_base_size(const Gfx::Size& base_size) +void Window::set_base_size(const Gfx::IntSize& base_size) { if (m_base_size == base_size) return; @@ -752,7 +752,7 @@ void Window::set_base_size(const Gfx::Size& base_size) WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowBaseSizeAndSizeIncrement>(m_window_id, m_base_size, m_size_increment); } -void Window::set_size_increment(const Gfx::Size& size_increment) +void Window::set_size_increment(const Gfx::IntSize& size_increment) { if (m_size_increment == size_increment) return; diff --git a/Libraries/LibGUI/Window.h b/Libraries/LibGUI/Window.h index f8d8428a64..b0f57c0154 100644 --- a/Libraries/LibGUI/Window.h +++ b/Libraries/LibGUI/Window.h @@ -98,18 +98,18 @@ public: int width() const { return rect().width(); } int height() const { return rect().height(); } - Gfx::Rect rect() const; - Gfx::Size size() const { return rect().size(); } - void set_rect(const Gfx::Rect&); + Gfx::IntRect rect() const; + Gfx::IntSize size() const { return rect().size(); } + void set_rect(const Gfx::IntRect&); void set_rect(int x, int y, int width, int height) { set_rect({ x, y, width, height }); } - Gfx::Point position() const { return rect().location(); } + Gfx::IntPoint position() const { return rect().location(); } void move_to(int x, int y) { move_to({ x, y }); } - void move_to(const Gfx::Point& point) { set_rect({ point, size() }); } + void move_to(const Gfx::IntPoint& point) { set_rect({ point, size() }); } void resize(int width, int height) { resize({ width, height }); } - void resize(const Gfx::Size& size) { set_rect({ position(), size }); } + void resize(const Gfx::IntSize& size) { set_rect({ position(), size }); } virtual void event(Core::Event&) override; @@ -140,7 +140,7 @@ public: void set_focused_widget(Widget*); void update(); - void update(const Gfx::Rect&); + void update(const Gfx::IntRect&); void set_global_cursor_tracking_widget(Widget*); Widget* global_cursor_tracking_widget() { return m_global_cursor_tracking_widget.ptr(); } @@ -157,10 +157,10 @@ public: Gfx::Bitmap* front_bitmap() { return m_front_bitmap.ptr(); } Gfx::Bitmap* back_bitmap() { return m_back_bitmap.ptr(); } - Gfx::Size size_increment() const { return m_size_increment; } - void set_size_increment(const Gfx::Size&); - Gfx::Size base_size() const { return m_base_size; } - void set_base_size(const Gfx::Size&); + Gfx::IntSize size_increment() const { return m_size_increment; } + void set_size_increment(const Gfx::IntSize&); + Gfx::IntSize base_size() const { return m_base_size; } + void set_base_size(const Gfx::IntSize&); void set_override_cursor(StandardCursor); void set_override_cursor(const Gfx::Bitmap&); @@ -199,10 +199,10 @@ private: void server_did_destroy(); - RefPtr<Gfx::Bitmap> create_backing_bitmap(const Gfx::Size&); - RefPtr<Gfx::Bitmap> create_shared_bitmap(Gfx::BitmapFormat, const Gfx::Size&); + RefPtr<Gfx::Bitmap> create_backing_bitmap(const Gfx::IntSize&); + RefPtr<Gfx::Bitmap> create_shared_bitmap(Gfx::BitmapFormat, const Gfx::IntSize&); void set_current_backing_bitmap(Gfx::Bitmap&, bool flush_immediately = false); - void flip(const Vector<Gfx::Rect, 32>& dirty_rects); + void flip(const Vector<Gfx::IntRect, 32>& dirty_rects); void force_update(); RefPtr<Gfx::Bitmap> m_front_bitmap; @@ -216,11 +216,11 @@ private: WeakPtr<Widget> m_global_cursor_tracking_widget; WeakPtr<Widget> m_automatic_cursor_tracking_widget; WeakPtr<Widget> m_hovered_widget; - Gfx::Rect m_rect_when_windowless; + Gfx::IntRect m_rect_when_windowless; String m_title_when_windowless; - Vector<Gfx::Rect, 32> m_pending_paint_event_rects; - Gfx::Size m_size_increment; - Gfx::Size m_base_size; + Vector<Gfx::IntRect, 32> m_pending_paint_event_rects; + Gfx::IntSize m_size_increment; + Gfx::IntSize m_base_size; Color m_background_color { Color::WarmGray }; WindowType m_window_type { WindowType::Normal }; StandardCursor m_override_cursor { StandardCursor::None }; diff --git a/Libraries/LibGfx/AffineTransform.cpp b/Libraries/LibGfx/AffineTransform.cpp index 976686d03b..02dad6c24e 100644 --- a/Libraries/LibGfx/AffineTransform.cpp +++ b/Libraries/LibGfx/AffineTransform.cpp @@ -75,12 +75,12 @@ void AffineTransform::map(float unmapped_x, float unmapped_y, float& mapped_x, f mapped_y = (m_values[1] * unmapped_x + m_values[3] * unmapped_y + m_values[5]); } -Point AffineTransform::map(const Point& point) const +IntPoint AffineTransform::map(const IntPoint& point) const { float mapped_x; float mapped_y; map(point.x(), point.y(), mapped_x, mapped_y); - return Point(roundf(mapped_x), roundf(mapped_y)); + return IntPoint(roundf(mapped_x), roundf(mapped_y)); } FloatPoint AffineTransform::map(const FloatPoint& point) const @@ -91,9 +91,9 @@ FloatPoint AffineTransform::map(const FloatPoint& point) const return FloatPoint(mapped_x, mapped_y); } -Size AffineTransform::map(const Size& size) const +IntSize AffineTransform::map(const IntSize& size) const { - return Size(roundf(size.width() * x_scale()), roundf(y_scale())); + return IntSize(roundf(size.width() * x_scale()), roundf(y_scale())); } FloatSize AffineTransform::map(const FloatSize& size) const @@ -101,7 +101,7 @@ FloatSize AffineTransform::map(const FloatSize& size) const return { size.width() * x_scale(), size.height() * y_scale() }; } -Rect AffineTransform::map(const Rect& rect) const +IntRect AffineTransform::map(const IntRect& rect) const { return enclosing_int_rect(map(FloatRect(rect))); } diff --git a/Libraries/LibGfx/AffineTransform.h b/Libraries/LibGfx/AffineTransform.h index 9cc2b080d7..9e6aa35113 100644 --- a/Libraries/LibGfx/AffineTransform.h +++ b/Libraries/LibGfx/AffineTransform.h @@ -43,13 +43,13 @@ public: void map(float unmapped_x, float unmapped_y, float& mapped_x, float& mapped_y) const; - Point map(const Point&) const; + IntPoint map(const IntPoint&) const; FloatPoint map(const FloatPoint&) const; - Size map(const Size&) const; + IntSize map(const IntSize&) const; FloatSize map(const FloatSize&) const; - Rect map(const Rect&) const; + IntRect map(const IntRect&) const; FloatRect map(const FloatRect&) const; float a() const { return m_values[0]; } diff --git a/Libraries/LibGfx/Bitmap.cpp b/Libraries/LibGfx/Bitmap.cpp index e885833110..0391b9b201 100644 --- a/Libraries/LibGfx/Bitmap.cpp +++ b/Libraries/LibGfx/Bitmap.cpp @@ -40,28 +40,28 @@ namespace Gfx { -static bool size_would_overflow(BitmapFormat format, const Size& size) +static bool size_would_overflow(BitmapFormat format, const IntSize& size) { if (size.width() < 0 || size.height() < 0) return true; return Checked<size_t>::multiplication_would_overflow(size.width(), size.height(), Bitmap::bpp_for_format(format)); } -RefPtr<Bitmap> Bitmap::create(BitmapFormat format, const Size& size) +RefPtr<Bitmap> Bitmap::create(BitmapFormat format, const IntSize& size) { if (size_would_overflow(format, size)) return nullptr; return adopt(*new Bitmap(format, size, Purgeable::No)); } -RefPtr<Bitmap> Bitmap::create_purgeable(BitmapFormat format, const Size& size) +RefPtr<Bitmap> Bitmap::create_purgeable(BitmapFormat format, const IntSize& size) { if (size_would_overflow(format, size)) return nullptr; return adopt(*new Bitmap(format, size, Purgeable::Yes)); } -Bitmap::Bitmap(BitmapFormat format, const Size& size, Purgeable purgeable) +Bitmap::Bitmap(BitmapFormat format, const IntSize& size, Purgeable purgeable) : m_size(size) , m_pitch(round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16)) , m_format(format) @@ -77,7 +77,7 @@ Bitmap::Bitmap(BitmapFormat format, const Size& size, Purgeable purgeable) m_needs_munmap = true; } -RefPtr<Bitmap> Bitmap::create_wrapper(BitmapFormat format, const Size& size, size_t pitch, RGBA32* data) +RefPtr<Bitmap> Bitmap::create_wrapper(BitmapFormat format, const IntSize& size, size_t pitch, RGBA32* data) { if (size_would_overflow(format, size)) return nullptr; @@ -94,7 +94,7 @@ RefPtr<Bitmap> Bitmap::load_from_file(const StringView& path) return nullptr; } -Bitmap::Bitmap(BitmapFormat format, const Size& size, size_t pitch, RGBA32* data) +Bitmap::Bitmap(BitmapFormat format, const IntSize& size, size_t pitch, RGBA32* data) : m_size(size) , m_data(data) , m_pitch(pitch) @@ -105,14 +105,14 @@ Bitmap::Bitmap(BitmapFormat format, const Size& size, size_t pitch, RGBA32* data m_palette = new RGBA32[256]; } -RefPtr<Bitmap> Bitmap::create_with_shared_buffer(BitmapFormat format, NonnullRefPtr<SharedBuffer>&& shared_buffer, const Size& size) +RefPtr<Bitmap> Bitmap::create_with_shared_buffer(BitmapFormat format, NonnullRefPtr<SharedBuffer>&& shared_buffer, const IntSize& size) { if (size_would_overflow(format, size)) return nullptr; return adopt(*new Bitmap(format, move(shared_buffer), size)); } -Bitmap::Bitmap(BitmapFormat format, NonnullRefPtr<SharedBuffer>&& shared_buffer, const Size& size) +Bitmap::Bitmap(BitmapFormat format, NonnullRefPtr<SharedBuffer>&& shared_buffer, const IntSize& size) : m_size(size) , m_data((RGBA32*)shared_buffer->data()) , m_pitch(round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16)) diff --git a/Libraries/LibGfx/Bitmap.h b/Libraries/LibGfx/Bitmap.h index 75be882187..4d1a0ef90b 100644 --- a/Libraries/LibGfx/Bitmap.h +++ b/Libraries/LibGfx/Bitmap.h @@ -49,11 +49,11 @@ enum RotationDirection { class Bitmap : public RefCounted<Bitmap> { public: - static RefPtr<Bitmap> create(BitmapFormat, const Size&); - static RefPtr<Bitmap> create_purgeable(BitmapFormat, const Size&); - static RefPtr<Bitmap> create_wrapper(BitmapFormat, const Size&, size_t pitch, RGBA32*); + static RefPtr<Bitmap> create(BitmapFormat, const IntSize&); + static RefPtr<Bitmap> create_purgeable(BitmapFormat, const IntSize&); + static RefPtr<Bitmap> create_wrapper(BitmapFormat, const IntSize&, size_t pitch, RGBA32*); static RefPtr<Bitmap> load_from_file(const StringView& path); - static RefPtr<Bitmap> create_with_shared_buffer(BitmapFormat, NonnullRefPtr<SharedBuffer>&&, const Size&); + static RefPtr<Bitmap> create_with_shared_buffer(BitmapFormat, NonnullRefPtr<SharedBuffer>&&, const IntSize&); RefPtr<Gfx::Bitmap> rotated(Gfx::RotationDirection) const; RefPtr<Gfx::Bitmap> flipped(Gfx::Orientation) const; @@ -69,8 +69,8 @@ public: u8* bits(int y); const u8* bits(int y) const; - Rect rect() const { return { {}, m_size }; } - Size size() const { return m_size; } + IntRect rect() const { return { {}, m_size }; } + IntSize size() const { return m_size; } int width() const { return m_size.width(); } int height() const { return m_size.height(); } size_t pitch() const { return m_pitch; } @@ -121,7 +121,7 @@ public: Color get_pixel(int x, int y) const; - Color get_pixel(const Point& position) const + Color get_pixel(const IntPoint& position) const { return get_pixel(position.x(), position.y()); } @@ -136,7 +136,7 @@ public: void set_pixel(int x, int y, Color); - void set_pixel(const Point& position, Color color) + void set_pixel(const IntPoint& position, Color color) { set_pixel(position.x(), position.y(), color); } @@ -149,11 +149,11 @@ public: private: enum class Purgeable { No, Yes }; - Bitmap(BitmapFormat, const Size&, Purgeable); - Bitmap(BitmapFormat, const Size&, size_t pitch, RGBA32*); - Bitmap(BitmapFormat, NonnullRefPtr<SharedBuffer>&&, const Size&); + Bitmap(BitmapFormat, const IntSize&, Purgeable); + Bitmap(BitmapFormat, const IntSize&, size_t pitch, RGBA32*); + Bitmap(BitmapFormat, NonnullRefPtr<SharedBuffer>&&, const IntSize&); - Size m_size; + IntSize m_size; RGBA32* m_data { nullptr }; RGBA32* m_palette { nullptr }; size_t m_pitch { 0 }; diff --git a/Libraries/LibGfx/CharacterBitmap.h b/Libraries/LibGfx/CharacterBitmap.h index 0a77d123af..9780383570 100644 --- a/Libraries/LibGfx/CharacterBitmap.h +++ b/Libraries/LibGfx/CharacterBitmap.h @@ -40,7 +40,7 @@ public: bool bit_at(unsigned x, unsigned y) const { return m_bits[y * width() + x] == '#'; } const char* bits() const { return m_bits; } - Size size() const { return m_size; } + IntSize size() const { return m_size; } unsigned width() const { return m_size.width(); } unsigned height() const { return m_size.height(); } @@ -48,7 +48,7 @@ private: CharacterBitmap(const char* b, unsigned w, unsigned h); const char* m_bits { nullptr }; - Size m_size; + IntSize m_size; }; } diff --git a/Libraries/LibGfx/DisjointRectSet.cpp b/Libraries/LibGfx/DisjointRectSet.cpp index 9600f65f65..2ca643b85b 100644 --- a/Libraries/LibGfx/DisjointRectSet.cpp +++ b/Libraries/LibGfx/DisjointRectSet.cpp @@ -28,7 +28,7 @@ namespace Gfx { -void DisjointRectSet::add(const Rect& new_rect) +void DisjointRectSet::add(const IntRect& new_rect) { for (auto& rect : m_rects) { if (rect.contains(new_rect)) @@ -42,7 +42,7 @@ void DisjointRectSet::add(const Rect& new_rect) void DisjointRectSet::shatter() { - Vector<Rect, 32> output; + Vector<IntRect, 32> output; output.ensure_capacity(m_rects.size()); bool pass_had_intersections = false; do { diff --git a/Libraries/LibGfx/DisjointRectSet.h b/Libraries/LibGfx/DisjointRectSet.h index 7b1c319141..5844d7bf75 100644 --- a/Libraries/LibGfx/DisjointRectSet.h +++ b/Libraries/LibGfx/DisjointRectSet.h @@ -40,19 +40,19 @@ public: { } - void add(const Rect&); + void add(const IntRect&); bool is_empty() const { return m_rects.is_empty(); } size_t size() const { return m_rects.size(); } void clear() { m_rects.clear(); } void clear_with_capacity() { m_rects.clear_with_capacity(); } - const Vector<Rect, 32>& rects() const { return m_rects; } + const Vector<IntRect, 32>& rects() const { return m_rects; } private: void shatter(); - Vector<Rect, 32> m_rects; + Vector<IntRect, 32> m_rects; }; } diff --git a/Libraries/LibGfx/FloatPoint.h b/Libraries/LibGfx/FloatPoint.h index 9867d8327d..ef50987e0b 100644 --- a/Libraries/LibGfx/FloatPoint.h +++ b/Libraries/LibGfx/FloatPoint.h @@ -44,7 +44,7 @@ public: { } - explicit FloatPoint(const Point& other) + explicit FloatPoint(const IntPoint& other) : m_x(other.x()) , m_y(other.y()) { @@ -149,7 +149,7 @@ public: set_y(value); } - Point to_int_point() const { return Point(x(), y()); } + IntPoint to_int_point() const { return IntPoint(x(), y()); } private: float m_x { 0 }; diff --git a/Libraries/LibGfx/FloatRect.h b/Libraries/LibGfx/FloatRect.h index 39caf90e03..3908dd8318 100644 --- a/Libraries/LibGfx/FloatRect.h +++ b/Libraries/LibGfx/FloatRect.h @@ -56,7 +56,7 @@ public: { } - explicit FloatRect(const Rect& other) + explicit FloatRect(const IntRect& other) : FloatRect((FloatPoint)other.location(), (FloatSize)other.size()) { } @@ -327,7 +327,7 @@ inline const LogStream& operator<<(const LogStream& stream, const FloatRect& val return stream << value.to_string(); } -inline Rect enclosing_int_rect(const FloatRect& float_rect) +inline IntRect enclosing_int_rect(const FloatRect& float_rect) { return { (int)float_rect.x(), (int)float_rect.y(), (int)ceilf(float_rect.width()), (int)ceilf(float_rect.height()) }; } diff --git a/Libraries/LibGfx/FloatSize.h b/Libraries/LibGfx/FloatSize.h index c513b921ce..1bbe2453a3 100644 --- a/Libraries/LibGfx/FloatSize.h +++ b/Libraries/LibGfx/FloatSize.h @@ -41,7 +41,7 @@ public: , m_height(h) { } - explicit FloatSize(const Size& other) + explicit FloatSize(const IntSize& other) : m_width(other.width()) , m_height(other.height()) { @@ -110,7 +110,7 @@ public: String to_string() const { return String::format("[%gx%g]", m_width, m_height); } - Size to_int_size() const { return Size(width(), height()); } + IntSize to_int_size() const { return IntSize(width(), height()); } private: float m_width { 0 }; diff --git a/Libraries/LibGfx/Font.h b/Libraries/LibGfx/Font.h index 2dae06f4b8..a28fde8a78 100644 --- a/Libraries/LibGfx/Font.h +++ b/Libraries/LibGfx/Font.h @@ -58,19 +58,19 @@ public: mutable_row &= ~(1 << x); } - Size size() const { return m_size; } + IntSize size() const { return m_size; } int width() const { return m_size.width(); } int height() const { return m_size.height(); } private: - GlyphBitmap(const unsigned* rows, Size size) + GlyphBitmap(const unsigned* rows, IntSize size) : m_rows(rows) , m_size(size) { } const unsigned* m_rows { nullptr }; - Size m_size; + IntSize m_size; }; class Font : public RefCounted<Font> { diff --git a/Libraries/LibGfx/Forward.h b/Libraries/LibGfx/Forward.h index 6a6378c9b2..befacc8171 100644 --- a/Libraries/LibGfx/Forward.h +++ b/Libraries/LibGfx/Forward.h @@ -43,10 +43,10 @@ class Painter; class Palette; class PaletteImpl; class Path; -class Point; -class Rect; +class IntPoint; +class IntRect; class ShareableBitmap; -class Size; +class IntSize; class StylePainter; struct SystemTheme; class Triangle; diff --git a/Libraries/LibGfx/GIFLoader.cpp b/Libraries/LibGfx/GIFLoader.cpp index 70d2354f14..0856e94324 100644 --- a/Libraries/LibGfx/GIFLoader.cpp +++ b/Libraries/LibGfx/GIFLoader.cpp @@ -538,7 +538,7 @@ GIFImageDecoderPlugin::GIFImageDecoderPlugin(const u8* data, size_t size) GIFImageDecoderPlugin::~GIFImageDecoderPlugin() { } -Size GIFImageDecoderPlugin::size() +IntSize GIFImageDecoderPlugin::size() { if (m_context->state == GIFLoadingContext::State::Error) { return {}; diff --git a/Libraries/LibGfx/GIFLoader.h b/Libraries/LibGfx/GIFLoader.h index b76b131d19..24be735381 100644 --- a/Libraries/LibGfx/GIFLoader.h +++ b/Libraries/LibGfx/GIFLoader.h @@ -41,7 +41,7 @@ public: virtual ~GIFImageDecoderPlugin() override; GIFImageDecoderPlugin(const u8*, size_t); - virtual Size size() override; + virtual IntSize size() override; virtual RefPtr<Gfx::Bitmap> bitmap() override; virtual void set_volatile() override; [[nodiscard]] virtual bool set_nonvolatile() override; diff --git a/Libraries/LibGfx/ImageDecoder.h b/Libraries/LibGfx/ImageDecoder.h index 7b8b5edf9d..a081348cbd 100644 --- a/Libraries/LibGfx/ImageDecoder.h +++ b/Libraries/LibGfx/ImageDecoder.h @@ -45,7 +45,7 @@ class ImageDecoderPlugin { public: virtual ~ImageDecoderPlugin() { } - virtual Size size() = 0; + virtual IntSize size() = 0; virtual RefPtr<Gfx::Bitmap> bitmap() = 0; virtual void set_volatile() = 0; @@ -68,7 +68,7 @@ public: static NonnullRefPtr<ImageDecoder> create(const ByteBuffer& data) { return adopt(*new ImageDecoder(data.data(), data.size())); } ~ImageDecoder(); - Size size() const { return m_plugin->size(); } + IntSize size() const { return m_plugin->size(); } int width() const { return size().width(); } int height() const { return size().height(); } RefPtr<Gfx::Bitmap> bitmap() const; diff --git a/Libraries/LibGfx/PNGLoader.cpp b/Libraries/LibGfx/PNGLoader.cpp index 584b77bc6c..eeb56d5771 100644 --- a/Libraries/LibGfx/PNGLoader.cpp +++ b/Libraries/LibGfx/PNGLoader.cpp @@ -763,7 +763,7 @@ PNGImageDecoderPlugin::~PNGImageDecoderPlugin() { } -Size PNGImageDecoderPlugin::size() +IntSize PNGImageDecoderPlugin::size() { if (m_context->state == PNGLoadingContext::State::Error) return {}; diff --git a/Libraries/LibGfx/PNGLoader.h b/Libraries/LibGfx/PNGLoader.h index d6820b931d..2432f231e0 100644 --- a/Libraries/LibGfx/PNGLoader.h +++ b/Libraries/LibGfx/PNGLoader.h @@ -41,7 +41,7 @@ public: virtual ~PNGImageDecoderPlugin() override; PNGImageDecoderPlugin(const u8*, size_t); - virtual Size size() override; + virtual IntSize size() override; virtual RefPtr<Gfx::Bitmap> bitmap() override; virtual void set_volatile() override; [[nodiscard]] virtual bool set_nonvolatile() override; diff --git a/Libraries/LibGfx/Painter.cpp b/Libraries/LibGfx/Painter.cpp index 5c2a67a79c..a7ecb7a763 100644 --- a/Libraries/LibGfx/Painter.cpp +++ b/Libraries/LibGfx/Painter.cpp @@ -73,7 +73,7 @@ Painter::~Painter() { } -void Painter::fill_rect_with_draw_op(const Rect& a_rect, Color color) +void Painter::fill_rect_with_draw_op(const IntRect& a_rect, Color color) { auto rect = a_rect.translated(translation()).intersected(clip_rect()); if (rect.is_empty()) @@ -89,7 +89,7 @@ void Painter::fill_rect_with_draw_op(const Rect& a_rect, Color color) } } -void Painter::clear_rect(const Rect& a_rect, Color color) +void Painter::clear_rect(const IntRect& a_rect, Color color) { auto rect = a_rect.translated(translation()).intersected(clip_rect()); if (rect.is_empty()) @@ -106,7 +106,7 @@ void Painter::clear_rect(const Rect& a_rect, Color color) } } -void Painter::fill_rect(const Rect& a_rect, Color color) +void Painter::fill_rect(const IntRect& a_rect, Color color) { if (color.alpha() == 0) return; @@ -137,7 +137,7 @@ void Painter::fill_rect(const Rect& a_rect, Color color) } } -void Painter::fill_rect_with_dither_pattern(const Rect& a_rect, Color color_a, Color color_b) +void Painter::fill_rect_with_dither_pattern(const IntRect& a_rect, Color color_a, Color color_b) { auto rect = a_rect.translated(translation()).intersected(clip_rect()); if (rect.is_empty()) @@ -155,7 +155,7 @@ void Painter::fill_rect_with_dither_pattern(const Rect& a_rect, Color color_a, C } } -void Painter::fill_rect_with_checkerboard(const Rect& a_rect, const Size& cell_size, Color color_dark, Color color_light) +void Painter::fill_rect_with_checkerboard(const IntRect& a_rect, const IntSize& cell_size, Color color_dark, Color color_light) { auto rect = a_rect.translated(translation()).intersected(clip_rect()); if (rect.is_empty()) @@ -174,13 +174,13 @@ void Painter::fill_rect_with_checkerboard(const Rect& a_rect, const Size& cell_s } } -void Painter::fill_rect_with_gradient(Orientation orientation, const Rect& a_rect, Color gradient_start, Color gradient_end) +void Painter::fill_rect_with_gradient(Orientation orientation, const IntRect& a_rect, Color gradient_start, Color gradient_end) { #ifdef NO_FPU return fill_rect(a_rect, gradient_start); #endif auto rect = a_rect.translated(translation()); - auto clipped_rect = Rect::intersection(rect, clip_rect()); + auto clipped_rect = IntRect::intersection(rect, clip_rect()); if (clipped_rect.is_empty()) return; @@ -227,12 +227,12 @@ void Painter::fill_rect_with_gradient(Orientation orientation, const Rect& a_rec } } -void Painter::fill_rect_with_gradient(const Rect& a_rect, Color gradient_start, Color gradient_end) +void Painter::fill_rect_with_gradient(const IntRect& a_rect, Color gradient_start, Color gradient_end) { return fill_rect_with_gradient(Orientation::Horizontal, a_rect, gradient_start, gradient_end); } -void Painter::fill_ellipse(const Rect& a_rect, Color color) +void Painter::fill_ellipse(const IntRect& a_rect, Color color) { auto rect = a_rect.translated(translation()).intersected(clip_rect()); if (rect.is_empty()) @@ -251,7 +251,7 @@ void Painter::fill_ellipse(const Rect& a_rect, Color color) } } -void Painter::draw_ellipse_intersecting(const Rect& rect, Color color, int thickness) +void Painter::draw_ellipse_intersecting(const IntRect& rect, Color color, int thickness) { constexpr int number_samples = 100; // FIXME: dynamically work out the number of samples based upon the rect size double increment = M_PI / number_samples; @@ -269,9 +269,9 @@ void Painter::draw_ellipse_intersecting(const Rect& rect, Color color, int thick } } -void Painter::draw_rect(const Rect& a_rect, Color color, bool rough) +void Painter::draw_rect(const IntRect& a_rect, Color color, bool rough) { - Rect rect = a_rect.translated(translation()); + IntRect rect = a_rect.translated(translation()); auto clipped_rect = rect.intersected(clip_rect()); if (clipped_rect.is_empty()) return; @@ -313,9 +313,9 @@ void Painter::draw_rect(const Rect& a_rect, Color color, bool rough) } } -void Painter::draw_bitmap(const Point& p, const CharacterBitmap& bitmap, Color color) +void Painter::draw_bitmap(const IntPoint& p, const CharacterBitmap& bitmap, Color color) { - auto rect = Rect(p, bitmap.size()).translated(translation()); + auto rect = IntRect(p, bitmap.size()).translated(translation()); auto clipped_rect = rect.intersected(clip_rect()); if (clipped_rect.is_empty()) return; @@ -339,9 +339,9 @@ void Painter::draw_bitmap(const Point& p, const CharacterBitmap& bitmap, Color c } } -void Painter::draw_bitmap(const Point& p, const GlyphBitmap& bitmap, Color color) +void Painter::draw_bitmap(const IntPoint& p, const GlyphBitmap& bitmap, Color color) { - auto dst_rect = Rect(p, bitmap.size()).translated(translation()); + auto dst_rect = IntRect(p, bitmap.size()).translated(translation()); auto clipped_rect = dst_rect.intersected(clip_rect()); if (clipped_rect.is_empty()) return; @@ -361,13 +361,13 @@ void Painter::draw_bitmap(const Point& p, const GlyphBitmap& bitmap, Color color } } -void Painter::draw_triangle(const Point& a, const Point& b, const Point& c, Color color) +void Painter::draw_triangle(const IntPoint& a, const IntPoint& b, const IntPoint& c, Color color) { RGBA32 rgba = color.value(); - Point p0(a); - Point p1(b); - Point p2(c); + IntPoint p0(a); + IntPoint p1(b); + IntPoint p2(c); if (p0.y() > p1.y()) swap(p0, p1); @@ -429,9 +429,9 @@ void Painter::draw_triangle(const Point& a, const Point& b, const Point& c, Colo } } -void Painter::blit_scaled(const Rect& dst_rect_raw, const Gfx::Bitmap& source, const Rect& src_rect, float hscale, float vscale) +void Painter::blit_scaled(const IntRect& dst_rect_raw, const Gfx::Bitmap& source, const IntRect& src_rect, float hscale, float vscale) { - auto dst_rect = Rect(dst_rect_raw.location(), dst_rect_raw.size()).translated(translation()); + auto dst_rect = IntRect(dst_rect_raw.location(), dst_rect_raw.size()).translated(translation()); auto clipped_rect = dst_rect.intersected(clip_rect()); if (clipped_rect.is_empty()) return; @@ -459,7 +459,7 @@ void Painter::blit_scaled(const Rect& dst_rect_raw, const Gfx::Bitmap& source, c return; } -void Painter::blit_with_opacity(const Point& position, const Gfx::Bitmap& source, const Rect& src_rect, float opacity) +void Painter::blit_with_opacity(const IntPoint& position, const Gfx::Bitmap& source, const IntRect& src_rect, float opacity) { ASSERT(!m_target->has_alpha_channel()); @@ -470,10 +470,10 @@ void Painter::blit_with_opacity(const Point& position, const Gfx::Bitmap& source u8 alpha = 255 * opacity; - Rect safe_src_rect = Rect::intersection(src_rect, source.rect()); - Rect dst_rect(position, safe_src_rect.size()); + IntRect safe_src_rect = IntRect::intersection(src_rect, source.rect()); + IntRect dst_rect(position, safe_src_rect.size()); dst_rect.move_by(state().translation); - auto clipped_rect = Rect::intersection(dst_rect, clip_rect()); + auto clipped_rect = IntRect::intersection(dst_rect, clip_rect()); if (clipped_rect.is_empty()) return; const int first_row = clipped_rect.top() - dst_rect.top(); @@ -497,10 +497,10 @@ void Painter::blit_with_opacity(const Point& position, const Gfx::Bitmap& source } } -void Painter::blit_filtered(const Point& position, const Gfx::Bitmap& source, const Rect& src_rect, Function<Color(Color)> filter) +void Painter::blit_filtered(const IntPoint& position, const Gfx::Bitmap& source, const IntRect& src_rect, Function<Color(Color)> filter) { - Rect safe_src_rect = src_rect.intersected(source.rect()); - auto dst_rect = Rect(position, safe_src_rect.size()).translated(translation()); + IntRect safe_src_rect = src_rect.intersected(source.rect()); + auto dst_rect = IntRect(position, safe_src_rect.size()).translated(translation()); auto clipped_rect = dst_rect.intersected(clip_rect()); if (clipped_rect.is_empty()) return; @@ -528,21 +528,21 @@ void Painter::blit_filtered(const Point& position, const Gfx::Bitmap& source, co } } -void Painter::blit_brightened(const Point& position, const Gfx::Bitmap& source, const Rect& src_rect) +void Painter::blit_brightened(const IntPoint& position, const Gfx::Bitmap& source, const IntRect& src_rect) { return blit_filtered(position, source, src_rect, [](Color src) { return src.lightened(); }); } -void Painter::blit_dimmed(const Point& position, const Gfx::Bitmap& source, const Rect& src_rect) +void Painter::blit_dimmed(const IntPoint& position, const Gfx::Bitmap& source, const IntRect& src_rect) { return blit_filtered(position, source, src_rect, [](Color src) { return src.to_grayscale().lightened(); }); } -void Painter::draw_tiled_bitmap(const Rect& a_dst_rect, const Gfx::Bitmap& source) +void Painter::draw_tiled_bitmap(const IntRect& a_dst_rect, const Gfx::Bitmap& source) { auto dst_rect = a_dst_rect.translated(translation()); auto clipped_rect = dst_rect.intersected(clip_rect()); @@ -570,12 +570,12 @@ void Painter::draw_tiled_bitmap(const Rect& a_dst_rect, const Gfx::Bitmap& sourc ASSERT_NOT_REACHED(); } -void Painter::blit_offset(const Point& position, +void Painter::blit_offset(const IntPoint& position, const Gfx::Bitmap& source, - const Rect& src_rect, - const Point& offset) + const IntRect& src_rect, + const IntPoint& offset) { - auto dst_rect = Rect(position, src_rect.size()).translated(translation()); + auto dst_rect = IntRect(position, src_rect.size()).translated(translation()); auto clipped_rect = dst_rect.intersected(clip_rect()); if (clipped_rect.is_empty()) return; @@ -607,11 +607,11 @@ void Painter::blit_offset(const Point& position, ASSERT_NOT_REACHED(); } -void Painter::blit_with_alpha(const Point& position, const Gfx::Bitmap& source, const Rect& src_rect) +void Painter::blit_with_alpha(const IntPoint& position, const Gfx::Bitmap& source, const IntRect& src_rect) { ASSERT(source.has_alpha_channel()); - Rect safe_src_rect = src_rect.intersected(source.rect()); - auto dst_rect = Rect(position, safe_src_rect.size()).translated(translation()); + IntRect safe_src_rect = src_rect.intersected(source.rect()); + auto dst_rect = IntRect(position, safe_src_rect.size()).translated(translation()); auto clipped_rect = dst_rect.intersected(clip_rect()); if (clipped_rect.is_empty()) return; @@ -639,7 +639,7 @@ void Painter::blit_with_alpha(const Point& position, const Gfx::Bitmap& source, } } -void Painter::blit(const Point& position, const Gfx::Bitmap& source, const Rect& src_rect, float opacity) +void Painter::blit(const IntPoint& position, const Gfx::Bitmap& source, const IntRect& src_rect, float opacity) { if (opacity < 1.0f) return blit_with_opacity(position, source, src_rect, opacity); @@ -647,7 +647,7 @@ void Painter::blit(const Point& position, const Gfx::Bitmap& source, const Rect& return blit_with_alpha(position, source, src_rect); auto safe_src_rect = src_rect.intersected(source.rect()); ASSERT(source.rect().contains(safe_src_rect)); - auto dst_rect = Rect(position, safe_src_rect.size()).translated(translation()); + auto dst_rect = IntRect(position, safe_src_rect.size()).translated(translation()); auto clipped_rect = dst_rect.intersected(clip_rect()); if (clipped_rect.is_empty()) return; @@ -684,7 +684,7 @@ void Painter::blit(const Point& position, const Gfx::Bitmap& source, const Rect& } template<bool has_alpha_channel, typename GetPixel> -ALWAYS_INLINE static void do_draw_integer_scaled_bitmap(Gfx::Bitmap& target, const Rect& dst_rect, const Gfx::Bitmap& source, int hfactor, int vfactor, GetPixel get_pixel) +ALWAYS_INLINE static void do_draw_integer_scaled_bitmap(Gfx::Bitmap& target, const IntRect& dst_rect, const Gfx::Bitmap& source, int hfactor, int vfactor, GetPixel get_pixel) { for (int y = source.rect().top(); y <= source.rect().bottom(); ++y) { int dst_y = dst_rect.y() + y * vfactor; @@ -705,7 +705,7 @@ ALWAYS_INLINE static void do_draw_integer_scaled_bitmap(Gfx::Bitmap& target, con } template<bool has_alpha_channel, typename GetPixel> -ALWAYS_INLINE static void do_draw_scaled_bitmap(Gfx::Bitmap& target, const Rect& dst_rect, const Rect& clipped_rect, const Gfx::Bitmap& source, const Rect& src_rect, int hscale, int vscale, GetPixel get_pixel) +ALWAYS_INLINE static void do_draw_scaled_bitmap(Gfx::Bitmap& target, const IntRect& dst_rect, const IntRect& clipped_rect, const Gfx::Bitmap& source, const IntRect& src_rect, int hscale, int vscale, GetPixel get_pixel) { if (dst_rect == clipped_rect && !(dst_rect.width() % src_rect.width()) && !(dst_rect.height() % src_rect.height())) { int hfactor = dst_rect.width() / src_rect.width(); @@ -734,7 +734,7 @@ ALWAYS_INLINE static void do_draw_scaled_bitmap(Gfx::Bitmap& target, const Rect& } } -void Painter::draw_scaled_bitmap(const Rect& a_dst_rect, const Gfx::Bitmap& source, const Rect& src_rect) +void Painter::draw_scaled_bitmap(const IntRect& a_dst_rect, const Gfx::Bitmap& source, const IntRect& src_rect) { auto dst_rect = a_dst_rect; if (dst_rect.size() == src_rect.size()) @@ -783,22 +783,22 @@ void Painter::draw_scaled_bitmap(const Rect& a_dst_rect, const Gfx::Bitmap& sour } } -FLATTEN void Painter::draw_glyph(const Point& point, u32 codepoint, Color color) +FLATTEN void Painter::draw_glyph(const IntPoint& point, u32 codepoint, Color color) { draw_glyph(point, codepoint, font(), color); } -FLATTEN void Painter::draw_glyph(const Point& point, u32 codepoint, const Font& font, Color color) +FLATTEN void Painter::draw_glyph(const IntPoint& point, u32 codepoint, const Font& font, Color color) { draw_bitmap(point, font.glyph_bitmap(codepoint), color); } -void Painter::draw_emoji(const Point& point, const Gfx::Bitmap& emoji, const Font& font) +void Painter::draw_emoji(const IntPoint& point, const Gfx::Bitmap& emoji, const Font& font) { if (!font.is_fixed_width()) blit(point, emoji, emoji.rect()); else { - Rect dst_rect { + IntRect dst_rect { point.x(), point.y(), font.glyph_width('x'), @@ -808,7 +808,7 @@ void Painter::draw_emoji(const Point& point, const Gfx::Bitmap& emoji, const Fon } } -void Painter::draw_glyph_or_emoji(const Point& point, u32 codepoint, const Font& font, Color color) +void Painter::draw_glyph_or_emoji(const IntPoint& point, u32 codepoint, const Font& font, Color color) { if (codepoint < (u32)font.glyph_count()) { // This looks like a regular character. @@ -829,7 +829,7 @@ void Painter::draw_glyph_or_emoji(const Point& point, u32 codepoint, const Font& draw_emoji(point, *emoji, font); } -void Painter::draw_text_line(const Rect& a_rect, const Utf8View& text, const Font& font, TextAlignment alignment, Color color, TextElision elision) +void Painter::draw_text_line(const IntRect& a_rect, const Utf8View& text, const Font& font, TextAlignment alignment, Color color, TextElision elision) { auto rect = a_rect; Utf8View final_text(text); @@ -894,7 +894,7 @@ void Painter::draw_text_line(const Rect& a_rect, const Utf8View& text, const Fon } } -void Painter::draw_text_line(const Rect& a_rect, const Utf32View& text, const Font& font, TextAlignment alignment, Color color, TextElision elision) +void Painter::draw_text_line(const IntRect& a_rect, const Utf32View& text, const Font& font, TextAlignment alignment, Color color, TextElision elision) { auto rect = a_rect; Utf32View final_text(text); @@ -960,17 +960,17 @@ void Painter::draw_text_line(const Rect& a_rect, const Utf32View& text, const Fo } } -void Painter::draw_text(const Rect& rect, const StringView& text, TextAlignment alignment, Color color, TextElision elision) +void Painter::draw_text(const IntRect& rect, const StringView& text, TextAlignment alignment, Color color, TextElision elision) { draw_text(rect, text, font(), alignment, color, elision); } -void Painter::draw_text(const Rect& rect, const Utf32View& text, TextAlignment alignment, Color color, TextElision elision) +void Painter::draw_text(const IntRect& rect, const Utf32View& text, TextAlignment alignment, Color color, TextElision elision) { draw_text(rect, text, font(), alignment, color, elision); } -void Painter::draw_text(const Rect& rect, const StringView& raw_text, const Font& font, TextAlignment alignment, Color color, TextElision elision) +void Painter::draw_text(const IntRect& rect, const StringView& raw_text, const Font& font, TextAlignment alignment, Color color, TextElision elision) { Utf8View text { raw_text }; Vector<Utf8View, 32> lines; @@ -993,7 +993,7 @@ void Painter::draw_text(const Rect& rect, const StringView& raw_text, const Font static const int line_spacing = 4; int line_height = font.glyph_height() + line_spacing; - Rect bounding_rect { 0, 0, 0, (static_cast<int>(lines.size()) * line_height) - line_spacing }; + IntRect bounding_rect { 0, 0, 0, (static_cast<int>(lines.size()) * line_height) - line_spacing }; for (auto& line : lines) { auto line_width = font.width(line); @@ -1023,13 +1023,13 @@ void Painter::draw_text(const Rect& rect, const StringView& raw_text, const Font for (size_t i = 0; i < lines.size(); ++i) { auto& line = lines[i]; - Rect line_rect { bounding_rect.x(), bounding_rect.y() + static_cast<int>(i) * line_height, bounding_rect.width(), line_height }; + IntRect line_rect { bounding_rect.x(), bounding_rect.y() + static_cast<int>(i) * line_height, bounding_rect.width(), line_height }; line_rect.intersect(rect); draw_text_line(line_rect, line, font, alignment, color, elision); } } -void Painter::draw_text(const Rect& rect, const Utf32View& text, const Font& font, TextAlignment alignment, Color color, TextElision elision) +void Painter::draw_text(const IntRect& rect, const Utf32View& text, const Font& font, TextAlignment alignment, Color color, TextElision elision) { Vector<Utf32View, 32> lines; @@ -1050,7 +1050,7 @@ void Painter::draw_text(const Rect& rect, const Utf32View& text, const Font& fon static const int line_spacing = 4; int line_height = font.glyph_height() + line_spacing; - Rect bounding_rect { 0, 0, 0, (static_cast<int>(lines.size()) * line_height) - line_spacing }; + IntRect bounding_rect { 0, 0, 0, (static_cast<int>(lines.size()) * line_height) - line_spacing }; for (auto& line : lines) { auto line_width = font.width(line); @@ -1080,13 +1080,13 @@ void Painter::draw_text(const Rect& rect, const Utf32View& text, const Font& fon for (size_t i = 0; i < lines.size(); ++i) { auto& line = lines[i]; - Rect line_rect { bounding_rect.x(), bounding_rect.y() + static_cast<int>(i) * line_height, bounding_rect.width(), line_height }; + IntRect line_rect { bounding_rect.x(), bounding_rect.y() + static_cast<int>(i) * line_height, bounding_rect.width(), line_height }; line_rect.intersect(rect); draw_text_line(line_rect, line, font, alignment, color, elision); } } -void Painter::set_pixel(const Point& p, Color color) +void Painter::set_pixel(const IntPoint& p, Color color) { auto point = p; point.move_by(state().translation); @@ -1103,16 +1103,16 @@ ALWAYS_INLINE void Painter::set_pixel_with_draw_op(u32& pixel, const Color& colo pixel ^= color.value(); } -void Painter::draw_pixel(const Point& position, Color color, int thickness) +void Painter::draw_pixel(const IntPoint& position, Color color, int thickness) { ASSERT(draw_op() == DrawOp::Copy); if (thickness == 1) return set_pixel_with_draw_op(m_target->scanline(position.y())[position.x()], color); - Rect rect { position.translated(-(thickness / 2), -(thickness / 2)), { thickness, thickness } }; + IntRect rect { position.translated(-(thickness / 2), -(thickness / 2)), { thickness, thickness } }; fill_rect(rect.translated(-state().translation), color); } -void Painter::draw_line(const Point& p1, const Point& p2, Color color, int thickness, LineStyle style) +void Painter::draw_line(const IntPoint& p1, const IntPoint& p2, Color color, int thickness, LineStyle style) { auto clip_rect = this->clip_rect(); @@ -1274,14 +1274,14 @@ void Painter::for_each_line_segment_on_bezier_curve(const FloatPoint& control_po for_each_line_segment_on_bezier_curve(control_point, p1, p2, callback); } -void Painter::draw_quadratic_bezier_curve(const Point& control_point, const Point& p1, const Point& p2, Color color, int thickness, LineStyle style) +void Painter::draw_quadratic_bezier_curve(const IntPoint& control_point, const IntPoint& p1, const IntPoint& p2, Color color, int thickness, LineStyle style) { for_each_line_segment_on_bezier_curve(FloatPoint(control_point.x(), control_point.y()), FloatPoint(p1.x(), p1.y()), FloatPoint(p2.x(), p2.y()), [&](const FloatPoint& p1, const FloatPoint& p2) { - draw_line(Point(p1.x(), p1.y()), Point(p2.x(), p2.y()), color, thickness, style); + draw_line(IntPoint(p1.x(), p1.y()), IntPoint(p2.x(), p2.y()), color, thickness, style); }); } -void Painter::add_clip_rect(const Rect& rect) +void Painter::add_clip_rect(const IntRect& rect) { state().clip_rect.intersect(rect.translated(translation())); state().clip_rect.intersect(m_target->rect()); @@ -1316,12 +1316,12 @@ void Painter::stroke_path(const Path& path, Color color, int thickness) cursor = segment.point; break; case Path::Segment::Type::LineTo: - draw_line(Point(cursor.x(), cursor.y()), Point(segment.point.x(), segment.point.y()), color, thickness); + draw_line(IntPoint(cursor.x(), cursor.y()), IntPoint(segment.point.x(), segment.point.y()), color, thickness); cursor = segment.point; break; case Path::Segment::Type::QuadraticBezierCurveTo: ASSERT(segment.through.has_value()); - draw_quadratic_bezier_curve(Point(segment.through.value().x(), segment.through.value().y()), Point(cursor.x(), cursor.y()), Point(segment.point.x(), segment.point.y()), color, thickness); + draw_quadratic_bezier_curve(IntPoint(segment.through.value().x(), segment.through.value().y()), IntPoint(cursor.x(), cursor.y()), IntPoint(segment.point.x(), segment.point.y()), color, thickness); cursor = segment.point; break; } @@ -1364,7 +1364,7 @@ void Painter::fill_path(Path& path, Color color, WindingRule winding_rule) ASSERT_NOT_REACHED(); }; - auto increment_winding = [winding_rule](int& winding_number, const Point& from, const Point& to) { + auto increment_winding = [winding_rule](int& winding_number, const IntPoint& from, const IntPoint& to) { if (winding_rule == WindingRule::EvenOdd) { ++winding_number; return; @@ -1400,8 +1400,8 @@ void Painter::fill_path(Path& path, Color color, WindingRule winding_rule) auto& current = active_list[i]; int int_distance = fabs(current.x - previous.x); - Point from(previous.x, scanline); - Point to(current.x, scanline); + IntPoint from(previous.x, scanline); + IntPoint to(current.x, scanline); if (int_distance < 1) { // the two lines intersect on an int grid @@ -1445,7 +1445,7 @@ void Painter::fill_path(Path& path, Color color, WindingRule winding_rule) } active_list.last().x -= active_list.last().inverse_slope; } else { - auto point = Point(active_list[0].x, scanline); + auto point = IntPoint(active_list[0].x, scanline); draw_line(point, point, color); // update the x coord diff --git a/Libraries/LibGfx/Painter.h b/Libraries/LibGfx/Painter.h index 4b06c78a90..89172c1716 100644 --- a/Libraries/LibGfx/Painter.h +++ b/Libraries/LibGfx/Painter.h @@ -50,37 +50,37 @@ public: Dashed, }; - void clear_rect(const Rect&, Color); - void fill_rect(const Rect&, Color); - void fill_rect_with_dither_pattern(const Rect&, Color, Color); - void fill_rect_with_checkerboard(const Rect&, const Size&, Color color_dark, Color color_light); - void fill_rect_with_gradient(Orientation, const Rect&, Color gradient_start, Color gradient_end); - void fill_rect_with_gradient(const Rect&, Color gradient_start, Color gradient_end); - void fill_ellipse(const Rect&, Color); - void draw_rect(const Rect&, Color, bool rough = false); - void draw_bitmap(const Point&, const CharacterBitmap&, Color = Color()); - void draw_bitmap(const Point&, const GlyphBitmap&, Color = Color()); - void draw_triangle(const Point&, const Point&, const Point&, Color); - void draw_ellipse_intersecting(const Rect&, Color, int thickness = 1); - void set_pixel(const Point&, Color); - void draw_line(const Point&, const Point&, Color, int thickness = 1, LineStyle style = LineStyle::Solid); - void draw_quadratic_bezier_curve(const Point& control_point, const Point&, const Point&, Color, int thickness = 1, LineStyle style = LineStyle::Solid); - void draw_scaled_bitmap(const Rect& dst_rect, const Gfx::Bitmap&, const Rect& src_rect); - void blit(const Point&, const Gfx::Bitmap&, const Rect& src_rect, float opacity = 1.0f); - void blit_dimmed(const Point&, const Gfx::Bitmap&, const Rect& src_rect); - void blit_brightened(const Point&, const Gfx::Bitmap&, const Rect& src_rect); - void blit_filtered(const Point&, const Gfx::Bitmap&, const Rect& src_rect, Function<Color(Color)>); - void draw_tiled_bitmap(const Rect& dst_rect, const Gfx::Bitmap&); - void blit_offset(const Point&, const Gfx::Bitmap&, const Rect& src_rect, const Point&); - void blit_scaled(const Rect&, const Gfx::Bitmap&, const Rect&, float, float); - void draw_text(const Rect&, const StringView&, const Font&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None); - void draw_text(const Rect&, const StringView&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None); - void draw_text(const Rect&, const Utf32View&, const Font&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None); - void draw_text(const Rect&, const Utf32View&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None); - void draw_glyph(const Point&, u32, Color); - void draw_glyph(const Point&, u32, const Font&, Color); - void draw_emoji(const Point&, const Gfx::Bitmap&, const Font&); - void draw_glyph_or_emoji(const Point&, u32 codepoint, const Font&, Color); + void clear_rect(const IntRect&, Color); + void fill_rect(const IntRect&, Color); + void fill_rect_with_dither_pattern(const IntRect&, Color, Color); + void fill_rect_with_checkerboard(const IntRect&, const IntSize&, Color color_dark, Color color_light); + void fill_rect_with_gradient(Orientation, const IntRect&, Color gradient_start, Color gradient_end); + void fill_rect_with_gradient(const IntRect&, Color gradient_start, Color gradient_end); + void fill_ellipse(const IntRect&, Color); + void draw_rect(const IntRect&, Color, bool rough = false); + void draw_bitmap(const IntPoint&, const CharacterBitmap&, Color = Color()); + void draw_bitmap(const IntPoint&, const GlyphBitmap&, Color = Color()); + void draw_triangle(const IntPoint&, const IntPoint&, const IntPoint&, Color); + void draw_ellipse_intersecting(const IntRect&, Color, int thickness = 1); + void set_pixel(const IntPoint&, Color); + void draw_line(const IntPoint&, const IntPoint&, Color, int thickness = 1, LineStyle style = LineStyle::Solid); + void draw_quadratic_bezier_curve(const IntPoint& control_point, const IntPoint&, const IntPoint&, Color, int thickness = 1, LineStyle style = LineStyle::Solid); + void draw_scaled_bitmap(const IntRect& dst_rect, const Gfx::Bitmap&, const IntRect& src_rect); + void blit(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect, float opacity = 1.0f); + void blit_dimmed(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect); + void blit_brightened(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect); + void blit_filtered(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect, Function<Color(Color)>); + void draw_tiled_bitmap(const IntRect& dst_rect, const Gfx::Bitmap&); + void blit_offset(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect, const IntPoint&); + void blit_scaled(const IntRect&, const Gfx::Bitmap&, const IntRect&, float, float); + void draw_text(const IntRect&, const StringView&, const Font&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None); + void draw_text(const IntRect&, const StringView&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None); + void draw_text(const IntRect&, const Utf32View&, const Font&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None); + void draw_text(const IntRect&, const Utf32View&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None); + void draw_glyph(const IntPoint&, u32, Color); + void draw_glyph(const IntPoint&, u32, const Font&, Color); + void draw_emoji(const IntPoint&, const Gfx::Bitmap&, const Font&); + void draw_glyph_or_emoji(const IntPoint&, u32 codepoint, const Font&, Color); static void for_each_line_segment_on_bezier_curve(const FloatPoint& control_point, const FloatPoint& p1, const FloatPoint& p2, Function<void(const FloatPoint&, const FloatPoint&)>&); static void for_each_line_segment_on_bezier_curve(const FloatPoint& control_point, const FloatPoint& p1, const FloatPoint& p2, Function<void(const FloatPoint&, const FloatPoint&)>&&); @@ -103,14 +103,14 @@ public: void set_draw_op(DrawOp op) { state().draw_op = op; } DrawOp draw_op() const { return state().draw_op; } - void add_clip_rect(const Rect& rect); + void add_clip_rect(const IntRect& rect); void clear_clip_rect(); - Rect clip_rect() const { return state().clip_rect; } + IntRect clip_rect() const { return state().clip_rect; } void translate(int dx, int dy) { state().translation.move_by(dx, dy); } - void translate(const Point& delta) { state().translation.move_by(delta); } + void translate(const IntPoint& delta) { state().translation.move_by(delta); } - Point translation() const { return state().translation; } + IntPoint translation() const { return state().translation; } Gfx::Bitmap* target() { return m_target.ptr(); } @@ -123,25 +123,25 @@ public: protected: void set_pixel_with_draw_op(u32& pixel, const Color&); - void fill_rect_with_draw_op(const Rect&, Color); - void blit_with_alpha(const Point&, const Gfx::Bitmap&, const Rect& src_rect); - void blit_with_opacity(const Point&, const Gfx::Bitmap&, const Rect& src_rect, float opacity); - void draw_pixel(const Point&, Color, int thickness = 1); + void fill_rect_with_draw_op(const IntRect&, Color); + void blit_with_alpha(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect); + void blit_with_opacity(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect, float opacity); + void draw_pixel(const IntPoint&, Color, int thickness = 1); - void draw_text_line(const Rect&, const Utf8View&, const Font&, TextAlignment, Color, TextElision); - void draw_text_line(const Rect&, const Utf32View&, const Font&, TextAlignment, Color, TextElision); + void draw_text_line(const IntRect&, const Utf8View&, const Font&, TextAlignment, Color, TextElision); + void draw_text_line(const IntRect&, const Utf32View&, const Font&, TextAlignment, Color, TextElision); struct State { const Font* font; - Point translation; - Rect clip_rect; + IntPoint translation; + IntRect clip_rect; DrawOp draw_op; }; State& state() { return m_state_stack.last(); } const State& state() const { return m_state_stack.last(); } - Rect m_clip_origin; + IntRect m_clip_origin; NonnullRefPtr<Gfx::Bitmap> m_target; Vector<State, 4> m_state_stack; }; diff --git a/Libraries/LibGfx/Point.cpp b/Libraries/LibGfx/Point.cpp index 9bdca66ed5..e792190847 100644 --- a/Libraries/LibGfx/Point.cpp +++ b/Libraries/LibGfx/Point.cpp @@ -31,12 +31,12 @@ namespace Gfx { -String Point::to_string() const +String IntPoint::to_string() const { return String::format("[%d,%d]", x(), y()); } -const LogStream& operator<<(const LogStream& stream, const Point& value) +const LogStream& operator<<(const LogStream& stream, const IntPoint& value) { return stream << value.to_string(); } @@ -45,13 +45,13 @@ const LogStream& operator<<(const LogStream& stream, const Point& value) namespace IPC { -bool encode(Encoder& encoder, const Gfx::Point& point) +bool encode(Encoder& encoder, const Gfx::IntPoint& point) { encoder << point.x() << point.y(); return true; } -bool decode(Decoder& decoder, Gfx::Point& point) +bool decode(Decoder& decoder, Gfx::IntPoint& point) { int x = 0; int y = 0; diff --git a/Libraries/LibGfx/Point.h b/Libraries/LibGfx/Point.h index 7b97b51a5d..9413095aa6 100644 --- a/Libraries/LibGfx/Point.h +++ b/Libraries/LibGfx/Point.h @@ -34,12 +34,12 @@ namespace Gfx { -class Rect; +class IntRect; -class Point { +class IntPoint { public: - Point() { } - Point(int x, int y) + IntPoint() { } + IntPoint(int x, int y) : m_x(x) , m_y(y) { @@ -57,71 +57,71 @@ public: m_y += dy; } - void move_by(const Point& delta) + void move_by(const IntPoint& delta) { move_by(delta.x(), delta.y()); } - Point translated(const Point& delta) const + IntPoint translated(const IntPoint& delta) const { - Point point = *this; + IntPoint point = *this; point.move_by(delta); return point; } - Point translated(int dx, int dy) const + IntPoint translated(int dx, int dy) const { - Point point = *this; + IntPoint point = *this; point.move_by(dx, dy); return point; } - void constrain(const Rect&); + void constrain(const IntRect&); - bool operator==(const Point& other) const + bool operator==(const IntPoint& other) const { return m_x == other.m_x && m_y == other.m_y; } - bool operator!=(const Point& other) const + bool operator!=(const IntPoint& other) const { return !(*this == other); } - Point operator-() const { return { -m_x, -m_y }; } + IntPoint operator-() const { return { -m_x, -m_y }; } - Point operator-(const Point& other) const { return { m_x - other.m_x, m_y - other.m_y }; } - Point& operator-=(const Point& other) + IntPoint operator-(const IntPoint& other) const { return { m_x - other.m_x, m_y - other.m_y }; } + IntPoint& operator-=(const IntPoint& other) { m_x -= other.m_x; m_y -= other.m_y; return *this; } - Point& operator+=(const Point& other) + IntPoint& operator+=(const IntPoint& other) { m_x += other.m_x; m_y += other.m_y; return *this; } - Point operator+(const Point& other) const { return { m_x + other.m_x, m_y + other.m_y }; } + IntPoint operator+(const IntPoint& other) const { return { m_x + other.m_x, m_y + other.m_y }; } - Point& operator*=(int factor) + IntPoint& operator*=(int factor) { m_x *= factor; m_y *= factor; return *this; } - Point operator*(int factor) const { return { m_x * factor, m_y * factor }; } + IntPoint operator*(int factor) const { return { m_x * factor, m_y * factor }; } - Point& operator/=(int factor) + IntPoint& operator/=(int factor) { m_x /= factor; m_y /= factor; return *this; } - Point operator/(int factor) const { return { m_x / factor, m_y / factor }; } + IntPoint operator/(int factor) const { return { m_x / factor, m_y / factor }; } String to_string() const; @@ -153,18 +153,18 @@ public: set_y(value); } - int dx_relative_to(const Point& other) const + int dx_relative_to(const IntPoint& other) const { return x() - other.x(); } - int dy_relative_to(const Point& other) const + int dy_relative_to(const IntPoint& other) const { return y() - other.y(); } // Returns pixels moved from other in either direction - int pixels_moved(const Point& other) const + int pixels_moved(const IntPoint& other) const { return max(abs(dx_relative_to(other)), abs(dy_relative_to(other))); } @@ -174,11 +174,11 @@ private: int m_y { 0 }; }; -const LogStream& operator<<(const LogStream&, const Point&); +const LogStream& operator<<(const LogStream&, const IntPoint&); } namespace IPC { -bool encode(Encoder&, const Gfx::Point&); -bool decode(Decoder&, Gfx::Point&); +bool encode(Encoder&, const Gfx::IntPoint&); +bool decode(Decoder&, Gfx::IntPoint&); } diff --git a/Libraries/LibGfx/Rect.cpp b/Libraries/LibGfx/Rect.cpp index 32d1f30c3c..f824f2b5ec 100644 --- a/Libraries/LibGfx/Rect.cpp +++ b/Libraries/LibGfx/Rect.cpp @@ -33,7 +33,7 @@ namespace Gfx { -void Rect::intersect(const Rect& other) +void IntRect::intersect(const IntRect& other) { int l = max(left(), other.left()); int r = min(right(), other.right()); @@ -52,13 +52,13 @@ void Rect::intersect(const Rect& other) m_size.set_height((b - t) + 1); } -Rect Rect::united(const Rect& other) const +IntRect IntRect::united(const IntRect& other) const { if (is_null()) return other; if (other.is_null()) return *this; - Rect rect; + IntRect rect; rect.set_left(min(left(), other.left())); rect.set_top(min(top(), other.top())); rect.set_right(max(right(), other.right())); @@ -66,32 +66,32 @@ Rect Rect::united(const Rect& other) const return rect; } -Vector<Rect, 4> Rect::shatter(const Rect& hammer) const +Vector<IntRect, 4> IntRect::shatter(const IntRect& hammer) const { - Vector<Rect, 4> pieces; + Vector<IntRect, 4> pieces; if (!intersects(hammer)) { pieces.unchecked_append(*this); return pieces; } - Rect top_shard { + IntRect top_shard { x(), y(), width(), hammer.y() - y() }; - Rect bottom_shard { + IntRect bottom_shard { x(), hammer.y() + hammer.height(), width(), (y() + height()) - (hammer.y() + hammer.height()) }; - Rect left_shard { + IntRect left_shard { x(), max(hammer.y(), y()), hammer.x() - x(), min((hammer.y() + hammer.height()), (y() + height())) - max(hammer.y(), y()) }; - Rect right_shard { + IntRect right_shard { hammer.x() + hammer.width(), max(hammer.y(), y()), right() - hammer.right(), @@ -109,7 +109,7 @@ Vector<Rect, 4> Rect::shatter(const Rect& hammer) const return pieces; } -void Rect::align_within(const Rect& other, TextAlignment alignment) +void IntRect::align_within(const IntRect& other, TextAlignment alignment) { switch (alignment) { case TextAlignment::Center: @@ -133,12 +133,12 @@ void Rect::align_within(const Rect& other, TextAlignment alignment) } } -String Rect::to_string() const +String IntRect::to_string() const { return String::format("[%d,%d %dx%d]", x(), y(), width(), height()); } -const LogStream& operator<<(const LogStream& stream, const Rect& value) +const LogStream& operator<<(const LogStream& stream, const IntRect& value) { return stream << value.to_string(); } @@ -147,16 +147,16 @@ const LogStream& operator<<(const LogStream& stream, const Rect& value) namespace IPC { -bool encode(Encoder& encoder, const Gfx::Rect& rect) +bool encode(Encoder& encoder, const Gfx::IntRect& rect) { encoder << rect.location() << rect.size(); return true; } -bool decode(Decoder& decoder, Gfx::Rect& rect) +bool decode(Decoder& decoder, Gfx::IntRect& rect) { - Gfx::Point point; - Gfx::Size size; + Gfx::IntPoint point; + Gfx::IntSize size; if (!decoder.decode(point)) return false; if (!decoder.decode(size)) diff --git a/Libraries/LibGfx/Rect.h b/Libraries/LibGfx/Rect.h index 6baedfe092..67c495b193 100644 --- a/Libraries/LibGfx/Rect.h +++ b/Libraries/LibGfx/Rect.h @@ -36,15 +36,15 @@ namespace Gfx { -class Rect { +class IntRect { public: - Rect() {} - Rect(int x, int y, int width, int height) + IntRect() {} + IntRect(int x, int y, int width, int height) : m_location(x, y) , m_size(width, height) { } - Rect(const Point& location, const Size& size) + IntRect(const IntPoint& location, const IntSize& size) : m_location(location) , m_size(size) { @@ -65,22 +65,22 @@ public: m_location.move_by(dx, dy); } - void move_by(const Point& delta) + void move_by(const IntPoint& delta) { m_location.move_by(delta); } - Point center() const + IntPoint center() const { return { x() + width() / 2, y() + height() / 2 }; } - void set_location(const Point& location) + void set_location(const IntPoint& location) { m_location = location; } - void set_size(const Size& size) + void set_size(const IntSize& size) { m_size = size; } @@ -107,30 +107,30 @@ public: set_height(height() - h); } - Rect shrunken(int w, int h) const + IntRect shrunken(int w, int h) const { - Rect rect = *this; + IntRect rect = *this; rect.shrink(w, h); return rect; } - Rect inflated(int w, int h) const + IntRect inflated(int w, int h) const { - Rect rect = *this; + IntRect rect = *this; rect.inflate(w, h); return rect; } - Rect translated(int dx, int dy) const + IntRect translated(int dx, int dy) const { - Rect rect = *this; + IntRect rect = *this; rect.move_by(dx, dy); return rect; } - Rect translated(const Point& delta) const + IntRect translated(const IntPoint& delta) const { - Rect rect = *this; + IntRect rect = *this; rect.move_by(delta); return rect; } @@ -150,12 +150,12 @@ public: return x >= m_location.x() && x <= right() && y >= m_location.y() && y <= bottom(); } - bool contains(const Point& point) const + bool contains(const IntPoint& point) const { return contains(point.x(), point.y()); } - bool contains(const Rect& other) const + bool contains(const IntRect& other) const { return left() <= other.left() && right() >= other.right() @@ -224,19 +224,19 @@ public: move_by(0, delta); } - bool intersects_vertically(const Rect& other) const + bool intersects_vertically(const IntRect& other) const { return top() <= other.bottom() && other.top() <= bottom(); } - bool intersects_horizontally(const Rect& other) const + bool intersects_horizontally(const IntRect& other) const { return left() <= other.right() && other.left() <= right(); } - bool intersects(const Rect& other) const + bool intersects(const IntRect& other) const { return left() <= other.right() && other.left() <= right() @@ -254,62 +254,62 @@ public: void set_width(int width) { m_size.set_width(width); } void set_height(int height) { m_size.set_height(height); } - Point location() const { return m_location; } - Size size() const { return m_size; } + IntPoint location() const { return m_location; } + IntSize size() const { return m_size; } - Vector<Rect, 4> shatter(const Rect& hammer) const; + Vector<IntRect, 4> shatter(const IntRect& hammer) const; - bool operator==(const Rect& other) const + bool operator==(const IntRect& other) const { return m_location == other.m_location && m_size == other.m_size; } - bool operator!=(const Rect& other) const + bool operator!=(const IntRect& other) const { return !(*this == other); } - void intersect(const Rect&); + void intersect(const IntRect&); - static Rect from_two_points(const Point& a, const Point& b) + static IntRect from_two_points(const IntPoint& a, const IntPoint& b) { return { min(a.x(), b.x()), min(a.y(), b.y()), abs(a.x() - b.x()), abs(a.y() - b.y()) }; } - static Rect intersection(const Rect& a, const Rect& b) + static IntRect intersection(const IntRect& a, const IntRect& b) { - Rect r(a); + IntRect r(a); r.intersect(b); return r; } - Rect intersected(const Rect& other) const + IntRect intersected(const IntRect& other) const { return intersection(*this, other); } - Rect united(const Rect&) const; + IntRect united(const IntRect&) const; - Point top_left() const { return { left(), top() }; } - Point top_right() const { return { right(), top() }; } - Point bottom_left() const { return { left(), bottom() }; } - Point bottom_right() const { return { right(), bottom() }; } + IntPoint top_left() const { return { left(), top() }; } + IntPoint top_right() const { return { right(), top() }; } + IntPoint bottom_left() const { return { left(), bottom() }; } + IntPoint bottom_right() const { return { right(), bottom() }; } - void align_within(const Rect&, TextAlignment); + void align_within(const IntRect&, TextAlignment); - void center_within(const Rect& other) + void center_within(const IntRect& other) { center_horizontally_within(other); center_vertically_within(other); } - void center_horizontally_within(const Rect& other) + void center_horizontally_within(const IntRect& other) { set_x(other.center().x() - width() / 2); } - void center_vertically_within(const Rect& other) + void center_vertically_within(const IntRect& other) { set_y(other.center().y() - height() / 2); } @@ -317,11 +317,11 @@ public: String to_string() const; private: - Point m_location; - Size m_size; + IntPoint m_location; + IntSize m_size; }; -inline void Point::constrain(const Rect& rect) +inline void IntPoint::constrain(const IntRect& rect) { if (x() < rect.left()) set_x(rect.left()); @@ -333,11 +333,11 @@ inline void Point::constrain(const Rect& rect) set_y(rect.bottom()); } -const LogStream& operator<<(const LogStream&, const Rect&); +const LogStream& operator<<(const LogStream&, const IntRect&); } namespace IPC { -bool decode(Decoder&, Gfx::Rect&); -bool encode(Encoder&, const Gfx::Rect&); +bool decode(Decoder&, Gfx::IntRect&); +bool encode(Encoder&, const Gfx::IntRect&); } diff --git a/Libraries/LibGfx/ShareableBitmap.cpp b/Libraries/LibGfx/ShareableBitmap.cpp index 606c857cce..ea19a5c67f 100644 --- a/Libraries/LibGfx/ShareableBitmap.cpp +++ b/Libraries/LibGfx/ShareableBitmap.cpp @@ -52,7 +52,7 @@ bool encode(Encoder& encoder, const Gfx::ShareableBitmap& shareable_bitmap) bool decode(Decoder& decoder, Gfx::ShareableBitmap& shareable_bitmap) { i32 shbuf_id = 0; - Gfx::Size size; + Gfx::IntSize size; if (!decoder.decode(shbuf_id)) return false; if (!decoder.decode(size)) diff --git a/Libraries/LibGfx/ShareableBitmap.h b/Libraries/LibGfx/ShareableBitmap.h index 8dd63d14ac..ac0ecca36b 100644 --- a/Libraries/LibGfx/ShareableBitmap.h +++ b/Libraries/LibGfx/ShareableBitmap.h @@ -44,8 +44,8 @@ public: const Bitmap* bitmap() const { return m_bitmap; } Bitmap* bitmap() { return m_bitmap; } - Size size() const { return m_bitmap ? m_bitmap->size() : Size(); } - Rect rect() const { return m_bitmap ? m_bitmap->rect() : Rect(); } + IntSize size() const { return m_bitmap ? m_bitmap->size() : IntSize(); } + IntRect rect() const { return m_bitmap ? m_bitmap->rect() : IntRect(); } int width() const { return size().width(); } int height() const { return size().height(); } diff --git a/Libraries/LibGfx/Size.cpp b/Libraries/LibGfx/Size.cpp index 45caf1ef57..648aa5708b 100644 --- a/Libraries/LibGfx/Size.cpp +++ b/Libraries/LibGfx/Size.cpp @@ -31,12 +31,12 @@ namespace Gfx { -String Size::to_string() const +String IntSize::to_string() const { return String::format("[%dx%d]", m_width, m_height); } -const LogStream& operator<<(const LogStream& stream, const Size& value) +const LogStream& operator<<(const LogStream& stream, const IntSize& value) { return stream << value.to_string(); } @@ -45,13 +45,13 @@ const LogStream& operator<<(const LogStream& stream, const Size& value) namespace IPC { -bool encode(Encoder& encoder, const Gfx::Size& size) +bool encode(Encoder& encoder, const Gfx::IntSize& size) { encoder << size.width() << size.height(); return true; } -bool decode(Decoder& decoder, Gfx::Size& size) +bool decode(Decoder& decoder, Gfx::IntSize& size) { int width = 0; int height = 0; diff --git a/Libraries/LibGfx/Size.h b/Libraries/LibGfx/Size.h index c48ebac2ec..59eb27a66d 100644 --- a/Libraries/LibGfx/Size.h +++ b/Libraries/LibGfx/Size.h @@ -32,10 +32,10 @@ namespace Gfx { -class Size { +class IntSize { public: - Size() {} - Size(int w, int h) + IntSize() {} + IntSize(int w, int h) : m_width(w) , m_height(h) { @@ -52,24 +52,24 @@ public: void set_width(int w) { m_width = w; } void set_height(int h) { m_height = h; } - bool operator==(const Size& other) const + bool operator==(const IntSize& other) const { return m_width == other.m_width && m_height == other.m_height; } - bool operator!=(const Size& other) const + bool operator!=(const IntSize& other) const { return !(*this == other); } - Size& operator-=(const Size& other) + IntSize& operator-=(const IntSize& other) { m_width -= other.m_width; m_height -= other.m_height; return *this; } - Size& operator+=(const Size& other) + IntSize& operator+=(const IntSize& other) { m_width += other.m_width; m_height += other.m_height; @@ -109,11 +109,11 @@ private: int m_height { 0 }; }; -const LogStream& operator<<(const LogStream&, const Size&); +const LogStream& operator<<(const LogStream&, const IntSize&); } namespace IPC { -bool encode(Encoder&, const Gfx::Size&); -bool decode(Decoder&, Gfx::Size&); +bool encode(Encoder&, const Gfx::IntSize&); +bool decode(Decoder&, Gfx::IntSize&); } diff --git a/Libraries/LibGfx/StylePainter.cpp b/Libraries/LibGfx/StylePainter.cpp index 3408594d8f..2e24ca3a9c 100644 --- a/Libraries/LibGfx/StylePainter.cpp +++ b/Libraries/LibGfx/StylePainter.cpp @@ -31,7 +31,7 @@ namespace Gfx { -void StylePainter::paint_tab_button(Painter& painter, const Rect& rect, const Palette& palette, bool active, bool hovered, bool enabled) +void StylePainter::paint_tab_button(Painter& painter, const IntRect& rect, const Palette& palette, bool active, bool hovered, bool enabled) { Color base_color = palette.button(); Color highlight_color2 = palette.threed_highlight(); @@ -72,7 +72,7 @@ void StylePainter::paint_tab_button(Painter& painter, const Rect& rect, const Pa shadow_color2); } -static void paint_button_new(Painter& painter, const Rect& rect, const Palette& palette, bool pressed, bool checked, bool hovered, bool enabled) +static void paint_button_new(Painter& painter, const IntRect& rect, const Palette& palette, bool pressed, bool checked, bool hovered, bool enabled) { Color button_color = palette.button(); Color highlight_color2 = palette.threed_highlight(); @@ -117,7 +117,7 @@ static void paint_button_new(Painter& painter, const Rect& rect, const Palette& } } -void StylePainter::paint_button(Painter& painter, const Rect& rect, const Palette& palette, ButtonStyle button_style, bool pressed, bool hovered, bool checked, bool enabled) +void StylePainter::paint_button(Painter& painter, const IntRect& rect, const Palette& palette, ButtonStyle button_style, bool pressed, bool hovered, bool checked, bool enabled) { if (button_style == ButtonStyle::Normal) return paint_button_new(painter, rect, palette, pressed, checked, hovered, enabled); @@ -157,7 +157,7 @@ void StylePainter::paint_button(Painter& painter, const Rect& rect, const Palett } } -void StylePainter::paint_surface(Painter& painter, const Rect& rect, const Palette& palette, bool paint_vertical_lines, bool paint_top_line) +void StylePainter::paint_surface(Painter& painter, const IntRect& rect, const Palette& palette, bool paint_vertical_lines, bool paint_top_line) { painter.fill_rect({ rect.x(), rect.y() + 1, rect.width(), rect.height() - 2 }, palette.button()); painter.draw_line(rect.top_left(), rect.top_right(), paint_top_line ? palette.threed_highlight() : palette.button()); @@ -168,7 +168,7 @@ void StylePainter::paint_surface(Painter& painter, const Rect& rect, const Palet } } -void StylePainter::paint_frame(Painter& painter, const Rect& rect, const Palette& palette, FrameShape shape, FrameShadow shadow, int thickness, bool skip_vertical_lines) +void StylePainter::paint_frame(Painter& painter, const IntRect& rect, const Palette& palette, FrameShape shape, FrameShadow shadow, int thickness, bool skip_vertical_lines) { Color top_left_color; Color bottom_right_color; @@ -218,7 +218,7 @@ void StylePainter::paint_frame(Painter& painter, const Rect& rect, const Palette top_left_color = dark_shade; bottom_right_color = dark_shade; } - Rect inner_container_frame_rect = rect.shrunken(2, 2); + IntRect inner_container_frame_rect = rect.shrunken(2, 2); painter.draw_line(inner_container_frame_rect.top_left(), inner_container_frame_rect.top_right(), top_left_color); painter.draw_line(inner_container_frame_rect.bottom_left(), inner_container_frame_rect.bottom_right(), bottom_right_color); painter.draw_line(inner_container_frame_rect.top_left().translated(0, 1), inner_container_frame_rect.bottom_left().translated(0, -1), top_left_color); @@ -227,7 +227,7 @@ void StylePainter::paint_frame(Painter& painter, const Rect& rect, const Palette if (shape == FrameShape::Box && thickness >= 2) { swap(top_left_color, bottom_right_color); - Rect inner_rect = rect.shrunken(2, 2); + IntRect inner_rect = rect.shrunken(2, 2); painter.draw_line(inner_rect.top_left(), inner_rect.top_right(), top_left_color); painter.draw_line(inner_rect.bottom_left(), inner_rect.bottom_right(), bottom_right_color); painter.draw_line(inner_rect.top_left().translated(0, 1), inner_rect.bottom_left().translated(0, -1), top_left_color); @@ -235,7 +235,7 @@ void StylePainter::paint_frame(Painter& painter, const Rect& rect, const Palette } } -void StylePainter::paint_window_frame(Painter& painter, const Rect& rect, const Palette& palette) +void StylePainter::paint_window_frame(Painter& painter, const IntRect& rect, const Palette& palette) { Color base_color = palette.button(); Color dark_shade = palette.threed_shadow2(); @@ -261,7 +261,7 @@ void StylePainter::paint_window_frame(Painter& painter, const Rect& rect, const painter.draw_line(rect.bottom_left().translated(3, -3), rect.bottom_right().translated(-3, -3), base_color); } -void StylePainter::paint_progress_bar(Painter& painter, const Rect& rect, const Palette& palette, int min, int max, int value, const StringView& text) +void StylePainter::paint_progress_bar(Painter& painter, const IntRect& rect, const Palette& palette, int min, int max, int value, const StringView& text) { // First we fill the entire widget with the gradient. This incurs a bit of // overdraw but ensures a consistent look throughout the progression. @@ -280,7 +280,7 @@ void StylePainter::paint_progress_bar(Painter& painter, const Rect& rect, const // Then we carve out a hole in the remaining part of the widget. // We draw the text a third time, clipped and inverse, for sharp contrast. float progress_width = progress * rect.width(); - Rect hole_rect { (int)progress_width, 0, (int)(rect.width() - progress_width), rect.height() }; + IntRect hole_rect { (int)progress_width, 0, (int)(rect.width() - progress_width), rect.height() }; hole_rect.move_by(rect.location()); hole_rect.set_right_without_resize(rect.right()); PainterStateSaver saver(painter); @@ -303,7 +303,7 @@ static const Gfx::Bitmap& circle_bitmap(bool checked, bool changing) return checked ? *s_filled_circle_bitmap : *s_unfilled_circle_bitmap; } -void StylePainter::paint_radio_button(Painter& painter, const Rect& rect, const Palette&, bool is_checked, bool is_being_pressed) +void StylePainter::paint_radio_button(Painter& painter, const IntRect& rect, const Palette&, bool is_checked, bool is_being_pressed) { if (!s_unfilled_circle_bitmap) { s_unfilled_circle_bitmap = Bitmap::load_from_file("/res/icons/unfilled-radio-circle.png"); diff --git a/Libraries/LibGfx/StylePainter.h b/Libraries/LibGfx/StylePainter.h index c677d21a91..a684dd8566 100644 --- a/Libraries/LibGfx/StylePainter.h +++ b/Libraries/LibGfx/StylePainter.h @@ -51,13 +51,13 @@ enum class FrameShape { class StylePainter { public: - static void paint_button(Painter&, const Rect&, const Palette&, ButtonStyle, bool pressed, bool hovered = false, bool checked = false, bool enabled = true); - static void paint_tab_button(Painter&, const Rect&, const Palette&, bool active, bool hovered, bool enabled); - static void paint_surface(Painter&, const Rect&, const Palette&, bool paint_vertical_lines = true, bool paint_top_line = true); - static void paint_frame(Painter&, const Rect&, const Palette&, FrameShape, FrameShadow, int thickness, bool skip_vertical_lines = false); - static void paint_window_frame(Painter&, const Rect&, const Palette&); - static void paint_progress_bar(Painter&, const Rect&, const Palette&, int min, int max, int value, const StringView& text); - static void paint_radio_button(Painter&, const Rect&, const Palette&, bool is_checked, bool is_being_pressed); + static void paint_button(Painter&, const IntRect&, const Palette&, ButtonStyle, bool pressed, bool hovered = false, bool checked = false, bool enabled = true); + static void paint_tab_button(Painter&, const IntRect&, const Palette&, bool active, bool hovered, bool enabled); + static void paint_surface(Painter&, const IntRect&, const Palette&, bool paint_vertical_lines = true, bool paint_top_line = true); + static void paint_frame(Painter&, const IntRect&, const Palette&, FrameShape, FrameShadow, int thickness, bool skip_vertical_lines = false); + static void paint_window_frame(Painter&, const IntRect&, const Palette&); + static void paint_progress_bar(Painter&, const IntRect&, const Palette&, int min, int max, int value, const StringView& text); + static void paint_radio_button(Painter&, const IntRect&, const Palette&, bool is_checked, bool is_being_pressed); }; } diff --git a/Libraries/LibGfx/Triangle.h b/Libraries/LibGfx/Triangle.h index 8720700cb9..7d8e69e80d 100644 --- a/Libraries/LibGfx/Triangle.h +++ b/Libraries/LibGfx/Triangle.h @@ -33,7 +33,7 @@ namespace Gfx { class Triangle { public: - Triangle(Point a, Point b, Point c) + Triangle(IntPoint a, IntPoint b, IntPoint c) : m_a(a) , m_b(b) , m_c(c) @@ -41,11 +41,11 @@ public: m_det = (m_b.x() - m_a.x()) * (m_c.y() - m_a.y()) - (m_b.y() - m_a.y()) * (m_c.x() - m_a.x()); } - Point a() const { return m_a; } - Point b() const { return m_b; } - Point c() const { return m_c; } + IntPoint a() const { return m_a; } + IntPoint b() const { return m_b; } + IntPoint c() const { return m_c; } - bool contains(Point p) const + bool contains(IntPoint p) const { int x = p.x(); int y = p.y(); @@ -71,9 +71,9 @@ public: private: int m_det; - Point m_a; - Point m_b; - Point m_c; + IntPoint m_a; + IntPoint m_b; + IntPoint m_c; }; const LogStream& operator<<(const LogStream&, const Triangle&); diff --git a/Libraries/LibVT/TerminalWidget.cpp b/Libraries/LibVT/TerminalWidget.cpp index ab666cc641..cf56948ae7 100644 --- a/Libraries/LibVT/TerminalWidget.cpp +++ b/Libraries/LibVT/TerminalWidget.cpp @@ -147,17 +147,17 @@ static inline Color color_from_rgb(unsigned color) return Color::from_rgb(color); } -Gfx::Rect TerminalWidget::glyph_rect(u16 row, u16 column) +Gfx::IntRect TerminalWidget::glyph_rect(u16 row, u16 column) { int y = row * m_line_height; int x = column * font().glyph_width('x'); return { x + frame_thickness() + m_inset, y + frame_thickness() + m_inset, font().glyph_width('x'), font().glyph_height() }; } -Gfx::Rect TerminalWidget::row_rect(u16 row) +Gfx::IntRect TerminalWidget::row_rect(u16 row) { int y = row * m_line_height; - Gfx::Rect rect = { frame_thickness() + m_inset, y + frame_thickness() + m_inset, font().glyph_width('x') * m_terminal.columns(), font().glyph_height() }; + Gfx::IntRect rect = { frame_thickness() + m_inset, y + frame_thickness() + m_inset, font().glyph_width('x') * m_terminal.columns(), font().glyph_height() }; rect.inflate(0, m_line_spacing); return rect; } @@ -264,7 +264,7 @@ void TerminalWidget::paint_event(GUI::PaintEvent& event) painter.add_clip_rect(event.rect()); - Gfx::Rect terminal_buffer_rect(frame_inner_rect().top_left(), { frame_inner_rect().width() - m_scrollbar->width(), frame_inner_rect().height() }); + Gfx::IntRect terminal_buffer_rect(frame_inner_rect().top_left(), { frame_inner_rect().width() - m_scrollbar->width(), frame_inner_rect().height() }); painter.add_clip_rect(terminal_buffer_rect); if (m_visual_beep_timer->is_active()) @@ -394,7 +394,7 @@ void TerminalWidget::flush_dirty_lines() m_terminal.m_need_full_flush = false; return; } - Gfx::Rect rect; + Gfx::IntRect rect; for (int i = 0; i < m_terminal.rows(); ++i) { if (m_terminal.visible_line(i).is_dirty()) { rect = rect.united(row_rect(i)); @@ -415,7 +415,7 @@ void TerminalWidget::resize_event(GUI::ResizeEvent& event) relayout(event.size()); } -void TerminalWidget::relayout(const Gfx::Size& size) +void TerminalWidget::relayout(const Gfx::IntSize& size) { if (!m_scrollbar) return; @@ -425,7 +425,7 @@ void TerminalWidget::relayout(const Gfx::Size& size) int new_rows = (size.height() - base_size.height()) / m_line_height; m_terminal.set_size(new_columns, new_rows); - Gfx::Rect scrollbar_rect = { + Gfx::IntRect scrollbar_rect = { size.width() - m_scrollbar->width() - frame_thickness(), frame_thickness(), m_scrollbar->width(), @@ -434,7 +434,7 @@ void TerminalWidget::relayout(const Gfx::Size& size) m_scrollbar->set_relative_rect(scrollbar_rect); } -Gfx::Size TerminalWidget::compute_base_size() const +Gfx::IntSize TerminalWidget::compute_base_size() const { int base_width = frame_thickness() * 2 + m_inset * 2 + m_scrollbar->width(); int base_height = frame_thickness() * 2 + m_inset * 2; @@ -499,7 +499,7 @@ bool TerminalWidget::selection_contains(const VT::Position& position) const return position >= normalized_selection_start() && position <= normalized_selection_end(); } -VT::Position TerminalWidget::buffer_position_at(const Gfx::Point& position) const +VT::Position TerminalWidget::buffer_position_at(const Gfx::IntPoint& position) const { auto adjusted_position = position.translated(-(frame_thickness() + m_inset), -(frame_thickness() + m_inset)); int row = adjusted_position.y() / m_line_height; diff --git a/Libraries/LibVT/TerminalWidget.h b/Libraries/LibVT/TerminalWidget.h index 6b48308955..6be5328079 100644 --- a/Libraries/LibVT/TerminalWidget.h +++ b/Libraries/LibVT/TerminalWidget.h @@ -69,7 +69,7 @@ public: bool has_selection() const; bool selection_contains(const VT::Position&) const; String selected_text() const; - VT::Position buffer_position_at(const Gfx::Point&) const; + VT::Position buffer_position_at(const Gfx::IntPoint&) const; VT::Position normalized_selection_start() const; VT::Position normalized_selection_end() const; @@ -115,15 +115,15 @@ private: void set_logical_focus(bool); - Gfx::Rect glyph_rect(u16 row, u16 column); - Gfx::Rect row_rect(u16 row); + Gfx::IntRect glyph_rect(u16 row, u16 column); + Gfx::IntRect row_rect(u16 row); void update_cursor(); void invalidate_cursor(); - void relayout(const Gfx::Size&); + void relayout(const Gfx::IntSize&); - Gfx::Size compute_base_size() const; + Gfx::IntSize compute_base_size() const; int first_selection_column_on_row(int row) const; int last_selection_column_on_row(int row) const; @@ -182,5 +182,5 @@ private: Core::ElapsedTimer m_triple_click_timer; - Gfx::Point m_left_mousedown_position; + Gfx::IntPoint m_left_mousedown_position; }; diff --git a/Libraries/LibWeb/DOM/CanvasRenderingContext2D.cpp b/Libraries/LibWeb/DOM/CanvasRenderingContext2D.cpp index 7f32f98a8c..3b61eee85b 100644 --- a/Libraries/LibWeb/DOM/CanvasRenderingContext2D.cpp +++ b/Libraries/LibWeb/DOM/CanvasRenderingContext2D.cpp @@ -201,7 +201,7 @@ void CanvasRenderingContext2D::put_image_data(const ImageData& image_data, float if (!painter) return; - painter->blit(Gfx::Point(x, y), image_data.bitmap(), image_data.bitmap().rect()); + painter->blit(Gfx::IntPoint(x, y), image_data.bitmap(), image_data.bitmap().rect()); did_draw(Gfx::FloatRect(x, y, image_data.width(), image_data.height())); } diff --git a/Libraries/LibWeb/DOM/HTMLCanvasElement.cpp b/Libraries/LibWeb/DOM/HTMLCanvasElement.cpp index 3a39d06487..46b518b214 100644 --- a/Libraries/LibWeb/DOM/HTMLCanvasElement.cpp +++ b/Libraries/LibWeb/DOM/HTMLCanvasElement.cpp @@ -82,7 +82,7 @@ CanvasRenderingContext2D* HTMLCanvasElement::get_context(String type) return m_context; } -static Gfx::Size bitmap_size_for_canvas(const HTMLCanvasElement& canvas) +static Gfx::IntSize bitmap_size_for_canvas(const HTMLCanvasElement& canvas) { int width = canvas.requested_width(); int height = canvas.requested_height(); diff --git a/Libraries/LibWeb/DOM/ImageData.cpp b/Libraries/LibWeb/DOM/ImageData.cpp index 11a17ffeaa..cd521861dd 100644 --- a/Libraries/LibWeb/DOM/ImageData.cpp +++ b/Libraries/LibWeb/DOM/ImageData.cpp @@ -47,7 +47,7 @@ RefPtr<ImageData> ImageData::create_with_size(JS::GlobalObject& global_object, i auto data_handle = JS::make_handle(data); - auto bitmap = Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::RGBA32, Gfx::Size(width, height), width * sizeof(u32), (u32*)data->data()); + auto bitmap = Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::RGBA32, Gfx::IntSize(width, height), width * sizeof(u32), (u32*)data->data()); if (!bitmap) return nullptr; return adopt(*new ImageData(bitmap.release_nonnull(), move(data_handle))); diff --git a/Libraries/LibWeb/Frame/EventHandler.cpp b/Libraries/LibWeb/Frame/EventHandler.cpp index 5145cc43e4..be2775a92b 100644 --- a/Libraries/LibWeb/Frame/EventHandler.cpp +++ b/Libraries/LibWeb/Frame/EventHandler.cpp @@ -38,7 +38,7 @@ namespace Web { -static Gfx::Point compute_mouse_event_offset(const Gfx::Point& position, const LayoutNode& layout_node) +static Gfx::IntPoint compute_mouse_event_offset(const Gfx::IntPoint& position, const LayoutNode& layout_node) { auto top_left_of_layout_node = layout_node.box_type_agnostic_position(); return { @@ -70,7 +70,7 @@ LayoutDocument* EventHandler::layout_root() return const_cast<LayoutDocument*>(m_frame.document()->layout_node()); } -bool EventHandler::handle_mouseup(const Gfx::Point& position, unsigned button, unsigned modifiers) +bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button, unsigned modifiers) { auto* layout_root_ptr = this->layout_root(); if (!layout_root_ptr) @@ -98,7 +98,7 @@ bool EventHandler::handle_mouseup(const Gfx::Point& position, unsigned button, u return handled_event; } -bool EventHandler::handle_mousedown(const Gfx::Point& position, unsigned button, unsigned modifiers) +bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned button, unsigned modifiers) { auto* layout_root_ptr = this->layout_root(); if (!layout_root_ptr) @@ -154,7 +154,7 @@ bool EventHandler::handle_mousedown(const Gfx::Point& position, unsigned button, return true; } -bool EventHandler::handle_mousemove(const Gfx::Point& position, unsigned buttons, unsigned modifiers) +bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned buttons, unsigned modifiers) { auto* layout_root_ptr = this->layout_root(); if (!layout_root_ptr) diff --git a/Libraries/LibWeb/Frame/EventHandler.h b/Libraries/LibWeb/Frame/EventHandler.h index 21f893617c..9a06a83c2e 100644 --- a/Libraries/LibWeb/Frame/EventHandler.h +++ b/Libraries/LibWeb/Frame/EventHandler.h @@ -40,9 +40,9 @@ public: explicit EventHandler(Badge<Frame>, Frame&); ~EventHandler(); - bool handle_mouseup(const Gfx::Point&, unsigned button, unsigned modifiers); - bool handle_mousedown(const Gfx::Point&, unsigned button, unsigned modifiers); - bool handle_mousemove(const Gfx::Point&, unsigned buttons, unsigned modifiers); + bool handle_mouseup(const Gfx::IntPoint&, unsigned button, unsigned modifiers); + bool handle_mousedown(const Gfx::IntPoint&, unsigned button, unsigned modifiers); + bool handle_mousemove(const Gfx::IntPoint&, unsigned buttons, unsigned modifiers); private: LayoutDocument* layout_root(); diff --git a/Libraries/LibWeb/Frame/Frame.cpp b/Libraries/LibWeb/Frame/Frame.cpp index 64efa4a533..11f4ade734 100644 --- a/Libraries/LibWeb/Frame/Frame.cpp +++ b/Libraries/LibWeb/Frame/Frame.cpp @@ -69,7 +69,7 @@ void Frame::set_document(Document* document) page().client().page_did_set_document_in_main_frame(m_document); } -void Frame::set_size(const Gfx::Size& size) +void Frame::set_size(const Gfx::IntSize& size) { if (m_size == size) return; @@ -78,7 +78,7 @@ void Frame::set_size(const Gfx::Size& size) m_document->layout(); } -void Frame::set_viewport_rect(const Gfx::Rect& rect) +void Frame::set_viewport_rect(const Gfx::IntRect& rect) { if (m_viewport_rect == rect) return; @@ -88,7 +88,7 @@ void Frame::set_viewport_rect(const Gfx::Rect& rect) m_document->layout_node()->did_set_viewport_rect({}, rect); } -void Frame::set_needs_display(const Gfx::Rect& rect) +void Frame::set_needs_display(const Gfx::IntRect& rect) { if (!m_viewport_rect.intersects(rect)) return; @@ -121,14 +121,14 @@ void Frame::scroll_to_anchor(const String& fragment) page().client().page_did_request_scroll_to_anchor(fragment); } -Gfx::Rect Frame::to_main_frame_rect(const Gfx::Rect& a_rect) +Gfx::IntRect Frame::to_main_frame_rect(const Gfx::IntRect& a_rect) { auto rect = a_rect; rect.set_location(to_main_frame_position(a_rect.location())); return rect; } -Gfx::Point Frame::to_main_frame_position(const Gfx::Point& a_position) +Gfx::IntPoint Frame::to_main_frame_position(const Gfx::IntPoint& a_position) { auto position = a_position; for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) { diff --git a/Libraries/LibWeb/Frame/Frame.h b/Libraries/LibWeb/Frame/Frame.h index af259be517..b72e25c912 100644 --- a/Libraries/LibWeb/Frame/Frame.h +++ b/Libraries/LibWeb/Frame/Frame.h @@ -55,13 +55,13 @@ public: Page& page() { return m_page; } const Page& page() const { return m_page; } - const Gfx::Size& size() const { return m_size; } - void set_size(const Gfx::Size&); + const Gfx::IntSize& size() const { return m_size; } + void set_size(const Gfx::IntSize&); - void set_needs_display(const Gfx::Rect&); + void set_needs_display(const Gfx::IntRect&); - void set_viewport_rect(const Gfx::Rect&); - Gfx::Rect viewport_rect() const { return m_viewport_rect; } + void set_viewport_rect(const Gfx::IntRect&); + Gfx::IntRect viewport_rect() const { return m_viewport_rect; } void did_scroll(Badge<PageView>); @@ -79,8 +79,8 @@ public: Element* host_element() { return m_host_element; } const Element* host_element() const { return m_host_element; } - Gfx::Point to_main_frame_position(const Gfx::Point&); - Gfx::Rect to_main_frame_rect(const Gfx::Rect&); + Gfx::IntPoint to_main_frame_position(const Gfx::IntPoint&); + Gfx::IntRect to_main_frame_rect(const Gfx::IntRect&); private: explicit Frame(Element& host_element, Frame& main_frame); @@ -94,8 +94,8 @@ private: WeakPtr<Element> m_host_element; RefPtr<Document> m_document; - Gfx::Size m_size; - Gfx::Rect m_viewport_rect; + Gfx::IntSize m_size; + Gfx::IntRect m_viewport_rect; }; } diff --git a/Libraries/LibWeb/Layout/LayoutBlock.cpp b/Libraries/LibWeb/Layout/LayoutBlock.cpp index 6b4816d74f..1afd9c9b22 100644 --- a/Libraries/LibWeb/Layout/LayoutBlock.cpp +++ b/Libraries/LibWeb/Layout/LayoutBlock.cpp @@ -449,7 +449,7 @@ void LayoutBlock::render(RenderingContext& context) } } -HitTestResult LayoutBlock::hit_test(const Gfx::Point& position) const +HitTestResult LayoutBlock::hit_test(const Gfx::IntPoint& position) const { if (!children_are_inline()) return LayoutBox::hit_test(position); diff --git a/Libraries/LibWeb/Layout/LayoutBlock.h b/Libraries/LibWeb/Layout/LayoutBlock.h index 0a1d770c88..af1ab548bf 100644 --- a/Libraries/LibWeb/Layout/LayoutBlock.h +++ b/Libraries/LibWeb/Layout/LayoutBlock.h @@ -51,7 +51,7 @@ public: LineBox& ensure_last_line_box(); LineBox& add_line_box(); - virtual HitTestResult hit_test(const Gfx::Point&) const override; + virtual HitTestResult hit_test(const Gfx::IntPoint&) const override; LayoutBlock* previous_sibling() { return to<LayoutBlock>(LayoutNode::previous_sibling()); } const LayoutBlock* previous_sibling() const { return to<LayoutBlock>(LayoutNode::previous_sibling()); } diff --git a/Libraries/LibWeb/Layout/LayoutBox.cpp b/Libraries/LibWeb/Layout/LayoutBox.cpp index dc0e513818..3f6223da30 100644 --- a/Libraries/LibWeb/Layout/LayoutBox.cpp +++ b/Libraries/LibWeb/Layout/LayoutBox.cpp @@ -240,7 +240,7 @@ void LayoutBox::render(RenderingContext& context) context.painter().draw_rect(enclosing_int_rect(absolute_rect()), Color::Magenta); } -HitTestResult LayoutBox::hit_test(const Gfx::Point& position) const +HitTestResult LayoutBox::hit_test(const Gfx::IntPoint& position) const { // FIXME: It would be nice if we could confidently skip over hit testing // parts of the layout tree, but currently we can't just check diff --git a/Libraries/LibWeb/Layout/LayoutBox.h b/Libraries/LibWeb/Layout/LayoutBox.h index d95155af7b..4303612eb8 100644 --- a/Libraries/LibWeb/Layout/LayoutBox.h +++ b/Libraries/LibWeb/Layout/LayoutBox.h @@ -53,7 +53,7 @@ public: float absolute_y() const { return absolute_rect().y(); } Gfx::FloatPoint absolute_position() const { return absolute_rect().location(); } - virtual HitTestResult hit_test(const Gfx::Point& absolute_position) const override; + virtual HitTestResult hit_test(const Gfx::IntPoint& absolute_position) const override; virtual void set_needs_display() override; bool is_body() const; diff --git a/Libraries/LibWeb/Layout/LayoutDocument.cpp b/Libraries/LibWeb/Layout/LayoutDocument.cpp index ca240dd1ff..ea81093724 100644 --- a/Libraries/LibWeb/Layout/LayoutDocument.cpp +++ b/Libraries/LibWeb/Layout/LayoutDocument.cpp @@ -66,7 +66,7 @@ void LayoutDocument::layout(LayoutMode layout_mode) }); } -void LayoutDocument::did_set_viewport_rect(Badge<Frame>, const Gfx::Rect& a_viewport_rect) +void LayoutDocument::did_set_viewport_rect(Badge<Frame>, const Gfx::IntRect& a_viewport_rect) { Gfx::FloatRect viewport_rect(a_viewport_rect.x(), a_viewport_rect.y(), a_viewport_rect.width(), a_viewport_rect.height()); for_each_in_subtree_of_type<LayoutImage>([&](auto& layout_image) { diff --git a/Libraries/LibWeb/Layout/LayoutDocument.h b/Libraries/LibWeb/Layout/LayoutDocument.h index 542b415818..025d178b51 100644 --- a/Libraries/LibWeb/Layout/LayoutDocument.h +++ b/Libraries/LibWeb/Layout/LayoutDocument.h @@ -43,7 +43,7 @@ public: const LayoutRange& selection() const { return m_selection; } LayoutRange& selection() { return m_selection; } - void did_set_viewport_rect(Badge<Frame>, const Gfx::Rect&); + void did_set_viewport_rect(Badge<Frame>, const Gfx::IntRect&); virtual bool is_root() const override { return true; } diff --git a/Libraries/LibWeb/Layout/LayoutListItemMarker.cpp b/Libraries/LibWeb/Layout/LayoutListItemMarker.cpp index fe7582985f..41e44951a9 100644 --- a/Libraries/LibWeb/Layout/LayoutListItemMarker.cpp +++ b/Libraries/LibWeb/Layout/LayoutListItemMarker.cpp @@ -40,7 +40,7 @@ LayoutListItemMarker::~LayoutListItemMarker() void LayoutListItemMarker::render(RenderingContext& context) { - Gfx::Rect bullet_rect { 0, 0, 4, 4 }; + Gfx::IntRect bullet_rect { 0, 0, 4, 4 }; bullet_rect.center_within(enclosing_int_rect(absolute_rect())); // FIXME: It would be nicer to not have to go via the parent here to get our inherited style. auto color = parent()->style().color_or_fallback(CSS::PropertyID::Color, document(), context.palette().base_text()); diff --git a/Libraries/LibWeb/Layout/LayoutNode.cpp b/Libraries/LibWeb/Layout/LayoutNode.cpp index b0133e210b..b19e064616 100644 --- a/Libraries/LibWeb/Layout/LayoutNode.cpp +++ b/Libraries/LibWeb/Layout/LayoutNode.cpp @@ -98,7 +98,7 @@ void LayoutNode::render(RenderingContext& context) }); } -HitTestResult LayoutNode::hit_test(const Gfx::Point& position) const +HitTestResult LayoutNode::hit_test(const Gfx::IntPoint& position) const { HitTestResult result; for_each_child([&](auto& child) { diff --git a/Libraries/LibWeb/Layout/LayoutNode.h b/Libraries/LibWeb/Layout/LayoutNode.h index cc9153bd78..2c4357b9bc 100644 --- a/Libraries/LibWeb/Layout/LayoutNode.h +++ b/Libraries/LibWeb/Layout/LayoutNode.h @@ -94,7 +94,7 @@ class LayoutNode : public TreeNode<LayoutNode> { public: virtual ~LayoutNode(); - virtual HitTestResult hit_test(const Gfx::Point&) const; + virtual HitTestResult hit_test(const Gfx::IntPoint&) const; bool is_anonymous() const { return !m_node; } const Node* node() const { return m_node; } diff --git a/Libraries/LibWeb/Page.cpp b/Libraries/LibWeb/Page.cpp index 9a8b51ddb1..94cb4bda4b 100644 --- a/Libraries/LibWeb/Page.cpp +++ b/Libraries/LibWeb/Page.cpp @@ -50,17 +50,17 @@ Gfx::Palette Page::palette() const return static_cast<const PageView&>(m_client).palette(); } -bool Page::handle_mouseup(const Gfx::Point& position, unsigned button, unsigned modifiers) +bool Page::handle_mouseup(const Gfx::IntPoint& position, unsigned button, unsigned modifiers) { return main_frame().event_handler().handle_mouseup(position, button, modifiers); } -bool Page::handle_mousedown(const Gfx::Point& position, unsigned button, unsigned modifiers) +bool Page::handle_mousedown(const Gfx::IntPoint& position, unsigned button, unsigned modifiers) { return main_frame().event_handler().handle_mousedown(position, button, modifiers); } -bool Page::handle_mousemove(const Gfx::Point& position, unsigned buttons, unsigned modifiers) +bool Page::handle_mousemove(const Gfx::IntPoint& position, unsigned buttons, unsigned modifiers) { return main_frame().event_handler().handle_mousemove(position, buttons, modifiers); } diff --git a/Libraries/LibWeb/Page.h b/Libraries/LibWeb/Page.h index af703deb68..290dac5676 100644 --- a/Libraries/LibWeb/Page.h +++ b/Libraries/LibWeb/Page.h @@ -54,9 +54,9 @@ public: void load(const URL&); - bool handle_mouseup(const Gfx::Point&, unsigned button, unsigned modifiers); - bool handle_mousedown(const Gfx::Point&, unsigned button, unsigned modifiers); - bool handle_mousemove(const Gfx::Point&, unsigned buttons, unsigned modifiers); + bool handle_mouseup(const Gfx::IntPoint&, unsigned button, unsigned modifiers); + bool handle_mousedown(const Gfx::IntPoint&, unsigned button, unsigned modifiers); + bool handle_mousemove(const Gfx::IntPoint&, unsigned buttons, unsigned modifiers); Gfx::Palette palette() const; @@ -73,15 +73,15 @@ public: virtual void page_did_start_loading(const URL&) { } virtual void page_did_change_selection() { } virtual void page_did_request_cursor_change(GUI::StandardCursor) { } - virtual void page_did_request_link_context_menu(const Gfx::Point&, [[maybe_unused]] const String& href, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) { } + virtual void page_did_request_link_context_menu(const Gfx::IntPoint&, [[maybe_unused]] const String& href, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) { } virtual void page_did_click_link([[maybe_unused]] const String& href, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) { } virtual void page_did_middle_click_link([[maybe_unused]] const String& href, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) { } - virtual void page_did_enter_tooltip_area(const Gfx::Point&, const String&) { } + virtual void page_did_enter_tooltip_area(const Gfx::IntPoint&, const String&) { } virtual void page_did_leave_tooltip_area() { } virtual void page_did_hover_link(const URL&) { } virtual void page_did_unhover_link() { } virtual void page_did_request_scroll_to_anchor([[maybe_unused]] const String& fragment) { } - virtual void page_did_invalidate(const Gfx::Rect&) { } + virtual void page_did_invalidate(const Gfx::IntRect&) { } virtual void page_did_change_favicon(const Gfx::Bitmap&) { } }; diff --git a/Libraries/LibWeb/PageView.cpp b/Libraries/LibWeb/PageView.cpp index 68ec47dc17..f660940c5e 100644 --- a/Libraries/LibWeb/PageView.cpp +++ b/Libraries/LibWeb/PageView.cpp @@ -97,7 +97,7 @@ void PageView::page_did_request_cursor_change(GUI::StandardCursor cursor) window()->set_override_cursor(cursor); } -void PageView::page_did_request_link_context_menu(const Gfx::Point& content_position, const String& href, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) +void PageView::page_did_request_link_context_menu(const Gfx::IntPoint& content_position, const String& href, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) { if (on_link_context_menu_request) on_link_context_menu_request(href, screen_relative_rect().location().translated(to_widget_position(content_position))); @@ -115,7 +115,7 @@ void PageView::page_did_middle_click_link(const String& href, [[maybe_unused]] c on_link_middle_click(href); } -void PageView::page_did_enter_tooltip_area(const Gfx::Point& content_position, const String& title) +void PageView::page_did_enter_tooltip_area(const Gfx::IntPoint& content_position, const String& title) { GUI::Application::the().show_tooltip(title, screen_relative_rect().location().translated(to_widget_position(content_position))); } @@ -140,7 +140,7 @@ void PageView::page_did_request_scroll_to_anchor(const String& fragment) scroll_to_anchor(fragment); } -void PageView::page_did_invalidate(const Gfx::Rect&) +void PageView::page_did_invalidate(const Gfx::IntRect&) { update(); } diff --git a/Libraries/LibWeb/PageView.h b/Libraries/LibWeb/PageView.h index 1e3de29f99..4b534442f6 100644 --- a/Libraries/LibWeb/PageView.h +++ b/Libraries/LibWeb/PageView.h @@ -63,7 +63,7 @@ public: void set_should_show_line_box_borders(bool value) { m_should_show_line_box_borders = value; } Function<void(const String& href, const String& target, unsigned modifiers)> on_link_click; - Function<void(const String& href, const Gfx::Point& screen_position)> on_link_context_menu_request; + Function<void(const String& href, const Gfx::IntPoint& screen_position)> on_link_context_menu_request; Function<void(const String& href)> on_link_middle_click; Function<void(const String&)> on_link_hover; Function<void(const String&)> on_title_change; @@ -96,15 +96,15 @@ private: virtual void page_did_start_loading(const URL&) override; virtual void page_did_change_selection() override; virtual void page_did_request_cursor_change(GUI::StandardCursor) override; - virtual void page_did_request_link_context_menu(const Gfx::Point&, const String& href, const String& target, unsigned modifiers) override; + virtual void page_did_request_link_context_menu(const Gfx::IntPoint&, const String& href, const String& target, unsigned modifiers) override; virtual void page_did_click_link(const String& href, const String& target, unsigned modifiers) override; virtual void page_did_middle_click_link(const String& href, const String& target, unsigned modifiers) override; - virtual void page_did_enter_tooltip_area(const Gfx::Point&, const String&) override; + virtual void page_did_enter_tooltip_area(const Gfx::IntPoint&, const String&) override; virtual void page_did_leave_tooltip_area() override; virtual void page_did_hover_link(const URL&) override; virtual void page_did_unhover_link() override; virtual void page_did_request_scroll_to_anchor(const String& fragment) override; - virtual void page_did_invalidate(const Gfx::Rect&) override; + virtual void page_did_invalidate(const Gfx::IntRect&) override; virtual void page_did_change_favicon(const Gfx::Bitmap&) override; void layout_and_sync_size(); diff --git a/Libraries/LibWeb/RenderingContext.h b/Libraries/LibWeb/RenderingContext.h index 36fc6c9d64..2c6e69c9df 100644 --- a/Libraries/LibWeb/RenderingContext.h +++ b/Libraries/LibWeb/RenderingContext.h @@ -46,13 +46,13 @@ public: bool should_show_line_box_borders() const { return m_should_show_line_box_borders; } void set_should_show_line_box_borders(bool value) { m_should_show_line_box_borders = value; } - Gfx::Rect viewport_rect() const { return m_viewport_rect; } - void set_viewport_rect(const Gfx::Rect& rect) { m_viewport_rect = rect; } + Gfx::IntRect viewport_rect() const { return m_viewport_rect; } + void set_viewport_rect(const Gfx::IntRect& rect) { m_viewport_rect = rect; } private: GUI::Painter& m_painter; Palette m_palette; - Gfx::Rect m_viewport_rect; + Gfx::IntRect m_viewport_rect; bool m_should_show_line_box_borders { false }; }; |