X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Fsrc%2Fgtkmm%2Fstate_smoothmove.cpp;h=f42df35eb9437e295ea80ba5ad54ff2876ab656e;hb=c11c4966980ed301f40b3dcc24e4fbec525f93e3;hp=56ca977e768f93dfd42501d76c6fe6bdb45b3975;hpb=adfc80c126f482d7ea2bac38001a2c4a7c7df88c;p=synfig.git diff --git a/synfig-studio/src/gtkmm/state_smoothmove.cpp b/synfig-studio/src/gtkmm/state_smoothmove.cpp index 56ca977..f42df35 100644 --- a/synfig-studio/src/gtkmm/state_smoothmove.cpp +++ b/synfig-studio/src/gtkmm/state_smoothmove.cpp @@ -7,6 +7,7 @@ ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley ** Copyright (c) 2008 Chris Moore +** Copyright (c) 2009 Nikita Kitaev ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -33,10 +34,13 @@ #include #include +#include +#include #include #include #include "state_smoothmove.h" +#include "state_normal.h" #include "canvasview.h" #include "workarea.h" #include "app.h" @@ -95,6 +99,7 @@ public: class studio::StateSmoothMove_Context : public sigc::trackable { etl::handle canvas_view_; + CanvasView::IsWorking is_working; //Duckmatic::Push duckmatic_push; @@ -140,6 +145,7 @@ StateSmoothMove::StateSmoothMove(): Smach::state("smooth_move") { insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateSmoothMove_Context::event_refresh_tool_options)); + insert(event_def(EVENT_STOP,&StateSmoothMove_Context::event_stop_handler)); } StateSmoothMove::~StateSmoothMove() @@ -165,6 +171,7 @@ StateSmoothMove_Context::save_settings() StateSmoothMove_Context::StateSmoothMove_Context(CanvasView* canvas_view): canvas_view_(canvas_view), + is_working(*canvas_view), // duckmatic_push(get_work_area()), settings(synfigapp::Main::get_selected_input_device()->settings()), duck_dragger_(new DuckDrag_SmoothMove()), @@ -190,8 +197,8 @@ StateSmoothMove_Context::StateSmoothMove_Context(CanvasView* canvas_view): App::toolbox->refresh(); -// get_canvas_view()->work_area->set_cursor(Gdk::CROSSHAIR); - get_canvas_view()->work_area->reset_cursor(); + get_work_area()->set_cursor(Gdk::FLEUR); + //get_work_area()->reset_cursor(); load_settings(); } @@ -212,12 +219,19 @@ StateSmoothMove_Context::event_refresh_tool_options(const Smach::event& /*x*/) return Smach::RESULT_ACCEPT; } +Smach::event_result +StateSmoothMove_Context::event_stop_handler(const Smach::event& /*x*/) +{ + throw &state_normal; + return Smach::RESULT_OK; +} + StateSmoothMove_Context::~StateSmoothMove_Context() { save_settings(); get_work_area()->clear_duck_dragger(); - get_canvas_view()->work_area->reset_cursor(); + get_work_area()->reset_cursor(); App::dialog_tool_options->clear(); @@ -262,6 +276,8 @@ DuckDrag_SmoothMove::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vecto int i; + Time time(duckmatic->get_time()); + // process vertex and position ducks first for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++) { @@ -276,7 +292,7 @@ DuckDrag_SmoothMove::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vecto dist=0; last_[i]=vect*dist; - (*iter)->set_trans_point(p+last_[i]); + (*iter)->set_trans_point(p+last_[i], time); } // then process non vertex and non position ducks @@ -293,9 +309,12 @@ DuckDrag_SmoothMove::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vecto dist=0; last_[i]=vect*dist; - (*iter)->set_trans_point(p+last_[i]); + (*iter)->set_trans_point(p+last_[i], time); } + // then patch up the tangents for the vertices we've moved + duckmatic->update_ducks(); + last_translate_=vect; //snap=Vector(0,0); } @@ -316,9 +335,45 @@ DuckDrag_SmoothMove::end_duck_drag(Duckmatic* duckmatic) for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++) { if(last_[i].mag()>0.0001) - if(!(*iter)->signal_edited()((*iter)->get_point())) { - throw String("Bad Move"); + if ((*iter)->get_type() == Duck::TYPE_ANGLE) + { + if(!(*iter)->signal_edited_angle()((*iter)->get_rotations())) + { + throw String("Bad edit"); + } + } + else if (App::restrict_radius_ducks && + (*iter)->is_radius()) + { + Point point((*iter)->get_point()); + bool changed = false; + + if (point[0] < 0) + { + point[0] = 0; + changed = true; + } + if (point[1] < 0) + { + point[1] = 0; + changed = true; + } + + if (changed) (*iter)->set_point(point); + + if(!(*iter)->signal_edited()(point)) + { + throw String("Bad edit"); + } + } + else + { + if(!(*iter)->signal_edited()((*iter)->get_point())) + { + throw String("Bad edit"); + } + } } } //duckmatic->get_selected_ducks()=new_set;