Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SD_SLIDESORTER_CONTROLLER_ANIMATION_FUNCTION_HXX
30 : : #define SD_SLIDESORTER_CONTROLLER_ANIMATION_FUNCTION_HXX
31 : :
32 : : #include "model/SlsSharedPageDescriptor.hxx"
33 : : #include <basegfx/point/b2dpoint.hxx>
34 : : #include <boost/noncopyable.hpp>
35 : : #include <boost/function.hpp>
36 : : #include <tools/gen.hxx>
37 : : #include <vector>
38 : :
39 : : namespace sd { namespace slidesorter { namespace view {
40 : : class SlideSorterView;
41 : : } } }
42 : :
43 : :
44 : :
45 : : namespace sd { namespace slidesorter { namespace controller {
46 : :
47 : : /** A collection of functions that are usefull when creating animations.
48 : : They are collected here until a better place is found.
49 : : */
50 : : class AnimationFunction
51 : : : private ::boost::noncopyable
52 : : {
53 : : public:
54 : : /** Acceleration function that maps [0,1] to [0,1] linearly, ie it
55 : : returns the given time value unaltered.
56 : : */
57 : : static double Linear (const double nTime);
58 : :
59 : : /** Blend two points together according to the given weight.
60 : : */
61 : : static double Blend (const double nStartValue, const double nEndValue, const double nWeight);
62 : :
63 : : /** Apply a gradual change the alpha value from the old value to a
64 : : new value (set prior to this call.)
65 : : */
66 : : static void ApplyButtonAlphaChange(
67 : : const model::SharedPageDescriptor& rpDescriptor,
68 : : view::SlideSorterView& rView,
69 : : const double nButtonAlpha,
70 : : const double nButtonBarAlpha);
71 : : };
72 : :
73 : :
74 : :
75 : :
76 : : class AnimationBezierFunction
77 : : {
78 : : public:
79 : : /** Create a cubic bezier curve whose start and end points are given
80 : : implicitly as P0=(0,0) and P3=(1,1). The second control point is
81 : : implicitly given as P2=(1-nY1,1-nX1).
82 : : */
83 : : AnimationBezierFunction (
84 : : const double nX1,
85 : : const double nY1);
86 : :
87 : : ::basegfx::B2DPoint operator() (const double nT);
88 : :
89 : : private:
90 : : const double mnX1;
91 : : const double mnY1;
92 : : const double mnX2;
93 : : const double mnY2;
94 : :
95 : : double EvaluateComponent (
96 : : const double nT,
97 : : const double nV1,
98 : : const double nV2);
99 : : };
100 : :
101 : :
102 : :
103 : :
104 : : /** Turn a parametric function into one whose y-Values depend on its
105 : : x-Values. Note a lot of interpolation takes place. The resulting
106 : : accuracy should be good enough for the purpose of acceleration
107 : : function for animations.
108 : : */
109 : 0 : class AnimationParametricFunction
110 : : {
111 : : public:
112 : : typedef ::boost::function<basegfx::B2DPoint(double)> ParametricFunction;
113 : : AnimationParametricFunction (const ParametricFunction& rFunction);
114 : :
115 : : double operator() (const double nX);
116 : :
117 : : private:
118 : : /** y-Values of the parametric function given to the constructor
119 : : evaluated (and interpolated) for evenly spaced x-Values.
120 : : */
121 : : ::std::vector<double> maY;
122 : : };
123 : :
124 : :
125 : :
126 : :
127 : : } } } // end of namespace ::sd::slidesorter::controller
128 : :
129 : : #endif
130 : :
131 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|