X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fduck.cpp;h=63bebe7099844e06e48f2c058ca71f00adf43c02;hb=a27deaf2322fab351ac47cbed699ec3ab8eb198d;hp=fed3826284264cc4061d1cbe57af40805b8c9e52;hpb=02252941b29de64037116f4d37991a38d9ff0d94;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/duck.cpp b/synfig-studio/trunk/src/gtkmm/duck.cpp index fed3826..63bebe7 100644 --- a/synfig-studio/trunk/src/gtkmm/duck.cpp +++ b/synfig-studio/trunk/src/gtkmm/duck.cpp @@ -2,19 +2,20 @@ /*! \file duck.cpp ** \brief Template File ** -** $Id: duck.cpp,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $ +** $Id$ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley ** -** 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 */ /* ========================================================================= */ @@ -29,6 +30,9 @@ #endif #include "duck.h" +#include + +#include "general.h" #endif @@ -63,6 +67,7 @@ int _DuckCounter::counter(0); /* === M E T H O D S ======================================================= */ Duck::Duck(): + rotations(synfig::Angle::deg(0)), origin(0,0), scalar(1), editable(false), @@ -73,6 +78,7 @@ Duck::Duck(): Duck::Duck(const synfig::Point &point): type_(TYPE_NONE), point(point), + rotations(synfig::Angle::deg(0)), origin(0,0), scalar(1), guid_(0), @@ -83,6 +89,7 @@ Duck::Duck(const synfig::Point &point): Duck::Duck(const synfig::Point &point,const synfig::Point &origin): point(point), + rotations(synfig::Angle::deg(0)), origin(origin), scalar(1), guid_(0), @@ -132,7 +139,7 @@ Duck::get_trans_point()const { return transform_stack_.perform(get_sub_trans_point()); } - + void Duck::set_trans_point(const synfig::Point &x) { @@ -183,7 +190,22 @@ Duck::get_sub_trans_point()const void Duck::set_sub_trans_point(const synfig::Point &x) { - set_point((x-get_sub_trans_origin())/get_scalar()); + if (get_type() == Duck::TYPE_TANGENT || + get_type() == Duck::TYPE_ANGLE) + { + Angle old_angle = get_point().angle(); + set_point((x-get_sub_trans_origin())/get_scalar()); + Angle change = get_point().angle() - old_angle; + while (change < Angle::deg(-180)) change += Angle::deg(360); + while (change > Angle::deg(180)) change -= Angle::deg(360); + int old_quarters = round_to_int(Angle::deg(rotations).get()/90); + rotations += change; + int new_quarters = round_to_int(Angle::deg(rotations).get()/90); + if (old_quarters != new_quarters) + synfig::info("rotation: %.2f turns", new_quarters/4.0); + } + else + set_point((x-get_sub_trans_origin())/get_scalar()); } synfig::Point