Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
304591d1
Commit
304591d1
authored
Sep 10, 2012
by
Aleksei Kanash
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resizing of items works fine in all cases.
parent
e68336e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
41 deletions
+58
-41
UBGraphicsDelegateFrame.cpp
src/domain/UBGraphicsDelegateFrame.cpp
+56
-41
UBGraphicsDelegateFrame.h
src/domain/UBGraphicsDelegateFrame.h
+2
-0
No files found.
src/domain/UBGraphicsDelegateFrame.cpp
View file @
304591d1
...
...
@@ -325,11 +325,53 @@ QPointF UBGraphicsDelegateFrame::getFixedPointFromPos()
fixedPoint
=
delegated
()
->
sceneBoundingRect
().
bottomRight
();
}
}
else
if
(
resizingBottomRight
())
}
return
fixedPoint
;
}
QSizeF
UBGraphicsDelegateFrame
::
getResizeVector
(
qreal
moveX
,
qreal
moveY
)
{
qreal
dPosX
=
0
;
qreal
dPosY
=
0
;
if
(
resizingTop
())
{
if
(
mMirrorX
&&
mMirrorY
)
dPosY
=
moveY
;
else
dPosY
=
-
moveY
;
}
else
if
(
resizingLeft
())
{
if
(
mMirrorX
&&
mMirrorY
)
dPosX
=
moveX
;
else
dPosX
=
-
moveX
;
}
else
if
(
resizingRight
())
dPosX
=
(
mMirrorX
)
?
-
moveX
:
moveX
;
else
if
(
resizingBottom
())
dPosY
=
mMirrorY
?
-
moveY
:
moveY
;
return
QSizeF
(
dPosX
,
dPosY
);
}
void
UBGraphicsDelegateFrame
::
resizeDelegate
(
qreal
moveX
,
qreal
moveY
)
{
QPointF
fixedPoint
=
getFixedPointFromPos
();
UBResizableGraphicsItem
*
resizableItem
=
dynamic_cast
<
UBResizableGraphicsItem
*>
(
delegated
());
if
(
resizableItem
)
{
QSizeF
originalSize
=
delegated
()
->
boundingRect
().
size
();
resizableItem
->
resize
(
originalSize
+
getResizeVector
(
moveX
,
moveY
));
if
(
resizingTop
()
||
resizingLeft
()
||
((
mMirrorX
||
mMirrorY
)
&&
resizingBottomRight
()))
{
delegated
()
->
setPos
(
delegated
()
->
pos
()
-
getFixedPointFromPos
()
+
fixedPoint
);
}
}
return
fixedPoint
;
}
void
UBGraphicsDelegateFrame
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
...
...
@@ -523,54 +565,27 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
else
if
(
mOperationMode
==
Resizing
)
{
QSizeF
originalSize
=
delegated
()
->
boundingRect
().
size
();
mScaleX
=
1
;
mScaleY
=
1
;
if
(
!
moving
()
&&
!
rotating
())
{
qreal
dPosX
=
0
;
qreal
dPosY
=
0
;
QPointF
fixedPoint
=
getFixedPointFromPos
();
if
(
resizingTop
())
{
if
(
mMirrorX
&&
mMirrorY
)
dPosY
=
moveY
;
else
dPosY
=
-
moveY
;
}
else
if
(
resizingLeft
())
if
(
resizingBottomRight
())
{
if
(
mMirrorX
&&
mMirrorY
)
dPosX
=
moveX
;
mCurrentTool
=
ResizeTop
;
else
dPosX
=
-
moveX
;
}
else
if
(
resizingBottomRight
())
{
dPosX
=
moveX
;
dPosY
=
moveY
;
}
else
if
(
resizingRight
())
dPosX
=
(
mMirrorX
)
?
-
moveX
:
moveX
;
else
if
(
resizingBottom
())
dPosY
=
mMirrorY
?
-
moveY
:
moveY
;
mCurrentTool
=
ResizeBottom
;
UBResizableGraphicsItem
*
resizableItem
=
dynamic_cast
<
UBResizableGraphicsItem
*>
(
delegated
());
if
(
resizableItem
)
{
resizableItem
->
resize
(
originalSize
.
width
()
+
dPosX
,
originalSize
.
height
()
+
dPosY
);
if
(
resizingTop
()
||
resizingLeft
()
||
((
mMirrorX
||
mMirrorY
)
&&
resizingBottomRight
()))
{
QPointF
newFixedPoint
=
getFixedPointFromPos
();;
resizeDelegate
(
moveX
,
moveY
);
delegated
()
->
setPos
(
delegated
()
->
pos
()
-
newFixedPoint
+
fixedPoint
);
}
if
(
mMirrorX
&&
mMirrorY
)
mCurrentTool
=
ResizeLeft
;
else
mCurrentTool
=
ResizeRight
;
resizeDelegate
(
moveX
,
moveY
);
mCurrentTool
=
ResizeBottomRight
;
}
else
resizeDelegate
(
moveX
,
moveY
);
}
}
...
...
src/domain/UBGraphicsDelegateFrame.h
View file @
304591d1
...
...
@@ -38,6 +38,8 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
QPointF
getFixedPointFromPos
();
QSizeF
getResizeVector
(
qreal
moveX
,
qreal
moveY
);
void
resizeDelegate
(
qreal
moveX
,
qreal
moveY
);
virtual
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment