10 #if VSTGUI_LIVE_EDITING 12 #include "uiselection.h" 13 #include "../uiviewfactory.h" 14 #include "../../lib/ccolor.h" 15 #include "../../lib/cgradient.h" 30 class BaseSelectionOperation :
public IAction,
protected std::list<T>
33 BaseSelectionOperation (UISelection* selection) : selection (selection) {}
36 SharedPointer<UISelection> selection;
40 class SizeToFitOperation :
public BaseSelectionOperation<std::pair<SharedPointer<CView>, CRect> >
43 SizeToFitOperation (UISelection* selection);
44 ~SizeToFitOperation ()
override =
default;
46 UTF8StringPtr getName ()
override;
49 void undo ()
override;
53 class UnembedViewOperation :
public BaseSelectionOperation<SharedPointer<CView> >
56 UnembedViewOperation (UISelection* selection,
const IViewFactory* factory);
57 ~UnembedViewOperation ()
override =
default;
59 UTF8StringPtr getName ()
override;
62 void undo ()
override;
65 void collectSubviews (CViewContainer* container,
bool deep);
66 const IViewFactory* factory;
67 SharedPointer<CViewContainer> containerView;
68 CViewContainer* parent;
72 class EmbedViewOperation :
public BaseSelectionOperation<std::pair<SharedPointer<CView>, CRect> >
75 EmbedViewOperation (UISelection* selection, CViewContainer* newContainer);
76 ~EmbedViewOperation ()
override =
default;
78 UTF8StringPtr getName ()
override;
80 void undo ()
override;
83 SharedPointer<CViewContainer> newContainer;
84 CViewContainer* parent;
88 class ViewCopyOperation :
public IAction,
protected std::list<SharedPointer<CView> >
91 ViewCopyOperation (UISelection* copySelection, UISelection* workingSelection, CViewContainer* parent,
const CPoint& offset, IUIDescription* desc);
92 ~ViewCopyOperation ()
override =
default;
94 UTF8StringPtr getName ()
override;
96 void undo ()
override;
98 SharedPointer<CViewContainer> parent;
99 SharedPointer<UISelection> copySelection;
100 SharedPointer<UISelection> workingSelection;
101 std::list<SharedPointer<CView> > oldSelectedViews;
105 class ViewSizeChangeOperation :
public BaseSelectionOperation<std::pair<SharedPointer<CView>, CRect> >
108 ViewSizeChangeOperation (UISelection* selection,
bool sizing,
bool autosizingEnabled);
109 ~ViewSizeChangeOperation ()
override =
default;
111 UTF8StringPtr getName ()
override;
113 void undo ()
override;
123 struct DeleteOperationViewAndNext
125 DeleteOperationViewAndNext (CView* view, CView* nextView) : view (view), nextView (nextView) {}
126 DeleteOperationViewAndNext (
const DeleteOperationViewAndNext& copy) : view (copy.view), nextView (copy.nextView) {}
127 SharedPointer<CView> view;
128 SharedPointer<CView> nextView;
132 class DeleteOperation :
public IAction,
protected std::multimap<SharedPointer<CViewContainer>, DeleteOperationViewAndNext>
135 DeleteOperation (UISelection* selection);
136 ~DeleteOperation ()
override =
default;
138 UTF8StringPtr getName ()
override;
140 void undo ()
override;
142 SharedPointer<UISelection> selection;
146 class InsertViewOperation :
public IAction
149 InsertViewOperation (CViewContainer* parent, CView* view, UISelection* selection);
150 ~InsertViewOperation ()
override =
default;
152 UTF8StringPtr getName ()
override;
154 void undo ()
override;
156 SharedPointer<CViewContainer> parent;
157 SharedPointer<CView> view;
158 SharedPointer<UISelection> selection;
162 class TransformViewTypeOperation :
public IAction
165 TransformViewTypeOperation (UISelection* selection, IdStringPtr viewClassName, UIDescription* desc,
const UIViewFactory* factory);
166 ~TransformViewTypeOperation ()
override;
168 UTF8StringPtr getName ()
override;
170 void exchangeSubViews (CViewContainer* src, CViewContainer* dst);
172 void undo ()
override;
174 SharedPointer<CView> view;
176 SharedPointer<CView> beforeView;
177 SharedPointer<CViewContainer> parent;
178 SharedPointer<UISelection> selection;
179 const UIViewFactory* factory;
180 SharedPointer<UIDescription> description;
184 class AttributeChangeAction :
public IAction,
protected std::map<SharedPointer<CView>, std::string>
187 AttributeChangeAction (UIDescription* desc, UISelection* selection,
const std::string& attrName,
const std::string& attrValue);
188 ~AttributeChangeAction ()
override =
default;
190 UTF8StringPtr getName ()
override;
192 void undo ()
override;
194 void updateSelection ();
197 SharedPointer<UISelection> selection;
198 std::string attrName;
199 std::string attrValue;
204 class MultipleAttributeChangeAction :
public IAction,
public std::vector<std::pair<SharedPointer<CView>, std::string> >
207 MultipleAttributeChangeAction (UIDescription* description,
const std::list<CView*>& views, IViewCreator::AttrType attrType, UTF8StringPtr oldValue, UTF8StringPtr newValue);
208 UTF8StringPtr getName ()
override {
return "multiple view attribute changes"; }
210 void undo ()
override;
212 void setAttributeValue (UTF8StringPtr value);
213 static void collectAllSubViews (CView* view, std::list<CView*>& views);
214 void collectViewsWithAttributeValue (
const UIViewFactory* viewFactory, IUIDescription* desc, CView* startView, IViewCreator::AttrType type,
const std::string& value);
216 SharedPointer<UIDescription> description;
217 std::string oldValue;
218 std::string newValue;
222 class TagChangeAction :
public IAction
225 TagChangeAction (UIDescription* description, UTF8StringPtr name, UTF8StringPtr newTagString,
bool remove,
bool performOrUndo);
227 UTF8StringPtr getName ()
override;
229 void undo ()
override;
231 bool isAddTag ()
const {
return isNewTag; }
233 SharedPointer<UIDescription> description;
236 std::string originalTag;
243 class TagNameChangeAction :
public IAction
246 TagNameChangeAction (UIDescription* description, UTF8StringPtr oldName, UTF8StringPtr newName,
bool performOrUndo);
248 UTF8StringPtr getName ()
override;
250 void undo ()
override;
252 SharedPointer<UIDescription> description;
259 class ColorChangeAction :
public IAction
262 ColorChangeAction (UIDescription* description, UTF8StringPtr name,
const CColor& color,
bool remove,
bool performOrUndo);
264 UTF8StringPtr getName ()
override;
266 void undo ()
override;
268 bool isAddColor ()
const {
return isNewColor; }
270 SharedPointer<UIDescription> description;
280 class ColorNameChangeAction :
public IAction
283 ColorNameChangeAction (UIDescription* description, UTF8StringPtr oldName, UTF8StringPtr newName,
bool performOrUndo);
285 UTF8StringPtr getName ()
override;
287 void undo ()
override;
289 SharedPointer<UIDescription> description;
296 class BitmapChangeAction :
public IAction
299 BitmapChangeAction (UIDescription* description, UTF8StringPtr name, UTF8StringPtr path,
bool remove,
bool performOrUndo);
301 UTF8StringPtr getName ()
override;
303 void undo ()
override;
305 bool isAddBitmap ()
const {
return isNewBitmap; }
307 SharedPointer<UIDescription> description;
310 std::string originalPath;
317 class BitmapNameChangeAction :
public IAction
320 BitmapNameChangeAction (UIDescription* description, UTF8StringPtr oldName, UTF8StringPtr newName,
bool performOrUndo);
322 UTF8StringPtr getName ()
override;
324 void undo ()
override;
326 SharedPointer<UIDescription> description;
333 class NinePartTiledBitmapChangeAction :
public IAction
336 NinePartTiledBitmapChangeAction (UIDescription* description, UTF8StringPtr name,
const CRect* rect,
bool performOrUndo);
337 ~NinePartTiledBitmapChangeAction ()
override;
339 UTF8StringPtr getName ()
override;
341 void undo ()
override;
343 SharedPointer<UIDescription> description;
351 class BitmapFilterChangeAction :
public IAction
354 BitmapFilterChangeAction (UIDescription* description, UTF8StringPtr bitmapName,
const std::list<SharedPointer<UIAttributes> >& attributes,
bool performOrUndo);
355 ~BitmapFilterChangeAction ()
override =
default;
357 UTF8StringPtr getName ()
override;
359 void undo ()
override;
361 SharedPointer<UIDescription> description;
362 std::string bitmapName;
363 std::list<SharedPointer<UIAttributes> > newAttributes;
364 std::list<SharedPointer<UIAttributes> > oldAttributes;
369 class GradientChangeAction :
public IAction
372 GradientChangeAction (UIDescription* description, UTF8StringPtr name, CGradient* gradient,
bool remove,
bool performOrUndo);
374 UTF8StringPtr getName ()
override;
376 void undo ()
override;
378 bool isAddGradient ()
const {
return originalGradient == 0; }
380 SharedPointer<UIDescription> description;
382 SharedPointer<CGradient> gradient;
383 SharedPointer<CGradient> originalGradient;
389 class GradientNameChangeAction :
public IAction
392 GradientNameChangeAction (UIDescription* description, UTF8StringPtr oldName, UTF8StringPtr newName,
bool performOrUndo);
394 UTF8StringPtr getName ()
override;
396 void undo ()
override;
398 SharedPointer<UIDescription> description;
405 class FontChangeAction :
public IAction
408 FontChangeAction (UIDescription* description, UTF8StringPtr name, CFontRef font,
bool remove,
bool performOrUndo);
410 UTF8StringPtr getName ()
override;
412 void undo ()
override;
414 bool isAddFont ()
const {
return originalFont == 0; }
416 SharedPointer<UIDescription> description;
418 std::string alternativeNames;
419 SharedPointer<CFontDesc> font;
420 SharedPointer<CFontDesc> originalFont;
426 class FontNameChangeAction :
public IAction
429 FontNameChangeAction (UIDescription* description, UTF8StringPtr oldName, UTF8StringPtr newName,
bool performOrUndo);
431 UTF8StringPtr getName ()
override;
433 void undo ()
override;
435 SharedPointer<UIDescription> description;
442 class AlternateFontChangeAction :
public IAction
445 AlternateFontChangeAction (UIDescription* description, UTF8StringPtr fontName, UTF8StringPtr newAlternateFontNames);
446 UTF8StringPtr getName ()
override;
448 void undo ()
override;
450 SharedPointer<UIDescription> description;
451 std::string fontName;
452 std::string newAlternateFontNames;
453 std::string oldAlternateFontNames;
457 class HierarchyMoveViewOperation :
public IAction
460 HierarchyMoveViewOperation (CView* view, UISelection* selection,
bool up);
461 ~HierarchyMoveViewOperation ()
override =
default;
463 UTF8StringPtr getName ()
override;
465 void undo ()
override;
467 SharedPointer<CView> view;
468 SharedPointer<CViewContainer> parent;
469 SharedPointer<UISelection> selection;
474 class TemplateNameChangeAction :
public IAction
477 TemplateNameChangeAction (UIDescription* description, IActionPerformer* actionPerformer, UTF8StringPtr oldName, UTF8StringPtr newName);
479 UTF8StringPtr getName ()
override;
481 void undo ()
override;
483 SharedPointer<UIDescription> description;
484 IActionPerformer* actionPerformer;
490 class CreateNewTemplateAction :
public IAction
493 CreateNewTemplateAction (UIDescription* description, IActionPerformer* actionPerformer, UTF8StringPtr name, UTF8StringPtr baseViewClassName);
495 UTF8StringPtr getName ()
override;
497 void undo ()
override;
499 SharedPointer<UIDescription> description;
500 IActionPerformer* actionPerformer;
501 SharedPointer<CView> view;
503 std::string baseViewClassName;
507 class DuplicateTemplateAction :
public IAction
510 DuplicateTemplateAction (UIDescription* description, IActionPerformer* actionPerformer, UTF8StringPtr name, UTF8StringPtr dupName);
512 UTF8StringPtr getName ()
override;
514 void undo ()
override;
516 SharedPointer<UIDescription> description;
517 IActionPerformer* actionPerformer;
518 SharedPointer<CView> view;
524 class DeleteTemplateAction :
public IAction
527 DeleteTemplateAction (UIDescription* description, IActionPerformer* actionPerformer, CView* view, UTF8StringPtr name);
529 UTF8StringPtr getName ()
override;
531 void undo ()
override;
533 SharedPointer<UIDescription> description;
534 IActionPerformer* actionPerformer;
535 SharedPointer<CView> view;
536 SharedPointer<UIAttributes> attributes;
542 #endif // VSTGUI_LIVE_EDITING 544 #endif // __uiactions__ void perform(Context context, Task &&task)
Definition: macasync.mm:29
Definition: customcontrols.cpp:8