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.
19 #include <dali-toolkit/public-api/controls/default-controls/push-button-factory.h>
22 #include <dali/public-api/actors/image-actor.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 = Image::New( imagePath );
49 return CreateAlignedImage( ImageActor::New( image ) );
55 PushButton CreatePushButton( const std::string& unselectedImagePath, const std::string& selectedImagePath, const std::string& backgroundImagePath,
56 const std::string& disabledUnselectedImagePath, const std::string& disabledBackgroundImagePath )
58 PushButton button = Toolkit::PushButton::New();
60 if( !unselectedImagePath.empty() )
62 button.SetButtonImage( CreateAlignedImage( unselectedImagePath ) );
65 if( !selectedImagePath.empty() )
67 button.SetSelectedImage( CreateAlignedImage( selectedImagePath ) );
70 if( !backgroundImagePath.empty() )
72 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
75 if( !disabledUnselectedImagePath.empty() )
77 button.SetDisabledImage( CreateAlignedImage( disabledUnselectedImagePath ) );
80 if( !disabledBackgroundImagePath.empty() )
82 button.SetDisabledBackgroundImage( CreateAlignedImage( disabledBackgroundImagePath ) );
88 PushButton CreatePushButton( Actor unselectedImageActor, Actor selectedImageActor, Actor backgroundImageActor,
89 Actor disabledUnselectedImageActor, Actor disabledBackgroundImageActor )
91 PushButton button = Toolkit::PushButton::New();
93 if( unselectedImageActor )
95 button.SetButtonImage( CreateAlignedImage( unselectedImageActor ) );
98 if( selectedImageActor )
100 button.SetSelectedImage( CreateAlignedImage( selectedImageActor ) );
103 if( backgroundImageActor )
105 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
108 if( disabledUnselectedImageActor )
110 button.SetDisabledImage( CreateAlignedImage( disabledUnselectedImageActor ) );
113 if( disabledBackgroundImageActor )
115 button.SetDisabledBackgroundImage( CreateAlignedImage( disabledBackgroundImageActor ) );
121 PushButton CreatePushButton( const std::string& backgroundImagePath )
123 PushButton button = Toolkit::PushButton::New();
125 if( !backgroundImagePath.empty() )
127 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
133 PushButton CreatePushButton( Actor backgroundImageActor )
135 PushButton button = Toolkit::PushButton::New();
137 if( backgroundImageActor )
139 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
145 } // namespace Toolkit