[3.0] Added a simple application for testing Styling
[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-toolkit/public-api/controls/control-impl.h>
22 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
23
24 namespace Demo
25 {
26
27 namespace Internal // To use TypeRegistry, handle and body classes need the same name
28 {
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 public:  // Properties
47   /**
48    * Called when a property of an object of this type is set.
49    * @param[in] object The object whose property is set.
50    * @param[in] index The property index.
51    * @param[in] value The new property value.
52    */
53   static void SetProperty( Dali::BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value );
54
55   /**
56    * Called to retrieve a property of an object of this type.
57    * @param[in] object The object whose property is to be retrieved.
58    * @param[in] index The property index.
59    * @return The current value of the property.
60    */
61   static Dali::Property::Value GetProperty( Dali::BaseObject* object, Dali::Property::Index propertyIndex );
62
63 private: // From Control
64   /**
65    * @copydoc Toolkit::Control::OnInitialize()
66    */
67   virtual void OnInitialize();
68
69   /**
70    * @copydoc Toolkit::Control::OnStageConnect()
71    */
72   virtual void OnStageConnection( int depth );
73
74   /**
75    * @copydoc Toolkit::Control::OnStageDisconnection()
76    */
77   virtual void OnStageDisconnection();
78
79   /**
80    * @copydoc Toolkit::Control::OnSizeSet()
81    */
82   virtual void OnSizeSet( const Dali::Vector3& targetSize );
83
84   /**
85    * @copydoc Toolkit::Control::GetNaturalSize
86    */
87   virtual Dali::Vector3 GetNaturalSize();
88
89 private:
90   //undefined
91   ImageChannelControl( const ImageChannelControl& );
92   ImageChannelControl& operator=( const ImageChannelControl& );
93
94 private:
95   // Implementation details
96   std::string mUrl;
97   Dali::Toolkit::Visual::Base mVisual;
98   Dali::Vector3 mChannels;
99   Dali::Property::Index mChannelIndex;
100 };
101
102 } // Internal
103
104 inline Internal::ImageChannelControl& GetImpl( Demo::ImageChannelControl& handle )
105 {
106   DALI_ASSERT_ALWAYS( handle );
107   Dali::RefObject& object = handle.GetImplementation();
108   return static_cast<Internal::ImageChannelControl&>(object);
109 }
110
111 inline const Internal::ImageChannelControl& GetImpl( const Demo::ImageChannelControl& handle )
112 {
113   DALI_ASSERT_ALWAYS( handle );
114   const Dali::RefObject& object = handle.GetImplementation();
115   return static_cast<const Internal::ImageChannelControl&>(object);
116 }
117
118 } // Demo
119
120 #endif //  DALI_DEMO_IMAGE_CHANNEL_CONTROL_IMPL_H