Merge "Added API flags into the control-wrapper files." into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / control-wrapper-impl.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali-toolkit/devel-api/controls/control-wrapper-impl.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/animation/animation.h>
23 #include <dali-toolkit/public-api/controls/control-impl.h>
24 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
25 #include <dali-toolkit/public-api/styling/style-manager.h>
26 #include <dali-toolkit/internal/styling/style-manager-impl.h>
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 namespace Internal
35 {
36
37 /*
38  * Implementation.
39  */
40
41 Dali::Toolkit::ControlWrapper ControlWrapper::New( ControlWrapper* controlWrapper )
42 {
43   ControlWrapperPtr wrapper( controlWrapper );
44
45   // Pass ownership to CustomActor via derived handle.
46   Dali::Toolkit::ControlWrapper handle( *wrapper );
47
48   // Second-phase initialisation of the implementation.
49   // This can only be done after the CustomActor connection has been made.
50   wrapper->Initialize();
51
52   return handle;
53 }
54
55 ControlWrapper::ControlWrapper( CustomControlBehaviour behaviourFlags )
56 : Control( static_cast< ControlBehaviour >( behaviourFlags ) )
57 {
58 }
59
60 ControlWrapper::~ControlWrapper()
61 {
62 }
63
64 void ControlWrapper::RelayoutRequest()
65 {
66   CustomActorImpl::RelayoutRequest();
67 }
68
69 float ControlWrapper::GetHeightForWidthBase( float width )
70 {
71   return CustomActorImpl::GetHeightForWidthBase( width );
72 }
73
74 float ControlWrapper::GetWidthForHeightBase( float height )
75 {
76   return CustomActorImpl::GetWidthForHeightBase( height );
77 }
78
79 float ControlWrapper::CalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension )
80 {
81   return CustomActorImpl::CalculateChildSizeBase( child, dimension );
82 }
83
84 bool ControlWrapper::RelayoutDependentOnChildrenBase( Dimension::Type dimension )
85 {
86   return CustomActorImpl::RelayoutDependentOnChildrenBase( dimension );
87 }
88
89 void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual )
90 {
91   Control::RegisterVisual( index, visual );
92 }
93
94 void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
95 {
96   Control::RegisterVisual( index, visual, enabled );
97 }
98
99 void ControlWrapper::UnregisterVisual( Property::Index index )
100 {
101   Control::UnregisterVisual( index );
102 }
103
104 Toolkit::Visual::Base ControlWrapper::GetVisual( Property::Index index ) const
105 {
106   return Control::GetVisual( index );
107 }
108
109 void ControlWrapper::EnableVisual( Property::Index index, bool enable )
110 {
111   Control::EnableVisual( index, enable );
112 }
113
114 bool ControlWrapper::IsVisualEnabled( Property::Index index ) const
115 {
116   return Control::IsVisualEnabled( index );
117 }
118
119 Dali::Animation ControlWrapper::CreateTransition( const Toolkit::TransitionData& handle )
120 {
121   return Control::CreateTransition( handle );
122 }
123
124 void ControlWrapper::ApplyThemeStyle()
125 {
126   Toolkit::StyleManager styleManager = StyleManager::Get();
127
128   // if style manager is available
129   if( styleManager )
130   {
131     StyleManager& styleManagerImpl = GetImpl( styleManager );
132
133     // Apply the current style
134     styleManagerImpl.ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
135   }
136 }
137
138 } // namespace Internal
139
140 } // namespace Toolkit
141
142 } // namespace Dali