From 3a6a2f78da62fcbeec32f04bd5050629b0c8f7c6 Mon Sep 17 00:00:00 2001 From: Micah Stanley Date: Wed, 20 Nov 2024 03:20:01 +0000 Subject: [PATCH] homescreen/folio: fix icon drop position misalignment within folder and outside folder view check not accounting for size differences This fixes an issue with folder app icon drop positions being misaligned. Noticeably causing issues when placing apps within folders when using gesture only mode. Also, this fixes an issue with the outsideView calculation not accounting for folder icon size differences. Causing an issues with some apps still being interactive when outside the current page. --- .../homescreens/folio/folioapplicationfolder.cpp | 11 ++++++----- containments/homescreens/folio/homescreenstate.cpp | 7 +++++-- .../folio/package/contents/ui/FolderView.qml | 4 ++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/containments/homescreens/folio/folioapplicationfolder.cpp b/containments/homescreens/folio/folioapplicationfolder.cpp index 6ec9fcaf..e597ab76 100644 --- a/containments/homescreens/folio/folioapplicationfolder.cpp +++ b/containments/homescreens/folio/folioapplicationfolder.cpp @@ -282,16 +282,17 @@ QPointF ApplicationFolderModel::getDelegatePosition(int index) return {0, 0}; } auto delegate = m_folder->m_delegates[index]; - qreal pageContentWidth = m_folder->m_homeScreen->homeScreenState()->folderPageContentWidth(); - qreal margin = horizontalPageMargin(); + qreal pageContentSize = m_folder->m_homeScreen->homeScreenState()->folderPageContentWidth(); + qreal topMargin = verticalPageMargin(); + qreal leftMargin = horizontalPageMargin(); - int cellSize = pageContentWidth / numGridLengthOnPage(); + int cellSize = pageContentSize / numGridLengthOnPage(); qreal cellWitdhRecenter = (cellSize - m_folder->m_homeScreen->homeScreenState()->pageCellWidth()) / 2; qreal cellHeightRecenter = (cellSize - m_folder->m_homeScreen->homeScreenState()->pageCellHeight()) / 2; - qreal xPosition = cellWitdhRecenter + margin + delegate.columnIndex * cellSize; - qreal yPosition = cellHeightRecenter + delegate.rowIndex * cellSize; + qreal xPosition = cellWitdhRecenter + leftMargin + delegate.columnIndex * cellSize; + qreal yPosition = cellHeightRecenter + topMargin + delegate.rowIndex * cellSize; return {xPosition, yPosition}; } diff --git a/containments/homescreens/folio/homescreenstate.cpp b/containments/homescreens/folio/homescreenstate.cpp index da1441cb..cdac52ce 100644 --- a/containments/homescreens/folio/homescreenstate.cpp +++ b/containments/homescreens/folio/homescreenstate.cpp @@ -703,8 +703,11 @@ QPointF HomeScreenState::getFolderDelegateScreenPosition(int position) return {0, 0}; } auto pos = m_currentFolder->applications()->getDelegatePosition(position); - qreal x = pos.x() + (m_viewWidth - m_folderPageWidth) / 2; - qreal y = pos.y() + (m_viewHeight - m_folderPageHeight) / 2; + + qreal x = pos.x() + (m_viewWidth - m_viewLeftPadding - m_viewRightPadding - m_folderPageWidth) / 2; + qreal y = pos.y() + (m_viewHeight - m_viewTopPadding - m_viewBottomPadding - m_folderPageHeight) / 2; + x += m_viewLeftPadding; + y += m_viewTopPadding; return {x, y}; } diff --git a/containments/homescreens/folio/package/contents/ui/FolderView.qml b/containments/homescreens/folio/package/contents/ui/FolderView.qml index 53c415eb..2e318c16 100644 --- a/containments/homescreens/folio/package/contents/ui/FolderView.qml +++ b/containments/homescreens/folio/package/contents/ui/FolderView.qml @@ -177,8 +177,8 @@ Folio.DelegateTouchArea { readonly property int cellHeight: folio.HomeScreenState.pageCellHeight readonly property bool outsideView: { - const appPosition = x + folio.HomeScreenState.folderViewX; - return (appPosition < -folderCellSize || appPosition > folderBackground.width) + const appPosition = x + (cellWidth - folderCellSize) / 2 + folio.HomeScreenState.folderViewX; + return (appPosition <= -folderCellSize || appPosition >= folderBackground.width); } readonly property var dragState: folio.HomeScreenState.dragState