Remove .gitignore do nothing is ignored.
[synfig.git] / synfig-studio / trunk / src / gtkmm / state_bline.cpp
index 61a30b2..7a27d84 100644 (file)
@@ -64,6 +64,9 @@ using namespace studio;
 
 /* === M A C R O S ========================================================= */
 
+// if defined, show the first duck as green while drawing
+#define DISTINGUISH_FIRST_DUCK
+
 /* === G L O B A L S ======================================================= */
 
 StateBLine studio::state_bline;
@@ -117,7 +120,7 @@ class studio::StateBLine_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;
        Gtk::CheckButton checkbutton_auto_export;
        Gtk::Button button_make;
        Gtk::Button button_clear;
@@ -158,8 +161,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); }
 
        Real get_feather() const { return adj_feather.get_value(); }
        void set_feather(Real x) { return adj_feather.set_value(x); }
@@ -214,15 +217,15 @@ public:
 StateBLine::StateBLine():
        Smach::state<StateBLine_Context>("bline")
 {
-       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,&StateBLine_Context::event_layer_selection_changed_handler));
-       insert(event_def(EVENT_STOP,&StateBLine_Context::event_stop_handler));
-       insert(event_def(EVENT_REFRESH,&StateBLine_Context::event_refresh_handler));
-       insert(event_def(EVENT_REFRESH_DUCKS,&StateBLine_Context::event_hijack));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateBLine_Context::event_mouse_click_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,&StateBLine_Context::event_mouse_release_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_MOTION,&StateBLine_Context::event_mouse_motion_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,&StateBLine_Context::event_mouse_motion_handler));
-       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateBLine_Context::event_refresh_tool_options));
+       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,         &StateBLine_Context::event_layer_selection_changed_handler));
+       insert(event_def(EVENT_STOP,                                            &StateBLine_Context::event_stop_handler));
+       insert(event_def(EVENT_REFRESH,                                         &StateBLine_Context::event_refresh_handler));
+       insert(event_def(EVENT_REFRESH_DUCKS,                           &StateBLine_Context::event_hijack));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,      &StateBLine_Context::event_mouse_click_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,        &StateBLine_Context::event_mouse_release_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_MOTION,           &StateBLine_Context::event_mouse_motion_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,      &StateBLine_Context::event_mouse_motion_handler));
+       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,            &StateBLine_Context::event_refresh_tool_options));
 }
 
 StateBLine::~StateBLine()
@@ -254,10 +257,10 @@ StateBLine_Context::load_settings()
        else
                set_layer_plant_flag(false);
 
