X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fstate_star.cpp;h=8b5c14f8dfba56c4b81e24b9efee766c8fd19915;hb=fac9dc0a044a6529e474a325332ba17502d6e7b2;hp=f4a71ff62877c4e93424c1691df6b3bfe1b44468;hpb=d3d3ac30d770f7201264fb83dc2f963c7ad310b0;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/state_star.cpp b/synfig-studio/trunk/src/gtkmm/state_star.cpp index f4a71ff..8b5c14f 100644 --- a/synfig-studio/trunk/src/gtkmm/state_star.cpp +++ b/synfig-studio/trunk/src/gtkmm/state_star.cpp @@ -96,9 +96,19 @@ class studio::StateStar_Context : public sigc::trackable Gtk::Adjustment adj_feather; Gtk::Adjustment adj_number_of_points; + Gtk::Adjustment adj_inner_tangent; + Gtk::Adjustment adj_outer_tangent; + Gtk::Adjustment adj_inner_width; + Gtk::Adjustment adj_outer_width; + Gtk::Adjustment adj_radius_ratio; Gtk::Adjustment adj_angle_offset; Gtk::SpinButton spin_feather; Gtk::SpinButton spin_number_of_points; + Gtk::SpinButton spin_inner_tangent; + Gtk::SpinButton spin_outer_tangent; + Gtk::SpinButton spin_inner_width; + Gtk::SpinButton spin_outer_width; + Gtk::SpinButton spin_radius_ratio; Gtk::SpinButton spin_angle_offset; Gtk::CheckButton checkbutton_invert; @@ -108,15 +118,16 @@ class studio::StateStar_Context : public sigc::trackable Gtk::CheckButton checkbutton_layer_outline; Gtk::CheckButton checkbutton_layer_curve_gradient; Gtk::CheckButton checkbutton_layer_plant; - Gtk::CheckButton checkbutton_layer_link_offsets; + Gtk::CheckButton checkbutton_layer_link_origins; public: // this only counts the layers which use blines - they're the only - // ones we link the offsets for + // ones we link the origins for int layers_to_create()const { return + get_layer_star_flag() + get_layer_region_flag() + get_layer_outline_flag() + get_layer_curve_gradient_flag() + @@ -132,6 +143,21 @@ public: Real get_number_of_points()const { return adj_number_of_points.get_value(); } void set_number_of_points(Real f) { adj_number_of_points.set_value(f); } + Real get_inner_tangent()const { return adj_inner_tangent.get_value(); } + void set_inner_tangent(Real f) { adj_inner_tangent.set_value(f); } + + Real get_outer_tangent()const { return adj_outer_tangent.get_value(); } + void set_outer_tangent(Real f) { adj_outer_tangent.set_value(f); } + + Real get_inner_width()const { return adj_inner_width.get_value(); } + void set_inner_width(Real f) { adj_inner_width.set_value(f); } + + Real get_outer_width()const { return adj_outer_width.get_value(); } + void set_outer_width(Real f) { adj_outer_width.set_value(f); } + + Real get_radius_ratio()const { return adj_radius_ratio.get_value(); } + void set_radius_ratio(Real f) { adj_radius_ratio.set_value(f); } + Real get_angle_offset()const { return adj_angle_offset.get_value(); } void set_angle_offset(Real f) { adj_angle_offset.set_value(f); } @@ -156,8 +182,8 @@ public: 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_offsets_flag()const { return checkbutton_layer_link_offsets.get_active(); } - void set_layer_link_offsets_flag(bool x) { return checkbutton_layer_link_offsets.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 @@ -234,6 +260,31 @@ StateStar_Context::load_settings() else set_number_of_points(5); + if(settings.get_value("star.inner_tangent",value)) + set_inner_tangent(atof(value.c_str())); + else + set_inner_tangent(0); + + if(settings.get_value("star.outer_tangent",value)) + set_outer_tangent(atof(value.c_str())); + else + set_outer_tangent(0); + + if(settings.get_value("star.inner_width",value)) + set_inner_width(atof(value.c_str())); + else + set_inner_width(1); + + if(settings.get_value("star.outer_width",value)) + set_outer_width(atof(value.c_str())); + else + set_outer_width(1); + + if(settings.get_value("star.radius_ratio",value)) + set_radius_ratio(atof(value.c_str())); + else + set_radius_ratio(0.5); + if(settings.get_value("star.angle_offset",value)) set_angle_offset(atof(value.c_str())); else @@ -274,10 +325,10 @@ StateStar_Context::load_settings() else set_layer_plant_flag(false); - if(settings.get_value("star.layer_link_offsets",value) && value=="0") - set_layer_link_offsets_flag(false); + if(settings.get_value("star.layer_link_origins",value) && value=="0") + set_layer_link_origins_flag(false); else - set_layer_link_offsets_flag(true); + set_layer_link_origins_flag(true); } void @@ -286,6 +337,11 @@ StateStar_Context::save_settings() settings.set_value("star.id",get_id()); settings.set_value("star.feather",strprintf("%f",(float)get_feather())); settings.set_value("star.number_of_points",strprintf("%d",(int)(get_number_of_points() + 0.5))); + settings.set_value("star.inner_tangent",strprintf("%f",(float)get_inner_tangent())); + settings.set_value("star.outer_tangent",strprintf("%f",(float)get_outer_tangent())); + settings.set_value("star.inner_width",strprintf("%f",(float)get_inner_width())); + settings.set_value("star.outer_width",strprintf("%f",(float)get_outer_width())); + settings.set_value("star.radius_ratio",strprintf("%f",(float)get_radius_ratio())); settings.set_value("star.angle_offset",strprintf("%f",(float)get_angle_offset())); settings.set_value("star.invert",get_invert()?"1":"0"); settings.set_value("star.regular_polygon",get_regular_polygon()?"1":"0"); @@ -294,7 +350,7 @@ StateStar_Context::save_settings() settings.set_value("star.layer_region",get_layer_region_flag()?"1":"0"); settings.set_value("star.layer_curve_gradient",get_layer_curve_gradient_flag()?"1":"0"); settings.set_value("star.layer_plant",get_layer_plant_flag()?"1":"0"); - settings.set_value("star.layer_link_offsets",get_layer_link_offsets_flag()?"1":"0"); + settings.set_value("star.layer_link_origins",get_layer_link_origins_flag()?"1":"0"); } void @@ -354,12 +410,22 @@ StateStar_Context::StateStar_Context(CanvasView* canvas_view): 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_points(4,2,120,1,1,1), // value, lower, upper, step_increment, page_increment, page_size - adj_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_points( 0, 2, 120, 1 , 1 ), + adj_inner_tangent( 0, -10, 10, 0.01, 0.1), + adj_outer_tangent( 0, -10, 10, 0.01, 0.1), + adj_inner_width( 0, -10, 10, 0.01, 0.1), + adj_outer_width( 0, -10, 10, 0.01, 0.1), + adj_radius_ratio( 0, -10, 10, 0.01, 0.1), + adj_angle_offset( 0, -360, 360, 0.1 , 1 ), spin_feather(adj_feather,0.1,3), spin_number_of_points(adj_number_of_points,1,0), + spin_inner_tangent(adj_inner_tangent,1,2), + spin_outer_tangent(adj_outer_tangent,1,2), + spin_inner_width(adj_inner_width,1,2), + spin_outer_width(adj_outer_width,1,2), + spin_radius_ratio(adj_radius_ratio,1,2), spin_angle_offset(adj_angle_offset,1,1), checkbutton_invert(_("Invert")), checkbutton_regular_polygon(_("Regular Polygon")), @@ -368,30 +434,39 @@ StateStar_Context::StateStar_Context(CanvasView* canvas_view): checkbutton_layer_outline(_("Create Outline BLine")), checkbutton_layer_curve_gradient(_("Create Curve Gradient BLine")), checkbutton_layer_plant(_("Create Plant BLine")), - checkbutton_layer_link_offsets(_("Link BLine Offsets")) + checkbutton_layer_link_origins(_("Link Origins")) { egress_on_selection_change=true; - // Set up the tool options dialog - //options_table.attach(*manage(new Gtk::Label(_("Star 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); load_settings(); - //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(checkbutton_invert, 0, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); - options_table.attach(checkbutton_regular_polygon, 0, 2, 6, 7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); - options_table.attach(checkbutton_layer_star, 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_offsets, 0, 2, 12, 13, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); - options_table.attach(*manage(new Gtk::Label(_("Number of Points:"))), 0, 1, 13, 14, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); - options_table.attach(spin_number_of_points, 1, 2, 13, 14, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); - options_table.attach(*manage(new Gtk::Label(_("Angle Offset:"))), 0, 1, 14, 15, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); - options_table.attach(spin_angle_offset, 1, 2, 14, 15, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + // Set up the tool options dialog + options_table.attach(*manage(new Gtk::Label(_("Star 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_star, 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); + options_table.attach(checkbutton_invert, 0, 2, 8, 9, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(checkbutton_regular_polygon, 0, 2, 9, 10, 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); + options_table.attach(*manage(new Gtk::Label(_("Number of Points:"))), 0, 1, 11, 12, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(spin_number_of_points, 1, 2, 11, 12, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(*manage(new Gtk::Label(_("Inner Tangent:"))), 0, 1, 12, 13, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(spin_inner_tangent, 1, 2, 12, 13, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(*manage(new Gtk::Label(_("Outer Tangent:"))), 0, 1, 13, 14, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(spin_outer_tangent, 1, 2, 13, 14, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(*manage(new Gtk::Label(_("Inner Width:"))), 0, 1, 14, 15, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(spin_inner_width, 1, 2, 14, 15, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(*manage(new Gtk::Label(_("Outer Width:"))), 0, 1, 15, 16, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(spin_outer_width, 1, 2, 15, 16, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(*manage(new Gtk::Label(_("Radius Ratio:"))), 0, 1, 16, 17, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(spin_radius_ratio, 1, 2, 16, 17, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(*manage(new Gtk::Label(_("Angle Offset:"))), 0, 1, 17, 18, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(spin_angle_offset, 1, 2, 17, 18, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); options_table.show_all(); @@ -501,40 +576,45 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) const Point p1(transform.unperform(_p1)); const Point p2(transform.unperform(_p2)); + Real radius_ratio(get_radius_ratio()); Real radius1((p2-p1).mag()); - Real radius2(radius1/2); + Real radius2(radius1 * radius_ratio); int points = get_number_of_points(); + Real inner_tangent = get_inner_tangent() * radius1; + Real outer_tangent = get_outer_tangent() * radius2; + Real inner_width = get_inner_width(); + Real outer_width = get_outer_width(); Angle::deg offset(get_angle_offset()); bool regular(get_regular_polygon()); Angle::deg angle(360.0/points); - Real x(p1[0]), y(p1[1]); - Real tangent(0); std::vector new_list; int point(0); for (int i = 0; i < points; i++) { new_list.push_back(*(new BLinePoint)); - new_list[point].set_width(1); - new_list[point].set_vertex(Point(radius1*Angle::cos(angle*i + offset).get() + x, - radius1*Angle::sin(angle*i + offset).get() + y)); - new_list[point++].set_tangent(Point(0,0)); + new_list[point].set_width(outer_width); + new_list[point].set_vertex(Point(radius1*Angle::cos(angle*i + offset).get(), + radius1*Angle::sin(angle*i + offset).get())); + new_list[point++].set_tangent(Point(-Angle::sin(angle*i + offset).get(), + Angle::cos(angle*i + offset).get()) * outer_tangent); if (!regular) { new_list.push_back(*(new BLinePoint)); - new_list[point].set_width(1); - new_list[point].set_vertex(Point(radius2*Angle::cos(angle*i + angle/2 + offset).get() + x, - radius2*Angle::sin(angle*i + angle/2 + offset).get() + y)); - new_list[point++].set_tangent(Point(0,0)); + new_list[point].set_width(inner_width); + new_list[point].set_vertex(Point(radius2*Angle::cos(angle*i + angle/2 + offset).get(), + radius2*Angle::sin(angle*i + angle/2 + offset).get())); + new_list[point++].set_tangent(Point(-Angle::sin(angle*i + angle/2 + offset).get(), + Angle::cos(angle*i + angle/2 + offset).get()) * inner_tangent); } } ValueNode_BLine::Handle value_node_bline(ValueNode_BLine::create(new_list)); assert(value_node_bline); - ValueNode_Const::Handle value_node_offset(ValueNode_Const::create(Vector())); - assert(value_node_offset); + ValueNode_Const::Handle value_node_origin(ValueNode_Const::create(p1)); + assert(value_node_origin); // Set the looping flag value_node_bline->set_loop(true); @@ -554,15 +634,21 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) if (get_layer_star_flag()) { layer=get_canvas_interface()->add_layer_to("star",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("offset",p1); - get_canvas_interface()->signal_layer_param_changed()(layer,"offset"); + layer->set_param("origin",p1); + get_canvas_interface()->signal_layer_param_changed()(layer,"origin"); - layer->set_param("radius1",(p2-p1).mag()); + layer->set_param("radius1",radius1); get_canvas_interface()->signal_layer_param_changed()(layer,"radius1"); - layer->set_param("radius2",(p2-p1).mag()/2); + layer->set_param("radius2",radius2); get_canvas_interface()->signal_layer_param_changed()(layer,"radius2"); layer->set_param("angle",offset); @@ -582,6 +668,40 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) 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"); + } + + // only link the star'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 Star layer")); + group.cancel(); + throw String(_("Unable to create Star layer")); + return; + } + } + else + { + layer->set_param("origin",p1); + get_canvas_interface()->signal_layer_param_changed()(layer,"origin"); + } } /////////////////////////////////////////////////////////////////////////// @@ -593,7 +713,12 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) 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()); @@ -619,8 +744,8 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) } } - // only link the curve gradient's offset parameter if the option is selected and we're creating more than one layer - if (get_layer_link_offsets_flag() && layers_to_create > 1) + // 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); @@ -628,9 +753,9 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) 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("offset"))) + if(!action->set_param("param",String("origin"))) synfig::error("LayerParamConnect didn't like \"param\""); - if(!action->set_param("value_node",ValueNode::Handle(value_node_offset))) + 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)) @@ -641,6 +766,11 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) return; } } + else + { + layer->set_param("origin",p1); + get_canvas_interface()->signal_layer_param_changed()(layer,"origin"); + } } /////////////////////////////////////////////////////////////////////////// @@ -652,7 +782,12 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) 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()); @@ -678,8 +813,8 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) } } - // only link the plant's offset parameter if the option is selected and we're creating more than one layer - if (get_layer_link_offsets_flag() && layers_to_create > 1) + // 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); @@ -687,9 +822,9 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) 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("offset"))) + if(!action->set_param("param",String("origin"))) synfig::error("LayerParamConnect didn't like \"param\""); - if(!action->set_param("value_node",ValueNode::Handle(value_node_offset))) + 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)) @@ -700,6 +835,11 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) return; } } + else + { + layer->set_param("origin",p1); + get_canvas_interface()->signal_layer_param_changed()(layer,"origin"); + } } /////////////////////////////////////////////////////////////////////////// @@ -711,7 +851,12 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) 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()); @@ -748,8 +893,8 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) } } - // only link the region's offset parameter if the option is selected and we're creating more than one layer - if (get_layer_link_offsets_flag() && layers_to_create > 1) + // 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); @@ -757,9 +902,9 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) 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("offset"))) + if(!action->set_param("param",String("origin"))) synfig::error("LayerParamConnect didn't like \"param\""); - if(!action->set_param("value_node",ValueNode::Handle(value_node_offset))) + 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)) @@ -770,6 +915,11 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) return; } } + else + { + layer->set_param("origin",p1); + get_canvas_interface()->signal_layer_param_changed()(layer,"origin"); + } } /////////////////////////////////////////////////////////////////////////// @@ -779,7 +929,12 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) 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()); @@ -811,8 +966,8 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) } } - // only link the outline's offset parameter if the option is selected and we're creating more than one layer - if (get_layer_link_offsets_flag() && layers_to_create > 1) + // 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); @@ -820,9 +975,9 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) 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("offset"))) + if(!action->set_param("param",String("origin"))) synfig::error("LayerParamConnect didn't like \"param\""); - if(!action->set_param("value_node",ValueNode::Handle(value_node_offset))) + 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)) @@ -833,6 +988,11 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) return; } } + else + { + layer->set_param("origin",p1); + get_canvas_interface()->signal_layer_param_changed()(layer,"origin"); + } } egress_on_selection_change=false; @@ -874,6 +1034,7 @@ StateStar_Context::event_mouse_click_handler(const Smach::event& x) if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DRAG && event.button==BUTTON_LEFT) { + if (!point2_duck) return Smach::RESULT_OK; point2_duck->set_point(point_holder-get_work_area()->snap_point_to_grid(event.pos)); get_work_area()->queue_draw(); return Smach::RESULT_ACCEPT;