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& releasedImagePath, const std::string& pressedImagePath, const std::string& backgroundImagePath,
56 const std::string& dimmedReleasedImagePath, const std::string& dimmedBackgroundImagePath )
58 PushButton button = Toolkit::PushButton::New();
60 if( !releasedImagePath.empty() )
62 button.SetButtonImage( CreateAlignedImage( releasedImagePath ) );
65 if( !pressedImagePath.empty() )
67 button.SetPressedImage( CreateAlignedImage( pressedImagePath ) );
70 if( !backgroundImagePath.empty() )
72 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
75 if( !dimmedReleasedImagePath.empty() )
77 button.SetDimmedImage( CreateAlignedImage( dimmedReleasedImagePath ) );
80 if( !dimmedBackgroundImagePath.empty() )
82 button.SetDimmedBackgroundImage( CreateAlignedImage( dimmedBackgroundImagePath ) );
88 PushButton CreatePushButton( Actor releasedImageActor, Actor pressedImageActor, Actor backgroundImageActor,
89 Actor dimmedReleasedImageActor, Actor dimmedBackgroundImageActor )
91 PushButton button = Toolkit::PushButton::New();
93 if( releasedImageActor )
95 button.SetButtonImage( CreateAlignedImage( releasedImageActor ) );
98 if( pressedImageActor )
100 button.SetPressedImage( CreateAlignedImage( pressedImageActor ) );
103 if( backgroundImageActor )
105 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
108 if( dimmedReleasedImageActor )
110 button.SetDimmedImage( CreateAlignedImage( dimmedReleasedImageActor ) );
113 if( dimmedBackgroundImageActor )
115 button.SetDimmedBackgroundImage( CreateAlignedImage( dimmedBackgroundImageActor ) );
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