X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fstate_rotate.cpp;h=16355000ed84cdb137909b03eae098e17b5ac076;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=df76994efd38cc05c33f138b6695884cec35505e;hpb=02252941b29de64037116f4d37991a38d9ff0d94;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/state_rotate.cpp b/synfig-studio/trunk/src/gtkmm/state_rotate.cpp index df76994..1635500 100644 --- a/synfig-studio/trunk/src/gtkmm/state_rotate.cpp +++ b/synfig-studio/trunk/src/gtkmm/state_rotate.cpp @@ -2,19 +2,21 @@ /*! \file state_rotate.cpp ** \brief Template File ** -** $Id: state_rotate.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $ +** $Id$ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 Chris Moore ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. ** \endlegal */ /* ========================================================================= */ @@ -49,6 +51,8 @@ #include #include +#include "general.h" + #endif /* === U S I N G =========================================================== */ @@ -82,11 +86,11 @@ class DuckDrag_Rotate : public DuckDrag_Base Real original_mag; std::vector positions; - - + + bool bad_drag; bool move_only; - + public: etl::handle canvas_view_; bool use_magnitude; @@ -102,20 +106,20 @@ public: class studio::StateRotate_Context : public sigc::trackable { etl::handle canvas_view_; - + synfigapp::Settings& settings; etl::handle duck_dragger_; Gtk::Table options_table; - + Gtk::CheckButton checkbutton_scale; - + public: bool get_scale_flag()const { return checkbutton_scale.get_active(); } void set_scale_flag(bool x) { return checkbutton_scale.set_active(x); refresh_scale_flag(); } - + Smach::event_result event_refresh_tool_options(const Smach::event& x); @@ -131,7 +135,7 @@ public: etl::handle get_canvas_interface()const{return canvas_view_->canvas_interface();} synfig::Canvas::Handle get_canvas()const{return canvas_view_->get_canvas();} WorkArea * get_work_area()const{return canvas_view_->get_work_area();} - + void load_settings(); void save_settings(); }; // END of class StateRotate_Context @@ -142,7 +146,7 @@ StateRotate::StateRotate(): Smach::state("rotate") { insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateRotate_Context::event_refresh_tool_options)); -} +} StateRotate::~StateRotate() { @@ -150,7 +154,7 @@ StateRotate::~StateRotate() void StateRotate_Context::load_settings() -{ +{ String value; if(settings.get_value("rotate.scale",value) && value=="0") @@ -161,7 +165,7 @@ StateRotate_Context::load_settings() void StateRotate_Context::save_settings() -{ +{ settings.set_value("rotate.scale",get_scale_flag()?"1":"0"); } @@ -170,21 +174,21 @@ StateRotate_Context::StateRotate_Context(CanvasView* canvas_view): settings(synfigapp::Main::get_selected_input_device()->settings()), duck_dragger_(new DuckDrag_Rotate()), checkbutton_scale(_("Allow Scale")) -{ +{ duck_dragger_->canvas_view_=get_canvas_view(); - + // Set up the tool options dialog - //options_table.attach(*manage(new Gtk::Label(_("Rotate Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); - options_table.attach(checkbutton_scale, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(*manage(new Gtk::Label(_("Rotate Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(checkbutton_scale, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); checkbutton_scale.signal_toggled().connect(sigc::mem_fun(*this,&StateRotate_Context::refresh_scale_flag)); - + options_table.show_all(); refresh_tool_options(); //App::dialog_tool_options->set_widget(options_table); App::dialog_tool_options->present(); - - get_work_area()->allow_layer_clicks=true; + + get_work_area()->set_allow_layer_clicks(true); get_work_area()->set_duck_dragger(duck_dragger_); // get_canvas_view()->work_area->set_cursor(Gdk::CROSSHAIR); @@ -206,7 +210,7 @@ StateRotate_Context::refresh_tool_options() } Smach::event_result -StateRotate_Context::event_refresh_tool_options(const Smach::event& x) +StateRotate_Context::event_refresh_tool_options(const Smach::event& /*x*/) { refresh_tool_options(); return Smach::RESULT_ACCEPT; @@ -239,7 +243,7 @@ DuckDrag_Rotate::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& off const DuckList selected_ducks(duckmatic->get_selected_ducks()); DuckList::const_iterator iter; - + /* if(duckmatic->get_selected_ducks().size()<2) { @@ -248,7 +252,7 @@ DuckDrag_Rotate::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& off } */ bad_drag=false; - + drag_offset=duckmatic->find_duck(offset)->get_trans_point(); //snap=drag_offset-duckmatic->snap_point_to_grid(drag_offset); @@ -276,7 +280,7 @@ DuckDrag_Rotate::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& off else move_only=false; - + synfig::Vector vect(offset-center); original_angle=Angle::tan(vect[1],vect[0]); original_mag=vect.mag(); @@ -288,7 +292,7 @@ DuckDrag_Rotate::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector) { if(bad_drag) return; - + //std::set >::iterator iter; synfig::Vector vect(duckmatic->snap_point_to_grid(vector)-center+snap); @@ -301,9 +305,9 @@ DuckDrag_Rotate::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector) for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++) { if((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION)continue; - + Vector p(positions[i]); - + p[0]+=vect[0]; p[1]+=vect[1]; (*iter)->set_trans_point(p); @@ -311,27 +315,27 @@ DuckDrag_Rotate::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector) for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++) { if(!((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION))continue; - + Vector p(positions[i]); - + p[0]+=vect[0]; p[1]+=vect[1]; (*iter)->set_trans_point(p); } return; } - + Angle::tan angle(vect[1],vect[0]); angle=original_angle-angle; Real mag(vect.mag()/original_mag); Real sine(Angle::sin(angle).get()); Real cosine(Angle::cos(angle).get()); - + int i; for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++) { if((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION)continue; - + Vector x(positions[i]-center),p; p[0]=cosine*x[0]+sine*x[1]; @@ -343,7 +347,7 @@ DuckDrag_Rotate::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector) for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++) { if(!((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION))continue; - + Vector x(positions[i]-center),p; p[0]=cosine*x[0]+sine*x[1]; @@ -352,7 +356,7 @@ DuckDrag_Rotate::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector) p+=center; (*iter)->set_trans_point(p); } - + last_rotate=vect; //snap=Vector(0,0); } @@ -367,9 +371,9 @@ DuckDrag_Rotate::end_duck_drag(Duckmatic* duckmatic) duckmatic->signal_edited_selected_ducks(); return true; } - + synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Rotate Ducks")); - + if((last_rotate-Vector(1,1)).mag()>0.0001) { duckmatic->signal_edited_selected_ducks();