Merge "DALi Version 2.1.23" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-controls / text-selection-popup-property-handler.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
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 <dali-toolkit/internal/controls/text-controls/text-selection-popup-property-handler.h>
18 #include <dali/integration-api/debug.h>
19
20 #if defined(DEBUG_ENABLED)
21 extern Debug::Filter* gLogFilter;
22 #endif
23
24 namespace Dali::Toolkit::Internal
25 {
26 void TextSelectionPopup::PropertyHandler::SetProperty(Toolkit::TextSelectionPopup selectionPopup, Property::Index index, const Property::Value& value)
27 {
28   TextSelectionPopup& impl(GetImpl(selectionPopup));
29
30   switch(index)
31   {
32     case Toolkit::TextSelectionPopup::Property::POPUP_MAX_SIZE:
33     {
34       impl.SetDimensionToCustomise(POPUP_MAXIMUM_SIZE, value.Get<Vector2>());
35       break;
36     }
37     case Toolkit::TextSelectionPopup::Property::OPTION_MAX_SIZE:
38     {
39       impl.SetDimensionToCustomise(OPTION_MAXIMUM_SIZE, value.Get<Vector2>());
40       break;
41     }
42     case Toolkit::TextSelectionPopup::Property::OPTION_MIN_SIZE:
43     {
44       impl.SetDimensionToCustomise(OPTION_MINIMUM_SIZE, value.Get<Vector2>());
45       break;
46     }
47     case Toolkit::TextSelectionPopup::Property::OPTION_DIVIDER_SIZE:
48     {
49       impl.SetDimensionToCustomise(OPTION_DIVIDER_SIZE, value.Get<Vector2>());
50       break;
51     }
52     case Toolkit::TextSelectionPopup::Property::OPTION_DIVIDER_PADDING:
53     {
54       Vector4 padding(value.Get<Vector4>());
55       impl.SetOptionDividerPadding(Padding(padding.x, padding.y, padding.z, padding.w));
56       break;
57     }
58     case Toolkit::TextSelectionPopup::Property::POPUP_CLIPBOARD_BUTTON_ICON_IMAGE:
59     {
60       impl.SetButtonImage(Toolkit::TextSelectionPopup::CLIPBOARD, value.Get<std::string>());
61       break;
62     }
63     case Toolkit::TextSelectionPopup::Property::POPUP_CUT_BUTTON_ICON_IMAGE:
64     {
65       impl.SetButtonImage(Toolkit::TextSelectionPopup::CUT, value.Get<std::string>());
66       break;
67     }
68     case Toolkit::TextSelectionPopup::Property::POPUP_COPY_BUTTON_ICON_IMAGE:
69     {
70       impl.SetButtonImage(Toolkit::TextSelectionPopup::COPY, value.Get<std::string>());
71       break;
72     }
73     case Toolkit::TextSelectionPopup::Property::POPUP_PASTE_BUTTON_ICON_IMAGE:
74     {
75       impl.SetButtonImage(Toolkit::TextSelectionPopup::PASTE, value.Get<std::string>());
76       break;
77     }
78     case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_BUTTON_ICON_IMAGE:
79     {
80       impl.SetButtonImage(Toolkit::TextSelectionPopup::SELECT, value.Get<std::string>());
81       break;
82     }
83     case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_ALL_BUTTON_ICON_IMAGE:
84     {
85       impl.SetButtonImage(Toolkit::TextSelectionPopup::SELECT_ALL, value.Get<std::string>());
86       break;
87     }
88     case Toolkit::TextSelectionPopup::Property::POPUP_DIVIDER_COLOR:
89     {
90       impl.mDividerColor = value.Get<Vector4>();
91       break;
92     }
93     case Toolkit::TextSelectionPopup::Property::POPUP_ICON_COLOR:
94     {
95       impl.mIconColor = value.Get<Vector4>();
96       break;
97     }
98     case Toolkit::TextSelectionPopup::Property::POPUP_PRESSED_COLOR:
99     {
100       impl.mPressedColor = value.Get<Vector4>();
101       break;
102     }
103     case Toolkit::TextSelectionPopup::Property::POPUP_PRESSED_IMAGE:
104     {
105       impl.SetPressedImage(value.Get<std::string>());
106       break;
107     }
108     case Toolkit::TextSelectionPopup::Property::POPUP_FADE_IN_DURATION:
109     {
110       impl.mFadeInDuration = value.Get<float>();
111       break;
112     }
113     case Toolkit::TextSelectionPopup::Property::POPUP_FADE_OUT_DURATION:
114     {
115       impl.mFadeOutDuration = value.Get<float>();
116       break;
117     }
118     case Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER:
119     {
120       Property::Map map = value.Get<Property::Map>();
121       impl.CreateBackgroundBorder(map);
122       break;
123     }
124   }
125 }
126
127 Property::Value TextSelectionPopup::PropertyHandler::GetProperty(Toolkit::TextSelectionPopup selectionPopup, Property::Index index)
128 {
129   Property::Value value;
130   TextSelectionPopup& impl(GetImpl(selectionPopup));
131
132   switch(index)
133   {
134     case Toolkit::TextSelectionPopup::Property::POPUP_MAX_SIZE:
135     {
136       value = impl.GetDimensionToCustomise(POPUP_MAXIMUM_SIZE);
137       break;
138     }
139     case Toolkit::TextSelectionPopup::Property::OPTION_MAX_SIZE:
140     {
141       value = impl.GetDimensionToCustomise(OPTION_MAXIMUM_SIZE);
142       break;
143     }
144     case Toolkit::TextSelectionPopup::Property::OPTION_MIN_SIZE:
145     {
146       value = impl.GetDimensionToCustomise(OPTION_MINIMUM_SIZE);
147       break;
148     }
149     case Toolkit::TextSelectionPopup::Property::OPTION_DIVIDER_SIZE:
150     {
151       value = impl.GetDimensionToCustomise(OPTION_DIVIDER_SIZE);
152       break;
153     }
154     case Toolkit::TextSelectionPopup::Property::OPTION_DIVIDER_PADDING:
155     {
156       Padding padding = impl.GetOptionDividerPadding();
157       value           = Vector4(padding.left, padding.right, padding.top, padding.bottom);
158       break;
159     }
160     case Toolkit::TextSelectionPopup::Property::POPUP_CLIPBOARD_BUTTON_ICON_IMAGE:
161     {
162       value = impl.GetButtonImage(Toolkit::TextSelectionPopup::CLIPBOARD);
163       break;
164     }
165     case Toolkit::TextSelectionPopup::Property::POPUP_CUT_BUTTON_ICON_IMAGE:
166     {
167       value = impl.GetButtonImage(Toolkit::TextSelectionPopup::CUT);
168       break;
169     }
170     case Toolkit::TextSelectionPopup::Property::POPUP_COPY_BUTTON_ICON_IMAGE:
171     {
172       value = impl.GetButtonImage(Toolkit::TextSelectionPopup::COPY);
173       break;
174     }
175     case Toolkit::TextSelectionPopup::Property::POPUP_PASTE_BUTTON_ICON_IMAGE:
176     {
177       value = impl.GetButtonImage(Toolkit::TextSelectionPopup::PASTE);
178       break;
179     }
180     case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_BUTTON_ICON_IMAGE:
181     {
182       value = impl.GetButtonImage(Toolkit::TextSelectionPopup::SELECT);
183       break;
184     }
185     case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_ALL_BUTTON_ICON_IMAGE:
186     {
187       value = impl.GetButtonImage(Toolkit::TextSelectionPopup::SELECT_ALL);
188       break;
189     }
190     case Toolkit::TextSelectionPopup::Property::POPUP_DIVIDER_COLOR:
191     {
192       value = impl.mDividerColor;
193       break;
194     }
195     case Toolkit::TextSelectionPopup::Property::POPUP_ICON_COLOR:
196     {
197       value = impl.mIconColor;
198       break;
199     }
200     case Toolkit::TextSelectionPopup::Property::POPUP_PRESSED_COLOR:
201     {
202       value = impl.mPressedColor;
203       break;
204     }
205     case Toolkit::TextSelectionPopup::Property::POPUP_PRESSED_IMAGE:
206     {
207       value = impl.GetPressedImage();
208       break;
209     }
210     case Toolkit::TextSelectionPopup::Property::POPUP_FADE_IN_DURATION:
211     {
212       value = impl.mFadeInDuration;
213       break;
214     }
215     case Toolkit::TextSelectionPopup::Property::POPUP_FADE_OUT_DURATION:
216     {
217       value = impl.mFadeOutDuration;
218       break;
219     }
220     case Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER:
221     {
222       Property::Map         map;
223       Toolkit::Visual::Base visual = DevelControl::GetVisual(impl, Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER);
224       if(visual)
225       {
226         visual.CreatePropertyMap(map);
227       }
228       value = map;
229       break;
230     }
231   }
232
233   return value;
234 }
235
236 } // namespace Dali::Toolkit::Internal