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>
22 #include <dali/public-api/images/resource-image.h>
25 #include <dali-toolkit/public-api/controls/alignment/alignment.h>
36 Alignment CreateAlignedImage( Actor image )
38 Alignment alignmentContainer = Toolkit::Alignment::New();
39 alignmentContainer.SetScaling( Toolkit::Alignment::ShrinkToFitKeepAspect );
41 alignmentContainer.Add( image );
43 return alignmentContainer;
46 Alignment CreateAlignedImage( const std::string& imagePath )
48 Image image = ResourceImage::New( imagePath );
50 return CreateAlignedImage( ImageActor::New( image ) );
56 CheckBoxButton CreateCheckBoxButton( const std::string& backgroundImagePath, const std::string& selectedImagePath, const std::string& disabledBackgroundImagePath, const std::string& disabledSelectedImagePath )
58 CheckBoxButton button = Toolkit::CheckBoxButton::New();
60 if( !backgroundImagePath.empty() )
62 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
65 if( !selectedImagePath.empty() )
67 button.SetSelectedImage( CreateAlignedImage( selectedImagePath ) );
70 if( !disabledBackgroundImagePath.empty() )
72 button.SetDisabledBackgroundImage( CreateAlignedImage( disabledBackgroundImagePath ) );
75 if( !disabledSelectedImagePath.empty() )
77 button.SetDisabledSelectedImage( CreateAlignedImage( disabledSelectedImagePath ) );
83 CheckBoxButton CreateCheckBoxButton( Actor backgroundImageActor, Actor selectedImageActor, Actor disabledBackgroundImageActor, Actor disabledSelectedImagActor )
85 CheckBoxButton button = Toolkit::CheckBoxButton::New();
87 if( backgroundImageActor )
89 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
92 if( selectedImageActor )
94 button.SetSelectedImage( CreateAlignedImage( selectedImageActor ) );
97 if( disabledBackgroundImageActor )
99 button.SetDisabledBackgroundImage( CreateAlignedImage( disabledBackgroundImageActor ) );
102 if( disabledSelectedImagActor )
104 button.SetDisabledSelectedImage( CreateAlignedImage( disabledSelectedImagActor ) );
110 CheckBoxButton CreateCheckBoxButton( const std::string& backgroundImagePath, const std::string& selectedImagePath )
112 CheckBoxButton button = Toolkit::CheckBoxButton::New();
114 if( !backgroundImagePath.empty() )
116 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
119 if( !selectedImagePath.empty() )
121 button.SetSelectedImage( CreateAlignedImage( selectedImagePath ) );
127 CheckBoxButton CreateCheckBoxButton( Actor backgroundImageActor, Actor selectedImageActor )
129 CheckBoxButton button = Toolkit::CheckBoxButton::New();
131 if( backgroundImageActor )
133 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
136 if( selectedImageActor )
138 button.SetSelectedImage( CreateAlignedImage( selectedImageActor ) );
144 } // namespace Toolkit