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 );
48 return CreateAlignedImage( ImageActor::New( image ) );
54 PushButton CreatePushButton( const std::string& releasedImagePath, const std::string& pressedImagePath, const std::string& backgroundImagePath,
55 const std::string& dimmedReleasedImagePath, const std::string& dimmedBackgroundImagePath )
57 PushButton button = Toolkit::PushButton::New();
59 if( !releasedImagePath.empty() )
61 button.SetButtonImage( CreateAlignedImage( releasedImagePath ) );
64 if( !pressedImagePath.empty() )
66 button.SetPressedImage( CreateAlignedImage( pressedImagePath ) );
69 if( !backgroundImagePath.empty() )
71 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
74 if( !dimmedReleasedImagePath.empty() )
76 button.SetDimmedImage( CreateAlignedImage( dimmedReleasedImagePath ) );
79 if( !dimmedBackgroundImagePath.empty() )
81 button.SetDimmedBackgroundImage( CreateAlignedImage( dimmedBackgroundImagePath ) );
87 PushButton CreatePushButton( Actor releasedImageActor, Actor pressedImageActor, Actor backgroundImageActor,
88 Actor dimmedReleasedImageActor, Actor dimmedBackgroundImageActor )
90 PushButton button = Toolkit::PushButton::New();
92 if( releasedImageActor )
94 button.SetButtonImage( CreateAlignedImage( releasedImageActor ) );
97 if( pressedImageActor )
99 button.SetPressedImage( CreateAlignedImage( pressedImageActor ) );
102 if( backgroundImageActor )
104 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
107 if( dimmedReleasedImageActor )
109 button.SetDimmedImage( CreateAlignedImage( dimmedReleasedImageActor ) );
112 if( dimmedBackgroundImageActor )
114 button.SetDimmedBackgroundImage( CreateAlignedImage( dimmedBackgroundImageActor ) );
120 PushButton CreatePushButton( const std::string& backgroundImagePath )
122 PushButton button = Toolkit::PushButton::New();
124 if( !backgroundImagePath.empty() )
126 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
132 PushButton CreatePushButton( Actor backgroundImageActor )
134 PushButton button = Toolkit::PushButton::New();
136 if( backgroundImageActor )
138 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
144 } // namespace Toolkit