diff --git a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp index ac1a7604a5..73141a2e25 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp @@ -94,8 +94,8 @@ void InfinitelyScrollableTableView::mousemove_event(GUI::MouseEvent& event) top_left_most_index = index; }); - auto top_left_rect = content_rect(top_left_most_index); - auto bottom_right_rect = content_rect(bottom_right_most_index); + auto top_left_rect = content_rect_minus_scrollbars(top_left_most_index); + auto bottom_right_rect = content_rect_minus_scrollbars(bottom_right_most_index); auto distance_tl = top_left_rect.center() - event.position(); auto distance_br = bottom_right_rect.center() - event.position(); auto is_over_top_line = false; @@ -201,7 +201,7 @@ void InfinitelyScrollableTableView::mousedown_event(GUI::MouseEvent& event) m_is_dragging_for_cut = true; else if (m_is_hovering_extend_zone) m_is_dragging_for_extend = true; - auto rect = content_rect(m_target_cell); + auto rect = content_rect_minus_scrollbars(m_target_cell); GUI::MouseEvent adjusted_event = { (GUI::Event::Type)event.type(), rect.center(), event.buttons(), event.button(), event.modifiers(), event.wheel_delta_x(), event.wheel_delta_y() }; AbstractTableView::mousedown_event(adjusted_event); } else { @@ -236,7 +236,7 @@ void InfinitelyScrollableTableView::mouseup_event(GUI::MouseEvent& event) m_has_committed_to_cutting = false; m_has_committed_to_extending = false; if (m_is_hovering_cut_zone || m_is_hovering_extend_zone) { - auto rect = content_rect(m_target_cell); + auto rect = content_rect_minus_scrollbars(m_target_cell); GUI::MouseEvent adjusted_event = { (GUI::Event::Type)event.type(), rect.center(), event.buttons(), event.button(), event.modifiers(), event.wheel_delta_x(), event.wheel_delta_y() }; TableView::mouseup_event(adjusted_event); } else { diff --git a/Userland/Libraries/LibGUI/AbstractTableView.cpp b/Userland/Libraries/LibGUI/AbstractTableView.cpp index eded7cf084..68db013f4c 100644 --- a/Userland/Libraries/LibGUI/AbstractTableView.cpp +++ b/Userland/Libraries/LibGUI/AbstractTableView.cpp @@ -326,6 +326,12 @@ Gfx::IntRect AbstractTableView::content_rect(const ModelIndex& index) const return content_rect(index.row(), index.column()); } +Gfx::IntRect AbstractTableView::content_rect_minus_scrollbars(const ModelIndex& index) const +{ + auto naive_content_rect = content_rect(index.row(), index.column()); + return { naive_content_rect.x() - horizontal_scrollbar().value(), naive_content_rect.y() - vertical_scrollbar().value(), naive_content_rect.width(), naive_content_rect.height() }; +} + Gfx::IntRect AbstractTableView::row_rect(int item_index) const { return { row_header().is_visible() ? row_header().width() : 0, diff --git a/Userland/Libraries/LibGUI/AbstractTableView.h b/Userland/Libraries/LibGUI/AbstractTableView.h index d4e43b00ce..74de744560 100644 --- a/Userland/Libraries/LibGUI/AbstractTableView.h +++ b/Userland/Libraries/LibGUI/AbstractTableView.h @@ -55,6 +55,7 @@ public: Gfx::IntPoint adjusted_position(const Gfx::IntPoint&) const; virtual Gfx::IntRect content_rect(const ModelIndex&) const override; + Gfx::IntRect content_rect_minus_scrollbars(const ModelIndex&) const; Gfx::IntRect content_rect(int row, int column) const; Gfx::IntRect row_rect(int item_index) const;