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>
23 #include <dali/public-api/images/resource-image.h>
26 #include <dali-toolkit/public-api/controls/alignment/alignment.h>
37 Alignment CreateAlignedImage( Actor image )
39 Alignment alignmentContainer = Toolkit::Alignment::New();
40 alignmentContainer.SetScaling( Toolkit::Alignment::ShrinkToFitKeepAspect );
42 alignmentContainer.Add( image );
44 return alignmentContainer;
47 Alignment CreateAlignedImage( const std::string& imagePath )
49 Image image = ResourceImage::New( imagePath );
50 return CreateAlignedImage( ImageActor::New( image ) );
56 PushButton CreatePushButton( const std::string& unselectedImagePath, const std::string& selectedImagePath, const std::string& backgroundImagePath,
57 const std::string& disabledUnselectedImagePath, const std::string& disabledBackgroundImagePath )
59 PushButton button = Toolkit::PushButton::New();
61 if( !unselectedImagePath.empty() )
63 button.SetButtonImage( CreateAlignedImage( unselectedImagePath ) );
66 if( !selectedImagePath.empty() )
68 button.SetSelectedImage( CreateAlignedImage( selectedImagePath ) );
71 if( !backgroundImagePath.empty() )
73 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
76 if( !disabledUnselectedImagePath.empty() )
78 button.SetDisabledImage( CreateAlignedImage( disabledUnselectedImagePath ) );
81 if( !disabledBackgroundImagePath.empty() )
83 button.SetDisabledBackgroundImage( CreateAlignedImage( disabledBackgroundImagePath ) );
89 PushButton CreatePushButton( Actor unselectedImageActor, Actor selectedImageActor, Actor backgroundImageActor,
90 Actor disabledUnselectedImageActor, Actor disabledBackgroundImageActor )
92 PushButton button = Toolkit::PushButton::New();
94 if( unselectedImageActor )
96 button.SetButtonImage( CreateAlignedImage( unselectedImageActor ) );
99 if( selectedImageActor )
101 button.SetSelectedImage( CreateAlignedImage( selectedImageActor ) );
104 if( backgroundImageActor )
106 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
109 if( disabledUnselectedImageActor )
111 button.SetDisabledImage( CreateAlignedImage( disabledUnselectedImageActor ) );
114 if( disabledBackgroundImageActor )
116 button.SetDisabledBackgroundImage( CreateAlignedImage( disabledBackgroundImageActor ) );
122 PushButton CreatePushButton( const std::string& backgroundImagePath )
124 PushButton button = Toolkit::PushButton::New();
126 if( !backgroundImagePath.empty() )
128 button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
134 PushButton CreatePushButton( Actor backgroundImageActor )
136 PushButton button = Toolkit::PushButton::New();
138 if( backgroundImageActor )
140 button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
146 } // namespace Toolkit