Add 'ExclusiveArch: armv7l' limit build to arm architecture
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / controls / default-controls / check-button-factory.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 #include "check-button-factory.h"
18
19 // EXTERNAL INCLUDES
20
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/alignment/alignment.h>
23 #include <dali/dali.h>
24
25 namespace Dali
26 {
27
28 namespace Toolkit
29 {
30
31 namespace
32 {
33
34 Alignment CreateAlignedImage( Actor image )
35 {
36   Alignment alignmentContainer = Toolkit::Alignment::New();
37   alignmentContainer.SetScaling( Toolkit::Alignment::ShrinkToFitKeepAspect );
38
39   alignmentContainer.Add( image );
40
41   return alignmentContainer;
42 }
43
44 Alignment CreateAlignedImage( const std::string& imagePath )
45 {
46   Image image = Image::New( imagePath );
47
48   return CreateAlignedImage( ImageActor::New( image ) );
49 }
50
51 } // namespace
52
53
54 CheckBoxButton CreateCheckBoxButton( const std::string& backgroundImagePath, const std::string& checkedImagePath, const std::string& dimmedBackgroundImagePath, const std::string& dimmedCheckedImagePath )
55 {
56   CheckBoxButton button = Toolkit::CheckBoxButton::New();
57
58   if( !backgroundImagePath.empty() )
59   {
60     button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
61   }
62
63   if( !checkedImagePath.empty() )
64   {
65     button.SetCheckedImage( CreateAlignedImage( checkedImagePath ) );
66   }
67
68   if( !dimmedBackgroundImagePath.empty() )
69   {
70     button.SetDimmedBackgroundImage( CreateAlignedImage( dimmedBackgroundImagePath ) );
71   }
72
73   if( !dimmedCheckedImagePath.empty() )
74   {
75     button.SetDimmedCheckedImage( CreateAlignedImage( dimmedCheckedImagePath ) );
76   }
77
78   return button;
79 }
80
81 CheckBoxButton CreateCheckBoxButton( Actor backgroundImageActor, Actor checkedImageActor, Actor dimmedBackgroundImageActor, Actor dimmedCheckedImagActor )
82 {
83   CheckBoxButton button = Toolkit::CheckBoxButton::New();
84
85   if( backgroundImageActor )
86   {
87     button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
88   }
89
90   if( checkedImageActor )
91   {
92     button.SetCheckedImage( CreateAlignedImage( checkedImageActor ) );
93   }
94
95   if( dimmedBackgroundImageActor )
96   {
97     button.SetDimmedBackgroundImage( CreateAlignedImage( dimmedBackgroundImageActor ) );
98   }
99
100   if( dimmedCheckedImagActor )
101   {
102     button.SetDimmedCheckedImage( CreateAlignedImage( dimmedCheckedImagActor ) );
103   }
104
105   return button;
106 }
107
108 CheckBoxButton CreateCheckBoxButton( const std::string& backgroundImagePath, const std::string& checkedImagePath )
109 {
110   CheckBoxButton button = Toolkit::CheckBoxButton::New();
111
112   if( !backgroundImagePath.empty() )
113   {
114     button.SetBackgroundImage( CreateAlignedImage( backgroundImagePath ) );
115   }
116
117   if( !checkedImagePath.empty() )
118   {
119     button.SetCheckedImage( CreateAlignedImage( checkedImagePath ) );
120   }
121
122   return button;
123 }
124
125 CheckBoxButton CreateCheckBoxButton( Actor backgroundImageActor, Actor checkedImageActor )
126 {
127   CheckBoxButton button = Toolkit::CheckBoxButton::New();
128
129   if( backgroundImageActor )
130   {
131     button.SetBackgroundImage( CreateAlignedImage( backgroundImageActor ) );
132   }
133
134   if( checkedImageActor )
135   {
136     button.SetCheckedImage( CreateAlignedImage( checkedImageActor ) );
137   }
138
139   return button;
140 }
141
142 } // namespace Toolkit
143
144 } // namespace Dali