}
void
-CanvasView::popup_param_menu(synfigapp::ValueDesc value_desc, float location)
+CanvasView::popup_param_menu(synfigapp::ValueDesc value_desc, float location, bool bezier)
{
parammenu.items().clear();
- get_instance()->make_param_menu(¶mmenu,get_canvas(),value_desc,location);
+ get_instance()->make_param_menu(¶mmenu,get_canvas(),value_desc,location,bezier);
parammenu.popup(3,gtk_get_current_event_time());
}
Gtk::Widget *create_time_bar();
void popup_param_menu_bezier(float location, synfigapp::ValueDesc value_desc)
- { popup_param_menu(value_desc,location); }
+ { popup_param_menu(value_desc,location,true); }
- void popup_param_menu(synfigapp::ValueDesc value_desc, float location=0);
+ void popup_param_menu(synfigapp::ValueDesc value_desc, float location=0, bool bezier=false);
void workarea_layer_selected(synfig::Layer::Handle layer);
duck->signal_user_click(2).connect(
sigc::bind(
sigc::bind(
- sigc::mem_fun(
- *canvas_view,
- &studio::CanvasView::popup_param_menu),
+ sigc::bind(
+ sigc::mem_fun(
+ *canvas_view,
+ &studio::CanvasView::popup_param_menu),
+ false),
0.0f),
value_desc));
duck->signal_user_click(2).connect(
sigc::bind(
sigc::bind(
- sigc::mem_fun(
- *canvas_view,
- &studio::CanvasView::popup_param_menu),
+ sigc::bind(
+ sigc::mem_fun(
+ *canvas_view,
+ &studio::CanvasView::popup_param_menu),
+ false),
0.0f),
value_desc));
duck->set_guid(calc_duck_guid(value_desc,transform_stack)^synfig::GUID::hasher(multiple));
duck->signal_user_click(2).connect(
sigc::bind(
sigc::bind(
- sigc::mem_fun(
- *canvas_view,
- &studio::CanvasView::popup_param_menu),
+ sigc::bind(
+ sigc::mem_fun(
+ *canvas_view,
+ &studio::CanvasView::popup_param_menu),
+ false),
1.0f),
value_desc));
duck->set_guid(calc_duck_guid(value_desc,transform_stack)^synfig::GUID::hasher(multiple));
duck->signal_user_click(2).connect(
sigc::bind(
sigc::bind(
- sigc::mem_fun(
- *canvas_view,
- &studio::CanvasView::popup_param_menu),
+ sigc::bind(
+ sigc::mem_fun(
+ *canvas_view,
+ &studio::CanvasView::popup_param_menu),
+ false),
1.0f),
synfigapp::ValueDesc(value_node,i)));
duck->set_value_desc(synfigapp::ValueDesc(value_node,i));
duck->signal_user_click(2).connect(
sigc::bind(
sigc::bind(
- sigc::mem_fun(
- *canvas_view,
- &studio::CanvasView::popup_param_menu),
+ sigc::bind(
+ sigc::mem_fun(
+ *canvas_view,
+ &studio::CanvasView::popup_param_menu),
+ false),
1.0f),
synfigapp::ValueDesc(value_node,i)));
duck->set_value_desc(synfigapp::ValueDesc(value_node,i));
duck->signal_user_click(2).connect(
sigc::bind(
sigc::bind(
- sigc::mem_fun(
- *canvas_view,
- &studio::CanvasView::popup_param_menu),
+ sigc::bind(
+ sigc::mem_fun(
+ *canvas_view,
+ &studio::CanvasView::popup_param_menu),
+ false),
1.0f),
synfigapp::ValueDesc(value_node,i)));
duck->set_value_desc(synfigapp::ValueDesc(value_node,i));
duck->signal_user_click(2).connect(
sigc::bind(
sigc::bind(
- sigc::mem_fun(
- *canvas_view,
- &studio::CanvasView::popup_param_menu),
+ sigc::bind(
+ sigc::mem_fun(
+ *canvas_view,
+ &studio::CanvasView::popup_param_menu),
+ false),
1.0f),
synfigapp::ValueDesc(value_node,first)));
duck->set_value_desc(synfigapp::ValueDesc(value_node,first));
#include "widget_waypointmodel.h"
#include <gtkmm/actiongroup.h>
#include "iconcontroller.h"
+#include "workarea.h"
#include <sys/stat.h>
#include <errno.h>
#include <ETL/stringf>
}
void
-Instance::make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas, synfigapp::ValueDesc value_desc, float location)
+Instance::make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas, synfigapp::ValueDesc value_desc, float location, bool bezier)
{
Gtk::Menu& parammenu(*menu);
parammenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::CONVERT,*convert_menu));
}
+ synfigapp::Action::Category categories = synfigapp::Action::CATEGORY_VALUEDESC|synfigapp::Action::CATEGORY_VALUENODE;
+ if (bezier)
+ {
+ categories = categories|synfigapp::Action::CATEGORY_BEZIER;
+
+ const DuckList selected_ducks(find_canvas_view(canvas)->get_work_area()->get_selected_ducks());
+ for(DuckList::const_iterator iter=selected_ducks.begin();iter!=selected_ducks.end();++iter)
+ {
+ synfigapp::ValueDesc value_desc((*iter)->get_value_desc());
+ if(value_desc.is_valid())
+ param_list.add("selected_value_desc",value_desc);
+ }
+ }
+
if(param_list2.empty())
- add_actions_to_menu(¶mmenu, param_list,synfigapp::Action::CATEGORY_VALUEDESC|synfigapp::Action::CATEGORY_VALUENODE);
+ add_actions_to_menu(¶mmenu, param_list,categories);
else
- add_actions_to_menu(¶mmenu, param_list2,param_list,synfigapp::Action::CATEGORY_VALUEDESC|synfigapp::Action::CATEGORY_VALUENODE);
+ add_actions_to_menu(¶mmenu, param_list2,param_list,categories);
if(value_desc.get_value_type()==ValueBase::TYPE_BLINEPOINT && value_desc.is_value_node() && ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()))
{
void process_action(synfig::String name, synfigapp::Action::ParamList param_list);
- void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas, synfigapp::ValueDesc value_desc, float location=0.5f);
+ void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas, synfigapp::ValueDesc value_desc, float location=0.5f, bool bezier=false);
void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas,const std::list<synfigapp::ValueDesc>& value_desc_list);
VALUEDESC_ACTION_HH = \
actions/valuedescconnect.h actions/valuedescconvert.h actions/valuedescdisconnect.h \
- actions/valuedescexport.h actions/valuedesclink.h actions/valuedescset.h
+ actions/valuedescexport.h actions/valuedesclink.h actions/valuedescblinelink.h actions/valuedescset.h
VALUEDESC_ACTION_CC = \
actions/valuedescconnect.cpp actions/valuedescconvert.cpp actions/valuedescdisconnect.cpp \
- actions/valuedescexport.cpp actions/valuedesclink.cpp actions/valuedescset.cpp
+ actions/valuedescexport.cpp actions/valuedesclink.cpp actions/valuedescblinelink.cpp actions/valuedescset.cpp
VALUENODE_ACTION_HH = \
actions/valuenodeadd.h actions/valuenodeconstset.h actions/valuenodedynamiclistinsert.h \
#include "actions/valuedescconnect.h"
#include "actions/valuedescdisconnect.h"
#include "actions/valuedesclink.h"
+#include "actions/valuedescblinelink.h"
#include "actions/waypointadd.h"
#include "actions/waypointset.h"
#include "actions/waypointsetsmart.h"
#include "actions/waypointremove.h"
+// #include "actions/waypointsimpleadd.h"
#include "actions/activepointadd.h"
#include "actions/activepointset.h"
#include "actions/activepointsetoff.h"
#include "actions/activepointseton.h"
#include "actions/activepointremove.h"
+// #include "actions/activepointsimpleadd.h"
#include "actions/keyframeadd.h"
#include "actions/keyframeset.h"
ADD_ACTION(Action::ValueDescConnect);
ADD_ACTION(Action::ValueDescDisconnect);
ADD_ACTION(Action::ValueDescLink);
+ ADD_ACTION(Action::ValueDescBLineLink);
ADD_ACTION(Action::WaypointAdd);
ADD_ACTION(Action::WaypointSet);
ADD_ACTION(Action::WaypointSetSmart);
ADD_ACTION(Action::WaypointRemove);
+// ADD_ACTION(Action::WaypointSimpleAdd);
ADD_ACTION(Action::ActivepointAdd);
ADD_ACTION(Action::ActivepointSet);
ADD_ACTION(Action::ActivepointSetOn);
ADD_ACTION(Action::ActivepointSetOff);
ADD_ACTION(Action::ActivepointRemove);
+// ADD_ACTION(Action::ActivepointSimpleAdd);
ADD_ACTION(Action::KeyframeAdd);
ADD_ACTION(Action::KeyframeSet);
CATEGORY_VALUENODE =(1<<5),
CATEGORY_KEYFRAME =(1<<6),
CATEGORY_GROUP =(1<<7),
+ CATEGORY_BEZIER =(1<<8),
CATEGORY_OTHER =(1<<12),
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file valuedescblinelink.cpp
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007, 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
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
+** \endlegal
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+# include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "valuenodelinkconnect.h"
+#include "valuedescblinelink.h"
+
+#include <synfigapp/canvasinterface.h>
+#include <synfig/valuenode_const.h>
+#include <synfig/valuenode_composite.h>
+#include <synfig/valuenode_blinecalcvertex.h>
+
+#include <synfigapp/general.h>
+
+#endif
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace synfigapp;
+using namespace Action;
+
+/* === M A C R O S ========================================================= */
+
+ACTION_INIT(Action::ValueDescBLineLink);
+ACTION_SET_NAME(Action::ValueDescBLineLink,"value_desc_bline_link");
+ACTION_SET_LOCAL_NAME(Action::ValueDescBLineLink,N_("Link to BLine"));
+ACTION_SET_TASK(Action::ValueDescBLineLink,"connect");
+ACTION_SET_CATEGORY(Action::ValueDescBLineLink,Action::CATEGORY_BEZIER);
+ACTION_SET_PRIORITY(Action::ValueDescBLineLink,0);
+ACTION_SET_VERSION(Action::ValueDescBLineLink,"0.0");
+ACTION_SET_CVS_ID(Action::ValueDescBLineLink,"$Id$");
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Action::ValueDescBLineLink::ValueDescBLineLink()
+{
+}
+
+Action::ParamVocab
+Action::ValueDescBLineLink::get_param_vocab()
+{
+ ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
+
+ ret.push_back(ParamDesc("selected_value_desc",Param::TYPE_VALUEDESC)
+ .set_local_name(_("ValueDesc to link"))
+ .set_supports_multiple()
+ );
+ ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
+ .set_local_name(_("ValueDesc on BLine to link to"))
+ );
+ ret.push_back(ParamDesc("time",Param::TYPE_TIME)
+ .set_local_name(_("Time"))
+ .set_optional()
+ );
+ ret.push_back(ParamDesc("origin",Param::TYPE_REAL)
+ .set_local_name(_("Origin"))
+ .set_optional()
+ );
+
+ return ret;
+}
+
+bool
+Action::ValueDescBLineLink::is_candidate(const ParamList &x)
+{
+ ParamList::const_iterator i;
+
+ ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());
+
+ if (!candidate_check(get_param_vocab(),x))
+ return false;
+
+ return (value_desc.parent_is_value_node() &&
+ // We need a dynamic list.
+ ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node()));
+}
+
+bool
+Action::ValueDescBLineLink::set_param(const synfig::String& name, const Action::Param ¶m)
+{
+ if(name=="time" && param.get_type()==Param::TYPE_TIME)
+ {
+ time=param.get_time();
+ return true;
+ }
+
+ if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
+ {
+ value_desc = param.get_value_desc();
+ index=value_desc.get_index();
+ return true;
+ }
+
+ if(name=="selected_value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
+ {
+ ValueDesc value_desc(param.get_value_desc());
+ value_desc_list.push_back(value_desc);
+ return true;
+ }
+
+ if(name=="origin" && param.get_type()==Param::TYPE_REAL)
+ {
+ origin=param.get_real();
+ return true;
+ }
+
+ return Action::CanvasSpecific::set_param(name,param);
+}
+
+bool
+Action::ValueDescBLineLink::is_ready()const
+{
+ if(value_desc_list.size()<1)
+ return false;
+ if(!value_desc)
+ return false;
+ return Action::CanvasSpecific::is_ready();
+}
+
+void
+Action::ValueDescBLineLink::prepare()
+{
+ if(value_desc_list.empty())
+ throw Error(Error::TYPE_NOTREADY);
+
+ clear();
+
+ ValueNode_DynamicList::Handle bline_value_node(ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node()));
+ bool loop(bline_value_node->get_loop());
+ int loop_adjust(loop ? 0 : -1);
+ const std::vector<ValueBase> bline((*bline_value_node)(time));
+ int size = bline.size();
+ Real amount = (index + origin + loop_adjust) / (size + loop_adjust);
+
+ std::list<ValueDesc>::iterator iter;
+ for(iter=value_desc_list.begin();iter!=value_desc_list.end();++iter)
+ {
+ ValueDesc& value_desc(*iter);
+ if (value_desc.parent_is_value_node())
+ {
+ ValueNode::Handle value_node(value_desc.get_value_node());
+ if (value_desc.get_value_type()==ValueBase::TYPE_BLINEPOINT &&
+ value_desc.is_value_node() &&
+ ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()))
+ {
+ LinkableValueNode::Handle bline_vertex(ValueNode_BLineCalcVertex::create(ValueBase::TYPE_VECTOR));
+ bline_vertex->set_link("bline", bline_value_node);
+ bline_vertex->set_link("loop", ValueNode_Const::create(loop));
+ bline_vertex->set_link("amount", ValueNode_Const::create(amount));
+
+ Action::Handle action(ValueNodeLinkConnect::create());
+
+ action->set_param("canvas",get_canvas());
+ action->set_param("canvas_interface",get_canvas_interface());
+ action->set_param("parent_value_node",value_node);
+ action->set_param("value_node",ValueNode::Handle(bline_vertex));
+ action->set_param("index",0); // index for 'vertex' in 'composite'
+
+ assert(action->is_ready());
+ if(!action->is_ready())
+ throw Error(Error::TYPE_NOTREADY);
+
+ add_action_front(action);
+ }
+ }
+ }
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file valuedescblinelink.h
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007 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
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
+** \endlegal
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_APP_ACTION_VALUEDESCBLINELINK_H
+#define __SYNFIG_APP_ACTION_VALUEDESCBLINELINK_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <synfigapp/action.h>
+#include <synfigapp/value_desc.h>
+#include <synfig/valuenode_dynamiclist.h>
+#include <list>
+
+/* === M A C R O S ========================================================= */
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace synfigapp {
+
+namespace Action {
+
+class ValueDescBLineLink :
+ public Super
+{
+private:
+
+ ValueDesc value_desc;
+ std::list<ValueDesc> value_desc_list;
+ synfig::ValueNode::Handle link_value_node;
+ synfig::Time time;
+ synfig::Real origin;
+ int index;
+public:
+
+ ValueDescBLineLink();
+
+ static ParamVocab get_param_vocab();
+ static bool is_candidate(const ParamList &x);
+
+ virtual bool set_param(const synfig::String& name, const Param &);
+ virtual bool is_ready()const;
+
+ virtual void prepare();
+
+ ACTION_MODULE_EXT
+};
+
+}; // END of namespace action
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif