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 <dali-toolkit/public-api/controls/alignment/alignment.h>
19 #include <dali-toolkit/public-api/controls/default-controls/push-button-factory.h>
34 Alignment CreateAlignedImage( Actor image )
36 Alignment alignmentContainer = Toolkit::Alignment::New();
37 alignmentContainer.SetScaling( Toolkit::Alignment::ShrinkToFitKeepAspect );
39 alignmentContainer.Add( image );
41 return alignmentContainer;
44 Alignment CreateAlignedImage( const std::string& imagePath )
46 Image image = Image::New( imagePath );
47 return CreateAlignedImage( ImageActor::New( image ) );
53 PushButton CreatePushButton( const std::string& releasedImagePath, const std::string& pressedImagePath, const std::string& backgroundImagePath,
54 const std::string& dimmedReleasedImagePath, const std::string& dimmedBackgroundImagePath )
56 PushButton button = Toolkit::PushButton::New();
58 if( !releasedImagePath.empty() )
60 button.SetButtonImage( CreateAlignedImage( releasedImagePath ) );
63 if( !pressedImagePath.empty() )
65 button.SetPressedImage( CreateAlignedImage( pressedImagePath ) );
68 if( !backgroundImagePath.empty() )
70 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
73 if( !dimmedReleasedImagePath.empty() )
75 button.SetDimmedImage( CreateAlignedImage( dimmedReleasedImagePath ) );
78 if( !dimmedBackgroundImagePath.empty() )
80 button.SetDimmedBackgroundImage( CreateAlignedImage( dimmedBackgroundImagePath ) );
86 PushButton CreatePushButton( Actor releasedImageActor, Actor pressedImageActor, Actor backgroundImageActor,
87 Actor dimmedReleasedImageActor, Actor dimmedBackgroundImageActor )
89 PushButton button = Toolkit::PushButton::New();
91 if( releasedImageActor )
93 button.SetButtonImage( CreateAlignedImage( releasedImageActor ) );
96 if( pressedImageActor )
98 button.SetPressedImage( CreateAlignedImage( pressedImageActor ) );
101 if( backgroundImageActor )
103 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
106 if( dimmedReleasedImageActor )
108 button.SetDimmedImage( CreateAlignedImage( dimmedReleasedImageActor ) );
111 if( dimmedBackgroundImageActor )
113 button.SetDimmedBackgroundImage( CreateAlignedImage( dimmedBackgroundImageActor ) );
119 PushButton CreatePushButton( const std::string& backgroundImagePath )
121 PushButton button = Toolkit::PushButton::New();
123 if( !backgroundImagePath.empty() )
125 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
131 PushButton CreatePushButton( Actor backgroundImageActor )
133 PushButton button = Toolkit::PushButton::New();
135 if( backgroundImageActor )
137 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
143 } // namespace Toolkit