/* === S Y N F I G ========================================================= */
-/*! \file state_gradient.cpp
+/*! \file state_rectangle.cpp
** \brief Template File
**
-** $Id: state_rectangle.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
#include <synfig/valuenode_dynamiclist.h>
#include <synfigapp/action_system.h>
+#include <synfig/valuenode_bline.h>
#include "state_rectangle.h"
#include "canvasview.h"
#include "duck.h"
#include <synfigapp/main.h>
+#include "general.h"
+
#endif
/* === U S I N G =========================================================== */
Gtk::Entry entry_id; //what to name the layer
Gtk::Adjustment adj_expand;
+ Gtk::Adjustment adj_feather;
Gtk::SpinButton spin_expand;
+ Gtk::SpinButton spin_feather;
- Gtk::CheckButton check_invert;
+ Gtk::CheckButton checkbutton_invert;
+ Gtk::CheckButton checkbutton_layer_rectangle;
+ Gtk::CheckButton checkbutton_layer_region;
+ Gtk::CheckButton checkbutton_layer_outline;
+ Gtk::CheckButton checkbutton_layer_curve_gradient;
+ Gtk::CheckButton checkbutton_layer_plant;
+ Gtk::CheckButton checkbutton_layer_link_origins;
public:
+ // this only counts the layers which use blines - they're the only
+ // ones we link the origins for
+ int layers_to_create()const
+ {
+ return
+ get_layer_region_flag() +
+ get_layer_outline_flag() +
+ get_layer_curve_gradient_flag() +
+ get_layer_plant_flag();
+ }
+
synfig::String get_id()const { return entry_id.get_text(); }
void set_id(const synfig::String& x) { return entry_id.set_text(x); }
Real get_expand()const { return adj_expand.get_value(); }
void set_expand(Real f) { adj_expand.set_value(f); }
- bool get_invert()const { return check_invert.get_active(); }
- void set_invert(bool i) { check_invert.set_active(i); }
+ Real get_feather()const { return adj_feather.get_value(); }
+ void set_feather(Real f) { adj_feather.set_value(f); }
+
+ bool get_invert()const { return checkbutton_invert.get_active(); }
+ void set_invert(bool i) { checkbutton_invert.set_active(i); }
+
+ bool get_layer_rectangle_flag()const { return checkbutton_layer_rectangle.get_active(); }
+ void set_layer_rectangle_flag(bool x) { return checkbutton_layer_rectangle.set_active(x); }
+
+ bool get_layer_region_flag()const { return checkbutton_layer_region.get_active(); }
+ void set_layer_region_flag(bool x) { return checkbutton_layer_region.set_active(x); }
+
+ bool get_layer_outline_flag()const { return checkbutton_layer_outline.get_active(); }
+ void set_layer_outline_flag(bool x) { return checkbutton_layer_outline.set_active(x); }
+
+ bool get_layer_curve_gradient_flag()const { return checkbutton_layer_curve_gradient.get_active(); }
+ void set_layer_curve_gradient_flag(bool x) { return checkbutton_layer_curve_gradient.set_active(x); }
+
+ bool get_layer_plant_flag()const { return checkbutton_layer_plant.get_active(); }
+ void set_layer_plant_flag(bool x) { return checkbutton_layer_plant.set_active(x); }
+
+ bool get_layer_link_origins_flag()const { return checkbutton_layer_link_origins.get_active(); }
+ void set_layer_link_origins_flag(bool x) { return checkbutton_layer_link_origins.set_active(x); }
void refresh_tool_options(); //to refresh the toolbox
void save_settings();
void reset();
void increment_id();
- bool no_egress_on_selection_change;
- Smach::event_result event_layer_selection_changed_handler(const Smach::event& x)
+ bool egress_on_selection_change;
+ Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/)
{
- if(!no_egress_on_selection_change)
+ if(egress_on_selection_change)
throw Smach::egress_exception();
return Smach::RESULT_OK;
}
else
set_expand(0);
+ if(settings.get_value("rectangle.feather",value))
+ set_feather(atof(value.c_str()));
+ else
+ set_feather(0);
+
if(settings.get_value("rectangle.invert",value) && value != "0")
set_invert(true);
else
set_invert(false);
+
+ if(settings.get_value("rectangle.layer_rectangle",value) && value=="0")
+ set_layer_rectangle_flag(false);
+ else
+ set_layer_rectangle_flag(true);
+
+ if(settings.get_value("rectangle.layer_region",value) && value=="1")
+ set_layer_region_flag(true);
+ else
+ set_layer_region_flag(false);
+
+ if(settings.get_value("rectangle.layer_outline",value) && value=="1")
+ set_layer_outline_flag(true);
+ else
+ set_layer_outline_flag(false);
+
+ if(settings.get_value("rectangle.layer_curve_gradient",value) && value=="1")
+ set_layer_curve_gradient_flag(true);
+ else
+ set_layer_curve_gradient_flag(false);
+
+ if(settings.get_value("rectangle.layer_plant",value) && value=="1")
+ set_layer_plant_flag(true);
+ else
+ set_layer_plant_flag(false);
+
+ if(settings.get_value("rectangle.layer_link_origins",value) && value=="0")
+ set_layer_link_origins_flag(false);
+ else
+ set_layer_link_origins_flag(true);
}
void
{
settings.set_value("rectangle.id",get_id().c_str());
settings.set_value("rectangle.expand",strprintf("%f",get_expand()));
+ settings.set_value("rectangle.feather",strprintf("%f",(float)get_feather()));
settings.set_value("rectangle.invert",get_invert()?"1":"0");
+ settings.set_value("rectangle.layer_rectangle",get_layer_rectangle_flag()?"1":"0");
+ settings.set_value("rectangle.layer_outline",get_layer_outline_flag()?"1":"0");
+ settings.set_value("rectangle.layer_region",get_layer_region_flag()?"1":"0");
+ settings.set_value("rectangle.layer_curve_gradient",get_layer_curve_gradient_flag()?"1":"0");
+ settings.set_value("rectangle.layer_plant",get_layer_plant_flag()?"1":"0");
+ settings.set_value("rectangle.layer_link_origins",get_layer_link_origins_flag()?"1":"0");
}
void
int digits=0;
if(id.empty())
- id="Circle";
+ id="Rectangle";
// If there is a number
// already at the end of the
if(id[id.size()-1]<='9' && id[id.size()-1]>='0')
{
// figure out how many digits it is
- for(digits=0;(int)id.size()-1>=digits && id[id.size()-1-digits]<='9' && id[id.size()-1-digits]>='0';digits++)while(false);
+ for (digits = 0;
+ (int)id.size()-1 >= digits && id[id.size()-1-digits] <= '9' && id[id.size()-1-digits] >= '0';
+ digits++)
+ ;
String str_number;
str_number=String(id,id.size()-digits,id.size());
canvas_view_(canvas_view),
is_working(*canvas_view),
duckmatic_push(get_work_area()),
- prev_workarea_layer_status_(get_work_area()->allow_layer_clicks),
+ prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
settings(synfigapp::Main::get_selected_input_device()->settings()),
entry_id(),
adj_expand(0,0,1,0.01,0.1),
+ adj_feather(0,0,1,0.01,0.1),
spin_expand(adj_expand,0.1,3),
- check_invert(_("Invert"))
+ spin_feather(adj_feather,0.1,3),
+ checkbutton_invert(_("Invert")),
+ checkbutton_layer_rectangle(_("Create Rectangle Layer")),
+ checkbutton_layer_region(_("Create Region BLine")),
+ checkbutton_layer_outline(_("Create Outline BLine")),
+ checkbutton_layer_curve_gradient(_("Create Curve Gradient BLine")),
+ checkbutton_layer_plant(_("Create Plant BLine")),
+ checkbutton_layer_link_origins(_("Link BLine Origins"))
{
- no_egress_on_selection_change=false;
+ egress_on_selection_change=true;
load_settings();
// Set up the tool options dialog
- //options_table.attach(*manage(new Gtk::Label(_("Circle Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(entry_id, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(*manage(new Gtk::Label(_("Rectangle Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(entry_id, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
//expand stuff
- options_table.attach(*manage(new Gtk::Label(_("Expansion:"))), 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(spin_expand, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(*manage(new Gtk::Label(_("Expansion:"))), 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(spin_expand, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+ //feather stuff
+ options_table.attach(*manage(new Gtk::Label(_("Feather:"))), 0, 1, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(spin_feather, 1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
//invert flag
- options_table.attach(check_invert, 1, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(checkbutton_invert, 1, 2, 4 , 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+ options_table.attach(checkbutton_layer_rectangle, 0, 2, 7, 8, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(checkbutton_layer_outline, 0, 2, 8, 9, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(checkbutton_layer_region, 0, 2, 9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(checkbutton_layer_plant, 0, 2, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(checkbutton_layer_curve_gradient, 0, 2, 11, 12, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(checkbutton_layer_link_origins, 0, 2, 12, 13, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
options_table.show_all();
App::dialog_tool_options->present();
// Turn off layer clicking
- get_work_area()->allow_layer_clicks=false;
+ get_work_area()->set_allow_layer_clicks(false);
// clear out the ducks
get_work_area()->clear_ducks();
//prev_table_status=get_canvas_view()->tables_are_visible();
//if(prev_table_status)get_canvas_view()->hide_tables();
- // Hide the time bar
- //get_canvas_view()->hide_timebar();
+ // Disable the time bar
+ //get_canvas_view()->set_sensitive_timebar(false);
// Connect a signal
//get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateRectangle_Context::on_user_click));
}
Smach::event_result
-StateRectangle_Context::event_refresh_tool_options(const Smach::event& x)
+StateRectangle_Context::event_refresh_tool_options(const Smach::event& /*x*/)
{
refresh_tool_options();
return Smach::RESULT_ACCEPT;
save_settings();
// Restore layer clicking
- get_work_area()->allow_layer_clicks = prev_workarea_layer_status_;
+ get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
get_canvas_view()->work_area->reset_cursor();
App::dialog_tool_options->clear();
- // Show the time bar
- if(get_canvas_view()->get_canvas()->rend_desc().get_time_start()!=get_canvas_view()->get_canvas()->rend_desc().get_time_end())
- get_canvas_view()->show_timebar();
+ // Enable the time bar
+ //get_canvas_view()->set_sensitive_timebar(true);
// Bring back the tables if they were out before
//if(prev_table_status)get_canvas_view()->show_tables();
// Refresh the work area
get_work_area()->queue_draw();
+ get_canvas_view()->queue_rebuild_ducks();
+
App::toolbox->refresh();
}
Smach::event_result
-StateRectangle_Context::event_stop_handler(const Smach::event& x)
+StateRectangle_Context::event_stop_handler(const Smach::event& /*x*/)
{
throw Smach::egress_exception();
}
Smach::event_result
-StateRectangle_Context::event_refresh_handler(const Smach::event& x)
+StateRectangle_Context::event_refresh_handler(const Smach::event& /*x*/)
{
refresh_ducks();
return Smach::RESULT_ACCEPT;
Layer::Handle layer;
- Canvas::Handle canvas(get_canvas_view()->get_canvas());
+ Canvas::Handle canvas;
int depth(0);
// we are temporarily using the layer to hold something
canvas=layer->get_canvas();
}
- //create the layer
- layer=get_canvas_interface()->add_layer_to("rectangle",canvas,depth);
+ synfigapp::SelectionManager::LayerList layer_selection;
+ if (!getenv("SYNFIG_TOOLS_CLEAR_SELECTION"))
+ layer_selection = get_canvas_view()->get_selection_manager()->get_selected_layers();
const synfig::TransformStack& transform(get_canvas_view()->get_curr_transform_stack());
const Point p1(transform.unperform(_p1));
const Point p2(transform.unperform(_p2));
+ Real x_min, x_max, y_min, y_max;
+ if (p1[0] < p2[0]) { x_min = p1[0]; x_max = p2[0]; } else { x_min = p2[0]; x_max = p1[0]; }
+ if (p1[1] < p2[1]) { y_min = p1[1]; y_max = p2[1]; } else { y_min = p2[1]; y_max = p1[1]; }
+ x_min -= get_expand(); x_max += get_expand(); y_min -= get_expand(); y_max += get_expand();
- //set all the parameters
- layer->set_param("point1",p1);
- get_canvas_interface()->signal_layer_param_changed()(layer,"point1");
- layer->set_param("point2",p2);
- get_canvas_interface()->signal_layer_param_changed()(layer,"point2");
+ std::vector<BLinePoint> new_list;
+ for (int i = 0; i < 4; i++)
+ {
+ new_list.push_back(*(new BLinePoint));
+ new_list[i].set_width(1);
+ new_list[i].set_vertex(Point((i==0||i==3)?x_min:x_max,
+ (i==0||i==1)?y_min:y_max));
+ new_list[i].set_tangent(Point(0,0));
+ }
- layer->set_param("expand",get_expand());
- get_canvas_interface()->signal_layer_param_changed()(layer,"expand");
+ ValueNode_BLine::Handle value_node_bline(ValueNode_BLine::create(new_list));
+ assert(value_node_bline);
- layer->set_param("invert",get_invert());
- get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
+ ValueNode_Const::Handle value_node_origin(ValueNode_Const::create(Vector()));
+ assert(value_node_origin);
- //name
- layer->set_description(get_id());
- get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+ // Set the looping flag
+ value_node_bline->set_loop(true);
+
+ if(!canvas)
+ canvas=get_canvas_view()->get_canvas();
+
+ value_node_bline->set_member_canvas(canvas);
+
+ // count how many layers we're going to be creating
+ int layers_to_create = this->layers_to_create();
+
+ ///////////////////////////////////////////////////////////////////////////
+ // R E C T A N G L E
+ ///////////////////////////////////////////////////////////////////////////
+
+ if (get_layer_rectangle_flag())
+ {
+ layer=get_canvas_interface()->add_layer_to("rectangle",canvas,depth);
+ layer_selection.push_back(layer);
+
+ layer->set_param("point1",p1);
+ get_canvas_interface()->signal_layer_param_changed()(layer,"point1");
+
+ layer->set_param("point2",p2);
+ get_canvas_interface()->signal_layer_param_changed()(layer,"point2");
+
+ layer->set_param("expand",get_expand());
+ get_canvas_interface()->signal_layer_param_changed()(layer,"expand");
+
+ layer->set_param("invert",get_invert());
+ get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
+
+ layer->set_description(get_id());
+ get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+ if(get_layer_outline_flag())
+ {
+ layer->set_param("color",synfigapp::Main::get_background_color());
+ get_canvas_interface()->signal_layer_param_changed()(layer,"color");
+ }
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // C U R V E G R A D I E N T
+ ///////////////////////////////////////////////////////////////////////////
+
+ if(get_layer_curve_gradient_flag())
+ {
+ synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+ Layer::Handle layer(get_canvas_interface()->add_layer_to("curve_gradient",canvas,depth));
+ assert(layer);
+ layer_selection.push_back(layer);
+ layer->set_description(get_id()+_(" Gradient"));
+ get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+ {
+ synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect"));
+ assert(action);
+
+ action->set_param("canvas",get_canvas());
+ action->set_param("canvas_interface",get_canvas_interface());
+ action->set_param("layer",layer);
+ if(!action->set_param("param",String("bline")))
+ synfig::error("LayerParamConnect didn't like \"param\"");
+ if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+ synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+ if(!get_canvas_interface()->get_instance()->perform_action(action))
+ {
+ //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+ group.cancel();
+ throw String(_("Unable to create Gradient layer"));
+ return;
+ }
+ }
+
+ // only link the curve gradient's origin parameter if the option is selected and we're creating more than one layer
+ if (get_layer_link_origins_flag() && layers_to_create > 1)
+ {
+ synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect"));
+ assert(action);
+
+ action->set_param("canvas",get_canvas());
+ action->set_param("canvas_interface",get_canvas_interface());
+ action->set_param("layer",layer);
+ if(!action->set_param("param",String("origin")))
+ synfig::error("LayerParamConnect didn't like \"param\"");
+ if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+ synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+ if(!get_canvas_interface()->get_instance()->perform_action(action))
+ {
+ //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+ group.cancel();
+ throw String(_("Unable to create Gradient layer"));
+ return;
+ }
+ }
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // P L A N T
+ ///////////////////////////////////////////////////////////////////////////
+
+ if(get_layer_plant_flag())
+ {
+ synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+ Layer::Handle layer(get_canvas_interface()->add_layer_to("plant",canvas,depth));
+ assert(layer);
+ layer_selection.push_back(layer);
+ layer->set_description(get_id()+_(" Plant"));
+ get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+ {
+ synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect"));
+ assert(action);
+
+ action->set_param("canvas",get_canvas());
+ action->set_param("canvas_interface",get_canvas_interface());
+ action->set_param("layer",layer);
+ if(!action->set_param("param",String("bline")))
+ synfig::error("LayerParamConnect didn't like \"param\"");
+ if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+ synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+ if(!get_canvas_interface()->get_instance()->perform_action(action))
+ {
+ //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+ group.cancel();
+ throw String(_("Unable to create Plant layer"));
+ return;
+ }
+ }
+
+ // only link the plant's origin parameter if the option is selected and we're creating more than one layer
+ if (get_layer_link_origins_flag() && layers_to_create > 1)
+ {
+ synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect"));
+ assert(action);
+
+ action->set_param("canvas",get_canvas());
+ action->set_param("canvas_interface",get_canvas_interface());
+ action->set_param("layer",layer);
+ if(!action->set_param("param",String("origin")))
+ synfig::error("LayerParamConnect didn't like \"param\"");
+ if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+ synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+ if(!get_canvas_interface()->get_instance()->perform_action(action))
+ {
+ //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+ group.cancel();
+ throw String(_("Unable to create Plant layer"));
+ return;
+ }
+ }
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // R E G I O N
+ ///////////////////////////////////////////////////////////////////////////
+
+ if(get_layer_region_flag())
+ {
+ synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+ Layer::Handle layer(get_canvas_interface()->add_layer_to("region",canvas,depth));
+ assert(layer);
+ layer_selection.push_back(layer);
+ layer->set_description(get_id()+_(" Region"));
+ get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+ layer->set_param("feather",get_feather());
+ get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
+
+ layer->set_param("invert",get_invert());
+ get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
+
+ if(get_layer_outline_flag())
+ layer->set_param("color",synfigapp::Main::get_background_color());
+
+ // I don't know if it's safe to reuse the same layer_param_connect action, so I'm
+ // using 2 separate ones.
+ {
+ synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect"));
+ assert(action);
+
+ action->set_param("canvas",get_canvas());
+ action->set_param("canvas_interface",get_canvas_interface());
+ action->set_param("layer",layer);
+ if(!action->set_param("param",String("bline")))
+ synfig::error("LayerParamConnect didn't like \"param\"");
+ if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+ synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+ if(!get_canvas_interface()->get_instance()->perform_action(action))
+ {
+ //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
+ group.cancel();
+ throw String(_("Unable to create Region layer"));
+ return;
+ }
+ }
+
+ // only link the region's origin parameter if the option is selected and we're creating more than one layer
+ if (get_layer_link_origins_flag() && layers_to_create > 1)
+ {
+ synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect"));
+ assert(action);
+
+ action->set_param("canvas",get_canvas());
+ action->set_param("canvas_interface",get_canvas_interface());
+ action->set_param("layer",layer);
+ if(!action->set_param("param",String("origin")))
+ synfig::error("LayerParamConnect didn't like \"param\"");
+ if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+ synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+ if(!get_canvas_interface()->get_instance()->perform_action(action))
+ {
+ //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
+ group.cancel();
+ throw String(_("Unable to create Region layer"));
+ return;
+ }
+ }
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // O U T L I N E
+ ///////////////////////////////////////////////////////////////////////////
+
+ if (get_layer_outline_flag())
+ {
+ Layer::Handle layer(get_canvas_interface()->add_layer_to("outline",canvas,depth));
+ assert(layer);
+ layer_selection.push_back(layer);
+ layer->set_description(get_id()+_(" Outline"));
+ get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+ layer->set_param("feather",get_feather());
+ get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
+
+ layer->set_param("invert",get_invert());
+ get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
+
+ {
+ synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect"));
+ assert(action);
+
+ action->set_param("canvas",get_canvas());
+ action->set_param("canvas_interface",get_canvas_interface());
+ action->set_param("layer",layer);
+ if(!action->set_param("param",String("bline")))
+ synfig::error("LayerParamConnect didn't like \"param\"");
+ if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+ synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+ if(!get_canvas_interface()->get_instance()->perform_action(action))
+ {
+ //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+ group.cancel();
+ throw String(_("Unable to create Outline layer"));
+ return;
+ }
+ }
+
+ // only link the outline's origin parameter if the option is selected and we're creating more than one layer
+ if (get_layer_link_origins_flag() && layers_to_create > 1)
+ {
+ synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect"));
+ assert(action);
+
+ action->set_param("canvas",get_canvas());
+ action->set_param("canvas_interface",get_canvas_interface());
+ action->set_param("layer",layer);
+ if(!action->set_param("param",String("origin")))
+ synfig::error("LayerParamConnect didn't like \"param\"");
+ if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+ synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+ if(!get_canvas_interface()->get_instance()->perform_action(action))
+ {
+ //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+ group.cancel();
+ throw String(_("Unable to create Outline layer"));
+ return;
+ }
+ }
+ }
- no_egress_on_selection_change=true;
+ egress_on_selection_change=false;
get_canvas_interface()->get_selection_manager()->clear_selected_layers();
- get_canvas_interface()->get_selection_manager()->set_selected_layer(layer);
- no_egress_on_selection_change=false;
+ get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
+ egress_on_selection_change=true;
//post clean up stuff...
reset();
if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DRAG && event.button==BUTTON_LEFT)
{
+ if (!point2_duck) return Smach::RESULT_OK;
point2_duck->set_point(get_work_area()->snap_point_to_grid(event.pos));
get_work_area()->queue_draw();
return Smach::RESULT_ACCEPT;