**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-** Copyright (c) 2007 Chris Moore
+** 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
#include <synfig/valuenode_dynamiclist.h>
#include <synfig/valuenode_twotone.h>
#include <synfig/valuenode_stripes.h>
+#include <synfig/valuenode_blinecalctangent.h>
+#include <synfig/valuenode_blinecalcvertex.h>
+#include <synfig/valuenode_blinecalcwidth.h>
+#include <synfig/valuenode_bline.h>
#include <synfig/layer.h>
#include <synfigapp/uimanager.h>
/* === C L A S S E S ======================================================= */
-
class studio::UniversalScrubber
{
CanvasView *canvas_view;
}
};
-
class studio::CanvasViewUIInterface : public synfigapp::UIInterface
{
CanvasView *view;
CanvasViewUIInterface(CanvasView *view):
view(view)
{
-
view->statusbar->push(_("Idle"));
}
CanvasView *view;
CanvasView::LayerTreeModel layer_tree_model;
CanvasView::ChildrenTreeModel children_tree_model;
-public:
-
- CanvasViewSelectionManager(CanvasView *view): view(view)
-{
-
- }
+public:
+ CanvasViewSelectionManager(CanvasView *view): view(view) { }
private:
void _set_selected_layer(const synfig::Layer::Handle &layer)
view->layer_tree->clear_selected_layers();
}
-
-
//! Returns the number of value_nodes selected.
virtual int get_selected_children_count()const
{
return;
}
-
-
int get_selected_layer_parameter_count()const
{
return get_selected_layer_parameters().size();
}; // END of class SelectionManager
-
CanvasView::IsWorking::IsWorking(CanvasView &canvas_view_):
canvas_view_(canvas_view_)
{
//vpaned->pack2(*notebook, Gtk::SHRINK);
//vpaned->show_all();
-
//notebook->show();
//notebook->append_page(*create_layer_tree(),_("Layers"));
init_menus();
//layout_table->attach(*App::ui_manager()->get_widget("/menu-main"), 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-
layout_table->attach(*create_time_bar(), 0, 1, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
layout_table->attach(*create_status_bar(), 0, 1, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
time_window_adjustment().signal_value_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::refresh_time_window));
time_adjustment().signal_value_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::time_was_changed));
-
work_area->signal_layer_selected().connect(sigc::mem_fun(*this,&studio::CanvasView::workarea_layer_selected));
work_area->signal_input_device_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::on_input_device_changed));
)
);
-
//MUCH TIME STUFF TAKES PLACE IN HERE
refresh_rend_desc();
refresh_time_window();
set_default_size(w,h);
property_window_position().set_value(Gtk::WIN_POS_NONE);
-
-
-
std::list<Gtk::TargetEntry> listTargets;
listTargets.push_back( Gtk::TargetEntry("STRING") );
listTargets.push_back( Gtk::TargetEntry("text/plain") );
drag_dest_set(listTargets);
signal_drag_data_received().connect( sigc::mem_fun(*this, &studio::CanvasView::on_drop_drag_data_received) );
-
/*
Time length(get_canvas()->rend_desc().get_time_end()-get_canvas()->rend_desc().get_time_start());
if(length<10.0)
time_window_adjustment().set_value(get_canvas()->rend_desc().get_time_start());
time_window_adjustment().value_changed();
-
GRAB_HINT_DATA("canvas_view");
/*
{
synfig::info("CanvasView::~CanvasView(): Deleted");
}
-
-
std::list<int>&
CanvasView::get_pixel_sizes()
{
timeslider->set_bounds_adjustment(&time_window_adjustment());
//layout_table->attach(*timeslider, 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL);
-
tooltips.set_tip(*time_window_scroll,_("Moves the time window"));
tooltips.set_tip(*timeslider,_("Changes the current time"));
time_window_scroll->show();
return work_area.get();
}
-
Gtk::Widget*
CanvasView::create_status_bar()
{
// statusbartable->attach(*lowerbutton, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
// statusbartable->attach(*raisebutton, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-
current_time_widget=manage(new Widget_Time);
current_time_widget->set_value(get_time());
current_time_widget->set_fps(get_canvas()->rend_desc().get_frame_rate());
refreshbutton->signal_clicked().connect(SLOT_EVENT(EVENT_REFRESH));
stopbutton->signal_clicked().connect(SLOT_EVENT(EVENT_STOP));
-
statusbartable->show_all();
return statusbartable;
}
CanvasView::on_current_time_widget_changed()
{
set_time(current_time_widget->get_value());
+
+ // show the value being used - it will have been rounded to nearest frame
+ // this was already being done elsewhere, but only if the time was really changed;
+ // if the current time was 6f and the user edited it to 6.1f, then the 6.1f would
+ // be left in the display without the following line to fix it
+ current_time_widget->set_value(get_time());
+ current_time_widget->set_position(-1); // leave the cursor at the end
}
// Gtk::Widget*
// // Connect Signals
// if(children_tree)children_tree->signal_edited_value().connect(sigc::mem_fun(*this, &studio::CanvasView::on_edited_value));
// if(children_tree)children_tree->signal_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_children_user_click));
-// if(children_tree)children_tree->signal_waypoint_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked));
+// if(children_tree)children_tree->signal_waypoint_clicked_childrentree().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked_canvasview));
// if(children_tree)children_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
//
// return children_tree;
// layer_tree->signal_edited_value().connect(sigc::mem_fun(*this, &studio::CanvasView::on_edited_value));
// layer_tree->signal_layer_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_layer_user_click));
// layer_tree->signal_param_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_children_user_click));
-// layer_tree->signal_waypoint_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked));
+// layer_tree->signal_waypoint_clicked_layertree().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked_canvasview));
// layer_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
//
// layer_tree->hide();
sigc::hide_return(sigc::ptr_fun(&studio::App::new_instance))
);
action_group->add( Gtk::Action::create("open", Gtk::Stock::OPEN),
- sigc::hide_return(sigc::ptr_fun(&studio::App::dialog_open))
+ sigc::hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::open))
);
action_group->add( Gtk::Action::create("save", Gtk::Stock::SAVE),
hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::save))
sigc::mem_fun(*work_area,&studio::WorkArea::select_all_ducks)
);
+ action_group->add( Gtk::Action::create("unselect-all-ducks", _("Unselect All Ducks")),
+ sigc::mem_fun(*work_area,&studio::WorkArea::unselect_all_ducks)
+ );
+
+ action_group->add( Gtk::Action::create("select-all-layers", _("Select All Layers")),
+ sigc::mem_fun(*this,&CanvasView::on_select_layers)
+ );
+
action_group->add( Gtk::Action::create("unselect-all-layers", _("Unselect All Layers")),
sigc::mem_fun(*this,&CanvasView::on_unselect_layers)
);
if (i == 10) note = _(" (fastest)");
Glib::RefPtr<Gtk::RadioAction> action(Gtk::RadioAction::create(quality_group,strprintf("quality-%02d",i),
strprintf(_("Set Quality to %d"),i) + note));
- if(i==9) // default quality
+ if (i==8) // default quality
{
action->set_active();
work_area->set_quality(i);
{
Glib::RefPtr<Gtk::ToggleAction> action;
- action = Gtk::ToggleAction::create("toggle-grid-show", _("Show Grid"));
- action->set_active(work_area->grid_status());
- action_group->add(action, sigc::mem_fun(*work_area, &studio::WorkArea::toggle_grid));
+ grid_show_toggle = Gtk::ToggleAction::create("toggle-grid-show", _("Show Grid"));
+ grid_show_toggle->set_active(work_area->grid_status());
+ action_group->add(grid_show_toggle, sigc::mem_fun(*work_area, &studio::WorkArea::toggle_grid));
- action = Gtk::ToggleAction::create("toggle-grid-snap", _("Snap to Grid"));
- action->set_active(work_area->get_grid_snap());
- action_group->add(action, sigc::mem_fun(*work_area, &studio::WorkArea::toggle_grid_snap));
+ grid_snap_toggle = Gtk::ToggleAction::create("toggle-grid-snap", _("Snap to Grid"));
+ grid_snap_toggle->set_active(work_area->get_grid_snap());
+ action_group->add(grid_snap_toggle, sigc::mem_fun(*work_area, &studio::WorkArea::toggle_grid_snap));
action = Gtk::ToggleAction::create("toggle-guide-show", _("Show Guides"));
action->set_active(work_area->get_show_guides());
}
+ {
+ Glib::RefPtr<Gtk::ToggleAction> action;
+
+#define DUCK_MASK(lower,upper,string) \
+ action=Gtk::ToggleAction::create("mask-" #lower "-ducks", string); \
+ action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_##upper)); \
+ action_group->add(action, \
+ sigc::bind( \
+ sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask), \
+ Duck::TYPE_##upper))
+
+ DUCK_MASK(position,POSITION,_("Show Position Ducks"));
+ DUCK_MASK(tangent,TANGENT,_("Show Tangent Ducks"));
+ DUCK_MASK(vertex,VERTEX,_("Show Vertex Ducks"));
+ DUCK_MASK(radius,RADIUS,_("Show Radius Ducks"));
+ DUCK_MASK(width,WIDTH,_("Show Width Ducks"));
+ DUCK_MASK(angle,ANGLE,_("Show Angle Ducks"));
-#define DUCK_MASK(lower,upper,string) \
- duck_mask_##lower=Gtk::ToggleAction::create("mask-" #lower "-ducks", string); \
- duck_mask_##lower->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_##upper)); \
- action_group->add( duck_mask_##lower, \
- sigc::bind( \
- sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask), \
- Duck::TYPE_##upper \
- ) \
- )
- DUCK_MASK(position,POSITION,_("Show Position Ducks"));
- DUCK_MASK(tangent,TANGENT,_("Show Tangent Ducks"));
- DUCK_MASK(vertex,VERTEX,_("Show Vertex Ducks"));
- DUCK_MASK(radius,RADIUS,_("Show Radius Ducks"));
- DUCK_MASK(width,WIDTH,_("Show Width Ducks"));
- DUCK_MASK(angle,ANGLE,_("Show Angle Ducks"));
#undef DUCK_MASK
+ }
add_accel_group(App::ui_manager()->get_accel_group());
}
*/
-
-
#if 0
//
// //Test some key stuff
// editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-paste"),NOT_IMPLEMENTED_SLOT));
// editmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
// editmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Select All Ducks"),Gtk::AccelKey('E',Gdk::CONTROL_MASK),sigc::mem_fun(*work_area,&studio::WorkArea::select_all_ducks)));
+// editmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Unselect All Ducks"),Gtk::AccelKey('E',Gdk::CONTROL_MASK),sigc::mem_fun(*work_area,&studio::WorkArea::unselect_all_ducks)));
+// editmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Select All Layers"),Gtk::AccelKey('A',Gdk::CONTROL_MASK),sigc::mem_fun(*this,&CanvasView::on_select_layers)));
// editmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Unselect All Layers"),Gtk::AccelKey('D',Gdk::CONTROL_MASK),sigc::mem_fun(*this,&CanvasView::on_unselect_layers)));
// editmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
//
}
void
+CanvasView::on_select_layers()
+{
+ Canvas::Handle canvas(get_canvas());
+ for (CanvasBase::iterator iter = canvas->begin(); iter != canvas->end(); iter++)
+ layer_tree->select_all_children_layers(*iter);
+}
+
+void
CanvasView::on_unselect_layers()
{
layer_tree->clear_selected_layers();
target_depth=canvas->get_depth(*layer_list.begin());
}
-
Layer::Handle layer(canvas_interface()->add_layer_to(x,canvas,target_depth));
if(layer)
{
get_selection_manager()->set_selected_layer(layer);
}
-
void
CanvasView::refresh_rend_desc()
{
current_time_widget->set_fps(get_canvas()->rend_desc().get_frame_rate());
-
//????
//synfig::info("Canvasview: Refreshing render desc info");
if(!get_time().is_equal(time_adjustment().get_value()))
}
//clamp time to big bounds...
+ if(time_window_adjustment().get_value() < begin_time)
+ {
+ time_window_adjustment().set_value(begin_time);
+ time_window_adjustment().value_changed();
+ }
+
+ if(time_window_adjustment().get_value() + time_window_adjustment().get_page_size() > end_time)
+ {
+ time_window_adjustment().set_value(end_time - time_window_adjustment().get_page_size());
+ time_window_adjustment().value_changed();
+ }
+
if(time_adjustment().get_value() < begin_time)
{
time_adjustment().set_value(begin_time);
work_area->queue_render_preview();
}
-
bool
CanvasView::close_view()
{
bool
CanvasView::close_instance()
{
+#ifdef SINGLE_THREADED
if (get_work_area()->get_updating())
{
get_work_area()->stop_updating(true); // stop and mark as cancelled
250);
}
else
+#endif
Glib::signal_timeout().connect(
sigc::bind(sigc::ptr_fun(_close_instance),
(etl::handle<Instance>)get_instance()),
{
string title;
- if(get_instance()->synfigapp::Instance::get_action_count())
- title="*";
- title+=etl::basename(get_instance()->get_file_name())
- +" : ";
- if(get_canvas()->get_name().empty())
- title+='"'+get_canvas()->get_id()+'"';
- else
- title+='"'+get_canvas()->get_name()+'"';
+ title = strprintf("%s%s\"%s\"",
+ (
+ get_instance()->get_action_count()
+ ? "*"
+ : ""
+ ), (
+ get_instance()->has_real_filename()
+ ? (etl::basename(get_instance()->get_file_name()) + " : ").c_str()
+ : ""
+ ), (
+ get_canvas()->get_name().empty()
+ ? get_canvas()->get_id().c_str()
+ : get_canvas()->get_name().c_str()
+ ));
if(get_instance()->synfigapp::Instance::in_repository())
{
set_title(title);
}
-
void
CanvasView::on_hide()
{
canvas_interface()->get_instance()->perform_action(action);
}
-
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());
}
{
case 3:
{
-
Gtk::MenuItem* menu = dynamic_cast<Gtk::MenuItem*>(App::ui_manager()->get_widget("/menu-main/menu-layer"));
if(menu && menu->get_submenu())
{
menu->get_submenu()->popup(button,gtk_get_current_event_time());
}
-
#if 0
bool multiple_selected=true;
}
}
-
-
bool
CanvasView::on_children_user_click(int button, Gtk::TreeRow row, ChildrenTree::ColumnID column_id)
{
return false;
}
-
void
CanvasView::refresh_time_window()
{
if(get_time() != time_adjustment().get_value())
{
-
//Recenters the window, causing it to jump (possibly undesirably... but whatever)
if(time < time_window_adjustment().get_value() ||
time > time_window_adjustment().get_value()+time_window_adjustment().get_page_size())
void
CanvasView::time_zoom_in()
{
+ float frame_rate = get_canvas()->rend_desc().get_frame_rate();
+ Time min_page_size = 2/frame_rate;
+
time_window_adjustment().set_page_size(time_window_adjustment().get_page_size()*0.75);
+ if (time_window_adjustment().get_page_size() < min_page_size)
+ time_window_adjustment().set_page_size(min_page_size);
+ time_window_adjustment().set_page_increment(time_window_adjustment().get_page_size());
time_window_adjustment().changed();
refresh_time_window();
void
CanvasView::time_zoom_out()
{
+ Time length = (get_canvas()->rend_desc().get_time_end() -
+ get_canvas()->rend_desc().get_time_start());
+
time_window_adjustment().set_page_size(time_window_adjustment().get_page_size()/0.75);
+ if (time_window_adjustment().get_page_size() > length)
+ time_window_adjustment().set_page_size(length);
+ time_window_adjustment().set_page_increment(time_window_adjustment().get_page_size());
time_window_adjustment().changed();
refresh_time_window();
update_title();
}
-
void
CanvasView::on_mode_changed(synfigapp::CanvasInterface::Mode mode)
{
bool
CanvasView::on_duck_changed(const synfig::Point &value,const synfigapp::ValueDesc& value_desc)
{
+ if (ValueNode_BLineCalcWidth::Handle bline_width = ValueNode_BLineCalcWidth::Handle::cast_dynamic(value_desc.get_value_node()))
+ {
+ Real old_width((*bline_width)(get_time()).get(Real()));
+ Real new_width(value.mag());
+ int scale_index(bline_width->get_link_index_from_name("scale"));
+ Real scale((*(bline_width->get_link(scale_index)))(get_time()).get(Real()));
+ return canvas_interface()->change_value(synfigapp::ValueDesc(bline_width,scale_index), new_width * scale / old_width);
+ }
+
+ if (ValueNode_BLineCalcVertex::Handle bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(value_desc.get_value_node()))
+ {
+ ValueNode_BLine::Handle bline = ValueNode_BLine::Handle::cast_dynamic(bline_vertex->get_link(bline_vertex->get_link_index_from_name("bline")));
+ Real radius = 0.0;
+ Real amount = synfig::find_closest_point((*bline)(get_time()), value, radius, bline->get_loop());
+ return canvas_interface()->change_value(synfigapp::ValueDesc(bline_vertex,bline_vertex->get_link_index_from_name("amount")), amount);
+ }
+
+ if (ValueNode_BLineCalcTangent::Handle bline_tangent = ValueNode_BLineCalcTangent::Handle::cast_dynamic(value_desc.get_value_node()))
+ {
+ switch(value_desc.get_value_type())
+ {
+ case ValueBase::TYPE_REAL:
+ {
+ Real old_length = (*bline_tangent)(get_time()).get(Real());
+ Real new_length = value.mag();
+ int scale_index(bline_tangent->get_link_index_from_name("scale"));
+ int fixed_length_index(bline_tangent->get_link_index_from_name("fixed_length"));
+ Real scale((*(bline_tangent->get_link(scale_index)))(get_time()).get(Real()));
+ bool fixed_length((*(bline_tangent->get_link(fixed_length_index)))(get_time()).get(bool()));
+ if (fixed_length)
+ return canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,scale_index), new_length);
+ if (old_length == 0)
+ return true;
+ return canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,scale_index), new_length * scale / old_length);
+ }
+
+ case ValueBase::TYPE_ANGLE:
+ assert(0); // doesn't happen?
+ break;
+
+ case ValueBase::TYPE_VECTOR:
+ {
+ Vector old_tangent = (*bline_tangent)(get_time()).get(Vector());
+ Angle old_angle = old_tangent.angle();
+ Real old_length = old_tangent.mag();
+ Angle new_angle = value.angle();
+ Real new_length = value.mag();
+ int offset_index(bline_tangent->get_link_index_from_name("offset"));
+ int scale_index(bline_tangent->get_link_index_from_name("scale"));
+ int fixed_length_index(bline_tangent->get_link_index_from_name("fixed_length"));
+ Angle old_offset((*(bline_tangent->get_link(offset_index)))(get_time()).get(Angle()));
+ Real scale((*(bline_tangent->get_link(scale_index)))(get_time()).get(Real()));
+ bool fixed_length((*(bline_tangent->get_link(fixed_length_index)))(get_time()).get(bool()));
+ if (fixed_length)
+ {
+ if (!(canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,scale_index), new_length)))
+ return false;
+ }
+ else if (old_length != 0 && !(canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,scale_index), new_length * scale / old_length)))
+ return false;
+ return canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,offset_index), old_offset + new_angle - old_angle);
+ }
+ default:
+ break;
+ }
+ }
+
switch(value_desc.get_value_type())
{
case ValueBase::TYPE_REAL:
return canvas_interface()->change_value(value_desc,value.mag());
- break;
case ValueBase::TYPE_ANGLE:
return canvas_interface()->change_value(value_desc,Angle::tan(value[1],value[0]));
- break;
default:
return canvas_interface()->change_value(value_desc,value);
- break;
}
-
- return true;
}
bool
CanvasView::on_duck_angle_changed(const synfig::Angle &rotation,const synfigapp::ValueDesc& value_desc)
{
+ if (ValueNode_BLineCalcTangent::Handle bline_tangent = ValueNode_BLineCalcTangent::Handle::cast_dynamic(value_desc.get_value_node()))
+ {
+ int offset_index(bline_tangent->get_link_index_from_name("offset"));
+ Angle old_offset((*(bline_tangent->get_link(offset_index)))(get_time()).get(Angle()));
+ return canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,offset_index), old_offset + rotation);
+ }
+
// \todo will this really always be the case?
assert(value_desc.get_value_type() == ValueBase::TYPE_ANGLE);
return canvas_interface()->change_value(value_desc, value_desc.get_value(get_time()).get(Angle()) + rotation);
children_tree->set_sensitive(sensitive);
}
+static void
+set_waypoint_model(std::set<synfig::Waypoint, std::less<UniqueID> > waypoints,
+ Waypoint::Model model,
+ etl::loose_handle<synfigapp::CanvasInterface> canvas_interface)
+{
+ // Create the action group
+ synfigapp::Action::PassiveGrouper group(canvas_interface->get_instance().get(),_("Change Waypoint Group"));
+
+ std::set<synfig::Waypoint, std::less<UniqueID> >::const_iterator iter;
+ for(iter=waypoints.begin();iter!=waypoints.end();++iter)
+ {
+ Waypoint waypoint(*iter);
+ waypoint.apply_model(model);
+
+ synfigapp::Action::Handle action(synfigapp::Action::create("waypoint_set"));
+
+ assert(action);
+
+ action->set_param("canvas",canvas_interface->get_canvas());
+ action->set_param("canvas_interface",canvas_interface);
+
+ action->set_param("waypoint",waypoint);
+ action->set_param("value_node",waypoint.get_parent_value_node());
+
+ if(!canvas_interface->get_instance()->perform_action(action))
+ {
+ group.cancel();
+ return;
+ }
+ }
+}
+
+static void
+duplicate_waypoints(std::set<synfig::Waypoint, std::less<UniqueID> > waypoints,
+ etl::loose_handle<synfigapp::CanvasInterface> canvas_interface)
+{
+ // Create the action group
+ synfigapp::Action::PassiveGrouper group(canvas_interface->get_instance().get(),_("Duplicate Waypoints"));
+
+ std::set<synfig::Waypoint, std::less<UniqueID> >::const_iterator iter;
+ for (iter = waypoints.begin(); iter != waypoints.end(); iter++)
+ {
+ Waypoint waypoint(*iter);
+ ValueNode::Handle value_node(iter->get_parent_value_node());
+ canvas_interface->waypoint_duplicate(value_node, waypoint);
+ }
+}
+
+static void
+remove_waypoints(std::set<synfig::Waypoint, std::less<UniqueID> > waypoints,
+ etl::loose_handle<synfigapp::CanvasInterface> canvas_interface)
+{
+ // Create the action group
+ synfigapp::Action::PassiveGrouper group(canvas_interface->get_instance().get(),_("Remove Waypoints"));
+
+ std::set<synfig::Waypoint, std::less<UniqueID> >::const_iterator iter;
+ for (iter = waypoints.begin(); iter != waypoints.end(); iter++)
+ {
+ Waypoint waypoint(*iter);
+ ValueNode::Handle value_node(iter->get_parent_value_node());
+ canvas_interface->waypoint_remove(value_node, waypoint);
+ }
+}
void
-CanvasView::on_waypoint_clicked(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint,int button)
+CanvasView::on_waypoint_clicked_canvasview(synfigapp::ValueDesc value_desc,
+ std::set<synfig::Waypoint, std::less<UniqueID> > waypoint_set,
+ int button)
{
- waypoint_dialog.set_value_desc(value_desc);
- waypoint_dialog.set_waypoint(waypoint);
+ int size = waypoint_set.size();
+ Waypoint waypoint(*(waypoint_set.begin()));
+ Time time(waypoint.get_time());
+
+ if (size == 1)
+ {
+ waypoint_dialog.set_value_desc(value_desc);
+ waypoint_dialog.set_waypoint(waypoint);
+ }
switch(button)
{
case -1:
- waypoint_dialog.show();
+ if (size == 1)
+ waypoint_dialog.show();
break;
case 2:
+ {
+ Gtk::Menu* waypoint_menu(manage(new Gtk::Menu()));
+ waypoint_menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), waypoint_menu));
+
+ Gtk::Menu* interp_menu_in(manage(new Gtk::Menu()));
+ Gtk::Menu* interp_menu_out(manage(new Gtk::Menu()));
+ Gtk::Menu* interp_menu_both(manage(new Gtk::Menu()));
+
{
- Gtk::Menu* waypoint_menu(manage(new Gtk::Menu()));
- waypoint_menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), waypoint_menu));
+ Waypoint::Model model;
+
+ model.reset(); model.set_before(INTERPOLATION_TCB);
+ interp_menu_in->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_TCB"),
+ sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+ model.reset(); model.set_after(INTERPOLATION_TCB);
+ interp_menu_out->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_TCB"),
+ sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+ model.set_before(INTERPOLATION_TCB);
+ interp_menu_both->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_TCB"),
+ sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+
+ model.reset(); model.set_before(INTERPOLATION_LINEAR);
+ interp_menu_in->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Linear"),
+ sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+ model.reset(); model.set_after(INTERPOLATION_LINEAR);
+ interp_menu_out->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Linear"),
+ sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+ model.set_before(INTERPOLATION_LINEAR);
+ interp_menu_both->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Linear"),
+ sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+
+ model.reset(); model.set_before(INTERPOLATION_HALT);
+ interp_menu_in->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Ease In"),
+ sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+ model.reset(); model.set_after(INTERPOLATION_HALT);
+ interp_menu_out->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Ease Out"),
+ sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+ model.set_before(INTERPOLATION_HALT);
+ interp_menu_both->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Ease In/Out"),
+ sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+
+ model.reset(); model.set_before(INTERPOLATION_CONSTANT);
+ interp_menu_in->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Constant"),
+ sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+ model.reset(); model.set_after(INTERPOLATION_CONSTANT);
+ interp_menu_out->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Constant"),
+ sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+ model.set_before(INTERPOLATION_CONSTANT);
+ interp_menu_both->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Constant"),
+ sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+ }
- waypoint_menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-jump-to"),
- sigc::bind(
- sigc::mem_fun(
- *canvas_interface(),
- &synfigapp::CanvasInterface::set_time
- ),
- waypoint.get_time()
- )
- ));
+ // ------------------------------------------------------------------------
+ waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Jump To"),
+ sigc::bind(sigc::mem_fun(*canvas_interface(), &synfigapp::CanvasInterface::set_time), time)));
- waypoint_menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID(_("Edit Waypoint")),
- sigc::mem_fun(
- waypoint_dialog,
- &Gtk::Widget::show
- )
- ));
+ waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Duplicate"),
+ sigc::bind(sigc::ptr_fun(duplicate_waypoints), waypoint_set, canvas_interface())));
+
+ waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem((size == 1) ? _("_Remove") : strprintf(_("_Remove %d Waypoints"), size),
+ sigc::bind(sigc::ptr_fun(remove_waypoints), waypoint_set, canvas_interface())));
+
+ if (size == 1 && value_desc.is_valid())
+ waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Edit"),
+ sigc::mem_fun(waypoint_dialog,&Gtk::Widget::show)));
+
+ // ------------------------------------------------------------------------
+ waypoint_menu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+
+ // ------------------------------------------------------------------------
+ waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Both"), *interp_menu_both));
+ waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_In"), *interp_menu_in));
+ waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Out"), *interp_menu_out));
+
+ // ------------------------------------------------------------------------
+ waypoint_menu->popup(button+1,gtk_get_current_event_time());
+ }
+ break;
- waypoint_menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-duplicate"),
- sigc::bind(
- sigc::bind(
- sigc::mem_fun(
- *canvas_interface(),
- &synfigapp::CanvasInterface::waypoint_duplicate
- ),
- waypoint
- ),
- value_desc
- )
- ));
- waypoint_menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-delete"),
- sigc::bind(
- sigc::bind(
- sigc::mem_fun(
- *canvas_interface(),
- &synfigapp::CanvasInterface::waypoint_remove
- ),
- waypoint
- ),
- value_desc
- )
- ));
- waypoint_menu->popup(button+1,gtk_get_current_event_time());
- }
- break;
default:
break;
}
canvas_interface()->get_instance()->perform_action(action);
}
-
void
CanvasView::toggle_duck_mask(Duckmatic::Type type)
{
bool is_currently_on(work_area->get_type_mask()&type);
- switch(type)
- {
- case Duck::TYPE_POSITION:
- if(duck_mask_position)
- duck_mask_position->set_active(!is_currently_on);
- break;
-
- case Duck::TYPE_VERTEX:
- if(duck_mask_vertex)
- duck_mask_vertex->set_active(!is_currently_on);
- break;
-
- case Duck::TYPE_TANGENT:
- if(duck_mask_tangent)
- duck_mask_tangent->set_active(!is_currently_on);
- break;
-
- case Duck::TYPE_RADIUS:
- if(duck_mask_radius)
- duck_mask_radius->set_active(!is_currently_on);
- break;
-
- case Duck::TYPE_WIDTH:
- if(duck_mask_width)
- duck_mask_width->set_active(!is_currently_on);
- break;
-
- case Duck::TYPE_ANGLE:
- if(duck_mask_angle)
- duck_mask_angle->set_active(!is_currently_on);
- break;
-
- default:
- synfig::warning("CanvasView::toggle_duck_mask():Unknown duck type!");
- break;
- }
-
if(is_currently_on)
work_area->set_type_mask(work_area->get_type_mask()-type);
else
work_area->queue_draw();
}
-
void
CanvasView::image_import()
{
return true;
}
-
-
Glib::RefPtr<Glib::ObjectBase>
CanvasView::get_ref_obj(const synfig::String& x)
{
layer_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
layer_tree->signal_layer_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_layer_user_click));
layer_tree->signal_param_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_children_user_click));
- layer_tree->signal_waypoint_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked));
+ layer_tree->signal_waypoint_clicked_layertree().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked_canvasview));
}
if(x=="children")
{
children_tree=dynamic_cast<ChildrenTree*>(y);
if(children_tree)children_tree->signal_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_children_user_click));
- if(children_tree)children_tree->signal_waypoint_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked));
+ if(children_tree)children_tree->signal_waypoint_clicked_childrentree().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked_canvasview));
if(children_tree)children_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
}
if(x=="keyframes")