Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUiCtrl_FlickAnimation.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FUiCtrl_FlickAnimation.h
20  * @brief       This is the header file for the _FlickAnimation class.
21  *
22  * This header file contains the declarations of the _FlickAnimation class.
23  */
24
25 #ifndef _FUI_CTRL_INTERNAL_FLICKANIMATION_H_
26 #define _FUI_CTRL_INTERNAL_FLICKANIMATION_H_
27
28 const int DEVICE_SIZE_HORIZONTAL = 56;                          // LCD Width (mm)
29 const int DEVICE_SIZE_VERTICAL = 93;                            // LCD Hight (mm)
30 const int FLICK_ANIMATION_FPS_LIST = 300;                       // List FPS
31 const int FLICK_ANIMATION_SENSITIVITY_LIST = 150;       // List Animation Sensitivity
32 const int FLICK_ANIMATION_FPS_ICONLIST = 60;            // IconList FPS
33 const int FLICK_ANIMATION_SENSITIVITY_ICONLIST = 30;// IconList Animation Sensitivity
34 const int FLICK_ANIMATION_FPS_PANEL = 30;                       // Panel FPS
35 const int FLICK_ANIMATION_SENSITIVITY_PANEL = 30;       // Panel Animation Sensitivity
36
37
38 namespace Tizen { namespace Ui { namespace Controls
39 {
40
41 enum FlickDir
42 {
43         FD_VERTICAL = 0x1,
44         FD_HORIZONTAL = 0x2,
45         FD_BOTH = FD_VERTICAL | FD_HORIZONTAL,
46 };
47
48 class _FlickAnimation
49 {
50 public:
51         _FlickAnimation(void);
52
53         virtual ~_FlickAnimation(void);
54
55         // Functions for Setting Parameter
56         void SetSizeInformation(int resW, int resH, int mmW, int mmH);
57
58         void SetAlignInformation(int alignW, int alignH);
59
60         void SetSensitivity(int fps, int sensitivity);
61
62         void SetDirection(int dir);
63
64         void SetTensionEnable(bool enableX, bool enableY);
65
66         // Check Item Executable or not
67         bool IsItemExecutable(int flickX, int flickY);
68
69         // Functions For Initializeialization of Flick Animation
70         void CalculateInitializeVelocity(int flickX, int flickY, int flickTime, int* pFlkVelX, int* pFlkVelY);
71
72         int EstimateInitializeVelocity(int totalDist, int idx = 1);
73
74         // Functions For Flick Animation
75         void InitializeFlickAmount(int flkVelX, int flkVelY);
76
77         int CalculateNextMove(int* pMoveX, int* pMoveY);
78
79         // For Legacy : Functions For Flick Animation
80         void InitializeFlickAmount(int flkVel);
81
82         int CalculateNextMove(void);
83
84         bool StartTensionEffect(int pos, int end, int idx = 1);
85
86         // Functions for Getting State Value
87         int GetCurVelocity(int idx = 1) const;
88
89         int GetCurFriction(int idx = 1) const;
90
91 private:
92         void InitializeFlick(int flkVelX, int flkVelY);
93
94         void InitializeFlickXY(int flkVel, int idx);
95
96         int CalculateNextMoveXY(int idx);
97
98         void InitializeTension(void);
99
100 private:
101         // Tuning Parameter
102         static const int FLK_ANI_TIME_MIN_MSEC = 1500;          // Minimum Animation Duration
103         static const int FLK_ANI_TIME_MAX_MSEC = 3000;          // Maximum Animation Duration
104         static const int FLK_ANI_DEFAULT_ALIGN_RATIO = 6;       // Default Item Counts for Virtual Align Height
105         static const int FLK_ANI_OVERSPEED_START_CNT = 1;       // Overspeed starting draw count
106         static const int FLK_ANI_OVERSPEED_END_CNT = 14;        // Overspeed ending draw count
107         static const int FLK_WEIGHT_VEL = 1;                            // Flick Velocity weight
108         static const int FLK_WEIGHT_DIST = 5;//20                       // Flick Distance weight
109         static const int FLK_ALPHA_PER_MM = 240;                        // mm - Flick Coefficient
110         static const int FLK_ALPHA_PER_PIXEL = 3;                       // pixel - Flick Coefficient
111         static const int FLK_ANI_SPEED_MIN_RATIO = 5;           // Flick Animation Minimum Speed Ratio (Vmin=Vmax/Ratio)
112         static const int FLK_SPEED_MIN = 400;                           // Minimum Flick Speed for Stage 1
113         static const int FLK_SPEED_THRES1 = 2400;                       // Flick Speed Threshold for Stage 2
114         static const int FLK_SPEED_THRES2 = 3000;                       // Flick Speed Threshold for Stage 3 (Overspeed applied)
115         static const int FLK_OVERSPEED_STEP = 800;                      // Acceleration Step for Overspeed
116
117         int __flickDirection;       // Flick Direction
118         int __dimension[2];             // Width/Height Dimension (mm)
119         int __resolution[2];        // Width/Height Resolution (pixel)
120         int __align[2];             // Align Width/Height Resolution (pixel)
121         int __margin[2];            // Margin Width/Height Resolution (pixel)
122
123         int __flickAnimationFPS;
124         int __flickAnimationFPSRef;
125         int __flickAnimaionTimeMin;
126         int __flickAnimationTimeMax;
127
128         int __friction[2];          // Friction Coefficient
129         int __velocity[2];          // Animation Velocity
130
131         int __frictionMin[2];       // Minimum Friction Coefficient near Stop
132         int __velocityMin[2];       // Minimum Animation Velocity near Stop
133
134         int __acceleration[2];      // Animation Acceleration Coefficient
135         int __drawCount;            // Drawing Count
136
137         enum
138         {
139                 TENSION_NA = 0,
140                 TENSION_DONE,
141                 TENSION_COMPRESS,
142                 TENSION_RELEASE
143         }
144
145         __tensionStatus[2];                                                                          // Tension Effect Status
146         int __tensionDistMax[2];    // Maximum Distance for Tension Effect
147 }; // _FlickAnimation
148
149 }}} // Tizen::Ui::Controls
150
151 #endif // _FUI_CTRL_INTERNAL_FLICKANIMATION_H_