1 /* === S Y N F I G ========================================================= */
2 /*!	\file action.cpp
3 **	\brief Template File
4 **
5 **	$Id$
6 **
7 **	\legal
8 **	Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **	Copyright (c) 2008 Chris Moore
10 **
11 **	This package is free software; you can redistribute it and/or
12 **	modify it under the terms of the GNU General Public License as
13 **	published by the Free Software Foundation; either version 2 of
14 **	the License, or (at your option) any later version.
15 **
16 **	This package is distributed in the hope that it will be useful,
17 **	but WITHOUT ANY WARRANTY; without even the implied warranty of
18 **	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 **	General Public License for more details.
20 **	\endlegal
21 */
22 /* ========================================================================= */
23 
24 /* === H E A D E R S ======================================================= */
25 
26 #ifdef USING_PCH
27 #	include "pch.h"
28 #else
29 #ifdef HAVE_CONFIG_H
30 #	include <config.h>
31 #endif
32 
33 #include <synfig/general.h>
34 
35 #include "action.h"
36 #include "instance.h"
37 
38 
39 #include "actions/layerremove.h"
40 #include "actions/layermove.h"
41 #include "actions/layerraise.h"
42 #include "actions/layerlower.h"
43 #include "actions/layeradd.h"
44 #include "actions/layeraddframe.h"
45 #include "actions/layeractivate.h"
46 #include "actions/layercopy.h"
47 #include "actions/layerfit.h"
48 #include "actions/layermakebline.h"
49 #include "actions/layerparamset.h"
50 #include "actions/layerparamsetstatic.h"
51 #include "actions/layerparamunsetstatic.h"
52 #include "actions/layerparamconnect.h"
53 #include "actions/layerparamdisconnect.h"
54 #include "actions/layerencapsulate.h"
55 #include "actions/layerencapsulatefilter.h"
56 #include "actions/layerencapsulateswitch.h"
57 #include "actions/layerduplicate.h"
58 #include "actions/layersetdesc.h"
59 #include "actions/layersetexcludefromrendering.h"
60 #include "actions/layerzdepthrangeset.h"
61 #include "actions/layerembed.h"
62 #include "actions/layerextract.h"
63 #include "actions/layerresetpose.h"
64 
65 #include "actions/valuenodeconstset.h"
66 #include "actions/valuenodeconstsetstatic.h"
67 #include "actions/valuenodeconstunsetstatic.h"
68 #include "actions/valuenodeadd.h"
69 #include "actions/valuenodereplace.h"
70 #include "actions/valuenodelinkconnect.h"
71 #include "actions/valuenodelinkdisconnect.h"
72 #include "actions/valuenodedynamiclistinsert.h"
73 #include "actions/valuenodedynamiclistremove.h"
74 #include "actions/valuenodedynamiclistinsertsmart.h"
75 #include "actions/valuenodedynamiclistremovesmart.h"
76 #include "actions/valuenodedynamiclistloop.h"
77 #include "actions/valuenodedynamiclistunloop.h"
78 #include "actions/valuenodedynamiclistrotateorder.h"
79 #include "actions/valuenodestaticlistinsert.h"
80 #include "actions/valuenodestaticlistremove.h"
81 #include "actions/valuenodestaticlistinsertsmart.h"
82 #include "actions/valuenodestaticlistremovesmart.h"
83 #include "actions/valuenodestaticlistloop.h"
84 #include "actions/valuenodestaticlistunloop.h"
85 #include "actions/valuenodestaticlistrotateorder.h"
86 #include "actions/valuenoderename.h"
87 #include "actions/valuenoderemove.h"
88 
89 #include "actions/valuedescset.h"
90 #include "actions/valuedescsetinterpolation.h"
91 #include "actions/valuedescexport.h"
92 #include "actions/valuedescconvert.h"
93 #include "actions/valuedescconnect.h"
94 #include "actions/valuedescdisconnect.h"
95 #include "actions/valuedesclink.h"
96 #include "actions/valuedescblinelink.h"
97 #include "actions/valuedescremovesmart.h"
98 #include "actions/valuedescbonelink.h"
99 #include "actions/valuedescskeletonlink.h"
100 #include "actions/valuedesccreatechildbone.h"
101 #include "actions/valuedescresetpose.h"
102 
103 #include "actions/waypointadd.h"
104 #include "actions/waypointset.h"
105 #include "actions/waypointsetsmart.h"
106 #include "actions/waypointremove.h"
107 #include "actions/waypointconnect.h"
108 #include "actions/waypointdisconnect.h"
109 // #include "actions/waypointsimpleadd.h"
110 
111 #include "actions/activepointadd.h"
112 #include "actions/activepointset.h"
113 #include "actions/activepointsetsmart.h"
114 #include "actions/activepointsetoff.h"
115 #include "actions/activepointseton.h"
116 #include "actions/activepointremove.h"
117 // #include "actions/activepointsimpleadd.h"
118 
119 #include "actions/keyframeadd.h"
120 #include "actions/keyframeset.h"
121 #include "actions/keyframeremove.h"
122 #include "actions/keyframetoggl.h"
123 #include "actions/keyframeduplicate.h"
124 #include "actions/keyframewaypointset.h"
125 #include "actions/keyframesetdelta.h"
126 
127 #include "actions/timepointsmove.h"
128 #include "actions/timepointscopy.h"
129 #include "actions/timepointsdelete.h"
130 
131 #include "actions/canvasdescriptionset.h"
132 #include "actions/canvasidset.h"
133 #include "actions/canvasmetadataerase.h"
134 #include "actions/canvasmetadataset.h"
135 #include "actions/canvasnameset.h"
136 #include "actions/canvasrenddescset.h"
137 #include "actions/canvasadd.h"
138 #include "actions/canvasremove.h"
139 
140 #include "actions/editmodeset.h"
141 
142 #include "actions/blinepointtangentmerge.h"
143 #include "actions/blinepointtangentsplit.h"
144 
145 #include "actions/gradientset.h"
146 #include "actions/colorset.h"
147 
148 #include "actions/groupaddlayers.h"
149 #include "actions/groupremovelayers.h"
150 #include "actions/groupremove.h"
151 #include "actions/grouprename.h"
152 
153 #include "canvasinterface.h"
154 
155 #include <synfigapp/localization.h>
156 
157 #endif
158 
159 using namespace std;
160 using namespace etl;
161 using namespace synfig;
162 using namespace synfigapp;
163 using namespace Action;
164 
165 /* === P R O C E D U R E S ================================================= */
166 
167 /* === S T A T I C S ======================================================= */
168 
169 synfigapp::Action::Book *book_;
170 
171 /* === M E T H O D S ======================================================= */
172 
173 #define ADD_ACTION(x) { BookEntry &be(book()[x::name__]); \
174 	be.name=x::name__; \
175 	be.local_name=dgettext("synfigstudio",x::local_name__); \
176 	be.version=x::version__; \
177 	be.task=x::task__; \
178 	be.priority=x::priority__; \
179 	be.category=x::category__; \
180 	be.factory=x::create; \
181 	be.get_param_vocab=x::get_param_vocab; \
182 	be.is_candidate=x::is_candidate; \
183 	}
184 
185 
Main()186 Action::Main::Main()
187 {
188 	book_=new synfigapp::Action::Book();
189 
190 	ADD_ACTION(Action::LayerRemove);
191 	ADD_ACTION(Action::LayerMove);
192 	ADD_ACTION(Action::LayerRaise);
193 	ADD_ACTION(Action::LayerLower);
194 	ADD_ACTION(Action::LayerAdd);
195 	ADD_ACTION(Action::LayerActivate);
196 	ADD_ACTION(Action::LayerFit);
197 	ADD_ACTION(Action::LayerMakeOutline);
198 	ADD_ACTION(Action::LayerMakeAdvancedOutline);
199 	ADD_ACTION(Action::LayerMakeRegion);
200 	ADD_ACTION(Action::LayerParamSet);
201 	ADD_ACTION(Action::LayerParamSetStatic);
202 	ADD_ACTION(Action::LayerParamUnSetStatic);
203 	ADD_ACTION(Action::LayerParamConnect);
204 	ADD_ACTION(Action::LayerParamDisconnect);
205 	ADD_ACTION(Action::LayerEncapsulate);
206 	ADD_ACTION(Action::LayerEncapsulateFilter);
207 	ADD_ACTION(Action::LayerEncapsulateSwitch);
208 	ADD_ACTION(Action::LayerDuplicate);
209 	ADD_ACTION(Action::LayerSetDesc);
210 	ADD_ACTION(Action::LayerZDepthRangeSet);
211 	ADD_ACTION(Action::LayerEmbed);
212 	ADD_ACTION(Action::LayerExtract);
213 	ADD_ACTION(Action::LayerSetExcludeFromRenderingOn);
214 	ADD_ACTION(Action::LayerSetExcludeFromRenderingOff);
215 	ADD_ACTION(Action::LayerAddFrame);
216 	ADD_ACTION(Action::LayerCopy);
217 	ADD_ACTION(Action::LayerResetPose);
218 
219 	ADD_ACTION(Action::ValueNodeConstSet);
220 	ADD_ACTION(Action::ValueNodeConstSetStatic);
221 	ADD_ACTION(Action::ValueNodeConstUnSetStatic);
222 	ADD_ACTION(Action::ValueNodeAdd);
223 	ADD_ACTION(Action::ValueNodeReplace);
224 	ADD_ACTION(Action::ValueNodeLinkConnect);
225 	ADD_ACTION(Action::ValueNodeLinkDisconnect);
226 	ADD_ACTION(Action::ValueNodeDynamicListInsert);
227 	ADD_ACTION(Action::ValueNodeDynamicListRemove);
228 	ADD_ACTION(Action::ValueNodeDynamicListInsertSmart);
229 	ADD_ACTION(Action::ValueNodeDynamicListInsertSmartKeepShape);
230 	ADD_ACTION(Action::ValueNodeDynamicListRemoveSmart);
231 	ADD_ACTION(Action::ValueNodeDynamicListLoop);
232 	ADD_ACTION(Action::ValueNodeDynamicListUnLoop);
233 	ADD_ACTION(Action::ValueNodeDynamicListRotateOrder);
234 	ADD_ACTION(Action::ValueNodeStaticListInsert);
235 	ADD_ACTION(Action::ValueNodeStaticListRemove);
236 	ADD_ACTION(Action::ValueNodeStaticListInsertSmart);
237 	ADD_ACTION(Action::ValueNodeStaticListRemoveSmart);
238 	ADD_ACTION(Action::ValueNodeStaticListLoop);
239 	ADD_ACTION(Action::ValueNodeStaticListUnLoop);
240 	ADD_ACTION(Action::ValueNodeStaticListRotateOrder);
241 	ADD_ACTION(Action::ValueNodeRename);
242 	ADD_ACTION(Action::ValueNodeRemove);
243 
244 	ADD_ACTION(Action::ValueDescSet);
245 	ADD_ACTION(Action::ValueDescSetInterpolation);
246 	ADD_ACTION(Action::ValueDescExport);
247 	ADD_ACTION(Action::ValueDescConvert);
248 	ADD_ACTION(Action::ValueDescConnect);
249 	ADD_ACTION(Action::ValueDescDisconnect);
250 	ADD_ACTION(Action::ValueDescLink);
251 	ADD_ACTION(Action::ValueDescLinkOpposite);
252 	ADD_ACTION(Action::ValueDescBLineLink);
253 	ADD_ACTION(Action::ValueDescRemoveSmart);
254 	ADD_ACTION(Action::ValueDescBoneLink);
255 	ADD_ACTION(Action::ValueDescSkeletonLink);
256 	ADD_ACTION(Action::ValueDescCreateChildBone);
257 	ADD_ACTION(Action::ValueDescResetPose);
258 
259 	ADD_ACTION(Action::WaypointAdd);
260 	ADD_ACTION(Action::WaypointSet);
261 	ADD_ACTION(Action::WaypointSetSmart);
262 	ADD_ACTION(Action::WaypointRemove);
263 	ADD_ACTION(Action::WaypointConnect);
264 	ADD_ACTION(Action::WaypointDisconnect);
265 //	ADD_ACTION(Action::WaypointSimpleAdd);
266 
267 	ADD_ACTION(Action::ActivepointAdd);
268 	ADD_ACTION(Action::ActivepointSet);
269 	ADD_ACTION(Action::ActivepointSetSmart);
270 	ADD_ACTION(Action::ActivepointSetOn);
271 	ADD_ACTION(Action::ActivepointSetOff);
272 	ADD_ACTION(Action::ActivepointRemove);
273 //	ADD_ACTION(Action::ActivepointSimpleAdd);
274 
275 	ADD_ACTION(Action::KeyframeAdd);
276 	ADD_ACTION(Action::KeyframeSet);
277 	ADD_ACTION(Action::KeyframeRemove);
278 	ADD_ACTION(Action::KeyframeToggl);
279 	ADD_ACTION(Action::KeyframeDuplicate);
280 	ADD_ACTION(Action::KeyframeWaypointSet);
281 	ADD_ACTION(Action::KeyframeSetDelta);
282 
283 	ADD_ACTION(Action::CanvasDescriptionSet);
284 	ADD_ACTION(Action::CanvasIdSet);
285 	ADD_ACTION(Action::CanvasNameSet)
286 	ADD_ACTION(Action::CanvasMetadataErase);;
287 	ADD_ACTION(Action::CanvasMetadataSet);
288 	ADD_ACTION(Action::CanvasRendDescSet);
289 	ADD_ACTION(Action::CanvasAdd);
290 	ADD_ACTION(Action::CanvasRemove);
291 
292 	ADD_ACTION(Action::EditModeSet);
293 
294 	ADD_ACTION(Action::BLinePointTangentMerge);
295 	ADD_ACTION(Action::BLinePointTangentMergeRadius);
296 	ADD_ACTION(Action::BLinePointTangentMergeAngle);
297 	ADD_ACTION(Action::BLinePointTangentSplit);
298 	ADD_ACTION(Action::BLinePointTangentSplitRadius);
299 	ADD_ACTION(Action::BLinePointTangentSplitAngle);
300 
301 	ADD_ACTION(Action::GradientSet);
302 	ADD_ACTION(Action::ColorSetFromOC);
303 	ADD_ACTION(Action::ColorSetFromFC);
304 
305 	ADD_ACTION(Action::TimepointsMove);
306 	ADD_ACTION(Action::TimepointsCopy);
307 	ADD_ACTION(Action::TimepointsDelete);
308 
309 	ADD_ACTION(Action::GroupAddLayers);
310 	ADD_ACTION(Action::GroupRemoveLayers);
311 	ADD_ACTION(Action::GroupRemove);
312 	ADD_ACTION(Action::GroupRename);
313 }
314 
~Main()315 Action::Main::~Main()
316 {
317 	delete book_;
318 }
319 
320 
book()321 Action::Book& Action::book() { return *book_; }
322 
323 
324 Action::Handle
create(const synfig::String & name)325 Action::create(const synfig::String &name)
326 {
327 	if(!book().count(name))
328 		return 0; //! \todo perhaps we should throw something instead?
329 	return book()[name].factory();
330 }
331 
332 
333 Action::CandidateList
compile_candidate_list(const ParamList & param_list,Category category)334 Action::compile_candidate_list(const ParamList& param_list, Category category)
335 {
336 	Action::CandidateList ret;
337 
338 	Book::const_iterator iter;
339 
340 	//synfig::info("param_list.size()=%d",param_list.size());
341 
342 	for(iter=book().begin();iter!=book().end();++iter)
343 	{
344 		if((iter->second.category&category))
345 		{
346 			if(iter->second.is_candidate(param_list))
347 			{
348 				//synfig::info("Action \"%s\" is in",iter->second.name.c_str());
349 				ret.push_back(iter->second);
350 			}
351 			else
352 			{
353 				//synfig::info("Action \"%s\" is not a candidate",iter->second.name.c_str());
354 			}
355 		}
356 		else
357 		{
358 			//synfig::info("Action \"%s\" has unsuitable category",iter->second.name.c_str());
359 		}
360 	}
361 
362 	return ret;
363 }
364 
365 Action::CandidateList::iterator
find(const synfig::String & x)366 Action::CandidateList::find(const synfig::String& x)
367 {
368 	iterator iter;
369 	for(iter=begin();iter!=end();++iter)
370 		if(iter->name==x)
371 			break;
372 	return iter;
373 }
374 
375 void
set_param_list(const ParamList & param_list)376 Action::Base::set_param_list(const ParamList &param_list)
377 {
378 	ParamList::const_iterator iter;
379 
380 	for(iter=param_list.begin();iter!=param_list.end();++iter)
381 		set_param(iter->first,iter->second);
382 }
383 
384 synfig::String
get_layer_descriptions(const std::list<synfig::Layer::Handle> layers,synfig::String singular_prefix,synfig::String plural_prefix)385 Action::Base::get_layer_descriptions(const std::list<synfig::Layer::Handle> layers, synfig::String singular_prefix, synfig::String plural_prefix)
386 {
387 	String ret;
388 	bool first = true;
389 
390 	if (plural_prefix.empty())
391 		plural_prefix = singular_prefix;
392 
393 	if (layers.empty())
394 		return plural_prefix;
395 
396 	if (layers.size() == 1)
397 		ret = singular_prefix;
398 	else
399 		ret = plural_prefix;
400 
401 	if (!ret.empty())
402 		ret.push_back(' ');
403 
404 	for(std::list<synfig::Layer::Handle>::const_iterator iter=layers.begin(); iter!=layers.end(); ++iter)
405 	{
406 		if (first)
407 			first = false;
408 		else
409 			ret += ", ";
410 
411 		ret += strprintf("'%s'", (*iter)->get_non_empty_description().c_str());
412 	}
413 
414 	return ret;
415 }
416 
417 synfig::String
get_layer_descriptions(const std::list<std::pair<synfig::Layer::Handle,int>> layers,synfig::String singular_prefix,synfig::String plural_prefix)418 Action::Base::get_layer_descriptions(const std::list<std::pair<synfig::Layer::Handle,int> > layers, synfig::String singular_prefix, synfig::String plural_prefix)
419 {
420 	String ret;
421 	bool first = true;
422 
423 	if (plural_prefix.empty())
424 		plural_prefix = singular_prefix;
425 
426 	if (layers.empty())
427 		return plural_prefix;
428 
429 	if (layers.size() == 1)
430 		ret = singular_prefix;
431 	else
432 		ret = plural_prefix;
433 
434 	if (!ret.empty())
435 		ret.push_back(' ');
436 
437 	for(std::list<std::pair<synfig::Layer::Handle,int> >::const_iterator iter=layers.begin(); iter!=layers.end(); ++iter)
438 	{
439 		if (first)
440 			first = false;
441 		else
442 			ret += ", ";
443 
444 		ret += strprintf("'%s'", iter->first->get_non_empty_description().c_str());
445 	}
446 
447 	return ret;
448 }
449 
450 void
perform()451 Super::perform()
452 {
453 	set_dirty(false);
454 
455 	prepare();
456 
457 	ActionList::const_iterator iter;
458 	for(iter=action_list_.begin();iter!=action_list_.end();++iter)
459 	{
460 		if (getenv("SYNFIG_DEBUG_ACTIONS"))
461 			synfig::info("%s:%d action: '%s'", __FILE__, __LINE__, (*iter)->get_name().c_str());
462 
463 		try
464 		{
465 			try
466 			{
467 				(*iter)->perform();
468 				CanvasSpecific* canvas_specific(dynamic_cast<CanvasSpecific*>(iter->get()));
469 				if(canvas_specific && canvas_specific->is_dirty())
470 					set_dirty(true);
471 			}
472 			catch(...)
473 			{
474 				if(iter!=action_list_.begin())
475 				{
476 					for(--iter;iter!=action_list_.begin();--iter)
477 						(*iter)->undo();
478 					(*iter)->undo();
479 				}
480 				throw;
481 			}
482 		}
483 		catch(Error x)
484 		{
485 			//synfig::info("%s:%d caught exception", __FILE__, __LINE__);
486 			throw Error(x.get_type(),((*iter)->get_local_name()+": "+x.get_desc()).c_str());
487 		}
488 		//synfig::info("%s:%d finished action: '%s'", __FILE__, __LINE__, (*iter)->get_name().c_str());
489 	}
490 }
491 
492 void
undo()493 Super::undo()
494 {
495 	set_dirty(false);
496 
497 	ActionList::const_reverse_iterator iter;
498 	for(iter=const_cast<const ActionList &>(action_list_).rbegin();iter!=const_cast<const ActionList &>(action_list_).rend();++iter)
499 	{
500 		try {
501 			(*iter)->undo();
502 			CanvasSpecific* canvas_specific(dynamic_cast<CanvasSpecific*>(iter->get()));
503 			if(canvas_specific && canvas_specific->is_dirty())
504 				set_dirty(true);
505 		}
506 		catch(...)
507 		{
508 			if(iter!=const_cast<const ActionList &>(action_list_).rbegin())
509 			{
510 				for(--iter;iter!=const_cast<const ActionList &>(action_list_).rbegin();--iter)
511 					(*iter)->perform();
512 				(*iter)->perform();
513 			}
514 			throw;
515 		}
516 	}
517 }
518 
519 void
add_action(etl::handle<Undoable> action)520 Super::add_action(etl::handle<Undoable> action)
521 {
522 	action_list_.push_back(action);
523 	CanvasSpecific *specific_action=dynamic_cast<CanvasSpecific *>(action.get());
524 	if(specific_action && !get_canvas())
525 		set_canvas(specific_action->get_canvas());
526 }
527 
528 void
add_action_front(etl::handle<Undoable> action)529 Super::add_action_front(etl::handle<Undoable> action)
530 {
531 	assert(action);
532 	action_list_.push_front(action);
533 	CanvasSpecific *specific_action=dynamic_cast<CanvasSpecific *>(action.get());
534 	if(specific_action && !get_canvas())
535 		set_canvas(specific_action->get_canvas());
536 }
537 
538 
Group(const synfig::String & str)539 Group::Group(const synfig::String &str):
540 	name_(str),
541 	ready_(true)
542 {
543 }
544 
~Group()545 Group::~Group()
546 {
547 }
548 
549 
550 
551 
552 Action::ParamVocab
get_param_vocab()553 Action::CanvasSpecific::get_param_vocab()
554 {
555 	ParamVocab ret;
556 
557 	ret.push_back(ParamDesc("canvas",Param::TYPE_CANVAS)
558 		.set_local_name(_("Canvas"))
559 		.set_desc(_("Selected Canvas"))
560 	);
561 
562 	ret.push_back(ParamDesc("canvas_interface",Param::TYPE_CANVASINTERFACE)
563 		.set_local_name(_("Canvas Interface"))
564 		.set_desc(_("Canvas Interface"))
565 		.set_optional(true)
566 	);
567 
568 
569 	return ret;
570 }
571 
572 bool
set_param(const synfig::String & name,const Param & param)573 CanvasSpecific::set_param(const synfig::String& name, const Param &param)
574 {
575 	if(name=="canvas" && param.get_type()==Param::TYPE_CANVAS)
576 	{
577 		if(!param.get_canvas())
578 			return false;
579 		set_canvas(param.get_canvas());
580 
581 		return true;
582 	}
583 	if(name=="canvas_interface" && param.get_type()==Param::TYPE_CANVASINTERFACE)
584 	{
585 		if(!param.get_canvas_interface())
586 			return false;
587 		set_canvas_interface(param.get_canvas_interface());
588 		if(!get_canvas())
589 			set_canvas(get_canvas_interface()->get_canvas());
590 
591 		return true;
592 	}
593 	if(name=="edit_mode" && param.get_type()==Param::TYPE_EDITMODE)
594 	{
595 		set_edit_mode(param.get_edit_mode());
596 
597 		return true;
598 	}
599 
600 	return false;
601 }
602 
603 bool
is_ready() const604 CanvasSpecific::is_ready()const
605 {
606 	if(!get_canvas())
607 		return false;
608 	return true;
609 }
610 
611 EditMode
get_edit_mode() const612 CanvasSpecific::get_edit_mode()const
613 {
614 	if(mode_!=MODE_UNDEFINED)
615 		return mode_;
616 
617 	if(get_canvas_interface())
618 		return get_canvas_interface()->get_mode();
619 
620 	return MODE_NORMAL;
621 }
622 
623 //DOO static int undoable_count = 0;
624 
Undoable()625 Undoable::Undoable():
626 	active_(true)
627 {
628 	//DOO printf("%s:%d Undoable::Undoable() (we have %d)\n", __FILE__, __LINE__, ++undoable_count);
629 }
630 
631 #ifdef _DEBUG
~Undoable()632 Undoable::~Undoable() {
633 	//DOO printf("%s:%d Undoable::~Undoable() (we now have %d)\n", __FILE__, __LINE__, --undoable_count);
634 }
635 
636 void
ref() const637 Undoable::ref()const
638 {
639 	if (getenv("SYNFIG_DEBUG_ACTION_REFCOUNT"))
640 		printf("%s:%d %lx   ref undoable %*s -> %2d\n", __FILE__, __LINE__, uintptr_t(this), (count()*2), "", count()+1);
641 
642 	Base::ref();
643 }
644 
645 bool
unref() const646 Undoable::unref()const
647 {
648 	if (getenv("SYNFIG_DEBUG_ACTION_REFCOUNT"))
649 		printf("%s:%d %lx unref undoable %*s%2d <-\n", __FILE__, __LINE__, uintptr_t(this), ((count()-1)*2), "", count()-1);
650 
651 	return Base::unref();
652 }
653 #endif
654