Added copyright lines for files I've edited this year.
[synfig.git] / synfig-studio / trunk / src / gtkmm / duckmatic.cpp
index 37aefe3..df247ae 100644 (file)
@@ -6,7 +6,7 @@
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007 Chris Moore
+**     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
@@ -99,7 +99,24 @@ Duckmatic::Duckmatic():
 Duckmatic::~Duckmatic()
 {
        clear_ducks();
-       //synfig::info("Duckmatic::~Duckmatic(): Deleted. Duck Count=%d",Duck::duck_count);
+
+       if (Duck::duck_count)
+               synfig::error("%d ducks not yet deleted!", Duck::duck_count);
+
+       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+               synfig::info("Duckmatic::~Duckmatic(): Deleted");
+}
+
+void
+Duckmatic::set_flip_x(bool flip_x)
+{
+       flip_x_ = flip_x;
+}
+
+void
+Duckmatic::set_flip_y(bool flip_y)
+{
+       flip_y_ = flip_y;
 }
 
 void
@@ -243,20 +260,17 @@ Duckmatic::is_duck_group_selectable(const etl::handle<Duck>& x)const
        const Type type(get_type_mask());
 
        if(( x->get_type() && (!(type & x->get_type())) ) )
-       {
                return false;
-       }
+
        if(x->get_value_desc().parent_is_layer_param() && type & Duck::TYPE_POSITION)
        {
                Layer::Handle layer(x->get_value_desc().get_layer());
                String layer_name(layer->get_name());
-               if(
-                       layer_name=="outline" ||
-                       layer_name=="region" ||
-                       layer_name=="polygon" ||
-                       layer_name=="curve_gradient"
-               )
+
+               if (layer_name == "outline" || layer_name == "region" || layer_name == "plant" ||
+                       layer_name == "polygon" || layer_name == "curve_gradient")
                        return false;
+
                if((layer_name=="PasteCanvas"|| layer_name=="paste_canvas") &&
                   !layer->get_param("children_lock").get(bool()))
                        return false;
@@ -408,7 +422,7 @@ Duckmatic::end_duck_drag()
 }
 
 Point
-Duckmatic::snap_point_to_grid(const Point& x, float radius)const
+Duckmatic::snap_point_to_grid(const synfig::Point& x, float radius)const
 {
        Point ret(x);
 
@@ -542,6 +556,31 @@ Duckmatic::signal_edited_selected_ducks()
                                throw String("Bad edit");
                        }
                }
+               else if (App::restrict_radius_ducks &&
+                                (*iter)->is_radius())
+               {
+                       Point point((*iter)->get_point());
+                       bool changed = false;
+
+                       if (point[0] * (flip_x_ ? -1 : 1) < 0)
+                       {
+                               point[0] = 0;
+                               changed = true;
+                       }
+                       if (point[1] * (flip_y_ ? -1 : 1) < 0)
+                       {
+                               point[1] = 0;
+                               changed = true;
+                       }
+
+                       if (changed) (*iter)->set_point(point);
+
+                       if(!(*iter)->signal_edited()(point))
+                       {
+                               selected_ducks=old_set;
+                               throw String("Bad edit");
+                       }
+               }
                else
                {
                        if(!(*iter)->signal_edited()((*iter)->get_point()))
@@ -993,7 +1032,8 @@ Duckmatic::add_to_ducks(const synfigapp::ValueDesc& value_desc,etl::handle<Canva
                        duck->set_radius(true);
                        duck->set_type(Duck::TYPE_RADIUS);
 
-                       duck->set_point(Point(value_desc.get_value(get_time()).get(Real()),0));
+                       // put the duck on the right hand side of the center, whether the display is flipped or not
+                       duck->set_point(Point(value_desc.get_value(get_time()).get(Real()) * (flip_x_ ? -1 : 1), 0));
                        duck->set_name(guid_string(value_desc));
                        if(value_desc.is_value_node())
                        {