int layers_to_create()const
{
return
+ get_layer_circle_flag() +
get_layer_region_flag() +
get_layer_outline_flag() +
get_layer_curve_gradient_flag() +
duckmatic_push(get_work_area()),
prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
settings(synfigapp::Main::get_selected_input_device()->settings()),
- entry_id(),
- adj_feather(0,0,1,0.01,0.1),
- adj_number_of_bline_points(4,2,120,1,1,1), // value, lower, upper, step_increment, page_increment, page_size
- adj_bline_point_angle_offset(0,-360,360,.1,1,1), // value, lower, upper, step_increment, page_increment, page_size
+ entry_id(), // value lower upper step page
+ adj_feather( 0, 0, 1, 0.01, 0.1),
+ adj_number_of_bline_points( 0, 2, 120, 1 , 1 ),
+ adj_bline_point_angle_offset( 0, -360, 360, 0.1 , 1 ),
spin_feather(adj_feather,0.1,3),
spin_number_of_bline_points(adj_number_of_bline_points,1,0),
spin_bline_point_angle_offset(adj_bline_point_angle_offset,1,1),
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"))
+ checkbutton_layer_link_origins(_("Link Origins"))
{
egress_on_selection_change=true;
- // 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);
+ // Set up the tool options dialog
enum_falloff.set_param_desc(ParamDesc("falloff")
.set_local_name(_("Falloff"))
.set_description(_("Determines the falloff function for the feather"))
load_settings();
+ 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(checkbutton_layer_circle, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(checkbutton_layer_outline, 0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(checkbutton_layer_region, 0, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(checkbutton_layer_plant, 0, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(checkbutton_layer_curve_gradient, 0, 2, 6, 7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(checkbutton_layer_link_origins, 0, 2, 7, 8, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+ //invert flag
+ options_table.attach(checkbutton_invert, 0, 2, 8, 9, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+ options_table.attach(*manage(new Gtk::Label(_("Falloff:"))), 0, 1, 9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(enum_falloff, 1, 2, 9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
//feather stuff
- options_table.attach(*manage(new Gtk::Label(_("Feather:"))), 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(spin_feather, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(enum_falloff, 0, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(*manage(new Gtk::Label(_("Feather:"))), 0, 1, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(spin_feather, 1, 2, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
- options_table.attach(enum_blend, 0, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(enum_blend, 0, 2, 11, 12, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
#endif // BLEND_METHOD_IN_TOOL_OPTIONS
- options_table.attach(checkbutton_invert, 0, 2, 6, 7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(checkbutton_layer_circle, 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.attach(*manage(new Gtk::Label(_("BLine Points:"))), 0, 1, 13, 14, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(spin_number_of_bline_points, 1, 2, 13, 14, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(*manage(new Gtk::Label(_("Point Angle Offset:"))), 0, 1, 14, 15, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(spin_bline_point_angle_offset, 1, 2, 14, 15, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+ options_table.attach(*manage(new Gtk::Label(_("BLine Points:"))), 0, 1, 12, 13, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(spin_number_of_bline_points, 1, 2, 12, 13, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+options_table.attach(*manage(new Gtk::Label(_("Point Angle Offset:"))), 0, 1, 13, 14, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(spin_bline_point_angle_offset, 1, 2, 13, 14, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
options_table.show_all();
Real tangent(4 * ((points == 2)
? 1
: ((2 * Angle::cos(angle/2).get() - Angle::cos(angle).get() - 1) / Angle::sin(angle).get())));
- Real x(p1[0]), y(p1[1]);
std::vector<BLinePoint> new_list;
for (int i = 0; i < points; i++)
{
new_list.push_back(*(new BLinePoint));
new_list[i].set_width(1);
- new_list[i].set_vertex(Point(radius*Angle::cos(angle*i + offset).get() + x,
- radius*Angle::sin(angle*i + offset).get() + y));
+ new_list[i].set_vertex(Point(radius*Angle::cos(angle*i + offset).get(),
+ radius*Angle::sin(angle*i + offset).get()));
new_list[i].set_tangent(Point(-radius*tangent*Angle::sin(angle*i + offset).get(),
radius*tangent*Angle::cos(angle*i + offset).get()));
}
ValueNode_BLine::Handle value_node_bline(ValueNode_BLine::create(new_list));
assert(value_node_bline);
- ValueNode_Const::Handle value_node_origin(ValueNode_Const::create(Vector()));
+ ValueNode_Const::Handle value_node_origin(ValueNode_Const::create(p1));
assert(value_node_origin);
// Set the looping flag
get_falloff() >= 0 && get_falloff() < CIRCLE_NUM_FALLOFF)
{
layer=get_canvas_interface()->add_layer_to("circle",canvas,depth);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_param("origin",p1);
layer->set_param("color",synfigapp::Main::get_background_color());
get_canvas_interface()->signal_layer_param_changed()(layer,"color");
}
+
+ // only link the circle'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 Circle layer"));
+ group.cancel();
+ throw String(_("Unable to create Circle layer"));
+ return;
+ }
+ }
+ else
+ {
+ layer->set_param("origin",p1);
+ get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
+ }
}
///////////////////////////////////////////////////////////////////////////
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);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Gradient"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
return;
}
}
+ else
+ {
+ layer->set_param("origin",p1);
+ get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
+ }
}
///////////////////////////////////////////////////////////////////////////
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
Layer::Handle layer(get_canvas_interface()->add_layer_to("plant",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Plant"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
return;
}
}
+ else
+ {
+ layer->set_param("origin",p1);
+ get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
+ }
}
///////////////////////////////////////////////////////////////////////////
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
Layer::Handle layer(get_canvas_interface()->add_layer_to("region",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Region"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
return;
}
}
+ else
+ {
+ layer->set_param("origin",p1);
+ get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
+ }
}
///////////////////////////////////////////////////////////////////////////
if (get_layer_outline_flag())
{
Layer::Handle layer(get_canvas_interface()->add_layer_to("outline",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Outline"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
return;
}
}
+ else
+ {
+ layer->set_param("origin",p1);
+ get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
+ }
}
egress_on_selection_change=false;