/* === 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 ======================================================= */
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_;
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;
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_;
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;
{
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;
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;
tl_-=focus;
tl_=tl_*ratio;
tl_+=focus;
- }else // IM_H
+ }else // IM_H // "Image Height"
{
//! \writeme or fix me
br_-=focus;
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]);
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]);
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
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 =============================================================== */