2 * Copyright (c) 2015 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.
19 #include "check-button-factory.h"
22 #include <dali/public-api/actors/image-actor.h>
23 #include <dali/public-api/images/resource-image.h>
26 #include <dali-toolkit/public-api/controls/alignment/alignment.h>
37 Alignment CreateAlignedImage( Actor image )
39 Alignment alignmentContainer = Toolkit::Alignment::New();
40 alignmentContainer.SetScaling( Toolkit::Alignment::ShrinkToFitKeepAspect );
42 alignmentContainer.Add( image );
44 return alignmentContainer;
47 Alignment CreateAlignedImage( const std::string& imagePath )
49 Image image = ResourceImage::New( imagePath );
51 return CreateAlignedImage( ImageActor::New( image ) );
57 CheckBoxButton CreateCheckBoxButton( const std::string& backgroundImagePath, const std::string& selectedImagePath, const std::string& disabledBackgroundImagePath, const std::string& disabledSelectedImagePath )
59 CheckBoxButton button = Toolkit::CheckBoxButton::New();
61 if( !backgroundImagePath.empty() )
63 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
66 if( !selectedImagePath.empty() )
68 button.SetSelectedImage( CreateAlignedImage( selectedImagePath ) );
71 if( !disabledBackgroundImagePath.empty() )
73 button.SetDisabledBackgroundImage( CreateAlignedImage( disabledBackgroundImagePath ) );
76 if( !disabledSelectedImagePath.empty() )
78 button.SetDisabledSelectedImage( CreateAlignedImage( disabledSelectedImagePath ) );
84 CheckBoxButton CreateCheckBoxButton( Actor backgroundImageActor, Actor selectedImageActor, Actor disabledBackgroundImageActor, Actor disabledSelectedImagActor )
86 CheckBoxButton button = Toolkit::CheckBoxButton::New();
88 if( backgroundImageActor )
90 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
93 if( selectedImageActor )
95 button.SetSelectedImage( CreateAlignedImage( selectedImageActor ) );
98 if( disabledBackgroundImageActor )
100 button.SetDisabledBackgroundImage( CreateAlignedImage( disabledBackgroundImageActor ) );
103 if( disabledSelectedImagActor )
105 button.SetDisabledSelectedImage( CreateAlignedImage( disabledSelectedImagActor ) );
111 CheckBoxButton CreateCheckBoxButton( const std::string& backgroundImagePath, const std::string& selectedImagePath )
113 CheckBoxButton button = Toolkit::CheckBoxButton::New();
115 if( !backgroundImagePath.empty() )
117 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
120 if( !selectedImagePath.empty() )
122 button.SetSelectedImage( CreateAlignedImage( selectedImagePath ) );
128 CheckBoxButton CreateCheckBoxButton( Actor backgroundImageActor, Actor selectedImageActor )
130 CheckBoxButton button = Toolkit::CheckBoxButton::New();
132 if( backgroundImageActor )
134 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
137 if( selectedImageActor )
139 button.SetSelectedImage( CreateAlignedImage( selectedImageActor ) );
145 } // namespace Toolkit