Added radial menu demo
[platform/core/uifw/dali-demo.git] / examples / radial-menu / radial-sweep-view-impl.h
1 #ifndef DALI_DEMO_RADIAL_SWEEP_VIEW_IMPL_H
2 #define DALI_DEMO_RADIAL_SWEEP_VIEW_IMPL_H
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.0 (the License);
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //     http://floralicense.org/license/
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an AS IS BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19
20 #include <dali-toolkit/dali-toolkit.h>
21 #include "radial-sweep-view.h"
22
23
24 /********************************************************************************
25  * Class to implement a layer with a radial sweep stencil mask and an actor tree
26  */
27 class RadialSweepViewImpl : public Dali::Toolkit::Internal::Control
28 {
29 public:
30   static RadialSweepView New();
31
32   static RadialSweepView New( float duration,
33                               float diameter,
34                               Dali::Degree initialAngle,
35                               Dali::Degree finalAngle,
36                               Dali::Degree initialSector,
37                               Dali::Degree finalSector );
38
39   RadialSweepViewImpl( float duration,
40                        float diameter,
41                        Dali::Degree initialAngle,
42                        Dali::Degree finalAngle,
43                        Dali::Degree initialSector,
44                        Dali::Degree finalSector );
45
46   void SetDuration(float duration);
47   void SetEasingFunction( Dali::AlphaFunction easingFunction );
48
49   void SetDiameter(float diameter);
50   void SetInitialAngle( Dali::Degree initialAngle);
51   void SetFinalAngle( Dali::Degree finalAngle);
52   void SetInitialSector( Dali::Degree initialSector);
53   void SetFinalSector( Dali::Degree finalSector);
54   void SetInitialActorAngle( Dali::Degree initialAngle );
55   void SetFinalActorAngle( Dali::Degree finalAngle );
56
57   float GetDuration( );
58   float GetDiameter( );
59   Dali::Degree GetInitialAngle( );
60   Dali::Degree GetFinalAngle( );
61   Dali::Degree GetInitialSector( );
62   Dali::Degree GetFinalSector( );
63   Dali::Degree GetInitialActorAngle( );
64   Dali::Degree GetFinalActorAngle( );
65
66   void RotateActorsWithStencil(bool rotate);
67
68   void Add( Dali::Actor actor );
69
70   void Activate( Dali::Animation anim = Dali::Animation(), float offsetTime=0, float duration=2.0f );
71
72   void Deactivate();
73
74 private:
75
76   /**
77    * Create the stencil mask
78    */
79   void CreateStencil(Dali::Degree initialSector );
80
81 private:
82   Dali::Layer           mLayer;
83   Dali::Animation       mAnim;
84   float                 mDuration;
85   float                 mDiameter;
86   Dali::Degree          mInitialAngle;
87   Dali::Degree          mFinalAngle;
88   Dali::Degree          mInitialSector;
89   Dali::Degree          mFinalSector;
90   Dali::Degree          mInitialActorAngle;
91   Dali::Degree          mFinalActorAngle;
92   Dali::AlphaFunction   mEasingFunction;
93   Dali::MeshActor       mStencilActor;       ///< Stencil actor which generates mask
94   Dali::Material        mMaterial;           ///< Material for drawing mesh actor
95   Dali::AnimatableMesh  mMesh;               ///< Animatable mesh
96   Dali::Property::Index mStartAngleIndex;    ///< Index of start-angle property
97   Dali::Property::Index mRotationAngleIndex; ///< Index of rotation-angle property
98   bool                  mRotateActorsWithStencil:1;
99   bool                  mRotateActors;
100 };
101
102
103 inline RadialSweepViewImpl& GetImpl( RadialSweepView& obj )
104 {
105   DALI_ASSERT_ALWAYS(obj);
106   Dali::RefObject& handle = obj.GetImplementation();
107   return static_cast<RadialSweepViewImpl&>(handle);
108 }
109
110 inline const RadialSweepViewImpl& GetImpl( const RadialSweepView& obj )
111 {
112   DALI_ASSERT_ALWAYS(obj);
113   const Dali::RefObject& handle = obj.GetImplementation();
114   return static_cast<const RadialSweepViewImpl&>(handle);
115 }
116
117
118
119 #endif // DALI_DEMO_RADIAL_SWEEP_VIEW_IMPL_H