From 116cf92156090bb3f5c15d5be145f1283884d65d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 10 Jun 2020 10:57:59 +0200 Subject: [PATCH] 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. --- Applications/Browser/BookmarksBarWidget.cpp | 2 +- Applications/Browser/Tab.cpp | 2 +- Applications/Browser/Tab.h | 2 +- Applications/Calendar/CalendarWidget.cpp | 8 +- .../DisplaySettings/DisplaySettings.cpp | 6 +- .../DisplaySettings/DisplaySettings.h | 2 +- .../DisplaySettings/MonitorWidget.cpp | 8 +- Applications/DisplaySettings/MonitorWidget.h | 8 +- Applications/FontEditor/GlyphEditorWidget.cpp | 2 +- Applications/FontEditor/GlyphMapWidget.cpp | 8 +- Applications/FontEditor/GlyphMapWidget.h | 2 +- Applications/HexEditor/HexEditor.cpp | 10 +- Applications/KeyboardMapper/KeyButton.cpp | 2 +- .../KeyboardMapper/KeyboardMapperWidget.cpp | 2 +- Applications/Piano/KeysWidget.cpp | 10 +- Applications/Piano/KeysWidget.h | 2 +- Applications/Piano/RollWidget.cpp | 4 +- Applications/Piano/SamplerWidget.cpp | 8 +- Applications/Piano/WaveWidget.cpp | 8 +- Applications/PixelPaint/BucketTool.cpp | 4 +- .../PixelPaint/CreateNewLayerDialog.cpp | 2 +- .../PixelPaint/CreateNewLayerDialog.h | 6 +- Applications/PixelPaint/EllipseTool.cpp | 6 +- Applications/PixelPaint/EllipseTool.h | 6 +- Applications/PixelPaint/EraseTool.cpp | 8 +- Applications/PixelPaint/EraseTool.h | 2 +- Applications/PixelPaint/Image.cpp | 6 +- Applications/PixelPaint/Image.h | 12 +- Applications/PixelPaint/ImageEditor.cpp | 24 +-- Applications/PixelPaint/ImageEditor.h | 18 +-- Applications/PixelPaint/Layer.cpp | 4 +- Applications/PixelPaint/Layer.h | 16 +- Applications/PixelPaint/LayerListWidget.cpp | 6 +- Applications/PixelPaint/LayerListWidget.h | 10 +- Applications/PixelPaint/LineTool.cpp | 2 +- Applications/PixelPaint/LineTool.h | 4 +- Applications/PixelPaint/MoveTool.h | 4 +- Applications/PixelPaint/PaletteWidget.cpp | 2 +- Applications/PixelPaint/PenTool.cpp | 2 +- Applications/PixelPaint/PenTool.h | 2 +- Applications/PixelPaint/RectangleTool.cpp | 6 +- Applications/PixelPaint/RectangleTool.h | 6 +- Applications/PixelPaint/SprayTool.h | 2 +- Applications/QuickShow/QSWidget.cpp | 4 +- Applications/QuickShow/QSWidget.h | 4 +- Applications/SoundPlayer/SampleWidget.cpp | 4 +- Applications/SystemMonitor/GraphWidget.cpp | 6 +- .../SystemMonitor/ProcessMemoryMapWidget.cpp | 2 +- Applications/SystemMonitor/main.cpp | 2 +- Applications/Welcome/main.cpp | 2 +- Demos/Cube/Cube.cpp | 2 +- Demos/Eyes/EyesWidget.cpp | 10 +- Demos/Eyes/EyesWidget.h | 4 +- Demos/Mouse/main.cpp | 8 +- DevTools/HackStudio/CursorTool.cpp | 6 +- DevTools/HackStudio/CursorTool.h | 12 +- DevTools/HackStudio/Editor.cpp | 4 +- DevTools/HackStudio/Editor.h | 4 +- DevTools/VisualBuilder/VBForm.cpp | 6 +- DevTools/VisualBuilder/VBForm.h | 6 +- DevTools/VisualBuilder/VBWidget.cpp | 8 +- DevTools/VisualBuilder/VBWidget.h | 12 +- Games/Minesweeper/Field.cpp | 12 +- Games/Minesweeper/Field.h | 4 +- Games/Snake/SnakeGame.cpp | 16 +- Games/Snake/SnakeGame.h | 6 +- Games/Solitaire/Card.cpp | 6 +- Games/Solitaire/Card.h | 12 +- Games/Solitaire/CardStack.cpp | 6 +- Games/Solitaire/CardStack.h | 14 +- Games/Solitaire/SolitaireWidget.h | 2 +- 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 +- .../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 +- .../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 +- .../NotificationServer/NotificationWindow.cpp | 8 +- .../NotificationServer/NotificationWindow.h | 4 +- Services/SystemMenu/ShutdownDialog.cpp | 2 +- Services/Taskbar/TaskbarButton.cpp | 8 +- Services/Taskbar/TaskbarWindow.cpp | 6 +- Services/Taskbar/TaskbarWindow.h | 2 +- Services/Taskbar/WindowList.h | 6 +- Services/WindowServer/AppletManager.cpp | 6 +- Services/WindowServer/AppletManager.h | 2 +- Services/WindowServer/Button.cpp | 2 +- Services/WindowServer/Button.h | 10 +- Services/WindowServer/ClientConnection.cpp | 6 +- Services/WindowServer/ClientConnection.h | 2 +- Services/WindowServer/Compositor.cpp | 34 ++--- Services/WindowServer/Compositor.h | 16 +- Services/WindowServer/Cursor.cpp | 4 +- Services/WindowServer/Cursor.h | 12 +- Services/WindowServer/Event.h | 18 +-- Services/WindowServer/Menu.cpp | 36 ++--- Services/WindowServer/Menu.h | 18 +-- Services/WindowServer/MenuItem.cpp | 2 +- Services/WindowServer/MenuItem.h | 6 +- Services/WindowServer/MenuManager.cpp | 4 +- Services/WindowServer/MenuManager.h | 2 +- Services/WindowServer/Screen.h | 8 +- Services/WindowServer/Window.cpp | 20 +-- Services/WindowServer/Window.h | 58 +++---- Services/WindowServer/WindowClient.ipc | 24 +-- Services/WindowServer/WindowFrame.cpp | 26 ++-- Services/WindowServer/WindowFrame.h | 10 +- Services/WindowServer/WindowManager.cpp | 30 ++-- Services/WindowServer/WindowManager.h | 30 ++-- Services/WindowServer/WindowServer.ipc | 30 ++-- Services/WindowServer/WindowSwitcher.cpp | 6 +- Services/WindowServer/WindowSwitcher.h | 4 +- 212 files changed, 1144 insertions(+), 1144 deletions(-) diff --git a/Applications/Browser/BookmarksBarWidget.cpp b/Applications/Browser/BookmarksBarWidget.cpp index da78f178b8..0f9240d345 100644 --- a/Applications/Browser/BookmarksBarWidget.cpp +++ b/Applications/Browser/BookmarksBarWidget.cpp @@ -120,7 +120,7 @@ void BookmarksBarWidget::did_update_model() auto title = model()->data(model()->index(item_index, 0)).to_string(); auto url = model()->data(model()->index(item_index, 1)).to_string(); - Gfx::Rect rect { width, 0, font().width(title) + 32, height() }; + Gfx::IntRect rect { width, 0, font().width(title) + 32, height() }; auto& button = add(); m_bookmarks.append(button); diff --git a/Applications/Browser/Tab.cpp b/Applications/Browser/Tab.cpp index c3f7ddba06..76b10a6cb6 100644 --- a/Applications/Browser/Tab.cpp +++ b/Applications/Browser/Tab.cpp @@ -409,7 +409,7 @@ void Tab::did_become_active() GUI::Application::the().set_menubar(m_menubar); } -void Tab::context_menu_requested(const Gfx::Point& screen_position) +void Tab::context_menu_requested(const Gfx::IntPoint& screen_position) { m_tab_context_menu->popup(screen_position); } diff --git a/Applications/Browser/Tab.h b/Applications/Browser/Tab.h index c473d16839..6a7f04c143 100644 --- a/Applications/Browser/Tab.h +++ b/Applications/Browser/Tab.h @@ -43,7 +43,7 @@ public: void load(const URL&); void did_become_active(); - void context_menu_requested(const Gfx::Point& screen_position); + void context_menu_requested(const Gfx::IntPoint& screen_position); Function on_title_change; Function on_tab_open_request; diff --git a/Applications/Calendar/CalendarWidget.cpp b/Applications/Calendar/CalendarWidget.cpp index 3f127e4140..9d44092a7d 100644 --- a/Applications/Calendar/CalendarWidget.cpp +++ b/Applications/Calendar/CalendarWidget.cpp @@ -249,16 +249,16 @@ void CalendarWidget::CalendarTile::paint_event(GUI::PaintEvent& event) painter.draw_line(frame_inner_rect().top_left(), frame_inner_rect().top_right(), Color::NamedColor::Black); painter.draw_line(frame_inner_rect().bottom_left(), frame_inner_rect().bottom_right(), Color::NamedColor::Black); - Gfx::Rect day_rect = Gfx::Rect(frame_inner_rect().x(), frame_inner_rect().y(), frame_inner_rect().width(), font().glyph_height() + 4); + Gfx::IntRect day_rect = Gfx::IntRect(frame_inner_rect().x(), frame_inner_rect().y(), frame_inner_rect().width(), font().glyph_height() + 4); int weekday_characters_width = (font().glyph_width('0') * (m_weekday_name.length() + 1)) + 4; if (m_display_weekday_name && (frame_inner_rect().height() > (font().glyph_height() + 4) * 2) && (frame_inner_rect().width() > weekday_characters_width)) { - auto weekday_rect = Gfx::Rect(frame_inner_rect().x(), frame_inner_rect().y(), frame_inner_rect().width(), font().glyph_height() + 4); + auto weekday_rect = Gfx::IntRect(frame_inner_rect().x(), frame_inner_rect().y(), frame_inner_rect().width(), font().glyph_height() + 4); weekday_rect.set_top(frame_inner_rect().y() + 2); painter.draw_text(weekday_rect, m_weekday_name, Gfx::Font::default_bold_font(), Gfx::TextAlignment::Center, palette().base_text()); day_rect.set_y(frame_inner_rect().y() + 15); } else { - day_rect = Gfx::Rect(frame_inner_rect().x(), frame_inner_rect().y(), frame_inner_rect().width(), font().glyph_height() + 4); + day_rect = Gfx::IntRect(frame_inner_rect().x(), frame_inner_rect().y(), frame_inner_rect().width(), font().glyph_height() + 4); day_rect.set_y(frame_inner_rect().y() + 4); } @@ -266,7 +266,7 @@ void CalendarWidget::CalendarTile::paint_event(GUI::PaintEvent& event) auto display_date = (m_date_time.day() == 1 && frame_inner_rect().width() > highlight_rect_width) ? m_display_date : String::number(m_date_time.day()); if (m_calendar.is_today(m_date_time)) { - auto highlight_rect = Gfx::Rect(day_rect.width() / 2 - (highlight_rect_width / 2), day_rect.y(), highlight_rect_width, font().glyph_height() + 4); + auto highlight_rect = Gfx::IntRect(day_rect.width() / 2 - (highlight_rect_width / 2), day_rect.y(), highlight_rect_width, font().glyph_height() + 4); painter.draw_rect(highlight_rect, palette().base_text()); painter.draw_text(day_rect, display_date, Gfx::Font::default_bold_font(), Gfx::TextAlignment::Center, palette().base_text()); } else diff --git a/Applications/DisplaySettings/DisplaySettings.cpp b/Applications/DisplaySettings/DisplaySettings.cpp index aa38bbc2a8..303b20f8b3 100644 --- a/Applications/DisplaySettings/DisplaySettings.cpp +++ b/Applications/DisplaySettings/DisplaySettings.cpp @@ -198,7 +198,7 @@ void DisplaySettingsWidget::create_frame() m_resolution_combo->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_resolution_combo->set_preferred_size(0, 22); m_resolution_combo->set_only_allow_values_from_model(true); - m_resolution_combo->set_model(*ItemListModel::create(m_resolutions)); + m_resolution_combo->set_model(*ItemListModel::create(m_resolutions)); m_resolution_combo->on_change = [this](auto&, const GUI::ModelIndex& index) { this->m_monitor_widget->set_desktop_resolution(m_resolutions.at(index.row())); this->m_monitor_widget->update(); @@ -301,7 +301,7 @@ void DisplaySettingsWidget::load_current_settings() } /// Resolution //////////////////////////////////////////////////////////////////////////////// - Gfx::Size find_size; + Gfx::IntSize find_size; bool okay = false; // Let's attempt to find the current resolution and select it! @@ -318,7 +318,7 @@ void DisplaySettingsWidget::load_current_settings() } size_t index = m_resolutions.find_first_index(find_size).value_or(0); - Gfx::Size m_current_resolution = m_resolutions.at(index); + Gfx::IntSize m_current_resolution = m_resolutions.at(index); m_monitor_widget->set_desktop_resolution(m_current_resolution); m_resolution_combo->set_selected_index(index); diff --git a/Applications/DisplaySettings/DisplaySettings.h b/Applications/DisplaySettings/DisplaySettings.h index d0215c7887..d66fa6ff9c 100644 --- a/Applications/DisplaySettings/DisplaySettings.h +++ b/Applications/DisplaySettings/DisplaySettings.h @@ -47,7 +47,7 @@ private: Vector m_wallpapers; Vector m_modes; - Vector m_resolutions; + Vector m_resolutions; RefPtr m_root_widget; RefPtr m_monitor_widget; diff --git a/Applications/DisplaySettings/MonitorWidget.cpp b/Applications/DisplaySettings/MonitorWidget.cpp index 1bd44888bc..71d6651593 100644 --- a/Applications/DisplaySettings/MonitorWidget.cpp +++ b/Applications/DisplaySettings/MonitorWidget.cpp @@ -54,12 +54,12 @@ String MonitorWidget::wallpaper_mode() return m_desktop_wallpaper_mode; } -void MonitorWidget::set_desktop_resolution(Gfx::Size resolution) +void MonitorWidget::set_desktop_resolution(Gfx::IntSize resolution) { m_desktop_resolution = resolution; } -Gfx::Size MonitorWidget::desktop_resolution() +Gfx::IntSize MonitorWidget::desktop_resolution() { return m_desktop_resolution; } @@ -76,7 +76,7 @@ Gfx::Color MonitorWidget::background_color() void MonitorWidget::paint_event(GUI::PaintEvent& event) { - Gfx::Rect screen_rect = { 0, 0, m_desktop_resolution.width(), m_desktop_resolution.height() }; + Gfx::IntRect screen_rect = { 0, 0, m_desktop_resolution.width(), m_desktop_resolution.height() }; auto screen_bitmap = Gfx::Bitmap::create(m_monitor_bitmap->format(), m_desktop_resolution); GUI::Painter screen_painter(*screen_bitmap); screen_painter.fill_rect(screen_rect, m_desktop_color); @@ -85,7 +85,7 @@ void MonitorWidget::paint_event(GUI::PaintEvent& event) if (m_desktop_wallpaper_mode == "simple") { screen_painter.blit({ 0, 0 }, *m_desktop_wallpaper_bitmap, m_desktop_wallpaper_bitmap->rect()); } else if (m_desktop_wallpaper_mode == "center") { - Gfx::Point offset { screen_rect.width() / 2 - m_desktop_wallpaper_bitmap->size().width() / 2, screen_rect.height() / 2 - m_desktop_wallpaper_bitmap->size().height() / 2 }; + Gfx::IntPoint offset { screen_rect.width() / 2 - m_desktop_wallpaper_bitmap->size().width() / 2, screen_rect.height() / 2 - m_desktop_wallpaper_bitmap->size().height() / 2 }; screen_painter.blit_offset(screen_rect.location(), *m_desktop_wallpaper_bitmap, screen_rect, offset); } else if (m_desktop_wallpaper_mode == "tile") { screen_painter.draw_tiled_bitmap(screen_bitmap->rect(), *m_desktop_wallpaper_bitmap); diff --git a/Applications/DisplaySettings/MonitorWidget.h b/Applications/DisplaySettings/MonitorWidget.h index f77fe67eb9..fa0a5dbbf8 100644 --- a/Applications/DisplaySettings/MonitorWidget.h +++ b/Applications/DisplaySettings/MonitorWidget.h @@ -41,8 +41,8 @@ public: void set_wallpaper_mode(String mode); String wallpaper_mode(); - void set_desktop_resolution(Gfx::Size resolution); - Gfx::Size desktop_resolution(); + void set_desktop_resolution(Gfx::IntSize resolution); + Gfx::IntSize desktop_resolution(); void set_background_color(Gfx::Color background_color); Gfx::Color background_color(); @@ -50,12 +50,12 @@ public: private: virtual void paint_event(GUI::PaintEvent& event) override; - Gfx::Rect m_monitor_rect; + Gfx::IntRect m_monitor_rect; RefPtr m_monitor_bitmap; String m_desktop_wallpaper_path; RefPtr m_desktop_wallpaper_bitmap; String m_desktop_wallpaper_mode; - Gfx::Size m_desktop_resolution; + Gfx::IntSize m_desktop_resolution; Gfx::Color m_desktop_color; }; diff --git a/Applications/FontEditor/GlyphEditorWidget.cpp b/Applications/FontEditor/GlyphEditorWidget.cpp index e3db6ba2a6..d1fcb13dd1 100644 --- a/Applications/FontEditor/GlyphEditorWidget.cpp +++ b/Applications/FontEditor/GlyphEditorWidget.cpp @@ -68,7 +68,7 @@ void GlyphEditorWidget::paint_event(GUI::PaintEvent& event) for (int y = 0; y < font().glyph_height(); ++y) { for (int x = 0; x < font().max_glyph_width(); ++x) { - Gfx::Rect rect { x * m_scale, y * m_scale, m_scale, m_scale }; + Gfx::IntRect rect { x * m_scale, y * m_scale, m_scale, m_scale }; if (x >= font().glyph_width(m_glyph)) { painter.fill_rect(rect, palette().threed_shadow1()); } else { diff --git a/Applications/FontEditor/GlyphMapWidget.cpp b/Applications/FontEditor/GlyphMapWidget.cpp index e252e617cc..9ec1355f4c 100644 --- a/Applications/FontEditor/GlyphMapWidget.cpp +++ b/Applications/FontEditor/GlyphMapWidget.cpp @@ -60,11 +60,11 @@ void GlyphMapWidget::set_selected_glyph(int glyph) update(); } -Gfx::Rect GlyphMapWidget::get_outer_rect(int glyph) const +Gfx::IntRect GlyphMapWidget::get_outer_rect(int glyph) const { int row = glyph / columns(); int column = glyph % columns(); - return Gfx::Rect { + return Gfx::IntRect { column * (font().max_glyph_width() + m_horizontal_spacing) + 1, row * (font().glyph_height() + m_vertical_spacing) + 1, font().max_glyph_width() + m_horizontal_spacing, @@ -89,8 +89,8 @@ void GlyphMapWidget::paint_event(GUI::PaintEvent& event) painter.fill_rect(frame_inner_rect(), palette().base()); for (int glyph = 0; glyph < m_glyph_count; ++glyph) { - Gfx::Rect outer_rect = get_outer_rect(glyph); - Gfx::Rect inner_rect( + Gfx::IntRect outer_rect = get_outer_rect(glyph); + Gfx::IntRect inner_rect( outer_rect.x() + m_horizontal_spacing / 2, outer_rect.y() + m_vertical_spacing / 2, font().max_glyph_width(), diff --git a/Applications/FontEditor/GlyphMapWidget.h b/Applications/FontEditor/GlyphMapWidget.h index bf24b7612d..e8583d1b6a 100644 --- a/Applications/FontEditor/GlyphMapWidget.h +++ b/Applications/FontEditor/GlyphMapWidget.h @@ -58,7 +58,7 @@ private: virtual void mousedown_event(GUI::MouseEvent&) override; virtual void keydown_event(GUI::KeyEvent&) override; - Gfx::Rect get_outer_rect(int glyph) const; + Gfx::IntRect get_outer_rect(int glyph) const; RefPtr m_font; int m_glyph_count; diff --git a/Applications/HexEditor/HexEditor.cpp b/Applications/HexEditor/HexEditor.cpp index 31ac165966..e192cd7974 100644 --- a/Applications/HexEditor/HexEditor.cpp +++ b/Applications/HexEditor/HexEditor.cpp @@ -336,7 +336,7 @@ void HexEditor::scroll_position_into_view(int position) { int y = position / bytes_per_row(); int x = position % bytes_per_row(); - Gfx::Rect rect { + Gfx::IntRect rect { frame_thickness() + offset_margin_width() + (x * (character_width() * 3)) + 10, frame_thickness() + 5 + (y * line_height()), (character_width() * 3), @@ -490,7 +490,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event) painter.translate(frame_thickness(), frame_thickness()); painter.translate(-horizontal_scrollbar().value(), -vertical_scrollbar().value()); - Gfx::Rect offset_clip_rect { + Gfx::IntRect offset_clip_rect { 0, vertical_scrollbar().value(), 85, @@ -510,7 +510,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event) // paint offsets for (int i = min_row; i < max_row; i++) { - Gfx::Rect side_offset_rect { + Gfx::IntRect side_offset_rect { frame_thickness() + 5, frame_thickness() + 5 + (i * line_height()), width() - width_occupied_by_vertical_scrollbar(), @@ -548,7 +548,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event) } } - Gfx::Rect hex_display_rect { + Gfx::IntRect hex_display_rect { frame_thickness() + offset_margin_width() + (j * (character_width() * 3)) + 10, frame_thickness() + 5 + (i * line_height()), (character_width() * 3), @@ -565,7 +565,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event) auto line = String::format("%02X", m_buffer[byte_position]); painter.draw_text(hex_display_rect, line, Gfx::TextAlignment::TopLeft, text_color); - Gfx::Rect text_display_rect { + Gfx::IntRect text_display_rect { frame_thickness() + offset_margin_width() + (bytes_per_row() * (character_width() * 3)) + (j * character_width()) + 20, frame_thickness() + 5 + (i * line_height()), character_width(), diff --git a/Applications/KeyboardMapper/KeyButton.cpp b/Applications/KeyboardMapper/KeyButton.cpp index 78e8195cca..6e1219be81 100644 --- a/Applications/KeyboardMapper/KeyButton.cpp +++ b/Applications/KeyboardMapper/KeyButton.cpp @@ -50,7 +50,7 @@ void KeyButton::paint_event(GUI::PaintEvent& event) painter.fill_rect(content_rect, Color::from_rgb(0x8C7272)); if (!text().is_empty()) { - Gfx::Rect text_rect { 0, 0, font.width(text()), font.glyph_height() }; + Gfx::IntRect text_rect { 0, 0, font.width(text()), font.glyph_height() }; text_rect.align_within(content_rect, Gfx::TextAlignment::Center); auto clipped_rect = rect().intersected(this->rect()); diff --git a/Applications/KeyboardMapper/KeyboardMapperWidget.cpp b/Applications/KeyboardMapper/KeyboardMapperWidget.cpp index ad3876d2fd..d775c53a4e 100644 --- a/Applications/KeyboardMapper/KeyboardMapperWidget.cpp +++ b/Applications/KeyboardMapper/KeyboardMapperWidget.cpp @@ -58,7 +58,7 @@ void KeyboardMapperWidget::create_frame() m_keys.resize(KEY_COUNT); for (unsigned i = 0; i < KEY_COUNT; i++) { - Gfx::Rect rect = { keys[i].x, keys[i].y, keys[i].width, keys[i].height }; + Gfx::IntRect rect = { keys[i].x, keys[i].y, keys[i].width, keys[i].height }; auto& tmp_button = main_widget.add(); tmp_button.set_relative_rect(rect); diff --git a/Applications/Piano/KeysWidget.cpp b/Applications/Piano/KeysWidget.cpp index e757ef57c4..c3428120d6 100644 --- a/Applications/Piano/KeysWidget.cpp +++ b/Applications/Piano/KeysWidget.cpp @@ -179,7 +179,7 @@ void KeysWidget::paint_event(GUI::PaintEvent& event) int x = 0; int i = 0; for (;;) { - Gfx::Rect rect(x, 0, white_key_width, frame_inner_rect().height()); + Gfx::IntRect rect(x, 0, white_key_width, frame_inner_rect().height()); painter.fill_rect(rect, m_key_on[note] ? note_pressed_color : Color::White); painter.draw_rect(rect, Color::Black); if (i < white_key_labels_count) { @@ -201,7 +201,7 @@ void KeysWidget::paint_event(GUI::PaintEvent& event) x = white_key_width - black_key_x_offset; i = 0; for (;;) { - Gfx::Rect rect(x, 0, black_key_width, black_key_height); + Gfx::IntRect rect(x, 0, black_key_width, black_key_height); painter.fill_rect(rect, m_key_on[note] ? note_pressed_color : Color::Black); painter.draw_rect(rect, Color::Black); if (i < black_key_labels_count) { @@ -245,7 +245,7 @@ static inline int note_from_white_keys(int white_keys) return note; } -int KeysWidget::note_for_event_position(const Gfx::Point& a_point) const +int KeysWidget::note_for_event_position(const Gfx::IntPoint& a_point) const { if (!frame_inner_rect().contains(a_point)) return -1; @@ -259,7 +259,7 @@ int KeysWidget::note_for_event_position(const Gfx::Point& a_point) const bool black_key_on_left = note != 0 && key_pattern[(note - 1) % notes_per_octave] == Black; if (black_key_on_left) { int black_key_x = (white_keys * white_key_width) - black_key_x_offset; - Gfx::Rect black_key(black_key_x, 0, black_key_width, black_key_height); + Gfx::IntRect black_key(black_key_x, 0, black_key_width, black_key_height); if (black_key.contains(point)) return note - 1; } @@ -267,7 +267,7 @@ int KeysWidget::note_for_event_position(const Gfx::Point& a_point) const bool black_key_on_right = key_pattern[(note + 1) % notes_per_octave] == Black; if (black_key_on_right) { int black_key_x = ((white_keys + 1) * white_key_width) - black_key_x_offset; - Gfx::Rect black_key(black_key_x, 0, black_key_width, black_key_height); + Gfx::IntRect black_key(black_key_x, 0, black_key_width, black_key_height); if (black_key.contains(point)) return note + 1; } diff --git a/Applications/Piano/KeysWidget.h b/Applications/Piano/KeysWidget.h index ee46e2b1a2..59bb6e5a4a 100644 --- a/Applications/Piano/KeysWidget.h +++ b/Applications/Piano/KeysWidget.h @@ -50,7 +50,7 @@ private: virtual void mouseup_event(GUI::MouseEvent&) override; virtual void mousemove_event(GUI::MouseEvent&) override; - int note_for_event_position(const Gfx::Point&) const; + int note_for_event_position(const Gfx::IntPoint&) const; AudioEngine& m_audio_engine; diff --git a/Applications/Piano/RollWidget.cpp b/Applications/Piano/RollWidget.cpp index b46989b0f1..d9968225d9 100644 --- a/Applications/Piano/RollWidget.cpp +++ b/Applications/Piano/RollWidget.cpp @@ -98,7 +98,7 @@ void RollWidget::paint_event(GUI::PaintEvent& event) int x_pos = x * m_note_width; int next_x_pos = (x + 1) * m_note_width; int distance_to_next_x = next_x_pos - x_pos; - Gfx::Rect rect(x_pos, y_pos, distance_to_next_x, note_height); + Gfx::IntRect rect(x_pos, y_pos, distance_to_next_x, note_height); if (key_pattern[key_pattern_index] == Black) painter.fill_rect(rect, Color::LightGray); @@ -128,7 +128,7 @@ void RollWidget::paint_event(GUI::PaintEvent& event) int y = ((note_count - 1) - note) * note_height; int height = note_height; - Gfx::Rect rect(x, y, width, height); + Gfx::IntRect rect(x, y, width, height); painter.fill_rect(rect, note_pressed_color); painter.draw_rect(rect, Color::Black); } diff --git a/Applications/Piano/SamplerWidget.cpp b/Applications/Piano/SamplerWidget.cpp index 64817fc32a..f3f116ebe4 100644 --- a/Applications/Piano/SamplerWidget.cpp +++ b/Applications/Piano/SamplerWidget.cpp @@ -74,12 +74,12 @@ void WaveEditor::paint_event(GUI::PaintEvent& event) int left_y = sample_to_y(recorded_sample[x].left); int right_y = sample_to_y(recorded_sample[x].right); - Gfx::Point left_point1(prev_x * width_scale, left_prev_y); - Gfx::Point left_point2(x * width_scale, left_y); + Gfx::IntPoint left_point1(prev_x * width_scale, left_prev_y); + Gfx::IntPoint left_point2(x * width_scale, left_y); painter.draw_line(left_point1, left_point2, left_wave_colors[RecordedSample]); - Gfx::Point right_point1(prev_x * width_scale, right_prev_y); - Gfx::Point right_point2(x * width_scale, right_y); + Gfx::IntPoint right_point1(prev_x * width_scale, right_prev_y); + Gfx::IntPoint right_point2(x * width_scale, right_y); painter.draw_line(right_point1, right_point2, right_wave_colors[RecordedSample]); prev_x = x; diff --git a/Applications/Piano/WaveWidget.cpp b/Applications/Piano/WaveWidget.cpp index 43fdf62d76..9a8cdebc94 100644 --- a/Applications/Piano/WaveWidget.cpp +++ b/Applications/Piano/WaveWidget.cpp @@ -71,12 +71,12 @@ void WaveWidget::paint_event(GUI::PaintEvent& event) int y_left = sample_to_y(buffer[x].left); int y_right = sample_to_y(buffer[x].right); - Gfx::Point point1_left(prev_x * width_scale, prev_y_left); - Gfx::Point point2_left(x * width_scale, y_left); + Gfx::IntPoint point1_left(prev_x * width_scale, prev_y_left); + Gfx::IntPoint point2_left(x * width_scale, y_left); painter.draw_line(point1_left, point2_left, left_wave_color); - Gfx::Point point1_right(prev_x * width_scale, prev_y_right); - Gfx::Point point2_right(x * width_scale, y_right); + Gfx::IntPoint point1_right(prev_x * width_scale, prev_y_right); + Gfx::IntPoint point2_right(x * width_scale, y_right); painter.draw_line(point1_right, point2_right, right_wave_color); prev_x = x; diff --git a/Applications/PixelPaint/BucketTool.cpp b/Applications/PixelPaint/BucketTool.cpp index 9795f5b440..92f3ab2aa8 100644 --- a/Applications/PixelPaint/BucketTool.cpp +++ b/Applications/PixelPaint/BucketTool.cpp @@ -43,7 +43,7 @@ BucketTool::~BucketTool() { } -static void flood_fill(Gfx::Bitmap& bitmap, const Gfx::Point& start_position, Color target_color, Color fill_color) +static void flood_fill(Gfx::Bitmap& bitmap, const Gfx::IntPoint& start_position, Color target_color, Color fill_color) { ASSERT(bitmap.bpp() == 32); @@ -53,7 +53,7 @@ static void flood_fill(Gfx::Bitmap& bitmap, const Gfx::Point& start_position, Co if (!bitmap.rect().contains(start_position)) return; - Queue queue; + Queue queue; queue.enqueue(start_position); while (!queue.is_empty()) { auto position = queue.dequeue(); diff --git a/Applications/PixelPaint/CreateNewLayerDialog.cpp b/Applications/PixelPaint/CreateNewLayerDialog.cpp index 18d57cd6ce..fdbcf37fd2 100644 --- a/Applications/PixelPaint/CreateNewLayerDialog.cpp +++ b/Applications/PixelPaint/CreateNewLayerDialog.cpp @@ -33,7 +33,7 @@ namespace PixelPaint { -CreateNewLayerDialog::CreateNewLayerDialog(const Gfx::Size& suggested_size, GUI::Window* parent_window) +CreateNewLayerDialog::CreateNewLayerDialog(const Gfx::IntSize& suggested_size, GUI::Window* parent_window) : Dialog(parent_window) { set_title("Create new layer"); diff --git a/Applications/PixelPaint/CreateNewLayerDialog.h b/Applications/PixelPaint/CreateNewLayerDialog.h index a42b4e7124..2f9334a7c1 100644 --- a/Applications/PixelPaint/CreateNewLayerDialog.h +++ b/Applications/PixelPaint/CreateNewLayerDialog.h @@ -33,13 +33,13 @@ namespace PixelPaint { class CreateNewLayerDialog final : public GUI::Dialog { C_OBJECT(CreateNewLayerDialog); public: - const Gfx::Size& layer_size() const { return m_layer_size; } + const Gfx::IntSize& layer_size() const { return m_layer_size; } const String& layer_name() const { return m_layer_name; } private: - CreateNewLayerDialog(const Gfx::Size& suggested_size, GUI::Window* parent_window); + CreateNewLayerDialog(const Gfx::IntSize& suggested_size, GUI::Window* parent_window); - Gfx::Size m_layer_size; + Gfx::IntSize m_layer_size; String m_layer_name; RefPtr m_name_textbox; diff --git a/Applications/PixelPaint/EllipseTool.cpp b/Applications/PixelPaint/EllipseTool.cpp index 9a24c07745..0997567cf5 100644 --- a/Applications/PixelPaint/EllipseTool.cpp +++ b/Applications/PixelPaint/EllipseTool.cpp @@ -43,7 +43,7 @@ EllipseTool::~EllipseTool() { } -void EllipseTool::draw_using(GUI::Painter& painter, const Gfx::Rect& ellipse_intersecting_rect) +void EllipseTool::draw_using(GUI::Painter& painter, const Gfx::IntRect& ellipse_intersecting_rect) { switch (m_mode) { case Mode::Outline: @@ -72,7 +72,7 @@ void EllipseTool::on_mouseup(Layer& layer, GUI::MouseEvent& event, GUI::MouseEve { if (event.button() == m_drawing_button) { GUI::Painter painter(layer.bitmap()); - draw_using(painter, Gfx::Rect::from_two_points(m_ellipse_start_position, m_ellipse_end_position)); + draw_using(painter, Gfx::IntRect::from_two_points(m_ellipse_start_position, m_ellipse_end_position)); m_drawing_button = GUI::MouseButton::None; m_editor->update(); } @@ -96,7 +96,7 @@ void EllipseTool::on_second_paint(const Layer& layer, GUI::PaintEvent& event) painter.add_clip_rect(event.rect()); auto preview_start = m_editor->layer_position_to_editor_position(layer, m_ellipse_start_position).to_int_point(); auto preview_end = m_editor->layer_position_to_editor_position(layer, m_ellipse_end_position).to_int_point(); - draw_using(painter, Gfx::Rect::from_two_points(preview_start, preview_end)); + draw_using(painter, Gfx::IntRect::from_two_points(preview_start, preview_end)); } void EllipseTool::on_keydown(GUI::KeyEvent& event) diff --git a/Applications/PixelPaint/EllipseTool.h b/Applications/PixelPaint/EllipseTool.h index 8169bc2c8e..8462f38d6f 100644 --- a/Applications/PixelPaint/EllipseTool.h +++ b/Applications/PixelPaint/EllipseTool.h @@ -51,11 +51,11 @@ private: }; virtual const char* class_name() const override { return "EllipseTool"; } - void draw_using(GUI::Painter&, const Gfx::Rect&); + void draw_using(GUI::Painter&, const Gfx::IntRect&); GUI::MouseButton m_drawing_button { GUI::MouseButton::None }; - Gfx::Point m_ellipse_start_position; - Gfx::Point m_ellipse_end_position; + Gfx::IntPoint m_ellipse_start_position; + Gfx::IntPoint m_ellipse_end_position; RefPtr m_context_menu; int m_thickness { 1 }; GUI::ActionGroup m_thickness_actions; diff --git a/Applications/PixelPaint/EraseTool.cpp b/Applications/PixelPaint/EraseTool.cpp index 6efab8c13f..77b76c52d3 100644 --- a/Applications/PixelPaint/EraseTool.cpp +++ b/Applications/PixelPaint/EraseTool.cpp @@ -42,21 +42,21 @@ EraseTool::~EraseTool() { } -Gfx::Rect EraseTool::build_rect(const Gfx::Point& pos, const Gfx::Rect& widget_rect) +Gfx::IntRect EraseTool::build_rect(const Gfx::IntPoint& pos, const Gfx::IntRect& widget_rect) { const int base_eraser_size = 10; const int eraser_size = (base_eraser_size * m_thickness); const int eraser_radius = eraser_size / 2; const auto ex = pos.x(); const auto ey = pos.y(); - return Gfx::Rect(ex - eraser_radius, ey - eraser_radius, eraser_size, eraser_size).intersected(widget_rect); + return Gfx::IntRect(ex - eraser_radius, ey - eraser_radius, eraser_size, eraser_size).intersected(widget_rect); } void EraseTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&) { if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right) return; - Gfx::Rect r = build_rect(event.position(), layer.rect()); + Gfx::IntRect r = build_rect(event.position(), layer.rect()); GUI::Painter painter(layer.bitmap()); painter.clear_rect(r, get_color()); layer.did_modify_bitmap(*m_editor->image()); @@ -65,7 +65,7 @@ void EraseTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEve void EraseTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&) { if (event.buttons() & GUI::MouseButton::Left || event.buttons() & GUI::MouseButton::Right) { - Gfx::Rect r = build_rect(event.position(), layer.rect()); + Gfx::IntRect r = build_rect(event.position(), layer.rect()); GUI::Painter painter(layer.bitmap()); painter.clear_rect(r, get_color()); layer.did_modify_bitmap(*m_editor->image()); diff --git a/Applications/PixelPaint/EraseTool.h b/Applications/PixelPaint/EraseTool.h index c574bde90f..70968452dd 100644 --- a/Applications/PixelPaint/EraseTool.h +++ b/Applications/PixelPaint/EraseTool.h @@ -45,7 +45,7 @@ public: private: Gfx::Color get_color() const; virtual const char* class_name() const override { return "EraseTool"; } - Gfx::Rect build_rect(const Gfx::Point& pos, const Gfx::Rect& widget_rect); + Gfx::IntRect build_rect(const Gfx::IntPoint& pos, const Gfx::IntRect& widget_rect); RefPtr m_context_menu; bool m_use_secondary_color { false }; diff --git a/Applications/PixelPaint/Image.cpp b/Applications/PixelPaint/Image.cpp index f0af8db10f..d56a0fc7f7 100644 --- a/Applications/PixelPaint/Image.cpp +++ b/Applications/PixelPaint/Image.cpp @@ -32,7 +32,7 @@ namespace PixelPaint { -RefPtr Image::create_with_size(const Gfx::Size& size) +RefPtr Image::create_with_size(const Gfx::IntSize& size) { if (size.is_empty()) return nullptr; @@ -43,12 +43,12 @@ RefPtr Image::create_with_size(const Gfx::Size& size) return adopt(*new Image(size)); } -Image::Image(const Gfx::Size& size) +Image::Image(const Gfx::IntSize& size) : m_size(size) { } -void Image::paint_into(GUI::Painter& painter, const Gfx::Rect& dest_rect) +void Image::paint_into(GUI::Painter& painter, const Gfx::IntRect& dest_rect) { float scale = (float)dest_rect.width() / (float)rect().width(); Gfx::PainterStateSaver saver(painter); diff --git a/Applications/PixelPaint/Image.h b/Applications/PixelPaint/Image.h index c2faed2c98..55bc109479 100644 --- a/Applications/PixelPaint/Image.h +++ b/Applications/PixelPaint/Image.h @@ -51,18 +51,18 @@ public: class Image : public RefCounted { public: - static RefPtr create_with_size(const Gfx::Size&); + static RefPtr create_with_size(const Gfx::IntSize&); size_t layer_count() const { return m_layers.size(); } const Layer& layer(size_t index) const { return m_layers.at(index); } Layer& layer(size_t index) { return m_layers.at(index); } - const Gfx::Size& size() const { return m_size; } - Gfx::Rect rect() const { return { {}, m_size }; } + const Gfx::IntSize& size() const { return m_size; } + Gfx::IntRect rect() const { return { {}, m_size }; } void add_layer(NonnullRefPtr); - void paint_into(GUI::Painter&, const Gfx::Rect& dest_rect); + void paint_into(GUI::Painter&, const Gfx::IntRect& dest_rect); void move_layer_to_front(Layer&); void move_layer_to_back(Layer&); @@ -79,12 +79,12 @@ public: size_t index_of(const Layer&) const; private: - explicit Image(const Gfx::Size&); + explicit Image(const Gfx::IntSize&); void did_change(); void did_modify_layer_stack(); - Gfx::Size m_size; + Gfx::IntSize m_size; NonnullRefPtrVector m_layers; HashTable m_clients; diff --git a/Applications/PixelPaint/ImageEditor.cpp b/Applications/PixelPaint/ImageEditor.cpp index ca8d39d774..dd58d5e382 100644 --- a/Applications/PixelPaint/ImageEditor.cpp +++ b/Applications/PixelPaint/ImageEditor.cpp @@ -76,12 +76,12 @@ void ImageEditor::paint_event(GUI::PaintEvent& event) } } -Gfx::FloatRect ImageEditor::layer_rect_to_editor_rect(const Layer& layer, const Gfx::Rect& layer_rect) const +Gfx::FloatRect ImageEditor::layer_rect_to_editor_rect(const Layer& layer, const Gfx::IntRect& layer_rect) const { return image_rect_to_editor_rect(layer_rect.translated(layer.location())); } -Gfx::FloatRect ImageEditor::image_rect_to_editor_rect(const Gfx::Rect& image_rect) const +Gfx::FloatRect ImageEditor::image_rect_to_editor_rect(const Gfx::IntRect& image_rect) const { Gfx::FloatRect editor_rect; editor_rect.set_location(image_position_to_editor_position(image_rect.location())); @@ -90,7 +90,7 @@ Gfx::FloatRect ImageEditor::image_rect_to_editor_rect(const Gfx::Rect& image_rec return editor_rect; } -Gfx::FloatRect ImageEditor::editor_rect_to_image_rect(const Gfx::Rect& editor_rect) const +Gfx::FloatRect ImageEditor::editor_rect_to_image_rect(const Gfx::IntRect& editor_rect) const { Gfx::FloatRect image_rect; image_rect.set_location(editor_position_to_image_position(editor_rect.location())); @@ -99,12 +99,12 @@ Gfx::FloatRect ImageEditor::editor_rect_to_image_rect(const Gfx::Rect& editor_re return image_rect; } -Gfx::FloatPoint ImageEditor::layer_position_to_editor_position(const Layer& layer, const Gfx::Point& layer_position) const +Gfx::FloatPoint ImageEditor::layer_position_to_editor_position(const Layer& layer, const Gfx::IntPoint& layer_position) const { return image_position_to_editor_position(layer_position.translated(layer.location())); } -Gfx::FloatPoint ImageEditor::image_position_to_editor_position(const Gfx::Point& image_position) const +Gfx::FloatPoint ImageEditor::image_position_to_editor_position(const Gfx::IntPoint& image_position) const { Gfx::FloatPoint editor_position; editor_position.set_x(m_editor_image_rect.x() + ((float)image_position.x() * m_scale)); @@ -112,7 +112,7 @@ Gfx::FloatPoint ImageEditor::image_position_to_editor_position(const Gfx::Point& return editor_position; } -Gfx::FloatPoint ImageEditor::editor_position_to_image_position(const Gfx::Point& editor_position) const +Gfx::FloatPoint ImageEditor::editor_position_to_image_position(const Gfx::IntPoint& editor_position) const { Gfx::FloatPoint image_position; image_position.set_x(((float)editor_position.x() - m_editor_image_rect.x()) / m_scale); @@ -131,7 +131,7 @@ GUI::MouseEvent ImageEditor::event_with_pan_and_scale_applied(const GUI::MouseEv auto image_position = editor_position_to_image_position(event.position()); return { static_cast(event.type()), - Gfx::Point(image_position.x(), image_position.y()), + Gfx::IntPoint(image_position.x(), image_position.y()), event.buttons(), event.button(), event.modifiers(), @@ -145,7 +145,7 @@ GUI::MouseEvent ImageEditor::event_adjusted_for_layer(const GUI::MouseEvent& eve image_position.move_by(-layer.location().x(), -layer.location().y()); return { static_cast(event.type()), - Gfx::Point(image_position.x(), image_position.y()), + Gfx::IntPoint(image_position.x(), image_position.y()), event.buttons(), event.button(), event.modifiers(), @@ -331,14 +331,14 @@ void ImageEditor::set_secondary_color(Color color) on_secondary_color_change(color); } -Layer* ImageEditor::layer_at_editor_position(const Gfx::Point& editor_position) +Layer* ImageEditor::layer_at_editor_position(const Gfx::IntPoint& editor_position) { if (!m_image) return nullptr; auto image_position = editor_position_to_image_position(editor_position); for (ssize_t i = m_image->layer_count() - 1; i >= 0; --i) { auto& layer = m_image->layer(i); - if (layer.relative_rect().contains(Gfx::Point(image_position.x(), image_position.y()))) + if (layer.relative_rect().contains(Gfx::IntPoint(image_position.x(), image_position.y()))) return const_cast(&layer); } return nullptr; @@ -350,12 +350,12 @@ void ImageEditor::relayout() return; auto& image = *this->image(); - Gfx::Size new_size; + Gfx::IntSize new_size; new_size.set_width(image.size().width() * m_scale); new_size.set_height(image.size().height() * m_scale); m_editor_image_rect.set_size(new_size); - Gfx::Point new_location; + Gfx::IntPoint new_location; new_location.set_x((width() / 2) - (new_size.width() / 2) - (m_pan_origin.x() * m_scale)); new_location.set_y((height() / 2) - (new_size.height() / 2) - (m_pan_origin.y() * m_scale)); m_editor_image_rect.set_location(new_location); diff --git a/Applications/PixelPaint/ImageEditor.h b/Applications/PixelPaint/ImageEditor.h index ad78c975a2..697b335538 100644 --- a/Applications/PixelPaint/ImageEditor.h +++ b/Applications/PixelPaint/ImageEditor.h @@ -56,7 +56,7 @@ public: void layers_did_change(); - Layer* layer_at_editor_position(const Gfx::Point&); + Layer* layer_at_editor_position(const Gfx::IntPoint&); Color primary_color() const { return m_primary_color; } void set_primary_color(Color); @@ -72,12 +72,12 @@ public: Function on_active_layer_change; - Gfx::FloatRect layer_rect_to_editor_rect(const Layer&, const Gfx::Rect&) const; - Gfx::FloatRect image_rect_to_editor_rect(const Gfx::Rect&) const; - Gfx::FloatRect editor_rect_to_image_rect(const Gfx::Rect&) const; - Gfx::FloatPoint layer_position_to_editor_position(const Layer&, const Gfx::Point&) const; - Gfx::FloatPoint image_position_to_editor_position(const Gfx::Point&) const; - Gfx::FloatPoint editor_position_to_image_position(const Gfx::Point&) const; + Gfx::FloatRect layer_rect_to_editor_rect(const Layer&, const Gfx::IntRect&) const; + Gfx::FloatRect image_rect_to_editor_rect(const Gfx::IntRect&) const; + Gfx::FloatRect editor_rect_to_image_rect(const Gfx::IntRect&) const; + Gfx::FloatPoint layer_position_to_editor_position(const Layer&, const Gfx::IntPoint&) const; + Gfx::FloatPoint image_position_to_editor_position(const Gfx::IntPoint&) const; + Gfx::FloatPoint editor_position_to_image_position(const Gfx::IntPoint&) const; private: ImageEditor(); @@ -110,11 +110,11 @@ private: Color m_primary_color { Color::Black }; Color m_secondary_color { Color::White }; - Gfx::Rect m_editor_image_rect; + Gfx::IntRect m_editor_image_rect; float m_scale { 1 }; Gfx::FloatPoint m_pan_origin; Gfx::FloatPoint m_saved_pan_origin; - Gfx::Point m_click_position; + Gfx::IntPoint m_click_position; }; } diff --git a/Applications/PixelPaint/Layer.cpp b/Applications/PixelPaint/Layer.cpp index 9c54eb7313..437fa74e3f 100644 --- a/Applications/PixelPaint/Layer.cpp +++ b/Applications/PixelPaint/Layer.cpp @@ -30,7 +30,7 @@ namespace PixelPaint { -RefPtr Layer::create_with_size(const Gfx::Size& size, const String& name) +RefPtr Layer::create_with_size(const Gfx::IntSize& size, const String& name) { if (size.is_empty()) return nullptr; @@ -41,7 +41,7 @@ RefPtr Layer::create_with_size(const Gfx::Size& size, const String& name) return adopt(*new Layer(size, name)); } -Layer::Layer(const Gfx::Size& size, const String& name) +Layer::Layer(const Gfx::IntSize& size, const String& name) : m_name(name) { m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::RGBA32, size); diff --git a/Applications/PixelPaint/Layer.h b/Applications/PixelPaint/Layer.h index 662c2feb18..1c0f43daaf 100644 --- a/Applications/PixelPaint/Layer.h +++ b/Applications/PixelPaint/Layer.h @@ -40,19 +40,19 @@ class Layer : public RefCounted { AK_MAKE_NONMOVABLE(Layer); public: - static RefPtr create_with_size(const Gfx::Size&, const String& name); + static RefPtr create_with_size(const Gfx::IntSize&, const String& name); ~Layer() {} - const Gfx::Point& location() const { return m_location; } - void set_location(const Gfx::Point& location) { m_location = location; } + const Gfx::IntPoint& location() const { return m_location; } + void set_location(const Gfx::IntPoint& location) { m_location = location; } const Gfx::Bitmap& bitmap() const { return *m_bitmap; } Gfx::Bitmap& bitmap() { return *m_bitmap; } - Gfx::Size size() const { return bitmap().size(); } + Gfx::IntSize size() const { return bitmap().size(); } - Gfx::Rect relative_rect() const { return { location(), size() }; } - Gfx::Rect rect() const { return { {}, size() }; } + Gfx::IntRect relative_rect() const { return { location(), size() }; } + Gfx::IntRect rect() const { return { {}, size() }; } const String& name() const { return m_name; } void set_name(const String& name) { m_name = name; } @@ -63,10 +63,10 @@ public: bool is_selected() const { return m_selected; } private: - explicit Layer(const Gfx::Size&, const String& name); + explicit Layer(const Gfx::IntSize&, const String& name); String m_name; - Gfx::Point m_location; + Gfx::IntPoint m_location; RefPtr m_bitmap; bool m_selected { false }; diff --git a/Applications/PixelPaint/LayerListWidget.cpp b/Applications/PixelPaint/LayerListWidget.cpp index 63a0f94888..756772bb87 100644 --- a/Applications/PixelPaint/LayerListWidget.cpp +++ b/Applications/PixelPaint/LayerListWidget.cpp @@ -102,11 +102,11 @@ void LayerListWidget::paint_event(GUI::PaintEvent& event) painter.draw_rect(adjusted_rect, Color::Black); - Gfx::Rect thumbnail_rect { adjusted_rect.x(), adjusted_rect.y(), adjusted_rect.height(), adjusted_rect.height() }; + Gfx::IntRect thumbnail_rect { adjusted_rect.x(), adjusted_rect.y(), adjusted_rect.height(), adjusted_rect.height() }; thumbnail_rect.shrink(8, 8); painter.draw_scaled_bitmap(thumbnail_rect, layer.bitmap(), layer.bitmap().rect()); - Gfx::Rect text_rect { thumbnail_rect.right() + 10, adjusted_rect.y(), adjusted_rect.width(), adjusted_rect.height() }; + Gfx::IntRect text_rect { thumbnail_rect.right() + 10, adjusted_rect.y(), adjusted_rect.width(), adjusted_rect.height() }; text_rect.intersect(adjusted_rect); painter.draw_text(text_rect, layer.name(), Gfx::TextAlignment::CenterLeft, layer.is_selected() ? palette().selection_text() : palette().button_text()); @@ -121,7 +121,7 @@ void LayerListWidget::paint_event(GUI::PaintEvent& event) paint_gadget(m_gadgets[m_moving_gadget_index.value()]); } -Optional LayerListWidget::gadget_at(const Gfx::Point& position) +Optional LayerListWidget::gadget_at(const Gfx::IntPoint& position) { for (size_t i = 0; i < m_gadgets.size(); ++i) { if (m_gadgets[i].rect.contains(position)) diff --git a/Applications/PixelPaint/LayerListWidget.h b/Applications/PixelPaint/LayerListWidget.h index 90a7dfd9b9..9550913b8e 100644 --- a/Applications/PixelPaint/LayerListWidget.h +++ b/Applications/PixelPaint/LayerListWidget.h @@ -69,21 +69,21 @@ private: struct Gadget { size_t layer_index { 0 }; - Gfx::Rect rect; - Gfx::Rect temporary_rect_during_move; + Gfx::IntRect rect; + Gfx::IntRect temporary_rect_during_move; bool is_moving { false }; - Gfx::Point movement_delta; + Gfx::IntPoint movement_delta; }; bool is_moving_gadget() const { return m_moving_gadget_index.has_value(); } - Optional gadget_at(const Gfx::Point&); + Optional gadget_at(const Gfx::IntPoint&); Vector m_gadgets; RefPtr m_image; Optional m_moving_gadget_index; - Gfx::Point m_moving_event_origin; + Gfx::IntPoint m_moving_event_origin; }; } diff --git a/Applications/PixelPaint/LineTool.cpp b/Applications/PixelPaint/LineTool.cpp index bffa6f11f1..87b9fdc44f 100644 --- a/Applications/PixelPaint/LineTool.cpp +++ b/Applications/PixelPaint/LineTool.cpp @@ -34,7 +34,7 @@ namespace PixelPaint { -static Gfx::Point constrain_line_angle(const Gfx::Point& start_pos, const Gfx::Point& end_pos, float angle_increment) +static Gfx::IntPoint constrain_line_angle(const Gfx::IntPoint& start_pos, const Gfx::IntPoint& end_pos, float angle_increment) { float current_angle = atan2(end_pos.y() - start_pos.y(), end_pos.x() - start_pos.x()) + M_PI * 2.; diff --git a/Applications/PixelPaint/LineTool.h b/Applications/PixelPaint/LineTool.h index df165ecb93..9655a3b629 100644 --- a/Applications/PixelPaint/LineTool.h +++ b/Applications/PixelPaint/LineTool.h @@ -49,8 +49,8 @@ private: virtual const char* class_name() const override { return "LineTool"; } GUI::MouseButton m_drawing_button { GUI::MouseButton::None }; - Gfx::Point m_line_start_position; - Gfx::Point m_line_end_position; + Gfx::IntPoint m_line_start_position; + Gfx::IntPoint m_line_end_position; RefPtr m_context_menu; GUI::ActionGroup m_thickness_actions; diff --git a/Applications/PixelPaint/MoveTool.h b/Applications/PixelPaint/MoveTool.h index 497795dc90..b680c71bc1 100644 --- a/Applications/PixelPaint/MoveTool.h +++ b/Applications/PixelPaint/MoveTool.h @@ -46,8 +46,8 @@ private: virtual bool is_move_tool() const override { return true; } RefPtr m_layer_being_moved; - Gfx::Point m_event_origin; - Gfx::Point m_layer_origin; + Gfx::IntPoint m_event_origin; + Gfx::IntPoint m_layer_origin; RefPtr m_context_menu; RefPtr m_context_menu_layer; }; diff --git a/Applications/PixelPaint/PaletteWidget.cpp b/Applications/PixelPaint/PaletteWidget.cpp index 289213b5f2..985f87144f 100644 --- a/Applications/PixelPaint/PaletteWidget.cpp +++ b/Applications/PixelPaint/PaletteWidget.cpp @@ -88,7 +88,7 @@ PaletteWidget::PaletteWidget(ImageEditor& editor) set_secondary_color(m_editor.secondary_color()); m_primary_color_widget = add(); - Gfx::Rect rect { 0, 0, 38, 15 }; + Gfx::IntRect rect { 0, 0, 38, 15 }; rect.center_within(m_secondary_color_widget->relative_rect()); m_primary_color_widget->set_relative_rect(rect); m_primary_color_widget->set_fill_with_background_color(true); diff --git a/Applications/PixelPaint/PenTool.cpp b/Applications/PixelPaint/PenTool.cpp index 0f1b7d8814..833453385d 100644 --- a/Applications/PixelPaint/PenTool.cpp +++ b/Applications/PixelPaint/PenTool.cpp @@ -64,7 +64,7 @@ void PenTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent return; GUI::Painter painter(layer.bitmap()); - if (m_last_drawing_event_position != Gfx::Point(-1, -1)) + if (m_last_drawing_event_position != Gfx::IntPoint(-1, -1)) painter.draw_line(m_last_drawing_event_position, event.position(), m_editor->color_for(event), m_thickness); else painter.draw_line(event.position(), event.position(), m_editor->color_for(event), m_thickness); diff --git a/Applications/PixelPaint/PenTool.h b/Applications/PixelPaint/PenTool.h index 85b718fe10..18d0cdae98 100644 --- a/Applications/PixelPaint/PenTool.h +++ b/Applications/PixelPaint/PenTool.h @@ -45,7 +45,7 @@ public: private: virtual const char* class_name() const override { return "PenTool"; } - Gfx::Point m_last_drawing_event_position { -1, -1 }; + Gfx::IntPoint m_last_drawing_event_position { -1, -1 }; RefPtr m_context_menu; int m_thickness { 1 }; GUI::ActionGroup m_thickness_actions; diff --git a/Applications/PixelPaint/RectangleTool.cpp b/Applications/PixelPaint/RectangleTool.cpp index 1207dc7888..a9d37b1ebf 100644 --- a/Applications/PixelPaint/RectangleTool.cpp +++ b/Applications/PixelPaint/RectangleTool.cpp @@ -43,7 +43,7 @@ RectangleTool::~RectangleTool() { } -void RectangleTool::draw_using(GUI::Painter& painter, const Gfx::Rect& rect) +void RectangleTool::draw_using(GUI::Painter& painter, const Gfx::IntRect& rect) { switch (m_mode) { case Mode::Fill: @@ -78,7 +78,7 @@ void RectangleTool::on_mouseup(Layer& layer, GUI::MouseEvent& event, GUI::MouseE { if (event.button() == m_drawing_button) { GUI::Painter painter(layer.bitmap()); - auto rect = Gfx::Rect::from_two_points(m_rectangle_start_position, m_rectangle_end_position); + auto rect = Gfx::IntRect::from_two_points(m_rectangle_start_position, m_rectangle_end_position); draw_using(painter, rect); m_drawing_button = GUI::MouseButton::None; layer.did_modify_bitmap(*m_editor->image()); @@ -101,7 +101,7 @@ void RectangleTool::on_second_paint(const Layer& layer, GUI::PaintEvent& event) GUI::Painter painter(*m_editor); painter.add_clip_rect(event.rect()); - auto rect = Gfx::Rect::from_two_points(m_editor->layer_position_to_editor_position(layer, m_rectangle_start_position).to_int_point(), m_editor->layer_position_to_editor_position(layer, m_rectangle_end_position).to_int_point()); + auto rect = Gfx::IntRect::from_two_points(m_editor->layer_position_to_editor_position(layer, m_rectangle_start_position).to_int_point(), m_editor->layer_position_to_editor_position(layer, m_rectangle_end_position).to_int_point()); draw_using(painter, rect); } diff --git a/Applications/PixelPaint/RectangleTool.h b/Applications/PixelPaint/RectangleTool.h index cb4d310ac0..dd6c41c846 100644 --- a/Applications/PixelPaint/RectangleTool.h +++ b/Applications/PixelPaint/RectangleTool.h @@ -52,11 +52,11 @@ private: }; virtual const char* class_name() const override { return "RectangleTool"; } - void draw_using(GUI::Painter&, const Gfx::Rect&); + void draw_using(GUI::Painter&, const Gfx::IntRect&); GUI::MouseButton m_drawing_button { GUI::MouseButton::None }; - Gfx::Point m_rectangle_start_position; - Gfx::Point m_rectangle_end_position; + Gfx::IntPoint m_rectangle_start_position; + Gfx::IntPoint m_rectangle_end_position; RefPtr m_context_menu; Mode m_mode { Mode::Outline }; }; diff --git a/Applications/PixelPaint/SprayTool.h b/Applications/PixelPaint/SprayTool.h index ab6309deb7..32c1c5f5f4 100644 --- a/Applications/PixelPaint/SprayTool.h +++ b/Applications/PixelPaint/SprayTool.h @@ -47,7 +47,7 @@ private: virtual const char* class_name() const override { return "SprayTool"; } void paint_it(); RefPtr m_timer; - Gfx::Point m_last_pos; + Gfx::IntPoint m_last_pos; Color m_color; RefPtr m_context_menu; GUI::ActionGroup m_thickness_actions; diff --git a/Applications/QuickShow/QSWidget.cpp b/Applications/QuickShow/QSWidget.cpp index 28b4a0b120..46e505947e 100644 --- a/Applications/QuickShow/QSWidget.cpp +++ b/Applications/QuickShow/QSWidget.cpp @@ -138,12 +138,12 @@ void QSWidget::relayout() float scale_factor = (float)m_scale / 100.0f; - Gfx::Size new_size; + Gfx::IntSize new_size; new_size.set_width(m_bitmap->width() * scale_factor); new_size.set_height(m_bitmap->height() * scale_factor); m_bitmap_rect.set_size(new_size); - Gfx::Point new_location; + Gfx::IntPoint new_location; new_location.set_x((width() / 2) - (new_size.width() / 2) - (m_pan_origin.x() * scale_factor)); new_location.set_y((height() / 2) - (new_size.height() / 2) - (m_pan_origin.y() * scale_factor)); m_bitmap_rect.set_location(new_location); diff --git a/Applications/QuickShow/QSWidget.h b/Applications/QuickShow/QSWidget.h index b77ade01d9..eade0a5ba1 100644 --- a/Applications/QuickShow/QSWidget.h +++ b/Applications/QuickShow/QSWidget.h @@ -76,11 +76,11 @@ private: RefPtr m_bitmap; int m_toolbar_height { 28 }; - Gfx::Rect m_bitmap_rect; + Gfx::IntRect m_bitmap_rect; int m_scale { 100 }; Gfx::FloatPoint m_pan_origin; - Gfx::Point m_click_position; + Gfx::IntPoint m_click_position; Gfx::FloatPoint m_saved_pan_origin; Vector m_files_in_same_dir; }; diff --git a/Applications/SoundPlayer/SampleWidget.cpp b/Applications/SoundPlayer/SampleWidget.cpp index f58845176c..5decd2b8b9 100644 --- a/Applications/SoundPlayer/SampleWidget.cpp +++ b/Applications/SoundPlayer/SampleWidget.cpp @@ -60,8 +60,8 @@ void SampleWidget::paint_event(GUI::PaintEvent& event) ++count; if (count >= samples_per_pixel) { - Gfx::Point min_point = { x, y_offset + static_cast(-sample_max * frame_inner_rect().height() / 2) }; - Gfx::Point max_point = { x++, y_offset + static_cast(sample_max * frame_inner_rect().height() / 2) }; + Gfx::IntPoint min_point = { x, y_offset + static_cast(-sample_max * frame_inner_rect().height() / 2) }; + Gfx::IntPoint max_point = { x++, y_offset + static_cast(sample_max * frame_inner_rect().height() / 2) }; painter.draw_line(min_point, max_point, Color::Green); count = 0; diff --git a/Applications/SystemMonitor/GraphWidget.cpp b/Applications/SystemMonitor/GraphWidget.cpp index d3120e9ca0..7bfb2d5bbf 100644 --- a/Applications/SystemMonitor/GraphWidget.cpp +++ b/Applications/SystemMonitor/GraphWidget.cpp @@ -53,20 +53,20 @@ void GraphWidget::paint_event(GUI::PaintEvent& event) auto inner_rect = frame_inner_rect(); float scale = (float)inner_rect.height() / (float)m_max; - Gfx::Point prev_point; + Gfx::IntPoint prev_point; for (size_t i = 0; i < m_values.size(); ++i) { int x = inner_rect.right() - (i * 2) + 1; if (x < 0) break; float scaled_value = (float)m_values.at(m_values.size() - i - 1) * scale; - Gfx::Point point = { x, inner_rect.bottom() - (int)scaled_value }; + Gfx::IntPoint point = { x, inner_rect.bottom() - (int)scaled_value }; if (i != 0) painter.draw_line(prev_point, point, m_graph_color); prev_point = point; } if (!m_values.is_empty() && text_formatter) { - Gfx::Rect text_rect = inner_rect.shrunken(8, 8); + Gfx::IntRect text_rect = inner_rect.shrunken(8, 8); text_rect.set_height(font().glyph_height()); auto text = text_formatter(m_values.last(), m_max); painter.draw_text(text_rect.translated(1, 1), text.characters(), Gfx::TextAlignment::CenterRight, Color::Black); diff --git a/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp b/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp index bd5b4fbabb..8ea21114d2 100644 --- a/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp +++ b/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp @@ -37,7 +37,7 @@ class PagemapPaintingDelegate final : public GUI::TableCellPaintingDelegate { public: virtual ~PagemapPaintingDelegate() override {} - virtual void paint(GUI::Painter& painter, const Gfx::Rect& a_rect, const Gfx::Palette&, const GUI::Model& model, const GUI::ModelIndex& index) override + virtual void paint(GUI::Painter& painter, const Gfx::IntRect& a_rect, const Gfx::Palette&, const GUI::Model& model, const GUI::ModelIndex& index) override { auto rect = a_rect.shrunken(2, 2); auto pagemap = model.data(index, GUI::Model::Role::Custom).to_string(); diff --git a/Applications/SystemMonitor/main.cpp b/Applications/SystemMonitor/main.cpp index 914fef186a..5fc07ab380 100644 --- a/Applications/SystemMonitor/main.cpp +++ b/Applications/SystemMonitor/main.cpp @@ -287,7 +287,7 @@ class ProgressBarPaintingDelegate final : public GUI::TableCellPaintingDelegate public: virtual ~ProgressBarPaintingDelegate() override { } - virtual void paint(GUI::Painter& painter, const Gfx::Rect& a_rect, const Palette& palette, const GUI::Model& model, const GUI::ModelIndex& index) override + virtual void paint(GUI::Painter& painter, const Gfx::IntRect& a_rect, const Palette& palette, const GUI::Model& model, const GUI::ModelIndex& index) override { auto rect = a_rect.shrunken(2, 2); auto percentage = model.data(index, GUI::Model::Role::Custom).to_i32(); diff --git a/Applications/Welcome/main.cpp b/Applications/Welcome/main.cpp index 1415b3227c..4a52aa419f 100644 --- a/Applications/Welcome/main.cpp +++ b/Applications/Welcome/main.cpp @@ -156,7 +156,7 @@ int main(int argc, char** argv) auto window = GUI::Window::construct(); window->set_title("Welcome"); - Gfx::Rect window_rect { 0, 0, 640, 360 }; + Gfx::IntRect window_rect { 0, 0, 640, 360 }; window_rect.center_within(GUI::Desktop::the().rect()); window->set_resizable(true); window->set_rect(window_rect); diff --git a/Demos/Cube/Cube.cpp b/Demos/Cube/Cube.cpp index 8cd78d1d12..36faa2deaf 100644 --- a/Demos/Cube/Cube.cpp +++ b/Demos/Cube/Cube.cpp @@ -145,7 +145,7 @@ void Cube::timer_event(Core::TimerEvent&) painter.fill_rect_with_gradient(Gfx::Orientation::Vertical, m_bitmap->rect(), Gfx::Color::White, Gfx::Color::Blue); auto to_point = [](const FloatVector3& v) { - return Gfx::Point(v.x(), v.y()); + return Gfx::IntPoint(v.x(), v.y()); }; for (size_t i = 0; i < sizeof(indices) / sizeof(indices[0]) / 3; i++) { diff --git a/Demos/Eyes/EyesWidget.cpp b/Demos/Eyes/EyesWidget.cpp index b26f856daa..036cd8375e 100644 --- a/Demos/Eyes/EyesWidget.cpp +++ b/Demos/Eyes/EyesWidget.cpp @@ -64,7 +64,7 @@ void EyesWidget::paint_event(GUI::PaintEvent& event) void EyesWidget::render_eyeball(int index, GUI::Painter& painter) const { auto eye_width = width() / m_num_eyes; - Gfx::Rect bounds { index * eye_width, 0, eye_width, height() }; + Gfx::IntRect bounds { index * eye_width, 0, eye_width, height() }; auto width_thickness = max(int(eye_width / 5.5), 1); auto height_thickness = max(int(height() / 5.5), 1); @@ -73,12 +73,12 @@ void EyesWidget::render_eyeball(int index, GUI::Painter& painter) const bounds.shrink(width_thickness, height_thickness); painter.fill_ellipse(bounds, palette().base()); - Gfx::Point pupil_center = this->pupil_center(bounds); - Gfx::Size pupil_size { + Gfx::IntPoint pupil_center = this->pupil_center(bounds); + Gfx::IntSize pupil_size { bounds.width() / 5, bounds.height() / 5 }; - Gfx::Rect pupil { + Gfx::IntRect pupil { pupil_center.x() - pupil_size.width() / 2, pupil_center.y() - pupil_size.height() / 2, pupil_size.width(), @@ -88,7 +88,7 @@ void EyesWidget::render_eyeball(int index, GUI::Painter& painter) const painter.fill_ellipse(pupil, palette().base_text()); } -Gfx::Point EyesWidget::pupil_center(Gfx::Rect& eyeball_bounds) const +Gfx::IntPoint EyesWidget::pupil_center(Gfx::IntRect& eyeball_bounds) const { auto mouse_vector = m_mouse_position - eyeball_bounds.center(); double dx = mouse_vector.x(); diff --git a/Demos/Eyes/EyesWidget.h b/Demos/Eyes/EyesWidget.h index 365c69b13a..44505e707e 100644 --- a/Demos/Eyes/EyesWidget.h +++ b/Demos/Eyes/EyesWidget.h @@ -46,8 +46,8 @@ private: virtual void paint_event(GUI::PaintEvent&) override; void render_eyeball(int index, GUI::Painter&) const; - Gfx::Point pupil_center(Gfx::Rect& eyeball_bounds) const; + Gfx::IntPoint pupil_center(Gfx::IntRect& eyeball_bounds) const; - Gfx::Point m_mouse_position; + Gfx::IntPoint m_mouse_position; int m_num_eyes { -1 }; }; diff --git a/Demos/Mouse/main.cpp b/Demos/Mouse/main.cpp index 0bc2b0ad9d..8b4ceb7956 100644 --- a/Demos/Mouse/main.cpp +++ b/Demos/Mouse/main.cpp @@ -114,10 +114,10 @@ public: auto off_x = 80; auto off_y = 38; - Gfx::Point p1; - Gfx::Point p2; - Gfx::Point p3; - Gfx::Point p4; + Gfx::IntPoint p1; + Gfx::IntPoint p2; + Gfx::IntPoint p3; + Gfx::IntPoint p4; p1.set_x(radius * cos(M_PI * m_wheel_delta_acc / 18) + off_x); p1.set_y(radius * sin(M_PI * m_wheel_delta_acc / 18) + off_y); diff --git a/DevTools/HackStudio/CursorTool.cpp b/DevTools/HackStudio/CursorTool.cpp index 920862037f..dd0e1516c8 100644 --- a/DevTools/HackStudio/CursorTool.cpp +++ b/DevTools/HackStudio/CursorTool.cpp @@ -153,7 +153,7 @@ void CursorTool::on_keydown(GUI::KeyEvent& event) } } -void CursorTool::set_rubber_band_position(const Gfx::Point& position) +void CursorTool::set_rubber_band_position(const Gfx::IntPoint& position) { if (m_rubber_band_position == position) return; @@ -171,11 +171,11 @@ void CursorTool::set_rubber_band_position(const Gfx::Point& position) m_editor.form_widget().update(); } -Gfx::Rect CursorTool::rubber_band_rect() const +Gfx::IntRect CursorTool::rubber_band_rect() const { if (!m_rubber_banding) return {}; - return Gfx::Rect::from_two_points(m_rubber_band_origin, m_rubber_band_position); + return Gfx::IntRect::from_two_points(m_rubber_band_origin, m_rubber_band_position); } void CursorTool::on_second_paint(GUI::Painter& painter, GUI::PaintEvent&) diff --git a/DevTools/HackStudio/CursorTool.h b/DevTools/HackStudio/CursorTool.h index 36e6a97a2c..9a603b0775 100644 --- a/DevTools/HackStudio/CursorTool.h +++ b/DevTools/HackStudio/CursorTool.h @@ -47,14 +47,14 @@ private: virtual void on_keydown(GUI::KeyEvent&) override; virtual void on_second_paint(GUI::Painter&, GUI::PaintEvent&) override; - void set_rubber_band_position(const Gfx::Point&); - Gfx::Rect rubber_band_rect() const; + void set_rubber_band_position(const Gfx::IntPoint&); + Gfx::IntRect rubber_band_rect() const; - Gfx::Point m_drag_origin; - HashMap m_positions_before_drag; + Gfx::IntPoint m_drag_origin; + HashMap m_positions_before_drag; bool m_dragging { false }; bool m_rubber_banding { false }; - Gfx::Point m_rubber_band_origin; - Gfx::Point m_rubber_band_position; + Gfx::IntPoint m_rubber_band_origin; + Gfx::IntPoint m_rubber_band_position; }; diff --git a/DevTools/HackStudio/Editor.cpp b/DevTools/HackStudio/Editor.cpp index 9520298a72..5cdd2b8828 100644 --- a/DevTools/HackStudio/Editor.cpp +++ b/DevTools/HackStudio/Editor.cpp @@ -80,7 +80,7 @@ void Editor::focusout_event(Core::Event& event) GUI::TextEditor::focusout_event(event); } -Gfx::Rect Editor::breakpoint_icon_rect(size_t line_number) const +Gfx::IntRect Editor::breakpoint_icon_rect(size_t line_number) const { auto ruler_line_rect = ruler_content_rect(line_number); @@ -140,7 +140,7 @@ static HashMap& man_paths() return paths; } -void Editor::show_documentation_tooltip_if_available(const String& hovered_token, const Gfx::Point& screen_location) +void Editor::show_documentation_tooltip_if_available(const String& hovered_token, const Gfx::IntPoint& screen_location) { auto it = man_paths().find(hovered_token); if (it == man_paths().end()) { diff --git a/DevTools/HackStudio/Editor.h b/DevTools/HackStudio/Editor.h index 0d83145660..6d4e15c0ba 100644 --- a/DevTools/HackStudio/Editor.h +++ b/DevTools/HackStudio/Editor.h @@ -61,10 +61,10 @@ private: virtual void enter_event(Core::Event&) override; virtual void leave_event(Core::Event&) override; - void show_documentation_tooltip_if_available(const String&, const Gfx::Point& screen_location); + void show_documentation_tooltip_if_available(const String&, const Gfx::IntPoint& screen_location); void navigate_to_include_if_available(String); - Gfx::Rect breakpoint_icon_rect(size_t line_number) const; + Gfx::IntRect breakpoint_icon_rect(size_t line_number) const; static const Gfx::Bitmap& breakpoint_icon_bitmap(); static const Gfx::Bitmap& current_position_icon_bitmap(); diff --git a/DevTools/VisualBuilder/VBForm.cpp b/DevTools/VisualBuilder/VBForm.cpp index 9963708153..7bd247c188 100644 --- a/DevTools/VisualBuilder/VBForm.cpp +++ b/DevTools/VisualBuilder/VBForm.cpp @@ -88,7 +88,7 @@ void VBForm::insert_widget(VBWidgetType type) { auto* insertion_parent = single_selected_widget(); auto widget = VBWidget::create(type, *this, insertion_parent); - Gfx::Point insertion_position = m_next_insertion_position; + Gfx::IntPoint insertion_position = m_next_insertion_position; if (insertion_parent) insertion_position.move_by(insertion_parent->gwidget()->window_relative_rect().location()); widget->set_rect({ insertion_position, { m_grid_size * 10 + 1, m_grid_size * 5 + 1 } }); @@ -136,7 +136,7 @@ bool VBForm::is_selected(const VBWidget& widget) const return m_selected_widgets.contains(const_cast(&widget)); } -VBWidget* VBForm::widget_at(const Gfx::Point& position) +VBWidget* VBForm::widget_at(const Gfx::IntPoint& position) { auto result = hit_test(position, GUI::Widget::ShouldRespectGreediness::No); if (!result.widget) @@ -354,7 +354,7 @@ void VBForm::mousemove_event(GUI::MouseEvent& event) if (widget.is_in_layout()) return; auto new_rect = widget.transform_origin_rect(); - Gfx::Size minimum_size { 5, 5 }; + Gfx::IntSize minimum_size { 5, 5 }; new_rect.set_x(new_rect.x() + change_x); new_rect.set_y(new_rect.y() + change_y); new_rect.set_width(max(minimum_size.width(), new_rect.width() + change_w)); diff --git a/DevTools/VisualBuilder/VBForm.h b/DevTools/VisualBuilder/VBForm.h index 7aef3c024a..d59c23cded 100644 --- a/DevTools/VisualBuilder/VBForm.h +++ b/DevTools/VisualBuilder/VBForm.h @@ -43,7 +43,7 @@ public: void set_name(const String& name) { m_name = name; } bool is_selected(const VBWidget&) const; - VBWidget* widget_at(const Gfx::Point&); + VBWidget* widget_at(const Gfx::IntPoint&); void set_should_snap_to_grip(bool snap) { m_should_snap_to_grid = snap; } bool should_snap_to_grid() const { return m_should_snap_to_grid; } @@ -85,8 +85,8 @@ private: NonnullRefPtrVector m_widgets; HashMap m_gwidget_map; HashTable m_selected_widgets; - Gfx::Point m_transform_event_origin; - Gfx::Point m_next_insertion_position; + Gfx::IntPoint m_transform_event_origin; + Gfx::IntPoint m_next_insertion_position; Direction m_resize_direction { Direction::None }; Direction m_mouse_direction_type { Direction::None }; RefPtr m_context_menu; diff --git a/DevTools/VisualBuilder/VBWidget.cpp b/DevTools/VisualBuilder/VBWidget.cpp index 82006047ec..661a3de416 100644 --- a/DevTools/VisualBuilder/VBWidget.cpp +++ b/DevTools/VisualBuilder/VBWidget.cpp @@ -59,12 +59,12 @@ VBWidget::~VBWidget() m_gwidget->parent()->remove_child(*m_gwidget); } -Gfx::Rect VBWidget::rect() const +Gfx::IntRect VBWidget::rect() const { return m_gwidget->window_relative_rect(); } -void VBWidget::set_rect(const Gfx::Rect& rect) +void VBWidget::set_rect(const Gfx::IntRect& rect) { if (rect == m_gwidget->window_relative_rect()) return; @@ -80,7 +80,7 @@ bool VBWidget::is_selected() const return m_form.is_selected(*this); } -Gfx::Rect VBWidget::grabber_rect(Direction direction) const +Gfx::IntRect VBWidget::grabber_rect(Direction direction) const { int grabber_size = 5; int half_grabber_size = grabber_size / 2; @@ -106,7 +106,7 @@ Gfx::Rect VBWidget::grabber_rect(Direction direction) const } } -Direction VBWidget::grabber_at(const Gfx::Point& position) const +Direction VBWidget::grabber_at(const Gfx::IntPoint& position) const { Direction found_grabber = Direction::None; for_each_direction([&](Direction direction) { diff --git a/DevTools/VisualBuilder/VBWidget.h b/DevTools/VisualBuilder/VBWidget.h index 7039b1a3c1..850d5584b6 100644 --- a/DevTools/VisualBuilder/VBWidget.h +++ b/DevTools/VisualBuilder/VBWidget.h @@ -74,11 +74,11 @@ public: bool is_selected() const; - Gfx::Rect rect() const; - void set_rect(const Gfx::Rect&); + Gfx::IntRect rect() const; + void set_rect(const Gfx::IntRect&); - Gfx::Rect grabber_rect(Direction) const; - Direction grabber_at(const Gfx::Point&) const; + Gfx::IntRect grabber_rect(Direction) const; + Direction grabber_at(const Gfx::IntPoint&) const; GUI::Widget* gwidget() { return m_gwidget; } @@ -93,7 +93,7 @@ public: void property_did_change(); - Gfx::Rect transform_origin_rect() const { return m_transform_origin_rect; } + Gfx::IntRect transform_origin_rect() const { return m_transform_origin_rect; } void capture_transform_origin_rect(); bool is_in_layout() const; @@ -108,5 +108,5 @@ private: RefPtr m_gwidget; NonnullOwnPtrVector m_properties; NonnullRefPtr m_property_model; - Gfx::Rect m_transform_origin_rect; + Gfx::IntRect m_transform_origin_rect; }; diff --git a/Games/Minesweeper/Field.cpp b/Games/Minesweeper/Field.cpp index c41fd59de9..fdd022c255 100644 --- a/Games/Minesweeper/Field.cpp +++ b/Games/Minesweeper/Field.cpp @@ -121,7 +121,7 @@ private: bool m_chord { false }; }; -Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, Function on_size_changed) +Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, Function on_size_changed) : m_face_button(face_button) , m_flag_label(flag_label) , m_time_label(time_label) @@ -241,7 +241,7 @@ void Field::reset() for (size_t c = 0; c < columns(); ++c) { if (!m_squares[i]) m_squares[i] = make(); - Gfx::Rect rect = { frame_thickness() + static_cast(c) * square_size(), frame_thickness() + static_cast(r) * square_size(), square_size(), square_size() }; + Gfx::IntRect rect = { frame_thickness() + static_cast(c) * square_size(), frame_thickness() + static_cast(r) * square_size(), square_size(), square_size() }; auto& square = this->square(r, c); square.field = this; square.row = r; @@ -329,13 +329,13 @@ void Field::paint_event(GUI::PaintEvent& event) painter.add_clip_rect(inner_rect); for (int y = inner_rect.top() - 1; y <= inner_rect.bottom(); y += square_size()) { - Gfx::Point a { inner_rect.left(), y }; - Gfx::Point b { inner_rect.right(), y }; + Gfx::IntPoint a { inner_rect.left(), y }; + Gfx::IntPoint b { inner_rect.right(), y }; painter.draw_line(a, b, palette().threed_shadow1()); } for (int x = frame_inner_rect().left() - 1; x <= frame_inner_rect().right(); x += square_size()) { - Gfx::Point a { x, inner_rect.top() }; - Gfx::Point b { x, inner_rect.bottom() }; + Gfx::IntPoint a { x, inner_rect.top() }; + Gfx::IntPoint b { x, inner_rect.bottom() }; painter.draw_line(a, b, palette().threed_shadow1()); } } diff --git a/Games/Minesweeper/Field.h b/Games/Minesweeper/Field.h index 742329fde8..2b5d688804 100644 --- a/Games/Minesweeper/Field.h +++ b/Games/Minesweeper/Field.h @@ -60,7 +60,7 @@ class Field final : public GUI::Frame { friend class Square; friend class SquareLabel; public: - Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, Function on_size_changed); + Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, Function on_size_changed); virtual ~Field() override; size_t rows() const { return m_rows; } @@ -126,5 +126,5 @@ private: bool m_chord_preview { false }; bool m_first_click { true }; bool m_single_chording { true }; - Function m_on_size_changed; + Function m_on_size_changed; }; diff --git a/Games/Snake/SnakeGame.cpp b/Games/Snake/SnakeGame.cpp index 58ca54c708..3d2bf109e1 100644 --- a/Games/Snake/SnakeGame.cpp +++ b/Games/Snake/SnakeGame.cpp @@ -92,13 +92,13 @@ void SnakeGame::spawn_fruit() m_fruit_type = rand() % m_fruit_bitmaps.size(); } -Gfx::Rect SnakeGame::score_rect() const +Gfx::IntRect SnakeGame::score_rect() const { int score_width = font().width(m_score_text); return { width() - score_width - 2, height() - font().glyph_height() - 2, score_width, font().glyph_height() }; } -Gfx::Rect SnakeGame::high_score_rect() const +Gfx::IntRect SnakeGame::high_score_rect() const { int high_score_width = font().width(m_high_score_text); return { 2, height() - font().glyph_height() - 2, high_score_width, font().glyph_height() }; @@ -197,10 +197,10 @@ void SnakeGame::keydown_event(GUI::KeyEvent& event) } } -Gfx::Rect SnakeGame::cell_rect(const Coordinate& coord) const +Gfx::IntRect SnakeGame::cell_rect(const Coordinate& coord) const { auto game_rect = rect(); - auto cell_size = Gfx::Size(game_rect.width() / m_columns, game_rect.height() / m_rows); + auto cell_size = Gfx::IntSize(game_rect.width() / m_columns, game_rect.height() / m_rows); return { coord.column * cell_size.width(), coord.row * cell_size.height(), @@ -220,10 +220,10 @@ void SnakeGame::paint_event(GUI::PaintEvent& event) auto rect = cell_rect(part); painter.fill_rect(rect, Color::from_rgb(0xaaaa00)); - Gfx::Rect left_side(rect.x(), rect.y(), 2, rect.height()); - Gfx::Rect top_side(rect.x(), rect.y(), rect.width(), 2); - Gfx::Rect right_side(rect.right() - 1, rect.y(), 2, rect.height()); - Gfx::Rect bottom_side(rect.x(), rect.bottom() - 1, rect.width(), 2); + Gfx::IntRect left_side(rect.x(), rect.y(), 2, rect.height()); + Gfx::IntRect top_side(rect.x(), rect.y(), rect.width(), 2); + Gfx::IntRect right_side(rect.right() - 1, rect.y(), 2, rect.height()); + Gfx::IntRect bottom_side(rect.x(), rect.bottom() - 1, rect.width(), 2); painter.fill_rect(left_side, Color::from_rgb(0xcccc00)); painter.fill_rect(right_side, Color::from_rgb(0x888800)); painter.fill_rect(top_side, Color::from_rgb(0xcccc00)); diff --git a/Games/Snake/SnakeGame.h b/Games/Snake/SnakeGame.h index e015f3fd73..790fc75746 100644 --- a/Games/Snake/SnakeGame.h +++ b/Games/Snake/SnakeGame.h @@ -63,9 +63,9 @@ private: bool is_available(const Coordinate&); void queue_velocity(int v, int h); const Velocity& last_velocity() const; - Gfx::Rect cell_rect(const Coordinate&) const; - Gfx::Rect score_rect() const; - Gfx::Rect high_score_rect() const; + Gfx::IntRect cell_rect(const Coordinate&) const; + Gfx::IntRect score_rect() const; + Gfx::IntRect high_score_rect() const; int m_rows { 20 }; int m_columns { 20 }; diff --git a/Games/Solitaire/Card.cpp b/Games/Solitaire/Card.cpp index 4db2e28bf4..980b48bdf5 100644 --- a/Games/Solitaire/Card.cpp +++ b/Games/Solitaire/Card.cpp @@ -79,13 +79,13 @@ static const NonnullRefPtr s_club = Gfx::CharacterBitmap:: static RefPtr s_background; Card::Card(Type type, uint8_t value) - : m_rect(Gfx::Rect({}, { width, height })) + : m_rect(Gfx::IntRect({}, { width, height })) , m_front(*Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, { width, height })) , m_type(type) , m_value(value) { ASSERT(value < card_count); - Gfx::Rect paint_rect({ 0, 0 }, { width, height }); + Gfx::IntRect paint_rect({ 0, 0 }, { width, height }); if (s_background.is_null()) { s_background = Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, { width, height }); @@ -96,7 +96,7 @@ Card::Card(Type type, uint8_t value) ASSERT(!image.is_null()); float aspect_ratio = image->width() / static_cast(image->height()); - auto target_size = Gfx::Size(static_cast(aspect_ratio * (height - 5)), height - 5); + auto target_size = Gfx::IntSize(static_cast(aspect_ratio * (height - 5)), height - 5); bg_painter.draw_scaled_bitmap( { { (width - target_size.width()) / 2, (height - target_size.height()) / 2 }, target_size }, diff --git a/Games/Solitaire/Card.h b/Games/Solitaire/Card.h index a2dcab197a..2f3f31084d 100644 --- a/Games/Solitaire/Card.h +++ b/Games/Solitaire/Card.h @@ -50,9 +50,9 @@ public: virtual ~Card() override; - Gfx::Rect& rect() { return m_rect; } - Gfx::Point position() const { return m_rect.location(); } - const Gfx::Point& old_positon() const { return m_old_position; } + Gfx::IntRect& rect() { return m_rect; } + Gfx::IntPoint position() const { return m_rect.location(); } + const Gfx::IntPoint& old_positon() const { return m_old_position; } uint8_t value() const { return m_value; }; Type type() const { return m_type; } @@ -61,7 +61,7 @@ public: bool is_upside_down() const { return m_upside_down; } Gfx::Color color() const { return (m_type == Diamonds || m_type == Hearts) ? Color::Red : Color::Black; } - void set_position(const Gfx::Point p) { m_rect.set_location(p); } + void set_position(const Gfx::IntPoint p) { m_rect.set_location(p); } void set_moving(bool moving) { m_moving = moving; } void set_upside_down(bool upside_down) { m_upside_down = upside_down; } @@ -74,9 +74,9 @@ public: private: Card(Type type, uint8_t value); - Gfx::Rect m_rect; + Gfx::IntRect m_rect; NonnullRefPtr m_front; - Gfx::Point m_old_position; + Gfx::IntPoint m_old_position; Type m_type; uint8_t m_value; bool m_old_position_valid { false }; diff --git a/Games/Solitaire/CardStack.cpp b/Games/Solitaire/CardStack.cpp index a13fec527b..dfac4b9347 100644 --- a/Games/Solitaire/CardStack.cpp +++ b/Games/Solitaire/CardStack.cpp @@ -36,7 +36,7 @@ CardStack::CardStack() { } -CardStack::CardStack(const Gfx::Point& position, Type type, uint8_t shift_x, uint8_t shift_y, uint8_t step) +CardStack::CardStack(const Gfx::IntPoint& position, Type type, uint8_t shift_x, uint8_t shift_y, uint8_t step) : m_position(position) , m_type(type) , m_shift_x(shift_x) @@ -110,7 +110,7 @@ void CardStack::rebound_cards() card.set_position(m_stack_positions.at(card_index++)); } -void CardStack::add_all_grabbed_cards(const Gfx::Point& click_location, NonnullRefPtrVector& grabbed) +void CardStack::add_all_grabbed_cards(const Gfx::IntPoint& click_location, NonnullRefPtrVector& grabbed) { ASSERT(grabbed.is_empty()); @@ -218,7 +218,7 @@ NonnullRefPtr CardStack::pop() void CardStack::calculate_bounding_box() { - m_bounding_box = Gfx::Rect(m_position, { Card::width, Card::height }); + m_bounding_box = Gfx::IntRect(m_position, { Card::width, Card::height }); if (m_stack.is_empty()) return; diff --git a/Games/Solitaire/CardStack.h b/Games/Solitaire/CardStack.h index f8721a219c..e4cb2be77b 100644 --- a/Games/Solitaire/CardStack.h +++ b/Games/Solitaire/CardStack.h @@ -40,7 +40,7 @@ public: }; CardStack(); - CardStack(const Gfx::Point& position, Type type, uint8_t shift_x, uint8_t shift_y, uint8_t step = 1); + CardStack(const Gfx::IntPoint& position, Type type, uint8_t shift_x, uint8_t shift_y, uint8_t step = 1); bool is_dirty() const { return m_dirty; } bool is_empty() const { return m_stack.is_empty(); } @@ -49,7 +49,7 @@ public: size_t count() const { return m_stack.size(); } const Card& peek() const { return m_stack.last(); } Card& peek() { return m_stack.last(); } - const Gfx::Rect& bounding_box() const { return m_bounding_box; } + const Gfx::IntRect& bounding_box() const { return m_bounding_box; } void set_focused(bool focused) { m_focused = focused; } void set_dirty() { m_dirty = true; }; @@ -59,7 +59,7 @@ public: void rebound_cards(); bool is_allowed_to_push(const Card&) const; - void add_all_grabbed_cards(const Gfx::Point& click_location, NonnullRefPtrVector& grabbed); + void add_all_grabbed_cards(const Gfx::IntPoint& click_location, NonnullRefPtrVector& grabbed); void draw(GUI::Painter&, const Gfx::Color& background_color); void clear(); @@ -67,14 +67,14 @@ private: void calculate_bounding_box(); NonnullRefPtrVector m_stack; - Vector m_stack_positions; - Gfx::Point m_position; - Gfx::Rect m_bounding_box; + Vector m_stack_positions; + Gfx::IntPoint m_position; + Gfx::IntRect m_bounding_box; Type m_type { Invalid }; uint8_t m_shift_x { 0 }; uint8_t m_shift_y { 0 }; uint8_t m_step {}; bool m_focused { false }; bool m_dirty { false }; - Gfx::Rect m_base; + Gfx::IntRect m_base; }; diff --git a/Games/Solitaire/SolitaireWidget.h b/Games/Solitaire/SolitaireWidget.h index 4f5207b5ca..ac9bbd109c 100644 --- a/Games/Solitaire/SolitaireWidget.h +++ b/Games/Solitaire/SolitaireWidget.h @@ -124,7 +124,7 @@ private: Animation m_animation; CardStack* m_focused_stack { nullptr }; CardStack m_stacks[StackLocation::__Count]; - Gfx::Point m_mouse_down_location; + Gfx::IntPoint m_mouse_down_location; bool m_mouse_down { false }; bool m_repaint_all { true }; bool m_has_to_repaint { true }; 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