adding some widget preview corrections

This commit is contained in:
tibbi 2022-09-26 22:00:14 +02:00
parent 968fd79f18
commit 4e295deb3e
1 changed files with 5 additions and 3 deletions

View File

@ -319,13 +319,15 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
// show the widget preview itself at dragging
val drawable = draggedItem!!.drawable!!
val aspectRatio = drawable.minimumHeight / drawable.minimumWidth.toFloat()
val drawableX = (draggedItemCurrentCoords.first - drawable.minimumWidth / 2f).toInt()
val drawableY = (draggedItemCurrentCoords.second - drawable.minimumHeight / 2f).toInt()
val drawableY = (draggedItemCurrentCoords.second - drawable.minimumHeight / 3f).toInt()
val drawableWidth = draggedItem!!.widthCells * rowWidth - iconMargin * (draggedItem!!.widthCells - 1)
drawable.setBounds(
drawableX,
drawableY,
drawableX + draggedItem!!.widthCells * rowWidth - iconMargin * 2,
drawableY + draggedItem!!.heightCells * rowHeight - iconMargin * 2
drawableX + drawableWidth,
(drawableY + drawableWidth * aspectRatio).toInt()
)
drawable.draw(canvas)
}