From 5936e27e17ad4f0c5612a2fc0c95ca147d3a8da0 Mon Sep 17 00:00:00 2001 From: dooglus Date: Thu, 13 Nov 2008 22:48:49 +0000 Subject: [PATCH] Same as the previous commit, but for the Star tool. git-svn-id: https://synfig.svn.sourceforge.net/svnroot/synfig@2197 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-studio/trunk/src/gtkmm/state_star.cpp | 62 ++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/synfig-studio/trunk/src/gtkmm/state_star.cpp b/synfig-studio/trunk/src/gtkmm/state_star.cpp index 24a50f6..2b1bb15 100644 --- a/synfig-studio/trunk/src/gtkmm/state_star.cpp +++ b/synfig-studio/trunk/src/gtkmm/state_star.cpp @@ -127,6 +127,7 @@ public: int layers_to_create()const { return + get_layer_star_flag() + get_layer_region_flag() + get_layer_outline_flag() + get_layer_curve_gradient_flag() + @@ -433,7 +434,7 @@ 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_origins(_("Link BLine Origins")) + checkbutton_layer_link_origins(_("Link Origins")) { egress_on_selection_change=true; @@ -586,7 +587,6 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) Angle::deg offset(get_angle_offset()); bool regular(get_regular_polygon()); Angle::deg angle(360.0/points); - Real x(p1[0]), y(p1[1]); std::vector new_list; int point(0); @@ -594,8 +594,8 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) { new_list.push_back(*(new BLinePoint)); new_list[point].set_width(outer_width); - 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_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); @@ -603,8 +603,8 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) { new_list.push_back(*(new BLinePoint)); new_list[point].set_width(inner_width); - 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_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); } @@ -613,7 +613,7 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) 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 @@ -668,6 +668,34 @@ StateStar_Context::make_star(const Point& _p1, const Point& _p2) 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"); + } } /////////////////////////////////////////////////////////////////////////// @@ -727,6 +755,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"); + } } /////////////////////////////////////////////////////////////////////////// @@ -786,6 +819,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"); + } } /////////////////////////////////////////////////////////////////////////// @@ -856,6 +894,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"); + } } /////////////////////////////////////////////////////////////////////////// @@ -919,6 +962,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; -- 2.7.4