Add further comments. Add local definition of FLAGS macro instead of using the one...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Wed, 26 Nov 2008 12:30:58 +0000 (12:30 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Wed, 26 Nov 2008 12:30:58 +0000 (12:30 +0000)
git-svn-id: https://synfig.svn.sourceforge.net/svnroot/synfig@2280 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-core/trunk/src/synfig/renddesc.cpp
synfig-core/trunk/src/synfig/renddesc.h

index cc3882c..9a498b1 100644 (file)
@@ -43,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 ======================================================= */
@@ -101,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_;
@@ -139,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;
@@ -162,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_;
@@ -200,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;
@@ -416,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;
@@ -425,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;
@@ -434,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;
@@ -479,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]);
@@ -502,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]);
index 0f433d6..cce4fd3 100644 (file)
@@ -55,15 +55,15 @@ class RendDesc
 public:
        enum Lock
        {
-               PX_ASPECT=(1<<0),               // "_Pixel Aspect" in Locks and Links
+               PX_ASPECT=(1<<0),               // "Pixel Aspect" in Locks and Links
                PX_AREA=(1<<1),                 // not used
-               PX_W=(1<<2),                    // "Pi_xel Width" in Locks and Links
-               PX_H=(1<<3),                    // "Pix_el Height" in Locks and Links
+               PX_W=(1<<2),                    // "Pixel Width" in Locks and Links - not used
+               PX_H=(1<<3),                    // "Pixel Height" in Locks and Links - not used
 
-               IM_ASPECT=(1<<4),               // "Image _Aspect" in Locks and Links
-               IM_SPAN=(1<<5),                 // "Image _Span" in Locks and Links
-               IM_W=(1<<6),                    // "Image _Width" in Locks and Links
-               IM_H=(1<<7),                    // "Image _Height" in Locks and Links
+               IM_ASPECT=(1<<4),               // "Image Aspect" in Locks and Links
+               IM_SPAN=(1<<5),                 // "Image Span" in Locks and Links
+               IM_W=(1<<6),                    // "Image Width" in Locks and Links
+               IM_H=(1<<7),                    // "Image Height" in Locks and Links
                IM_ZOOMIN=(1<<8),               // not used
                IM_ZOOMOUT=(1<<9),              // not used
 
@@ -304,17 +304,6 @@ inline RendDesc::Lock operator~(RendDesc::Lock rhs)
        return static_cast<RendDesc::Lock>(~(int)rhs);
 }
 
-//! \todo This code isn't used - so how are flags checked?  Using the FLAGS macro from color.h?
-//! This operator is for checking RendDesc::Lock flags.
-/*! Don't think of it as "less then or equal to", but think of it
-**     like an arrow. Is \a rhs inside of \a lhs ?
-**     \see RendDesc::Lock, RendDesc */
-// inline bool operator<=(RendDesc::Lock lhs, RendDesc::Lock rhs)
-// {
-//     return (static_cast<int>(lhs) & static_cast<int>(rhs)) == static_cast<int>(rhs);
-// }
-
-
 }; /* end namespace synfig */
 
 /* === E N D =============================================================== */