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.
17 #include "check-button-factory.h"
22 #include <dali-toolkit/public-api/controls/alignment/alignment.h>
23 #include <dali/dali.h>
34 Alignment CreateAlignedImage( Actor image )
36 Alignment alignmentContainer = Toolkit::Alignment::New();
37 alignmentContainer.SetScaling( Toolkit::Alignment::ShrinkToFitKeepAspect );
39 alignmentContainer.Add( image );
41 return alignmentContainer;
44 Alignment CreateAlignedImage( const std::string& imagePath )
46 Image image = Image::New( imagePath );
48 return CreateAlignedImage( ImageActor::New( image ) );
54 CheckBoxButton CreateCheckBoxButton( const std::string& backgroundImagePath, const std::string& checkedImagePath, const std::string& dimmedBackgroundImagePath, const std::string& dimmedCheckedImagePath )
56 CheckBoxButton button = Toolkit::CheckBoxButton::New();
58 if( !backgroundImagePath.empty() )
60 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
63 if( !checkedImagePath.empty() )
65 button.SetCheckedImage( CreateAlignedImage( checkedImagePath ) );
68 if( !dimmedBackgroundImagePath.empty() )
70 button.SetDimmedBackgroundImage( CreateAlignedImage( dimmedBackgroundImagePath ) );
73 if( !dimmedCheckedImagePath.empty() )
75 button.SetDimmedCheckedImage( CreateAlignedImage( dimmedCheckedImagePath ) );
81 CheckBoxButton CreateCheckBoxButton( Actor backgroundImageActor, Actor checkedImageActor, Actor dimmedBackgroundImageActor, Actor dimmedCheckedImagActor )
83 CheckBoxButton button = Toolkit::CheckBoxButton::New();
85 if( backgroundImageActor )
87 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
90 if( checkedImageActor )
92 button.SetCheckedImage( CreateAlignedImage( checkedImageActor ) );
95 if( dimmedBackgroundImageActor )
97 button.SetDimmedBackgroundImage( CreateAlignedImage( dimmedBackgroundImageActor ) );
100 if( dimmedCheckedImagActor )
102 button.SetDimmedCheckedImage( CreateAlignedImage( dimmedCheckedImagActor ) );
108 CheckBoxButton CreateCheckBoxButton( const std::string& backgroundImagePath, const std::string& checkedImagePath )
110 CheckBoxButton button = Toolkit::CheckBoxButton::New();
112 if( !backgroundImagePath.empty() )
114 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
117 if( !checkedImagePath.empty() )
119 button.SetCheckedImage( CreateAlignedImage( checkedImagePath ) );
125 CheckBoxButton CreateCheckBoxButton( Actor backgroundImageActor, Actor checkedImageActor )
127 CheckBoxButton button = Toolkit::CheckBoxButton::New();
129 if( backgroundImageActor )
131 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
134 if( checkedImageActor )
136 button.SetCheckedImage( CreateAlignedImage( checkedImageActor ) );
142 } // namespace Toolkit