Add support for Animation::EndAction::BakeFinal to builder
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / builder / builder-control.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // EXTERNAL INCLUDES
18 #include <string>
19
20 // INTERNAL INCLUDES
21 #include <dali-toolkit/internal/builder/builder-get-is.inl.h>
22 #include <dali-toolkit/public-api/controls/control.h>
23 #include <dali-toolkit/public-api/controls/alignment/alignment.h>
24 #include <dali/public-api/scripting/scripting.h>
25
26 namespace // unnamed namespace
27 {
28
29 using namespace Dali;
30 using namespace Dali::Toolkit;
31 using namespace Dali::Scripting; // SetIfEqual
32
33 Control::SizePolicy GetSizePolicy( const std::string& value )
34 {
35   Control::SizePolicy v(Control::Flexible);
36
37   bool set = \
38     SetIfEqual(value, "FIXED",    v, Control::Fixed    ) || \
39     SetIfEqual(value, "MINIMUM",  v, Control::Minimum  ) || \
40     SetIfEqual(value, "MAXIMUM",  v, Control::Maximum  ) || \
41     SetIfEqual(value, "RANGE",    v, Control::Range    ) || \
42     SetIfEqual(value, "FLEXIBLE", v, Control::Flexible );
43
44   if( !set )
45   {
46     DALI_ASSERT_ALWAYS( !"Unknown Color mode" );
47   }
48
49   return v;
50 }
51
52 } // anon namespace
53
54
55 namespace Dali
56 {
57
58 namespace Toolkit
59 {
60
61 namespace Internal
62 {
63
64 /*
65  * Handles special case control configuration (anything thats not already a property)
66  *
67  */
68 Dali::Toolkit::Control SetupControl( const TreeNode& child, Dali::Toolkit::Control& control )
69 {
70   DALI_ASSERT_ALWAYS( control && "Empty actor handle" );
71
72   Control::SizePolicy widthPolicy(Control::Flexible);
73   Control::SizePolicy heightPolicy(Control::Flexible);
74
75   if( OptionalString v = IsString(child, "width-policy") )
76   {
77     widthPolicy = GetSizePolicy(*v);
78     control.SetSizePolicy( widthPolicy, heightPolicy );
79   }
80
81   if( OptionalString v = IsString(child, "height-policy") )
82   {
83     heightPolicy = GetSizePolicy(*v);
84     control.SetSizePolicy( widthPolicy, heightPolicy );
85   }
86
87   if( OptionalVector3 v = IsVector3(child, "minimum-size") )
88   {
89     control.SetMinimumSize( *v );
90   }
91
92   if( OptionalVector3 v = IsVector3(child, "maximum-size") )
93   {
94     control.SetMaximumSize( *v );
95   }
96
97   if( OptionalBoolean v = IsBoolean(child, "key-input-focus") )
98   {
99     if( *v )
100     {
101       control.SetKeyInputFocus();
102     }
103   }
104
105   return control;
106 }
107
108 } // namespace Internal
109
110 } // namespace Toolkit
111
112 } // namespace Dali