X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fstate_rectangle.cpp;h=c1fcc5955f1007845080b2ac663c2f99968a2059;hb=1f453e8ab546a357781372fe98aa1d004387d4b1;hp=3a82b4d059aa0efd8bbd39dc20031c6d191dcaab;hpb=fc0650a8957c3205adb99fa154a955a68a48f3c8;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/state_rectangle.cpp b/synfig-studio/trunk/src/gtkmm/state_rectangle.cpp index 3a82b4d..c1fcc59 100644 --- a/synfig-studio/trunk/src/gtkmm/state_rectangle.cpp +++ b/synfig-studio/trunk/src/gtkmm/state_rectangle.cpp @@ -93,7 +93,9 @@ class studio::StateRectangle_Context : public sigc::trackable 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 checkbutton_invert; Gtk::CheckButton checkbutton_layer_rectangle; @@ -101,12 +103,12 @@ class studio::StateRectangle_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 @@ -122,6 +124,9 @@ public: Real get_expand()const { return adj_expand.get_value(); } void set_expand(Real f) { adj_expand.set_value(f); } + 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); } @@ -140,8 +145,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 @@ -213,6 +218,11 @@ StateRectangle_Context::load_settings() 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 @@ -243,10 +253,10 @@ StateRectangle_Context::load_settings() else set_layer_plant_flag(false); - if(settings.get_value("rectangle.layer_link_offsets",value) && value=="0") - set_layer_link_offsets_flag(false); + if(settings.get_value("rectangle.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 @@ -254,13 +264,14 @@ StateRectangle_Context::save_settings() { 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_offsets",get_layer_link_offsets_flag()?"1":"0"); + settings.set_value("rectangle.layer_link_origins",get_layer_link_origins_flag()?"1":"0"); } void @@ -322,35 +333,41 @@ StateRectangle_Context::StateRectangle_Context(CanvasView* canvas_view): 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), + 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_offsets(_("Link BLine Offsets")) + checkbutton_layer_link_origins(_("Link BLine Origins")) { egress_on_selection_change=true; load_settings(); // Set up the tool options dialog - //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); + 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(checkbutton_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_offsets, 0, 2, 12, 13, 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(); @@ -480,8 +497,8 @@ StateRectangle_Context::make_rectangle(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_offset(ValueNode_Const::create(Vector())); - assert(value_node_offset); + ValueNode_Const::Handle value_node_origin(ValueNode_Const::create(Vector())); + assert(value_node_origin); // Set the looping flag value_node_bline->set_loop(true); @@ -517,6 +534,12 @@ StateRectangle_Context::make_rectangle(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"); + } } /////////////////////////////////////////////////////////////////////////// @@ -554,8 +577,8 @@ StateRectangle_Context::make_rectangle(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); @@ -563,9 +586,9 @@ StateRectangle_Context::make_rectangle(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)) @@ -613,8 +636,8 @@ StateRectangle_Context::make_rectangle(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); @@ -622,9 +645,9 @@ StateRectangle_Context::make_rectangle(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)) @@ -651,6 +674,9 @@ StateRectangle_Context::make_rectangle(const Point& _p1, const Point& _p2) 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"); @@ -680,8 +706,8 @@ StateRectangle_Context::make_rectangle(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); @@ -689,9 +715,9 @@ StateRectangle_Context::make_rectangle(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)) @@ -716,6 +742,9 @@ StateRectangle_Context::make_rectangle(const Point& _p1, const Point& _p2) 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"); @@ -740,8 +769,8 @@ StateRectangle_Context::make_rectangle(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); @@ -749,9 +778,9 @@ StateRectangle_Context::make_rectangle(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))