2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 // http://floralicense.org/license/
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.
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>
26 namespace // unnamed namespace
30 using namespace Dali::Toolkit;
31 using namespace Dali::Scripting; // SetIfEqual
33 Control::SizePolicy GetSizePolicy( const std::string& value )
35 Control::SizePolicy v(Control::Flexible);
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 );
46 DALI_ASSERT_ALWAYS( !"Unknown Color mode" );
65 * Handles special case control configuration (anything thats not already a property)
68 Dali::Toolkit::Control SetupControl( const TreeNode& child, Dali::Toolkit::Control& control )
70 DALI_ASSERT_ALWAYS( control && "Empty actor handle" );
72 Control::SizePolicy widthPolicy(Control::Flexible);
73 Control::SizePolicy heightPolicy(Control::Flexible);
75 if( OptionalString v = IsString(child, "width-policy") )
77 widthPolicy = GetSizePolicy(*v);
78 control.SetSizePolicy( widthPolicy, heightPolicy );
81 if( OptionalString v = IsString(child, "height-policy") )
83 heightPolicy = GetSizePolicy(*v);
84 control.SetSizePolicy( widthPolicy, heightPolicy );
87 if( OptionalVector3 v = IsVector3(child, "minimum-size") )
89 control.SetMinimumSize( *v );
92 if( OptionalVector3 v = IsVector3(child, "maximum-size") )
94 control.SetMaximumSize( *v );
97 if( OptionalBoolean v = IsBoolean(child, "key-input-focus") )
101 control.SetKeyInputFocus();
108 } // namespace Internal
110 } // namespace Toolkit