X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Fsrc%2Fsynfig%2Frenddesc.cpp;fp=synfig-core%2Fsrc%2Fsynfig%2Frenddesc.cpp;h=9a498b176d841640e2abe0d4465a57565ed573d2;hb=a095981e18cc37a8ecc7cd237cc22b9c10329264;hp=0000000000000000000000000000000000000000;hpb=9459638ad6797b8139f1e9f0715c96076dbf0890;p=synfig.git diff --git a/synfig-core/src/synfig/renddesc.cpp b/synfig-core/src/synfig/renddesc.cpp new file mode 100644 index 0000000..9a498b1 --- /dev/null +++ b/synfig-core/src/synfig/renddesc.cpp @@ -0,0 +1,566 @@ +/* === S Y N F I G ========================================================= */ +/*! \file synfig/renddesc.cpp +** \brief RendDesc +** +** $Id$ +** +** \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 +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. +** +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** \endlegal +*/ +/* ========================================================================= */ + +/* === H E A D E R S ======================================================= */ + +#ifdef USING_PCH +# include "pch.h" +#else +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "renddesc.h" +#include + +#endif + +/* === U S I N G =========================================================== */ + +using namespace std; +using namespace etl; +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 ======================================================= */ + +RendDesc & +RendDesc::apply(const RendDesc &x) +{ + operator=(x); + return *this; +} + +const Color & +RendDesc::get_bg_color()const +{ + return background; +} + +RendDesc & +RendDesc::set_bg_color(const Color &bg) +{ + background=bg; return *this; +} + +Real +RendDesc::get_physical_w()const +{ + return (Real)get_w()/get_x_res(); +} + +Real +RendDesc::get_physical_h()const +{ + return (Real)get_h()/get_y_res(); +} + +RendDesc& +RendDesc::set_physical_w(Real w) +{ + set_w(round_to_int(w*get_x_res())); + return *this; +} + +RendDesc& +RendDesc::set_physical_h(Real h) +{ + set_h(round_to_int(h*get_y_res())); + return *this; +} + +int +RendDesc::get_w()const +{ + return w_; +} + +RendDesc & +RendDesc::set_w(int x) +{ + if(FLAGS(flags,LINK_PX_ASPECT)) // never set + { + h_=h_*x/w_; + w_=x; + } + else if(FLAGS(flags,LINK_PX_AREA)) // never set + { + //! \writeme + w_=x; + } + 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) // "Image Width" + || (FLAGS(flags,IM_ZOOMIN) && d[1]>d[1]/x*w_) // never set + || (FLAGS(flags,IM_ZOOMOUT) && d[1]d[0]/y*h_) // never set + || (FLAGS(flags,IM_ZOOMOUT) && d[0]time_end) + time_begin=time_end=x; + else + time_begin=x; + return *this; +} + + +const Time +RendDesc::get_time_end()const +{ + return time_end; +} + +RendDesc & +RendDesc::set_time_end(Time x) +{ + if(x