-       if(settings.get_value("bline.layer_link_offsets",value) && value=="0")
-               set_layer_link_offsets_flag(false);
+       if(settings.get_value("bline.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);
 
        if(settings.get_value("bline.auto_export",value) && value=="1")
                set_auto_export_flag(true);
@@ -286,7 +289,7 @@ StateBLine_Context::save_settings()
        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.layer_link_origins",get_layer_link_origins_flag()?"1":"0");
        settings.set_value("bline.auto_export",get_auto_export_flag()?"1":"0");
        settings.set_value("bline.id",get_id().c_str());
        settings.set_value("bline.feather",strprintf("%f",get_feather()));
@@ -324,7 +327,7 @@ StateBLine_Context::increment_id()
                String str_number;
                str_number=String(id,id.size()-digits,id.size());
                id=String(id,0,id.size()-digits);
-               synfig::info("---------------- \"%s\"",str_number.c_str());
+               // synfig::info("---------------- \"%s\"",str_number.c_str());
 
                number=atoi(str_number.c_str());
        }
@@ -355,11 +358,11 @@ StateBLine_Context::StateBLine_Context(CanvasView* canvas_view):
        duckmatic_push(get_work_area()),
        settings(synfigapp::Main::get_selected_input_device()->settings()),
        entry_id(),
-       checkbutton_layer_region(_("Fill")),
-       checkbutton_layer_outline(_("Outline")),
-       checkbutton_layer_curve_gradient(_("Gradient")),
-       checkbutton_layer_plant(_("Plant")),
-       checkbutton_layer_link_offsets(_("Link Offsets")),
+       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_origins(_("Link Origins")),
        checkbutton_auto_export(_("Auto Export")),
        button_make(_("Make")),
        button_clear(_("Clear")),
@@ -371,16 +374,16 @@ StateBLine_Context::StateBLine_Context(CanvasView* canvas_view):
        load_settings();
 
        // Set up the tool options dialog
-       //options_table.attach(*manage(new Gtk::Label(_("BLine 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_outline,                         0, 2,  2,  3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_region,                          0, 2,  3,  4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_plant,                           0, 2,  4,  5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_curve_gradient,          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(*manage(new Gtk::Label(_("BLine 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_outline,                                 0, 2,  2,  3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_region,                                  0, 2,  3,  4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_plant,                                   0, 2,  4,  5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_curve_gradient,                  0, 2,  5,  6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_link_origins,                    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);
        //button_make.signal_pressed().connect(sigc::mem_fun(*this,&StateBLine_Context::run));
        options_table.show_all();
@@ -475,7 +478,7 @@ StateBLine_Context::~StateBLine_Context()
 Smach::event_result
 StateBLine_Context::event_stop_handler(const Smach::event& /*x*/)
 {
-       synfig::info("STATE RotoBLine: Received Stop Event");
+//     synfig::info("STATE RotoBLine: Received Stop Event");
 //     run();
        reset();
 //     throw Smach::egress_exception();
@@ -486,7 +489,7 @@ StateBLine_Context::event_stop_handler(const Smach::event& /*x*/)
 Smach::event_result
 StateBLine_Context::event_refresh_handler(const Smach::event& /*x*/)
 {
-       synfig::info("STATE RotoBLine: Received Refresh Event");
+//     synfig::info("STATE RotoBLine: Received Refresh Event");
        refresh_ducks();
        return Smach::RESULT_ACCEPT;
 }
@@ -566,8 +569,8 @@ StateBLine_Context::run_()
                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(loop_);
@@ -600,7 +603,14 @@ StateBLine_Context::run_()
                if(!canvas)
                        canvas=get_canvas_view()->get_canvas();
 
+               value_node_bline->set_member_canvas(canvas);
+
                synfigapp::SelectionManager::LayerList layer_selection;
+               if (!getenv("SYNFIG_TOOLS_CLEAR_SELECTION"))
+                       layer_selection = get_canvas_view()->get_selection_manager()->get_selected_layers();
+
+               // count how many layers we're going to be creating
+               int layers_to_create = this->layers_to_create();
 
                ///////////////////////////////////////////////////////////////////////////
                //   C U R V E   G R A D I E N T
@@ -611,13 +621,17 @@ StateBLine_Context::run_()
                        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)
+                       {
+                               group.cancel();
+                               throw String(_("Unable to create layer"));
+                       }
                        layer_selection.push_back(layer);
                        layer->set_description(get_id()+_(" Gradient"));
                        get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
 
                        {
-                               synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect"));
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
                                assert(action);
 
                                action->set_param("canvas",get_canvas());
@@ -637,17 +651,18 @@ StateBLine_Context::run_()
                                }
                        }
 
-                       if (get_layer_link_offsets_flag())
+                       // 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"));
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
                                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")))
+                               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))
@@ -669,13 +684,17 @@ StateBLine_Context::run_()
                        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)
+                       {
+                               group.cancel();
+                               throw String(_("Unable to create layer"));
+                       }
                        layer_selection.push_back(layer);
                        layer->set_description(get_id()+_(" Plant"));
                        get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
 
                        {
-                               synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect"));
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
                                assert(action);
 
                                action->set_param("canvas",get_canvas());
@@ -695,18 +714,18 @@ StateBLine_Context::run_()
                                }
                        }
 
-                       // plants don't have offsets?
-                       if (get_layer_link_offsets_flag())
+                       // 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"));
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
                                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")))
+                               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))
@@ -728,7 +747,11 @@ StateBLine_Context::run_()
                        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)
+                       {
+                               group.cancel();
+                               throw String(_("Unable to create layer"));
+                       }
                        layer_selection.push_back(layer);
                        layer->set_description(get_id()+_(" Region"));
                        get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
@@ -739,13 +762,10 @@ StateBLine_Context::run_()
                                get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
                        }
 
-                       if(get_layer_outline_flag())
-                               layer->set_param("color",synfigapp::Main::get_background_color());
-
-                       // I don't know if it's safe to reuse the same layer_param_connect action, so I'm
+                       // I don't know if it's safe to reuse the same LayerParamConnect action, so I'm
                        // using 2 separate ones.
                        {
-                               synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect"));
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
                                assert(action);
 
                                action->set_param("canvas",get_canvas());
@@ -765,17 +785,18 @@ StateBLine_Context::run_()
                                }
                        }
 
-                       if (get_layer_link_offsets_flag())
+                       // 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"));
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
                                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")))
+                               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))
@@ -797,7 +818,11 @@ StateBLine_Context::run_()
                        synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
 
                        Layer::Handle layer(get_canvas_interface()->add_layer_to("outline",canvas,depth));
-                       assert(layer);
+                       if (!layer)
+                       {
+                               group.cancel();
+                               throw String(_("Unable to create layer"));
+                       }
                        layer_selection.push_back(layer);
                        layer->set_description(get_id()+_(" Outline"));
                        get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
@@ -808,7 +833,7 @@ StateBLine_Context::run_()
                        }
 
                        {
-                               synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect"));
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
                                assert(action);
 
                                action->set_param("canvas",get_canvas());
@@ -828,17 +853,18 @@ StateBLine_Context::run_()
                                }
                        }
 
