Remove .gitignore do nothing is ignored.
[synfig.git] / synfig-core / trunk / src / synfig / renddesc.cpp
index b1b2832..9a498b1 100644 (file)
@@ -6,6 +6,7 @@
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 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
@@ -42,6 +43,9 @@ using namespace synfig;
 
 /* === M A C R O S ========================================================= */
 
+#undef FLAGS
+#define FLAGS(x,y)             (((x)&(y))==(y))
+
 /* === G L O B A L S ======================================================= */
 
 /* === M E T H O D S ======================================================= */
@@ -100,25 +104,25 @@ RendDesc::get_w()const
 RendDesc &
 RendDesc::set_w(int x)
 {
-       if(FLAGS(flags,LINK_PX_ASPECT))
+       if(FLAGS(flags,LINK_PX_ASPECT)) // never set
        {
                h_=h_*x/w_;
                w_=x;
        }
-       else if(FLAGS(flags,LINK_PX_AREA))
+       else if(FLAGS(flags,LINK_PX_AREA)) // never set
        {
                //! \writeme
                w_=x;
        }
-       else if(FLAGS(flags,PX_ASPECT))
+       else if(FLAGS(flags,PX_ASPECT)) // "Pixel Aspect"
        {
                Vector d=br_-tl_;
                float old_span=get_span();
 
                // If we should preserve image width
-               if(             FLAGS(flags,IM_W)
-                       || (FLAGS(flags,IM_ZOOMIN) && d[1]>d[1]/x*w_)
-                       || (FLAGS(flags,IM_ZOOMOUT) && d[1]<d[1]/x*w_))
+               if(             FLAGS(flags,IM_W)                                                       // "Image Width"
+                       || (FLAGS(flags,IM_ZOOMIN) && d[1]>d[1]/x*w_)   // never set
+                       || (FLAGS(flags,IM_ZOOMOUT) && d[1]<d[1]/x*w_)) // never set
                {
                        br_[1]-=focus[1];
                        br_[1]=br_[1]/x*w_;
@@ -138,10 +142,10 @@ RendDesc::set_w(int x)
 
                w_=x;
 
-               if(FLAGS(flags,IM_SPAN))
+               if(FLAGS(flags,IM_SPAN)) // "Image Span"
                        set_span(old_span);
        }
-       else if(FLAGS(flags,PX_AREA))
+       else if(FLAGS(flags,PX_AREA)) // never set
        {
                //! \writeme
                w_=x;
@@ -161,25 +165,25 @@ RendDesc::get_h()const
 RendDesc &
 RendDesc::set_h(int y)
 {
-       if(FLAGS(flags,LINK_PX_ASPECT))
+       if(FLAGS(flags,LINK_PX_ASPECT)) // never set
        {
                w_=w_*y/h_;
                h_=y;
        }
-       else if(FLAGS(flags,LINK_PX_AREA))
+       else if(FLAGS(flags,LINK_PX_AREA)) // never set
        {
                //! \writeme
                h_=y;
        }
-       else if(FLAGS(flags,PX_ASPECT))
+       else if(FLAGS(flags,PX_ASPECT)) // "Pixel Aspect"
        {
                Vector d=br_-tl_;
                float old_span=get_span();
 
                // If we should preserve image width
-               if(             FLAGS(flags,IM_W)
-                       || (FLAGS(flags,IM_ZOOMIN) && d[0]>d[0]/y*h_)
-                       || (FLAGS(flags,IM_ZOOMOUT) && d[0]<d[0]/y*h_))
+               if(             FLAGS(flags,IM_W)                                                       // "Image Width"
+                       || (FLAGS(flags,IM_ZOOMIN) && d[0]>d[0]/y*h_)   // never set
+                       || (FLAGS(flags,IM_ZOOMOUT) && d[0]<d[0]/y*h_)) // never set
                {
                        br_[0]-=focus[0];
                        br_[0]=br_[0]/y*h_;
@@ -199,10 +203,10 @@ RendDesc::set_h(int y)
 
                h_=y;
 
-               if(FLAGS(flags,IM_SPAN))
+               if(FLAGS(flags,IM_SPAN)) // "Image Span"
                        set_span(old_span);
        }
-       else if(FLAGS(flags,PX_AREA))
+       else if(FLAGS(flags,PX_AREA)) // never set
        {
                //! \writeme
                h_=y;
@@ -250,7 +254,7 @@ RendDesc::set_y_res(Real y)
 int
 RendDesc::get_frame_start()const
 {
-       return time_begin*frame_rate;
+       return round_to_int(time_begin*frame_rate);
 }
 
 RendDesc &
@@ -262,7 +266,7 @@ RendDesc::set_frame_start(int x)
 int
 RendDesc::get_frame_end()const
 {
-       return time_end*frame_rate;
+       return round_to_int(time_end*frame_rate);
 }
 
 RendDesc &
@@ -396,7 +400,7 @@ const int &
 RendDesc::get_antialias()const
 { return a; }
 
-//! Set the antilaias amount
+//! Set the antialias amount
 RendDesc &
 RendDesc::set_antialias(const int &x)
 { a=x; return *this; }
@@ -415,7 +419,10 @@ RendDesc::set_span(const Real &x)
 {
        Vector::value_type ratio=x/get_span();
 
-       if(!FLAGS(flags,IM_W|IM_H) || FLAGS(flags,IM_ASPECT))
+       //! \todo this looks wrong.  I suspect the intention was to check
+       //                "(not IM_W) AND (not IM_H)", ie "not(IM_W OR IM_H)" but
+       //                this check does "not(IM_W AND IM_H)"
+       if(!FLAGS(flags,IM_W|IM_H) || FLAGS(flags,IM_ASPECT)) // (not "Image Width") or (not "Image Height") or "Image Aspect"
        {
                br_-=focus;
                br_=br_*ratio;
@@ -424,7 +431,7 @@ RendDesc::set_span(const Real &x)
                tl_=tl_*ratio;
                tl_+=focus;
        }
-       else if(FLAGS(flags,IM_W))
+       else if(FLAGS(flags,IM_W))      // "Image Width"
        {
                //! \writeme or fix me
                br_-=focus;
@@ -433,7 +440,7 @@ RendDesc::set_span(const Real &x)
                tl_-=focus;
                tl_=tl_*ratio;
                tl_+=focus;
-       }else // IM_H
+       }else // IM_H                           // "Image Height"
        {
                //! \writeme or fix me
                br_-=focus;
@@ -478,7 +485,7 @@ RendDesc::get_br()const
 RendDesc &
 RendDesc::set_tl(const Point &x)
 {
-       if(FLAGS(flags,PX_ASPECT))
+       if(FLAGS(flags,PX_ASPECT)) // "Pixel Aspect"
        {
                Vector new_size(x-br_);
                new_size[0]=abs(new_size[0]);
@@ -501,7 +508,7 @@ RendDesc::set_tl(const Point &x)
 RendDesc &
 RendDesc::set_br(const Point &x)
 {
-       if(FLAGS(flags,PX_ASPECT))
+       if(FLAGS(flags,PX_ASPECT)) // "Pixel Aspect"
        {
                Vector new_size(x-tl_);
                new_size[0]=abs(new_size[0]);
@@ -525,7 +532,7 @@ RendDesc::set_viewport(const Point &__tl, const Point &__br)
 { tl_=__tl; br_=__br; return *this; }
 
 RendDesc &
-RendDesc::set_viewport(Real a,Real b,Real c,Real d)
+RendDesc::set_viewport(Vector::value_type a, Vector::value_type b, Vector::value_type c, Vector::value_type d)
 { tl_=Point(a,b); br_=Point(c,d); return *this; }
 
 Real