2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include "check-button-factory.h"
21 #include <dali/public-api/actors/image-actor.h>
24 #include <dali-toolkit/public-api/controls/alignment/alignment.h>
35 Alignment CreateAlignedImage( Actor image )
37 Alignment alignmentContainer = Toolkit::Alignment::New();
38 alignmentContainer.SetScaling( Toolkit::Alignment::ShrinkToFitKeepAspect );
40 alignmentContainer.Add( image );
42 return alignmentContainer;
45 Alignment CreateAlignedImage( const std::string& imagePath )
47 Image image = Image::New( imagePath );
49 return CreateAlignedImage( ImageActor::New( image ) );
55 CheckBoxButton CreateCheckBoxButton( const std::string& backgroundImagePath, const std::string& checkedImagePath, const std::string& disabledBackgroundImagePath, const std::string& disabledCheckedImagePath )
57 CheckBoxButton button = Toolkit::CheckBoxButton::New();
59 if( !backgroundImagePath.empty() )
61 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
64 if( !checkedImagePath.empty() )
66 button.SetCheckedImage( CreateAlignedImage( checkedImagePath ) );
69 if( !disabledBackgroundImagePath.empty() )
71 button.SetDisabledBackgroundImage( CreateAlignedImage( disabledBackgroundImagePath ) );
74 if( !disabledCheckedImagePath.empty() )
76 button.SetDisabledCheckedImage( CreateAlignedImage( disabledCheckedImagePath ) );
82 CheckBoxButton CreateCheckBoxButton( Actor backgroundImageActor, Actor checkedImageActor, Actor disabledBackgroundImageActor, Actor disabledCheckedImagActor )
84 CheckBoxButton button = Toolkit::CheckBoxButton::New();
86 if( backgroundImageActor )
88 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
91 if( checkedImageActor )
93 button.SetCheckedImage( CreateAlignedImage( checkedImageActor ) );
96 if( disabledBackgroundImageActor )
98 button.SetDisabledBackgroundImage( CreateAlignedImage( disabledBackgroundImageActor ) );
101 if( disabledCheckedImagActor )
103 button.SetDisabledCheckedImage( CreateAlignedImage( disabledCheckedImagActor ) );
109 CheckBoxButton CreateCheckBoxButton( const std::string& backgroundImagePath, const std::string& checkedImagePath )
111 CheckBoxButton button = Toolkit::CheckBoxButton::New();
113 if( !backgroundImagePath.empty() )
115 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
118 if( !checkedImagePath.empty() )
120 button.SetCheckedImage( CreateAlignedImage( checkedImagePath ) );
126 CheckBoxButton CreateCheckBoxButton( Actor backgroundImageActor, Actor checkedImageActor )
128 CheckBoxButton button = Toolkit::CheckBoxButton::New();
130 if( backgroundImageActor )
132 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
135 if( checkedImageActor )
137 button.SetCheckedImage( CreateAlignedImage( checkedImageActor ) );
143 } // namespace Toolkit