Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-demo.git] / examples / styling / image-channel-control-impl.h
1 #ifndef DALI_DEMO_INTERNAL_IMAGE_CHANNEL_CONTROL_IMPL_H
2 #define DALI_DEMO_INTERNAL_IMAGE_CHANNEL_CONTROL_IMPL_H
3
4 /*
5  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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 "image-channel-control.h"
21 #include <dali/public-api/animation/animation.h>
22 #include <dali-toolkit/public-api/controls/control-impl.h>
23 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
24 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
25
26 namespace Demo
27 {
28
29 namespace Internal // To use TypeRegistry, handle and body classes need the same name
30 {
31
32 class ImageChannelControl : public Dali::Toolkit::Internal::Control
33 {
34 public:
35   /**
36    * Instantiate a new ImageChannelControl object
37    */
38   static Demo::ImageChannelControl New();
39   ImageChannelControl();
40   ~ImageChannelControl();
41
42 public: // API
43   /**
44    * @copydoc ImageChannelControl::SetImage
45    */
46   void SetImage( const std::string& url );
47
48   /**
49    * @copydoc ImageChannelControl::SetVisibility
50    */
51   void SetVisibility( bool visibility );
52
53 public:  // Properties
54   /**
55    * Called when a property of an object of this type is set.
56    * @param[in] object The object whose property is set.
57    * @param[in] index The property index.
58    * @param[in] value The new property value.
59    */
60   static void SetProperty( Dali::BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value );
61
62   /**
63    * Called to retrieve a property of an object of this type.
64    * @param[in] object The object whose property is to be retrieved.
65    * @param[in] index The property index.
66    * @return The current value of the property.
67    */
68   static Dali::Property::Value GetProperty( Dali::BaseObject* object, Dali::Property::Index propertyIndex );
69
70 private: // From Control
71   /**
72    * @copydoc Toolkit::Control::OnInitialize()
73    */
74   virtual void OnInitialize();
75
76   /**
77    * @copydoc Toolkit::Control::OnStageConnect()
78    */
79   virtual void OnStageConnection( int depth );
80
81   /**
82    * @copydoc Toolkit::Control::OnStageDisconnection()
83    */
84   virtual void OnStageDisconnection();
85
86   /**
87    * @copydoc Toolkit::Control::OnSizeSet()
88    */
89   virtual void OnSizeSet( const Dali::Vector3& targetSize );
90
91   /**
92    * @copydoc Toolkit::Control::GetNaturalSize
93    */
94   virtual Dali::Vector3 GetNaturalSize();
95
96   /**
97    * @copydoc Toolkit::Control::OnStyleChange
98    */
99   virtual void OnStyleChange( Dali::Toolkit::StyleManager styleManager, Dali::StyleChange::Type change );
100
101 private:
102   void OnStateChangeAnimationFinished(Dali::Animation& handle);
103
104 private:
105   //undefined
106   ImageChannelControl( const ImageChannelControl& );
107   ImageChannelControl& operator=( const ImageChannelControl& );
108
109 private:
110   // Implementation details
111   std::string mUrl;
112   Dali::Toolkit::Visual::Base mVisual;
113   Dali::Vector3 mChannels;
114   Dali::Toolkit::TransitionData mEnableVisibilityTransition;
115   Dali::Toolkit::TransitionData mDisableVisibilityTransition;
116   Dali::Animation mAnimation;
117   Dali::Property::Index mChannelIndex;
118   bool mVisibility:1;
119   bool mTargetVisibility:1;
120 };
121
122 } // Internal
123
124 inline Internal::ImageChannelControl& GetImpl( Demo::ImageChannelControl& handle )
125 {
126   DALI_ASSERT_ALWAYS( handle );
127   Dali::RefObject& object = handle.GetImplementation();
128   return static_cast<Internal::ImageChannelControl&>(object);
129 }
130
131 inline const Internal::ImageChannelControl& GetImpl( const Demo::ImageChannelControl& handle )
132 {
133   DALI_ASSERT_ALWAYS( handle );
134   const Dali::RefObject& object = handle.GetImplementation();
135   return static_cast<const Internal::ImageChannelControl&>(object);
136 }
137
138 } // Demo
139
140 #endif //  DALI_DEMO_IMAGE_CHANNEL_CONTROL_IMPL_H