Vuo
2.0.3
editor
VuoCommandResizeComment.cc
Go to the documentation of this file.
1
10
#include "
VuoCommandCommon.hh
"
11
#include "
VuoCommandResizeComment.hh
"
12
#include "
VuoComment.hh
"
13
#include "
VuoCompilerComment.hh
"
14
#include "
VuoEditorComposition.hh
"
15
#include "
VuoEditorWindow.hh
"
16
#include "
VuoRendererComment.hh
"
17
21
VuoCommandResizeComment::VuoCommandResizeComment
(
VuoRendererComment
*comment, qreal dx, qreal dy,
VuoEditorWindow
*window)
22
:
VuoCommandCommon
(window)
23
{
24
setText(QApplication::translate(
"VuoEditorWindow"
,
"Resize Comment"
));
25
this->window = window;
26
this->revertedSnapshot = window->
getComposition
()->
takeSnapshot
();
27
28
// Since the only current way to resize a comment is by dragging, the resizing must already have happened.
29
bool
changeAlreadyMade =
true
;
30
if
(changeAlreadyMade)
31
{
32
// If the item's size has already been updated, reconstruct its original size
33
// for the composition's "Before" snapshot.
34
comment->
getBase
()->
setWidth
(comment->
getBase
()->
getWidth
() - dx);
35
comment->
getBase
()->
setHeight
(comment->
getBase
()->
getHeight
() - dy);
36
37
this->revertedSnapshot = window->
getComposition
()->
takeSnapshot
();
38
39
// Now re-re-size it.
40
comment->
getBase
()->
setWidth
(comment->
getBase
()->
getWidth
() + dx);
41
comment->
getBase
()->
setHeight
(comment->
getBase
()->
getHeight
() + dy);
42
}
43
else
44
this->revertedSnapshot = window->
getComposition
()->
takeSnapshot
();
45
46
47
// Start of command content.
48
{
49
// Would only need to do something here if @c changeAlreadyMade were false.
50
}
51
// End of command content.
52
53
this->updatedSnapshot = window->
getComposition
()->
takeSnapshot
();
54
55
setDescription
(
"Resize comment %s to %d,%d"
,
56
comment->
getBase
()->
getCompiler
()->
getGraphvizIdentifier
().c_str(),
57
comment->
getBase
()->
getWidth
(),
58
comment->
getBase
()->
getHeight
());
59
}
60
64
int
VuoCommandResizeComment::id
()
const
65
{
66
return
VuoCommandCommon::resizeCommentCommandID
;
67
}
68
72
void
VuoCommandResizeComment::undo
()
73
{
74
VuoCommandCommon_undo
;
75
76
window->
resetCompositionWithSnapshot
(revertedSnapshot);
77
}
78
82
void
VuoCommandResizeComment::redo
()
83
{
84
VuoCommandCommon_redo
;
85
86
window->
resetCompositionWithSnapshot
(updatedSnapshot);
87
}
Generated on Tue Apr 28 2020 16:53:59 for Vuo by
1.8.17