summaryrefslogtreecommitdiff
path: root/src/wrapper/anim_wrap.cpp
blob: 0dfadf211ddc346b66e96ee88282f572cba4d24b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//
//  libavg - Media Playback Engine. 
//  Copyright (C) 2003-2014 Ulrich von Zadow
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2 of the License, or (at your option) any later version.
//
//  This library 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
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
//  Current versions can be found at www.libavg.de
//

#include "WrapHelper.h"

#include "../anim/SimpleAnim.h"
#include "../anim/LinearAnim.h"
#include "../anim/EaseInOutAnim.h"
#include "../anim/ContinuousAnim.h"
#include "../anim/WaitAnim.h"
#include "../anim/ParallelAnim.h"
#include "../anim/StateAnim.h"

#include "../player/BoostPython.h"

using namespace boost::python;
using namespace avg;
namespace bp = boost::python;

BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(start_overloads, start, 0, 1);
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(setState_overloads, StateAnim::setState, 1, 2);
BOOST_PYTHON_FUNCTION_OVERLOADS(fadeIn_overloads, fadeIn, 2, 4);
BOOST_PYTHON_FUNCTION_OVERLOADS(fadeOut_overloads, fadeOut, 2, 3);

void export_anim()
{
    from_python_sequence<std::vector<AnimPtr>, variable_capacity_policy>();
    from_python_sequence<std::vector<AnimState>, variable_capacity_policy>();
    
    def("getNumRunningAnims", AttrAnim::getNumRunningAnims);
    
    class_<Anim, boost::shared_ptr<Anim>, boost::noncopyable>("Anim", no_init)
        .def("setStartCallback", &Anim::setStartCallback)
        .def("setStopCallback", &Anim::setStopCallback)
        .def("abort", &Anim::abort)
        .def("isRunning", &Anim::isRunning)
        ;

    class_<AttrAnim, boost::shared_ptr<AttrAnim>, bases<Anim>, boost::noncopyable>
            ("AttrAnim", no_init)
        .def("start", &AttrAnim::start, start_overloads(args("bKeepAttr")))
        ;
 
    class_<SimpleAnim, boost::shared_ptr<SimpleAnim>, bases<AttrAnim>, 
            boost::noncopyable>("SimpleAnim", no_init)
        ;

    class_<LinearAnim, boost::shared_ptr<LinearAnim>, bases<SimpleAnim>, 
            boost::noncopyable>("LinearAnim", no_init)
        .def(init<const object&, const std::string&, long long, const object&, 
                const object&, optional<bool, const object&, const object&> >
                ((bp::arg("node"), bp::arg("attrName"), bp::arg("duration"), 
                 bp::arg("startValue"), bp::arg("endValue"), bp::arg("useInt")=false,
                 bp::arg("startCallback")=object(), bp::arg("stopCallback")=object())))
        ;

    class_<EaseInOutAnim, boost::shared_ptr<EaseInOutAnim>, bases<SimpleAnim>, 
            boost::noncopyable>("EaseInOutAnim", no_init)
        .def(init<const object&, const std::string&, long long, const object&,
                const object&, long long, long long, 
                optional<bool, const object&, const object&> >
                ((bp::arg("node"), bp::arg("attrName"), bp::arg("duration"), 
                 bp::arg("startValue"), bp::arg("endValue"), bp::arg("easeInDuration"), 
                 bp::arg("easeOutDuration"), bp::arg("useInt")=false,
                 bp::arg("startCallback")=object(), bp::arg("stopCallback")=object())))
        ;
   
    class_<ContinuousAnim, boost::shared_ptr<ContinuousAnim>, bases<AttrAnim>, 
            boost::noncopyable>("ContinuousAnim", no_init)
        .def(init<const object&, const std::string&, const object&, const object&, 
                optional<bool, const object&, const object&> >
                ((bp::arg("node"), bp::arg("attrName"), bp::arg("duration"), 
                 bp::arg("startValue"), bp::arg("speed"), bp::arg("useInt")=false,
                 bp::arg("startCallback")=object(), bp::arg("stopCallback")=object())))
        ;

    class_<WaitAnim, boost::shared_ptr<WaitAnim>, bases<Anim>, boost::noncopyable>(
            "WaitAnim", no_init)
        .def(init<optional<long long, const object&, const object&> >
                ((bp::arg("duration")=-1, bp::arg("startCallback")=object(),
                 bp::arg("stopCallback")=object())))
        .def("start", &WaitAnim::start, start_overloads(bp::args("bKeepAttr")))
        ;
    
    class_<ParallelAnim, boost::shared_ptr<ParallelAnim>, bases<Anim>, 
            boost::noncopyable>("ParallelAnim", no_init)
        .def(init<const std::vector<AnimPtr>&,
                optional<const object&, const object&, long long> >
                ((bp::arg("anims"), bp::arg("startCallback")=object(),
                 bp::arg("stopCallback")=object(), bp::arg("maxAge")=-1)))
        .def("start", &ParallelAnim::start, start_overloads(args("bKeepAttr")))
        ;
      
    class_<AnimState, boost::noncopyable>("AnimState", no_init)
        .def(init<const std::string&, AnimPtr, optional<const std::string&> >
                ((bp::arg("name"), bp::arg("anim"), bp::arg("nextName")="")))
        ;

    class_<StateAnim, boost::shared_ptr<StateAnim>, bases<Anim>, 
            boost::noncopyable>("StateAnim", init<const std::vector<AnimState>&>())
        .def("setState", &StateAnim::setState, setState_overloads(args("bKeepAttr")))
        .def("getState", make_function(&StateAnim::getState,
                return_value_policy<copy_const_reference>()))
        .def("setDebug", &StateAnim::setDebug) 
        ;

    def("fadeIn", fadeIn, (bp::arg("node"), bp::arg("duration"), bp::arg("max")=1.0, 
            bp::arg("stopCallback")=object()));

    def("fadeOut", fadeOut, (bp::arg("node"), bp::arg("duration"),
            bp::arg("stopCallback")=object()));

}