-                       if (get_layer_link_offsets_flag())
+                       // 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"));
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
                                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")))
+                               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))
@@ -906,7 +932,7 @@ StateBLine_Context::event_mouse_release_handler(const Smach::event& /*x*/)
 Smach::event_result
 StateBLine_Context::event_mouse_click_handler(const Smach::event& x)
 {
-       synfig::info("STATE BLINE: Received mouse button down Event");
+       // synfig::info("STATE BLINE: Received mouse button down Event");
        const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
        switch(event.button)
        {
@@ -954,10 +980,6 @@ StateBLine_Context::event_mouse_click_handler(const Smach::event& x)
                        return Smach::RESULT_ACCEPT;
                }
 
-       case BUTTON_RIGHT: // Intercept the right-button click to short-circuit the pop-up menu
-               if (!getenv("SYNFIG_ENABLE_POPUP_MENU_IN_ALL_TOOLS"))
-                       return Smach::RESULT_ACCEPT;
-
        default:
                return Smach::RESULT_OK;
        }
@@ -988,7 +1010,12 @@ StateBLine_Context::refresh_ducks(bool button_down)
                // First add the duck associated with this vertex
                duck=new WorkArea::Duck(bline_point.get_vertex());
                duck->set_editable(true);
+#ifdef DISTINGUISH_FIRST_DUCK
+               if (iter!=bline_point_list.begin())
+                       duck->set_type(Duck::TYPE_VERTEX);
+#else
                duck->set_type(Duck::TYPE_VERTEX);
+#endif
                duck->set_name(strprintf("%x-vertex",value_node.get()));
                duck->signal_edited().connect(
                        sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::on_vertex_change),value_node)
@@ -996,7 +1023,7 @@ StateBLine_Context::refresh_ducks(bool button_down)
                duck->signal_user_click(2).connect(
                        sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::popup_vertex_menu),value_node)
                );
-               duck->set_guid(value_node->get_guid()^GUID::hasher(0));
+               duck->set_guid(value_node->get_guid()^synfig::GUID::hasher(0));
 
                get_work_area()->add_duck(duck);
 
@@ -1007,7 +1034,7 @@ StateBLine_Context::refresh_ducks(bool button_down)
                tduck->set_origin(duck);
                tduck->set_scalar(-0.33333333333333333);
                tduck->set_tangent(true);
-               tduck->set_guid(value_node->get_guid()^GUID::hasher(3));
+               tduck->set_guid(value_node->get_guid()^synfig::GUID::hasher(3));
                tduck->signal_edited().connect(
                        sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::on_tangent1_change),value_node)
                );
@@ -1070,7 +1097,7 @@ StateBLine_Context::refresh_ducks(bool button_down)
                                sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::on_tangent1_change),value_node)
                        );
                }
-               tduck->set_guid(value_node->get_guid()^GUID::hasher(4));
+               tduck->set_guid(value_node->get_guid()^synfig::GUID::hasher(4));
                tduck->signal_user_click(2).connect(
                        sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::popup_handle_menu),value_node)
                );
@@ -1091,6 +1118,9 @@ StateBLine_Context::refresh_ducks(bool button_down)
 
                duck=new WorkArea::Duck(bline_point.get_vertex());
                duck->set_editable(true);
+#ifndef DISTINGUISH_FIRST_DUCK
+               duck->set_type(Duck::TYPE_VERTEX);
+#endif
                duck->set_name(strprintf("%x-vertex",bline_point_list.front().get()));
                duck->signal_edited().connect(
                        sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::on_vertex_change),bline_point_list.front())
@@ -1152,8 +1182,8 @@ StateBLine_Context::refresh_ducks(bool button_down)
                //get_work_area()->add_duck(bezier->c2);
                get_work_area()->add_bezier(bezier);
 
-               duck->set_guid(GUID());
-               tduck->set_guid(GUID());
+               duck->set_guid(synfig::GUID());
+               tduck->set_guid(synfig::GUID());
 
                next_duck=duck;
        }
@@ -1293,11 +1323,7 @@ StateBLine_Context::bline_insert_vertex(synfig::ValueNode_Const::Handle value_no
 
                        bline_point.set_vertex(curve(origin));
                        bline_point.set_width((next_bline_point.get_width()-prev_bline_point.get_width())*origin+prev_bline_point.get_width());
-#ifdef ETL_FIXED_DERIVATIVE
                        bline_point.set_tangent1(deriv(origin)*std::min(1.0f-origin,origin));
-#else
-                       bline_point.set_tangent1(-deriv(origin)*std::min(1.0f-origin,origin));
-#endif
                        bline_point.set_tangent2(bline_point.get_tangent1());
                        bline_point.set_split_tangent_flag(false);
                        bline_point.set_origin(origin);