Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/ign-gui2' into 2_to_3_2020-06-12
Browse files Browse the repository at this point in the history
  • Loading branch information
chapulina committed Jun 13, 2020
2 parents 412d0c3 + b6f7179 commit 3df3ad6
Showing 1 changed file with 141 additions and 27 deletions.
168 changes: 141 additions & 27 deletions include/ignition/gui/qml/IgnRulers.qml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Rectangle {
// Left ruler
Rectangle {
width: rulersThickness
height: parent.height
height: parent.height - 20
visible: rulersRect.enabled
color: "transparent"
anchors.horizontalCenter: parent.left
Expand All @@ -60,13 +60,7 @@ Rectangle {
onMouseXChanged: {
if (drag.active)
{
var newCardX = Math.max(target.x + mouseX, 0)
var newCardWidth = Math.max(target.width + (target.x - newCardX),
rulersRect.minSize)
if (newCardWidth === target.width)
return;
target.x = newCardX
target.width = newCardWidth
resizeLeft(target, mouseX);
}
}
}
Expand All @@ -75,7 +69,7 @@ Rectangle {
// Right ruler
Rectangle {
width: rulersThickness
height: parent.height
height: parent.height - 20
visible: rulersRect.enabled
color: "transparent"
anchors.horizontalCenter: parent.right
Expand All @@ -88,18 +82,15 @@ Rectangle {
onMouseXChanged: {
if (drag.active)
{
target.width = Math.max(target.width + mouseX, rulersRect.minSize)

if (target.width + target.x > target.parent.width)
target.width = target.parent.width - target.x
resizeRight(target, mouseX);
}
}
}
}

// Top ruler
Rectangle {
width: parent.width
width: parent.width - 20
height: rulersThickness
visible: rulersRect.enabled
color: "transparent"
Expand All @@ -113,23 +104,15 @@ Rectangle {
onMouseYChanged: {
if (drag.active)
{
var newCardY = Math.max(target.y + mouseY, 0)
var newCardHeight = Math.max(target.height + (target.y - newCardY),
rulersRect.minSize)

if (newCardHeight === target.height)
return;

target.y = newCardY
target.height = newCardHeight
resizeTop(target, mouseY);
}
}
}
}

// Bottom ruler
Rectangle {
width: parent.width
width: parent.width - 20
height: rulersThickness
visible: rulersRect.enabled
color: "transparent"
Expand All @@ -143,12 +126,143 @@ Rectangle {
onMouseYChanged: {
if (drag.active)
{
target.height = Math.max(target.height + mouseY, rulersRect.minSize)
resizeBottom(target, mouseY);
}
}
}
}

// Top-Left Ruler
Rectangle {
width: 25
height: 25
visible: rulersRect.enabled
color: "transparent"
anchors.horizontalCenter: parent.left
anchors.verticalCenter: parent.top

MouseArea {
anchors.fill: parent
cursorShape: Qt.SizeFDiagCursor
drag { target: parent; axis: Drag.XAndYAxis }
onMouseYChanged: {
if (drag.active)
{
resizeTop(target, mouseY);
resizeLeft(target, mouseX);
}
}
}
}

// Top-Right Ruler
Rectangle {
width: 25
height: 25
visible: rulersRect.enabled
color: "transparent"
anchors.horizontalCenter: parent.right
anchors.verticalCenter: parent.top

MouseArea {
anchors.fill: parent
cursorShape: Qt.SizeBDiagCursor
drag { target: parent; axis: Drag.XAndYAxis }
onMouseYChanged: {
if (drag.active)
{
resizeTop(target, mouseY);
resizeRight(target, mouseX);
}
}
}
}

// Bottom-Left Ruler
Rectangle {
width: 25
height: 25
visible: rulersRect.enabled
color: "transparent"
anchors.horizontalCenter: parent.left
anchors.verticalCenter: parent.bottom

MouseArea {
anchors.fill: parent
cursorShape: Qt.SizeBDiagCursor
drag { target: parent; axis: Drag.XAndYAxis }
onMouseYChanged: {
if (drag.active)
{
resizeBottom(target, mouseY);
resizeLeft(target, mouseX);
}
}
}
}

// Bottom-Right Ruler
Rectangle {
width: 25
height: 25
visible: rulersRect.enabled
color: "transparent"
anchors.horizontalCenter: parent.right
anchors.verticalCenter: parent.bottom

if (target.height + target.y > target.parent.height)
target.height = target.parent.height - target.y
MouseArea {
anchors.fill: parent
cursorShape: Qt.SizeFDiagCursor
drag { target: parent; axis: Drag.XAndYAxis }
onMouseYChanged: {
if (drag.active)
{
resizeBottom(target, mouseY);
resizeRight(target, mouseX);
}
}
}
}

function resizeLeft(target, mouseX)
{
var newCardX = Math.max(target.x + mouseX, 0)
var newCardWidth = Math.max(target.width + (target.x - newCardX),
rulersRect.minSize)

if (newCardWidth === target.width)
return;

target.x = newCardX
target.width = newCardWidth
}

function resizeRight(target, mouseX)
{
target.width = Math.max(target.width + mouseX, rulersRect.minSize)

if (target.width + target.x > target.parent.width)
target.width = target.parent.width - target.x
}

function resizeTop(target, mouseY)
{
var newCardY = Math.max(target.y + mouseY, 0)
var newCardHeight = Math.max(target.height + (target.y - newCardY),
rulersRect.minSize)

if (newCardHeight === target.height)
return;

target.y = newCardY
target.height = newCardHeight
}

function resizeBottom(target, mouseY)
{
target.height = Math.max(target.height + mouseY, rulersRect.minSize)

if (target.height + target.y > target.parent.height)
target.height = target.parent.height - target.y
}
}

0 comments on commit 3df3ad6

Please sign in to comment.