Initial Stable Commit
[synfig.git] / synfig-core / trunk / src / modules / lyr_std / timeloop.cpp
1 /*! ========================================================================
2 ** Sinfg
3 ** Image Layer_TimeLoop Layer Implementation
4 ** $Id: timeloop.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $
5 **
6 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
7 **
8 ** This software and associated documentation
9 ** are CONFIDENTIAL and PROPRIETARY property of
10 ** the above-mentioned copyright holder.
11 **
12 ** You may not copy, print, publish, or in any
13 ** other way distribute this software without
14 ** a prior written agreement with
15 ** the copyright holder.
16 **
17 ** === N O T E S ===========================================================
18 **
19 ** ========================================================================= */
20
21 /* === H E A D E R S ======================================================= */
22
23 #ifdef USING_PCH
24 #       include "pch.h"
25 #else
26 #ifdef HAVE_CONFIG_H
27 #       include <config.h>
28 #endif
29
30 #include "timeloop.h"
31 #include <sinfg/time.h>
32 #include <sinfg/context.h>
33 #include <sinfg/paramdesc.h>
34 #include <sinfg/renddesc.h>
35 #include <sinfg/value.h>
36
37 #endif
38
39 using namespace sinfg;
40 using namespace std;
41 using namespace etl;
42
43 /* === M A C R O S ========================================================= */
44
45 /* === G L O B A L S ======================================================= */
46
47 SINFG_LAYER_INIT(Layer_TimeLoop);
48 SINFG_LAYER_SET_NAME(Layer_TimeLoop,"timeloop");
49 SINFG_LAYER_SET_LOCAL_NAME(Layer_TimeLoop,_("TimeLoop"));
50 SINFG_LAYER_SET_CATEGORY(Layer_TimeLoop,_("Other"));
51 SINFG_LAYER_SET_VERSION(Layer_TimeLoop,"0.1");
52 SINFG_LAYER_SET_CVS_ID(Layer_TimeLoop,"$Id: timeloop.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $");
53
54 /* === P R O C E D U R E S ================================================= */
55
56 /* === M E T H O D S ======================================================= */
57
58 Layer_TimeLoop::Layer_TimeLoop()
59 {
60         start_time=0;
61         end_time=1;
62 }
63
64 Layer_TimeLoop::~Layer_TimeLoop()
65 {
66 }
67
68 bool
69 Layer_TimeLoop::set_param(const String & param, const ValueBase &value)
70 {
71         IMPORT(start_time);
72         IMPORT(end_time);
73         return Layer::set_param(param,value);
74 }
75
76 ValueBase
77 Layer_TimeLoop::get_param(const String & param)const
78 {
79         EXPORT(start_time);
80         EXPORT(end_time);
81         EXPORT_NAME();
82         EXPORT_VERSION();
83
84         return Layer::get_param(param);
85 }
86
87 Layer::Vocab
88 Layer_TimeLoop::get_param_vocab()const
89 {
90         Layer::Vocab ret(Layer::get_param_vocab());
91         
92         ret.push_back(ParamDesc("start_time")
93                 .set_local_name(_("Start Time"))
94         );
95
96         ret.push_back(ParamDesc("end_time")
97                 .set_local_name(_("End Time"))
98         );
99         
100         return ret;
101 }
102
103 void
104 Layer_TimeLoop::set_time(Context context, Time time)const
105 {
106         Real diff(end_time-start_time);
107         if(diff>0)
108                 time-=int(Real(time-start_time)/diff)*diff+start_time;
109         context.set_time(time);
110 }
111
112 Color
113 Layer_TimeLoop::get_color(Context context, const Point &pos)const
114 {
115         return context.get_color(pos);
116 }
117
118 bool
119 Layer_TimeLoop::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
120 {
121         return context.accelerated_render(surface,quality,renddesc,cb);
122 }