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