From 116cf92156090bb3f5c15d5be145f1283884d65d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 10 Jun 2020 10:57:59 +0200 Subject: 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. --- Libraries/LibGUI/AbstractButton.cpp | 2 +- Libraries/LibGUI/AbstractButton.h | 2 +- Libraries/LibGUI/AbstractTableView.cpp | 26 ++-- Libraries/LibGUI/AbstractTableView.h | 20 +-- Libraries/LibGUI/AbstractView.h | 8 +- Libraries/LibGUI/Application.cpp | 6 +- Libraries/LibGUI/Application.h | 2 +- Libraries/LibGUI/BoxLayout.cpp | 8 +- Libraries/LibGUI/Button.cpp | 4 +- Libraries/LibGUI/CheckBox.cpp | 2 +- Libraries/LibGUI/ColorInput.cpp | 2 +- Libraries/LibGUI/ColorInput.h | 2 +- Libraries/LibGUI/ColorPicker.cpp | 2 +- Libraries/LibGUI/ColumnsView.cpp | 10 +- Libraries/LibGUI/ColumnsView.h | 2 +- Libraries/LibGUI/ComboBox.cpp | 4 +- Libraries/LibGUI/Desktop.cpp | 2 +- Libraries/LibGUI/Desktop.h | 8 +- Libraries/LibGUI/DragOperation.cpp | 2 +- Libraries/LibGUI/Event.cpp | 2 +- Libraries/LibGUI/Event.h | 76 ++++++------ Libraries/LibGUI/FileSystemModel.cpp | 2 +- Libraries/LibGUI/Frame.h | 4 +- Libraries/LibGUI/GroupBox.cpp | 4 +- Libraries/LibGUI/IconView.cpp | 34 ++--- Libraries/LibGUI/IconView.h | 18 +-- Libraries/LibGUI/ListView.cpp | 12 +- Libraries/LibGUI/ListView.h | 8 +- Libraries/LibGUI/Menu.cpp | 4 +- Libraries/LibGUI/Menu.h | 2 +- Libraries/LibGUI/RadioButton.cpp | 6 +- Libraries/LibGUI/RadioButton.h | 2 +- Libraries/LibGUI/ScrollBar.cpp | 10 +- Libraries/LibGUI/ScrollBar.h | 12 +- Libraries/LibGUI/ScrollableWidget.cpp | 20 +-- Libraries/LibGUI/ScrollableWidget.h | 26 ++-- Libraries/LibGUI/Slider.cpp | 6 +- Libraries/LibGUI/Slider.h | 6 +- Libraries/LibGUI/Splitter.cpp | 4 +- Libraries/LibGUI/Splitter.h | 10 +- Libraries/LibGUI/TabWidget.cpp | 14 +-- Libraries/LibGUI/TabWidget.h | 8 +- Libraries/LibGUI/TableView.cpp | 4 +- Libraries/LibGUI/TextEditor.cpp | 40 +++--- Libraries/LibGUI/TextEditor.h | 20 +-- Libraries/LibGUI/TreeView.cpp | 38 +++--- Libraries/LibGUI/TreeView.h | 2 +- Libraries/LibGUI/Variant.cpp | 6 +- Libraries/LibGUI/Variant.h | 12 +- Libraries/LibGUI/Widget.cpp | 18 +-- Libraries/LibGUI/Widget.h | 38 +++--- Libraries/LibGUI/Window.cpp | 24 ++-- Libraries/LibGUI/Window.h | 36 +++--- Libraries/LibGfx/AffineTransform.cpp | 10 +- Libraries/LibGfx/AffineTransform.h | 6 +- Libraries/LibGfx/Bitmap.cpp | 16 +-- Libraries/LibGfx/Bitmap.h | 24 ++-- Libraries/LibGfx/CharacterBitmap.h | 4 +- Libraries/LibGfx/DisjointRectSet.cpp | 4 +- Libraries/LibGfx/DisjointRectSet.h | 6 +- Libraries/LibGfx/FloatPoint.h | 4 +- Libraries/LibGfx/FloatRect.h | 4 +- Libraries/LibGfx/FloatSize.h | 4 +- Libraries/LibGfx/Font.h | 6 +- Libraries/LibGfx/Forward.h | 6 +- Libraries/LibGfx/GIFLoader.cpp | 2 +- Libraries/LibGfx/GIFLoader.h | 2 +- Libraries/LibGfx/ImageDecoder.h | 4 +- Libraries/LibGfx/PNGLoader.cpp | 2 +- Libraries/LibGfx/PNGLoader.h | 2 +- Libraries/LibGfx/Painter.cpp | 144 +++++++++++----------- Libraries/LibGfx/Painter.h | 88 ++++++------- Libraries/LibGfx/Point.cpp | 8 +- Libraries/LibGfx/Point.h | 54 ++++---- Libraries/LibGfx/Rect.cpp | 32 ++--- Libraries/LibGfx/Rect.h | 92 +++++++------- Libraries/LibGfx/ShareableBitmap.cpp | 2 +- Libraries/LibGfx/ShareableBitmap.h | 4 +- Libraries/LibGfx/Size.cpp | 8 +- Libraries/LibGfx/Size.h | 20 +-- Libraries/LibGfx/StylePainter.cpp | 22 ++-- Libraries/LibGfx/StylePainter.h | 14 +-- Libraries/LibGfx/Triangle.h | 16 +-- Libraries/LibVT/TerminalWidget.cpp | 18 +-- Libraries/LibVT/TerminalWidget.h | 12 +- Libraries/LibWeb/DOM/CanvasRenderingContext2D.cpp | 2 +- Libraries/LibWeb/DOM/HTMLCanvasElement.cpp | 2 +- Libraries/LibWeb/DOM/ImageData.cpp | 2 +- Libraries/LibWeb/Frame/EventHandler.cpp | 8 +- Libraries/LibWeb/Frame/EventHandler.h | 6 +- Libraries/LibWeb/Frame/Frame.cpp | 10 +- Libraries/LibWeb/Frame/Frame.h | 18 +-- Libraries/LibWeb/Layout/LayoutBlock.cpp | 2 +- Libraries/LibWeb/Layout/LayoutBlock.h | 2 +- Libraries/LibWeb/Layout/LayoutBox.cpp | 2 +- Libraries/LibWeb/Layout/LayoutBox.h | 2 +- Libraries/LibWeb/Layout/LayoutDocument.cpp | 2 +- Libraries/LibWeb/Layout/LayoutDocument.h | 2 +- Libraries/LibWeb/Layout/LayoutListItemMarker.cpp | 2 +- Libraries/LibWeb/Layout/LayoutNode.cpp | 2 +- Libraries/LibWeb/Layout/LayoutNode.h | 2 +- Libraries/LibWeb/Page.cpp | 6 +- Libraries/LibWeb/Page.h | 12 +- Libraries/LibWeb/PageView.cpp | 6 +- Libraries/LibWeb/PageView.h | 8 +- Libraries/LibWeb/RenderingContext.h | 6 +- 106 files changed, 693 insertions(+), 693 deletions(-) (limited to 'Libraries') 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, OwnPtradjusted_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 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 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