Show the name of the current tool in the tool options panel if it has any options...
[synfig.git] / synfig-studio / trunk / src / gtkmm / state_bline.cpp
index cee1d8d..45a8120 100644 (file)
@@ -217,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()
@@ -374,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_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);
        //button_make.signal_pressed().connect(sigc::mem_fun(*this,&StateBLine_Context::run));
        options_table.show_all();
@@ -606,6 +606,11 @@ StateBLine_Context::run_()
                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
@@ -642,7 +647,8 @@ StateBLine_Context::run_()
                                }
                        }
 
-                       if (get_layer_link_offsets_flag())
+                       // 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)
                        {
                                synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect"));
                                assert(action);
@@ -700,8 +706,8 @@ StateBLine_Context::run_()
                                }
                        }
 
-                       // plants don't have offsets?
-                       if (get_layer_link_offsets_flag())
+                       // 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)
                        {
                                synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect"));
                                assert(action);
@@ -770,7 +776,8 @@ StateBLine_Context::run_()
                                }
                        }
 
-                       if (get_layer_link_offsets_flag())
+                       // 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)
                        {
                                synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect"));
                                assert(action);
@@ -833,7 +840,8 @@ StateBLine_Context::run_()
                                }
                        }
 
-                       if (get_layer_link_offsets_flag())
+                       // 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)
                        {
                                synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect"));
                                assert(action);