Vuo 2.4.4
Loading...
Searching...
No Matches
VuoCommandResizeComment.cc
Go to the documentation of this file.
1
10#include "VuoCommandCommon.hh"
12#include "VuoComment.hh"
13#include "VuoCompilerComment.hh"
15#include "VuoEditorWindow.hh"
16#include "VuoRendererComment.hh"
17
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
68
73{
75
76 window->resetCompositionWithSnapshot(revertedSnapshot);
77}
78
83{
85
86 window->resetCompositionWithSnapshot(updatedSnapshot);
87}