X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fstate_bline.cpp;h=39cf863aaecdd89181257e0a96d0f5215a551a47;hb=e4b736fc37dfd3212db87992369b609f9ef2a06e;hp=56d1b6dff9a35eb1ecb81ab8bea14247891e124d;hpb=f8bc4d2360809daabbf66dbbebd92295b911bbaa;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/state_bline.cpp b/synfig-studio/trunk/src/gtkmm/state_bline.cpp index 56d1b6d..39cf863 100644 --- a/synfig-studio/trunk/src/gtkmm/state_bline.cpp +++ b/synfig-studio/trunk/src/gtkmm/state_bline.cpp @@ -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; @@ -214,15 +217,15 @@ public: StateBLine::StateBLine(): Smach::state("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() @@ -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()); } @@ -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; } @@ -600,7 +603,12 @@ StateBLine_Context::run_() if(!canvas) canvas=get_canvas_view()->get_canvas(); - synfigapp::SelectionManager::LayerList layer_selection; + value_node_bline->set_member_canvas(canvas); + + synfigapp::SelectionManager::LayerList 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 @@ -637,7 +645,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); @@ -695,8 +704,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); @@ -765,7 +774,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); @@ -828,7 +838,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); @@ -906,7 +917,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(&x)); switch(event.button) { @@ -988,7 +999,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 +1012,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 +1023,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 +1086,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 +1107,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()) @@ -1134,12 +1153,12 @@ StateBLine_Context::refresh_ducks(bool button_down) if(bezier && !loop_) { duck=new WorkArea::Duck(bline_point.get_vertex()); - duck->set_editable(false); + duck->set_ignore(true); duck->set_name("temp"); // Add the tangent1 duck tduck=new WorkArea::Duck(Vector(0,0)); - tduck->set_editable(false); + tduck->set_ignore(true); tduck->set_name("ttemp"); tduck->set_origin(duck); tduck->set_scalar(-0.33333333333333333); @@ -1152,8 +1171,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 +1312,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);