X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fsynfigapp%2Factions%2Fvaluedescexport.cpp;h=65252cfac62763423b9b1395ccd3720134163b46;hb=4ba22fb51d97f1ecce04dcc5e40569a4354c1bae;hp=3a517a508f2b8fb188363dd75f662674c28f7e55;hpb=c34eaa5441242b3e9a7b7645e9ee4983d14eae85;p=synfig.git diff --git a/synfig-studio/trunk/src/synfigapp/actions/valuedescexport.cpp b/synfig-studio/trunk/src/synfigapp/actions/valuedescexport.cpp index 3a517a5..65252cf 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/valuedescexport.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/valuedescexport.cpp @@ -1,11 +1,12 @@ /* === S Y N F I G ========================================================= */ -/*! \file valuedescset.cpp +/*! \file valuedescexport.cpp ** \brief Template File ** -** $Id: valuedescexport.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $ +** $Id$ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -34,10 +35,13 @@ #include "canvasadd.h" #include "valuedescexport.h" #include "layerparamconnect.h" +#include "layerparamset.h" #include #include +#include + #endif using namespace std; @@ -48,14 +52,14 @@ using namespace Action; /* === M A C R O S ========================================================= */ -ACTION_INIT(Action::ValueDescExport); -ACTION_SET_NAME(Action::ValueDescExport,"value_desc_export"); -ACTION_SET_LOCAL_NAME(Action::ValueDescExport,"Export"); +ACTION_INIT_NO_GET_LOCAL_NAME(Action::ValueDescExport); +ACTION_SET_NAME(Action::ValueDescExport,"ValueDescExport"); +ACTION_SET_LOCAL_NAME(Action::ValueDescExport,N_("Export")); ACTION_SET_TASK(Action::ValueDescExport,"export"); ACTION_SET_CATEGORY(Action::ValueDescExport,Action::CATEGORY_VALUEDESC); ACTION_SET_PRIORITY(Action::ValueDescExport,0); ACTION_SET_VERSION(Action::ValueDescExport,"0.0"); -ACTION_SET_CVS_ID(Action::ValueDescExport,"$Id: valuedescexport.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $"); +ACTION_SET_CVS_ID(Action::ValueDescExport,"$Id$"); /* === G L O B A L S ======================================================= */ @@ -67,6 +71,15 @@ Action::ValueDescExport::ValueDescExport() { } +synfig::String +Action::ValueDescExport::get_local_name()const +{ + // TRANSLATORS: This is used in the 'history' dialog when a ValueNode is exported. The first %s is what is exported, the 2nd is the name it is given. + return strprintf(_("Export '%s' as '%s'"), + value_desc.get_description(false).c_str(), + name.c_str()); +} + Action::ParamVocab Action::ValueDescExport::get_param_vocab() { @@ -91,8 +104,22 @@ Action::ValueDescExport::is_candidate(const ParamList &x) if(candidate_check(get_param_vocab(),x)) { ValueDesc value_desc=x.find("value_desc")->second.get_value_desc(); - if(!value_desc || value_desc.parent_is_canvas() || (value_desc.is_value_node() && value_desc.get_value_node()->is_exported())) + if(!value_desc || + value_desc.parent_is_canvas() || + (value_desc.is_value_node() && value_desc.get_value_node()->is_exported()) || + (value_desc.get_value_type()==ValueBase::TYPE_CANVAS && !value_desc.get_value().get(Canvas::Handle())->is_inline())) + { +// if (!value_desc) +// synfig::info("%s:%d no export because no value_desc", __FILE__, __LINE__); +// else if (value_desc.parent_is_canvas()) +// synfig::info("%s:%d no export because parent is canvas", __FILE__, __LINE__); +// else if (value_desc.is_value_node() && value_desc.get_value_node()->is_exported()) +// synfig::info("%s:%d no export because exported value node", __FILE__, __LINE__); +// else if (value_desc.get_value_type()==ValueBase::TYPE_CANVAS && !value_desc.get_value().get(Canvas::Handle())->is_inline()) +// synfig::info("%s:%d no export because canvas isn't inline", __FILE__, __LINE__); + return false; + } return true; } return false; @@ -135,9 +162,11 @@ Action::ValueDescExport::prepare() if(value_desc.get_value_type()==ValueBase::TYPE_CANVAS) { + // action: CanvasAdd if(!value_desc.is_const()) throw Error(_("Can only export Canvas when used as constant parameter")); Canvas::Handle canvas(value_desc.get_value().get(Canvas::Handle())); + if (canvas) canvas=canvas->clone(); Action::Handle action(CanvasAdd::create()); @@ -152,10 +181,27 @@ Action::ValueDescExport::prepare() add_action_front(action); + if(value_desc.parent_is_layer_param() && !value_desc.is_value_node()) + { + // action: LayerParamSet + Action::Handle action(LayerParamSet::create()); + + action->set_param("canvas",get_canvas()); + action->set_param("canvas_interface",get_canvas_interface()); + action->set_param("layer",value_desc.get_layer()); + action->set_param("param",value_desc.get_param_name()); + action->set_param("new_value",ValueBase(canvas)); + + assert(action->is_ready()); + if(!action->is_ready()) + throw Error(Error::TYPE_NOTREADY); + + add_action_front(action); + } + return; } - if(value_desc.is_value_node()) { if(value_desc.get_value_node()->is_exported()) @@ -165,6 +211,7 @@ Action::ValueDescExport::prepare() } else { + // action: LayerParamConnect if(!value_desc.parent_is_layer_param()) throw Error(_("Unable to export parameter. (Bug?)")); @@ -185,6 +232,7 @@ Action::ValueDescExport::prepare() add_action_front(action); } + // action: ValueNodeAdd Action::Handle action(ValueNodeAdd::create()); action->set_param("canvas",get_canvas());