mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-22 22:23:57 -06:00
Move setting the dragged-to position to its own function. [CURA-6478]
This commit is contained in:
parent
78f15d8fcb
commit
7382798b6a
1 changed files with 14 additions and 9 deletions
|
@ -214,6 +214,19 @@ Item
|
|||
border.color: UM.Theme.getColor("lining")
|
||||
radius: UM.Theme.getSize("default_radius").width
|
||||
|
||||
function trySetPosition(posNewX, posNewY)
|
||||
{
|
||||
var margin = UM.Theme.getSize("narrow_margin");
|
||||
var minPt = base.mapFromItem(null, margin.width, margin.height);
|
||||
var maxPt = base.mapFromItem(null,
|
||||
CuraApplication.appWidth() - (contentContainer.width + margin.width),
|
||||
CuraApplication.appHeight() - (contentContainer.height + margin.height));
|
||||
var initialY = background.height + base.shadowOffset + margin.height;
|
||||
|
||||
contentContainer.x = Math.min(maxPt.x, Math.max(minPt.x, posNewX));
|
||||
contentContainer.y = Math.min(maxPt.y, Math.max(initialY, posNewY));
|
||||
}
|
||||
|
||||
ExpandableComponentHeader
|
||||
{
|
||||
id: contentHeader
|
||||
|
@ -247,15 +260,7 @@ Item
|
|||
var delta = Qt.point(mouse.x - clickPos.x, mouse.y - clickPos.y);
|
||||
if (delta.x !== 0 || delta.y !== 0)
|
||||
{
|
||||
var margin = UM.Theme.getSize("narrow_margin");
|
||||
var minPt = base.mapFromItem(null, margin.width, margin.height);
|
||||
var maxPt = base.mapFromItem(null,
|
||||
CuraApplication.appWidth() - (contentContainer.width + margin.width),
|
||||
CuraApplication.appHeight() - (contentContainer.height + margin.width));
|
||||
var initialY = background.height + base.shadowOffset + margin.height;
|
||||
|
||||
contentContainer.x = Math.min(maxPt.x, Math.max(minPt.x, contentContainer.x + delta.x));
|
||||
contentContainer.y = Math.min(maxPt.y, Math.max(initialY, contentContainer.y + delta.y));
|
||||
contentContainer.trySetPosition(contentContainer.x + delta.x, contentContainer.y + delta.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue