2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
17 #include <dali-toolkit/public-api/controls/alignment/alignment.h>
18 #include <dali-toolkit/public-api/controls/default-controls/push-button-factory.h>
33 Alignment CreateAlignedImage( Actor image )
35 Alignment alignmentContainer = Toolkit::Alignment::New();
36 alignmentContainer.SetScaling( Toolkit::Alignment::ShrinkToFitKeepAspect );
38 alignmentContainer.Add( image );
40 return alignmentContainer;
43 Alignment CreateAlignedImage( const std::string& imagePath )
45 Image image = Image::New( imagePath );
46 return CreateAlignedImage( ImageActor::New( image ) );
52 PushButton CreatePushButton( const std::string& releasedImagePath, const std::string& pressedImagePath, const std::string& backgroundImagePath,
53 const std::string& dimmedReleasedImagePath, const std::string& dimmedBackgroundImagePath )
55 PushButton button = Toolkit::PushButton::New();
57 if( !releasedImagePath.empty() )
59 button.SetButtonImage( CreateAlignedImage( releasedImagePath ) );
62 if( !pressedImagePath.empty() )
64 button.SetPressedImage( CreateAlignedImage( pressedImagePath ) );
67 if( !backgroundImagePath.empty() )
69 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
72 if( !dimmedReleasedImagePath.empty() )
74 button.SetDimmedImage( CreateAlignedImage( dimmedReleasedImagePath ) );
77 if( !dimmedBackgroundImagePath.empty() )
79 button.SetDimmedBackgroundImage( CreateAlignedImage( dimmedBackgroundImagePath ) );
85 PushButton CreatePushButton( Actor releasedImageActor, Actor pressedImageActor, Actor backgroundImageActor,
86 Actor dimmedReleasedImageActor, Actor dimmedBackgroundImageActor )
88 PushButton button = Toolkit::PushButton::New();
90 if( releasedImageActor )
92 button.SetButtonImage( CreateAlignedImage( releasedImageActor ) );
95 if( pressedImageActor )
97 button.SetPressedImage( CreateAlignedImage( pressedImageActor ) );
100 if( backgroundImageActor )
102 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
105 if( dimmedReleasedImageActor )
107 button.SetDimmedImage( CreateAlignedImage( dimmedReleasedImageActor ) );
110 if( dimmedBackgroundImageActor )
112 button.SetDimmedBackgroundImage( CreateAlignedImage( dimmedBackgroundImageActor ) );
118 PushButton CreatePushButton( const std::string& backgroundImagePath )
120 PushButton button = Toolkit::PushButton::New();
122 if( !backgroundImagePath.empty() )
124 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
130 PushButton CreatePushButton( Actor backgroundImageActor )
132 PushButton button = Toolkit::PushButton::New();
134 if( backgroundImageActor )
136 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
142 } // namespace Toolkit