From: dooglus Date: Mon, 4 Feb 2008 18:40:20 +0000 (+0000) Subject: Allow the bline tool to draw plants as well as outlines, regions, and curvegradients. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=de499aac7262fa6c2a0dafbbdf5a95a59b51a6e7;p=synfig.git Allow the bline tool to draw plants as well as outlines, regions, and curvegradients. git-svn-id: http://svn.voria.com/code@1574 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-studio/trunk/src/gtkmm/state_bline.cpp b/synfig-studio/trunk/src/gtkmm/state_bline.cpp index 6aa1072..2cd2bbd 100644 --- a/synfig-studio/trunk/src/gtkmm/state_bline.cpp +++ b/synfig-studio/trunk/src/gtkmm/state_bline.cpp @@ -116,6 +116,7 @@ class studio::StateBLine_Context : public sigc::trackable Gtk::CheckButton checkbutton_layer_region; Gtk::CheckButton checkbutton_layer_bline; Gtk::CheckButton checkbutton_layer_curve_gradient; + Gtk::CheckButton checkbutton_layer_plant; Gtk::CheckButton checkbutton_layer_link_offsets; Gtk::CheckButton checkbutton_auto_export; Gtk::Button button_make; @@ -132,7 +133,8 @@ public: return get_layer_region_flag()+ get_layer_bline_flag()+ - get_layer_curve_gradient_flag(); + get_layer_curve_gradient_flag() + + get_layer_plant_flag(); } void sanity_check() @@ -153,6 +155,9 @@ public: 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_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); } @@ -244,6 +249,11 @@ StateBLine_Context::load_settings() else set_layer_curve_gradient_flag(false); + if(settings.get_value("bline.layer_plant",value) && value=="1") + set_layer_plant_flag(true); + else + set_layer_plant_flag(false); + if(settings.get_value("bline.layer_link_offsets",value) && value=="0") set_layer_link_offsets_flag(false); else @@ -275,6 +285,7 @@ StateBLine_Context::save_settings() settings.set_value("bline.layer_bline",get_layer_bline_flag()?"1":"0"); settings.set_value("bline.layer_region",get_layer_region_flag()?"1":"0"); settings.set_value("bline.layer_curve_gradient",get_layer_curve_gradient_flag()?"1":"0"); + settings.set_value("bline.layer_plant",get_layer_plant_flag()?"1":"0"); settings.set_value("bline.layer_link_offsets",get_layer_link_offsets_flag()?"1":"0"); settings.set_value("bline.auto_export",get_auto_export_flag()?"1":"0"); settings.set_value("bline.id",get_id().c_str()); @@ -347,6 +358,7 @@ StateBLine_Context::StateBLine_Context(CanvasView* canvas_view): checkbutton_layer_region(_("Fill")), checkbutton_layer_bline(_("Outline")), checkbutton_layer_curve_gradient(_("Gradient")), + checkbutton_layer_plant(_("Plant")), checkbutton_layer_link_offsets(_("Link Offsets")), checkbutton_auto_export(_("Auto Export")), button_make(_("Make")), @@ -364,8 +376,9 @@ StateBLine_Context::StateBLine_Context(CanvasView* canvas_view): options_table.attach(checkbutton_layer_region, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); options_table.attach(checkbutton_layer_bline, 0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); options_table.attach(checkbutton_layer_curve_gradient, 0, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); - options_table.attach(checkbutton_layer_link_offsets, 0, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); - options_table.attach(checkbutton_auto_export, 0, 2, 6, 7, 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_link_offsets, 0, 2, 6, 7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(checkbutton_auto_export, 0, 2, 7, 8, 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(button_make, 0, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); @@ -589,7 +602,10 @@ StateBLine_Context::run_() synfigapp::SelectionManager::LayerList layer_selection; - // If we were asked to create a region layer, go ahead and do so + /////////////////////////////////////////////////////////////////////////// + // R E G I O N + /////////////////////////////////////////////////////////////////////////// + if(get_layer_region_flag()) { synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL); @@ -655,7 +671,10 @@ StateBLine_Context::run_() } } - // If we were asked to create a BLine layer, go ahead and do so + /////////////////////////////////////////////////////////////////////////// + // O U T L I N E + /////////////////////////////////////////////////////////////////////////// + if(get_layer_bline_flag()) { synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL); @@ -713,16 +732,12 @@ StateBLine_Context::run_() return false; } } - - /*if(get_layer_region_flag() && !get_auto_export_flag()) - { - get_canvas_interface()->auto_export(synfigapp::ValueDesc(layer,"bline")); - }*/ } + /////////////////////////////////////////////////////////////////////////// + // C U R V E G R A D I E N T + /////////////////////////////////////////////////////////////////////////// - - // If we were asked to create a CurveGradient layer, go ahead and do so if(get_layer_curve_gradient_flag()) { synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL); @@ -775,11 +790,65 @@ StateBLine_Context::run_() return false; } } + } + + /////////////////////////////////////////////////////////////////////////// + // 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()); - /*if(get_layer_region_flag() && !get_auto_export_flag()) { - get_canvas_interface()->auto_export(synfigapp::ValueDesc(layer,"bline")); - }*/ + 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 false; + } + } + + // plants don't have offsets? + if (false && get_layer_link_offsets_flag()) + { + 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("offset"))) + synfig::error("LayerParamConnect didn't like \"param\""); + if(!action->set_param("value_node",ValueNode::Handle(value_node_offset))) + 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 false; + } + } } egress_on_selection_change=false;