X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fduck.cpp;h=e88306e1ebe5d31d70ffe48a338867b15348786f;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=8500b89bdaae6266bf6ec7bd6fb999a4c19330c2;hpb=8ef042c40521681cea99944097c4f90a5ac6cf74;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/duck.cpp b/synfig-studio/trunk/src/gtkmm/duck.cpp index 8500b89..e88306e 100644 --- a/synfig-studio/trunk/src/gtkmm/duck.cpp +++ b/synfig-studio/trunk/src/gtkmm/duck.cpp @@ -6,6 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007, 2008 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -72,7 +73,9 @@ Duck::Duck(): scalar(1), editable(false), radius_(false), - tangent_(false) + tangent_(false), + hover_(false), + ignore_(false) { duck_count++; _DuckCounter::counter++; } Duck::Duck(const synfig::Point &point): @@ -84,7 +87,9 @@ Duck::Duck(const synfig::Point &point): guid_(0), editable(false), radius_(false), - tangent_(false) + tangent_(false), + hover_(false), + ignore_(false) { duck_count++; _DuckCounter::counter++;} Duck::Duck(const synfig::Point &point,const synfig::Point &origin): @@ -95,7 +100,9 @@ Duck::Duck(const synfig::Point &point,const synfig::Point &origin): guid_(0), editable(false), radius_(true), - tangent_(false) + tangent_(false), + hover_(false), + ignore_(false) { duck_count++; _DuckCounter::counter++;} Duck::~Duck() { duck_count--; _DuckCounter::counter--;} @@ -105,16 +112,16 @@ Duck::get_data_guid()const { if(value_desc_.is_value_node()) return value_desc_.get_value_node()->get_guid(); - return GUID::hasher(get_name()); + return synfig::GUID::hasher(get_name()); } void Duck::set_name(const synfig::String &x) { name=x; - if(guid_==GUID::zero()) + if(guid_==synfig::GUID::zero()) { - guid_=GUID::hasher(name); + guid_=synfig::GUID::hasher(name); } } @@ -195,12 +202,16 @@ Duck::set_sub_trans_point(const synfig::Point &x) { Angle old_angle = get_point().angle(); set_point((x-get_sub_trans_origin())/get_scalar()); - Angle new_angle = get_point().angle(); - int old_quarters = round_to_int(Angle::deg(rotations).get()/90); - rotations += new_angle.dist(old_angle); - 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); + 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_halves = round_to_int(Angle::deg(rotations).get()/180); + rotations += change; + int new_halves = round_to_int(Angle::deg(rotations).get()/180); + if (old_halves != new_halves && + (new_halves > 1 || new_halves < -1 || + old_halves > 1 || old_halves < -1)) + synfig::info("rotation: %.2f turns", new_halves/2.0); } else set_point((x-get_sub_trans_origin())/get_scalar()); @@ -211,3 +222,23 @@ Duck::get_sub_trans_origin()const { return origin_duck?origin_duck->get_sub_trans_point():origin; } + +#ifdef _DEBUG +synfig::String +Duck::type_name(Type id) +{ + String ret; + + if (id & TYPE_POSITION) { if (!ret.empty()) ret += ", "; ret += "position"; } + if (id & TYPE_TANGENT ) { if (!ret.empty()) ret += ", "; ret += "tangent" ; } + if (id & TYPE_RADIUS ) { if (!ret.empty()) ret += ", "; ret += "radius" ; } + if (id & TYPE_WIDTH ) { if (!ret.empty()) ret += ", "; ret += "width" ; } + if (id & TYPE_ANGLE ) { if (!ret.empty()) ret += ", "; ret += "angle" ; } + if (id & TYPE_VERTEX ) { if (!ret.empty()) ret += ", "; ret += "vertex" ; } + + if (ret.empty()) + ret = "none"; + + return ret; +} +#endif // _DEBUG