0dc96e302db93fd3870369cad828da6abcc9f012
[platform/core/uifw/dali-demo.git] / examples / size-negotiation / size-negotiation-example.cpp
1 /*
2  * Copyright (c) 2020 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
18 #include <dali-toolkit/dali-toolkit.h>
19 #include <dali-toolkit/devel-api/controls/popup/popup.h>
20 #include <dali-toolkit/devel-api/controls/table-view/table-view.h>
21 #include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
22 #include <dali/dali.h>
23 #include "shared/view.h"
24
25 using namespace Dali;
26
27 using Dali::Toolkit::TextLabel;
28
29 struct ButtonItem
30 {
31   const char* name;
32   const char* text;
33 };
34
35 namespace
36 {
37 const char* const BACKGROUND_IMAGE = DEMO_IMAGE_DIR "background-gradient.jpg";
38 const char* const TOOLBAR_IMAGE    = DEMO_IMAGE_DIR "top-bar.png";
39 const char* const IMAGE            = DEMO_IMAGE_DIR "background-magnifier.jpg";
40
41 const char* const TOOLBAR_TITLE = "Negotiate Size";
42
43 // This example contains size negotiation tests for TableView and Popup.
44 const char* const TABLEVIEW_BUTTON_1CELL_ID           = "TABLEVIEW_BUTTON_1CELL";
45 const char* const TABLEVIEW_BUTTON_3CELL_ID           = "TABLEVIEW_BUTTON_3CELL";
46 const char* const TABLEVIEW_BUTTON_3X3CELL_ID         = "TABLEVIEW_BUTTON_3X3CELL";
47 const char* const TABLEVIEW_BUTTON_FIXED1_ID          = "TABLEVIEW_BUTTON_FIXED1";
48 const char* const TABLEVIEW_BUTTON_FIXED2_ID          = "TABLEVIEW_BUTTON_FIXED2";
49 const char* const TABLEVIEW_BUTTON_FIT1_ID            = "TABLEVIEW_BUTTON_FIT1";
50 const char* const TABLEVIEW_BUTTON_FIT2_ID            = "TABLEVIEW_BUTTON_FIT2";
51 const char* const TABLEVIEW_BUTTON_NATURAL1_ID        = "TABLEVIEW_BUTTON_NATURAL1";
52 const char* const TABLEVIEW_BUTTON_NATURAL2_ID        = "TABLEVIEW_BUTTON_NATURAL2";
53 const char* const TABLEVIEW_BUTTON_NATURAL3_ID        = "TABLEVIEW_BUTTON_NATURAL3";
54 const char* const POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID = "POPUP_BUTTON_CONTENT_IMAGE_SCALE";
55 const char* const POPUP_BUTTON_CONTENT_IMAGE_FIT_ID   = "POPUP_BUTTON_CONTENT_IMAGE_FIT";
56 const char* const POPUP_BUTTON_CONTENT_IMAGE_FILL_ID  = "POPUP_BUTTON_CONTENT_IMAGE_FILL";
57
58 const ButtonItem TABLEVIEW_BUTTON_ITEMS[] = {
59   {TABLEVIEW_BUTTON_1CELL_ID, "1 Cell"},
60   {TABLEVIEW_BUTTON_3CELL_ID, "3 Cell"},
61   {TABLEVIEW_BUTTON_3X3CELL_ID, "3x3 Cells"},
62   {TABLEVIEW_BUTTON_FIXED1_ID, "Fixed 1"},
63   {TABLEVIEW_BUTTON_FIXED2_ID, "Fixed 2"},
64   {TABLEVIEW_BUTTON_FIT1_ID, "Fit Top Bottom"},
65   {TABLEVIEW_BUTTON_FIT2_ID, "Fit Middle"},
66   {TABLEVIEW_BUTTON_NATURAL1_ID, "Natural 1"},
67   {TABLEVIEW_BUTTON_NATURAL2_ID, "Natural 2"},
68   {TABLEVIEW_BUTTON_NATURAL3_ID, "Natural 3"},
69   {POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID, "Image Scale"},
70   {POPUP_BUTTON_CONTENT_IMAGE_FIT_ID, "Image Fit"},
71   {POPUP_BUTTON_CONTENT_IMAGE_FILL_ID, "Image Fill"},
72 };
73
74 const unsigned int TABLEVIEW_BUTTON_ITEMS_COUNT = sizeof(TABLEVIEW_BUTTON_ITEMS) / sizeof(TABLEVIEW_BUTTON_ITEMS[0]);
75
76 Actor CreateSolidColor(Vector4 color)
77 {
78   Toolkit::Control control = Toolkit::Control::New();
79
80   Property::Map map;
81   map[Toolkit::Visual::Property::TYPE]           = Toolkit::Visual::COLOR;
82   map[Toolkit::ColorVisual::Property::MIX_COLOR] = color;
83   control.SetProperty(Toolkit::Control::Property::BACKGROUND, map);
84
85   return control;
86 }
87
88 } // anonymous namespace
89
90 /**
91  * This example shows the usage of size negotiation.
92  */
93 class SizeNegotiationController : public ConnectionTracker, public Toolkit::ItemFactory
94 {
95 public:
96   SizeNegotiationController(Application& application)
97   : mApplication(application)
98   {
99     // Connect to the Application's Init signal
100     mApplication.InitSignal().Connect(this, &SizeNegotiationController::Create);
101   }
102
103   ~SizeNegotiationController()
104   {
105     // Nothing to do here
106   }
107
108   void Create(Application& application)
109   {
110     // The Init signal is received once (only) during the Application lifetime
111     Window window = application.GetWindow();
112
113     // Respond to key events if not handled
114     window.KeyEventSignal().Connect(this, &SizeNegotiationController::OnKeyEvent);
115
116     // Creates a default view with a default tool bar.
117     // The view is added to the window.
118     mContentLayer = DemoHelper::CreateView(application,
119                                            mView,
120                                            mToolBar,
121                                            BACKGROUND_IMAGE,
122                                            TOOLBAR_IMAGE,
123                                            std::string(""));
124
125     mTitleActor = DemoHelper::CreateToolBarLabel("CUSTOM_TOOLBAR_TITLE");
126     mTitleActor.SetProperty(Toolkit::TextLabel::Property::TEXT, TOOLBAR_TITLE);
127
128     // Add title to the tool bar.
129     const float padding(DemoHelper::DEFAULT_VIEW_STYLE.mToolBarPadding);
130     mToolBar.AddControl(mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HORIZONTAL_CENTER, Toolkit::Alignment::Padding(padding, padding, padding, padding));
131
132     mItemView = Toolkit::ItemView::New(*this);
133     mItemView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
134     mItemView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
135     mItemView.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
136
137     // Use a grid layout for tests
138     Vector2                windowSize = window.GetSize();
139     Toolkit::ItemLayoutPtr gridLayout = Toolkit::DefaultItemLayout::New(Toolkit::DefaultItemLayout::LIST);
140     Vector3                itemSize;
141     gridLayout->GetItemSize(0, Vector3(windowSize), itemSize);
142     itemSize.height = windowSize.y / 10;
143     gridLayout->SetItemSize(itemSize);
144     mItemView.AddLayout(*gridLayout);
145
146     mItemView.ActivateLayout(0, Vector3(windowSize.x, windowSize.y, windowSize.x), 0.0f);
147
148     mContentLayer.Add(mItemView);
149   }
150
151   void ShowPopup(Toolkit::Popup popup)
152   {
153     mApplication.GetWindow().Add(popup);
154     popup.SetDisplayState(Toolkit::Popup::SHOWN);
155   }
156
157   void OnPopupOutsideTouched()
158   {
159     if(mPopup)
160     {
161       mPopup.SetDisplayState(Toolkit::Popup::HIDDEN);
162     }
163   }
164
165   void PopupHidden()
166   {
167     if(mPopup)
168     {
169       mPopup.Unparent();
170       mPopup.Reset();
171     }
172   }
173
174   Toolkit::Popup CreatePopup()
175   {
176     Window      window         = mApplication.GetWindow();
177     const float POPUP_WIDTH_DP = window.GetSize().GetWidth() * 0.75f;
178
179     Toolkit::Popup popup = Toolkit::Popup::New();
180     popup.SetProperty(Dali::Actor::Property::NAME, "popup");
181     popup.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
182     popup.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
183     popup.SetProperty(Actor::Property::SIZE, Vector2(POPUP_WIDTH_DP, 0.0f));
184     popup.SetProperty(Toolkit::Popup::Property::TAIL_VISIBILITY, false);
185
186     popup.OutsideTouchedSignal().Connect(this, &SizeNegotiationController::OnPopupOutsideTouched);
187     popup.HiddenSignal().Connect(this, &SizeNegotiationController::PopupHidden);
188
189     return popup;
190   }
191
192   bool OnButtonClicked(Toolkit::Button button)
193   {
194     if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_1CELL_ID)
195     {
196       mPopup = CreatePopup();
197       mPopup.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS);
198       mPopup.SetProperty(Actor::Property::SIZE_MODE_FACTOR, Vector3(0.75f, 0.5f, 1.0f));
199
200       Toolkit::TableView table = Toolkit::TableView::New(0, 0);
201       table.SetProperty(Dali::Actor::Property::NAME, "TABLEVIEW_BUTTON_1CELL_ID");
202       table.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
203
204       Actor backing = CreateSolidColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
205       backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
206       table.Add(backing);
207
208       mPopup.Add(table);
209
210       ShowPopup(mPopup);
211     }
212     else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_3CELL_ID)
213     {
214       mPopup = CreatePopup();
215       mPopup.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS);
216       mPopup.SetProperty(Actor::Property::SIZE_MODE_FACTOR, Vector3(0.75f, 0.5f, 1.0f));
217
218       Toolkit::TableView table = Toolkit::TableView::New(3, 1);
219       table.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
220
221       {
222         Actor backing = CreateSolidColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
223         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
224         table.AddChild(backing, Toolkit::TableView::CellPosition(0, 0));
225       }
226       {
227         Actor backing = CreateSolidColor(Vector4(1.0f, 1.0f, 0.0f, 1.0f));
228         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
229         table.AddChild(backing, Toolkit::TableView::CellPosition(1, 0));
230       }
231       {
232         Actor backing = CreateSolidColor(Vector4(0.0f, 1.0f, 0.0f, 1.0f));
233         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
234         table.AddChild(backing, Toolkit::TableView::CellPosition(2, 0));
235       }
236
237       mPopup.SetContent(table);
238
239       ShowPopup(mPopup);
240     }
241     else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_3X3CELL_ID)
242     {
243       mPopup = CreatePopup();
244       mPopup.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS);
245       mPopup.SetProperty(Actor::Property::SIZE_MODE_FACTOR, Vector3(0.75f, 0.5f, 1.0f));
246
247       Toolkit::TableView table = Toolkit::TableView::New(3, 3);
248       table.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
249
250       // Column 0
251       {
252         Actor backing = CreateSolidColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
253         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
254         table.AddChild(backing, Toolkit::TableView::CellPosition(0, 0));
255       }
256       {
257         Actor backing = CreateSolidColor(Vector4(1.0f, 1.0f, 0.0f, 1.0f));
258         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
259         table.AddChild(backing, Toolkit::TableView::CellPosition(1, 0));
260       }
261       {
262         Actor backing = CreateSolidColor(Vector4(0.0f, 1.0f, 0.0f, 1.0f));
263         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
264         table.AddChild(backing, Toolkit::TableView::CellPosition(2, 0));
265       }
266
267       // Column 1
268       {
269         Actor backing = CreateSolidColor(Vector4(1.0f, 0.0f, 1.0f, 1.0f));
270         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
271         table.AddChild(backing, Toolkit::TableView::CellPosition(0, 1));
272       }
273       {
274         Actor backing = CreateSolidColor(Vector4(1.0f, 1.0f, 1.0f, 1.0f));
275         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
276         table.AddChild(backing, Toolkit::TableView::CellPosition(1, 1));
277       }
278       {
279         Actor backing = CreateSolidColor(Vector4(0.0f, 0.0f, 1.0f, 1.0f));
280         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
281         table.AddChild(backing, Toolkit::TableView::CellPosition(2, 1));
282       }
283
284       // Column 2
285       {
286         Actor backing = CreateSolidColor(Vector4(0.0f, 0.0f, 0.0f, 1.0f));
287         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
288         table.AddChild(backing, Toolkit::TableView::CellPosition(0, 2));
289       }
290       {
291         Actor backing = CreateSolidColor(Vector4(0.5f, 0.5f, 0.5f, 1.0f));
292         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
293         table.AddChild(backing, Toolkit::TableView::CellPosition(1, 2));
294       }
295       {
296         Actor backing = CreateSolidColor(Vector4(1.0f, 0.5f, 0.0f, 1.0f));
297         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
298         table.AddChild(backing, Toolkit::TableView::CellPosition(2, 2));
299       }
300
301       mPopup.Add(table);
302
303       ShowPopup(mPopup);
304     }
305     else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_FIXED1_ID)
306     {
307       mPopup = CreatePopup();
308       mPopup.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS);
309       mPopup.SetProperty(Actor::Property::SIZE_MODE_FACTOR, Vector3(0.75f, 0.5f, 1.0f));
310
311       Toolkit::TableView table = Toolkit::TableView::New(3, 1);
312       table.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
313       table.SetFixedHeight(0, 50.0f);
314
315       {
316         Actor backing = CreateSolidColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
317         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
318         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fixed");
319         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
320         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
321         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
322         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
323         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
324         backing.Add(text);
325         table.Add(backing);
326       }
327       {
328         Actor backing = CreateSolidColor(Vector4(1.0f, 1.0f, 0.0f, 1.0f));
329         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
330         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fill");
331         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
332         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
333         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
334         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
335         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
336         backing.Add(text);
337         table.Add(backing);
338       }
339       {
340         Actor backing = CreateSolidColor(Vector4(0.0f, 1.0f, 0.0f, 1.0f));
341         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
342         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fill");
343         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
344         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
345         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
346         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
347         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
348         backing.Add(text);
349         table.Add(backing);
350       }
351
352       mPopup.Add(table);
353
354       ShowPopup(mPopup);
355     }
356     else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_FIXED2_ID)
357     {
358       mPopup = CreatePopup();
359       mPopup.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS);
360       mPopup.SetProperty(Actor::Property::SIZE_MODE_FACTOR, Vector3(0.75f, 0.5f, 1.0f));
361
362       Toolkit::TableView table = Toolkit::TableView::New(3, 1);
363       table.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
364       table.SetFixedHeight(0, 50.0f);
365       table.SetFixedHeight(2, 50.0f);
366
367       {
368         Actor backing = CreateSolidColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
369         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
370         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fixed");
371         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
372         text.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
373         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
374         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
375         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
376         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
377
378         backing.Add(text);
379         table.Add(backing);
380       }
381       {
382         Actor backing = CreateSolidColor(Vector4(1.0f, 1.0f, 0.0f, 1.0f));
383         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
384         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fill");
385         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
386         text.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
387         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
388         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
389         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
390         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
391
392         backing.Add(text);
393         table.Add(backing);
394       }
395       {
396         Actor backing = CreateSolidColor(Vector4(0.0f, 1.0f, 0.0f, 1.0f));
397         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
398         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fixed");
399         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
400         text.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
401         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
402         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
403         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
404         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
405
406         backing.Add(text);
407         table.Add(backing);
408       }
409
410       mPopup.Add(table);
411
412       ShowPopup(mPopup);
413     }
414     else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_FIT1_ID)
415     {
416       mPopup = CreatePopup();
417       mPopup.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS);
418       mPopup.SetProperty(Actor::Property::SIZE_MODE_FACTOR, Vector3(0.75f, 0.5f, 1.0f));
419
420       Toolkit::TableView table = Toolkit::TableView::New(3, 1);
421       table.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
422       table.SetFitHeight(0);
423       table.SetFitHeight(2);
424
425       {
426         Actor backing = CreateSolidColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
427         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
428         backing.SetProperty(Actor::Property::SIZE, Vector2(0.0f, 100.0f));
429
430         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fit");
431         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
432         text.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
433         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
434         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
435         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
436         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
437
438         backing.Add(text);
439
440         table.Add(backing);
441       }
442       {
443         Actor backing = CreateSolidColor(Vector4(1.0f, 1.0f, 0.0f, 1.0f));
444         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
445
446         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fill");
447         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
448         text.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
449         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
450         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
451         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
452         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
453
454         backing.Add(text);
455
456         table.Add(backing);
457       }
458       {
459         Actor backing = CreateSolidColor(Vector4(0.0f, 1.0f, 0.0f, 1.0f));
460         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
461         backing.SetProperty(Actor::Property::SIZE, Vector2(0.0f, 100.0f));
462
463         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fit");
464         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
465         text.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
466         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
467         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
468         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
469         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
470
471         backing.Add(text);
472
473         table.Add(backing);
474       }
475
476       mPopup.Add(table);
477
478       ShowPopup(mPopup);
479     }
480     else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_FIT2_ID)
481     {
482       mPopup = CreatePopup();
483       mPopup.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS);
484       mPopup.SetProperty(Actor::Property::SIZE_MODE_FACTOR, Vector3(0.75f, 0.5f, 1.0f));
485
486       Toolkit::TableView table = Toolkit::TableView::New(3, 1);
487       table.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
488       table.SetFitHeight(1);
489
490       {
491         Actor backing = CreateSolidColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
492         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
493
494         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fill");
495         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
496         text.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
497         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
498         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
499         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
500         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
501
502         backing.Add(text);
503
504         table.Add(backing);
505       }
506       {
507         Actor backing = CreateSolidColor(Vector4(1.0f, 1.0f, 0.0f, 1.0f));
508         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
509         backing.SetProperty(Actor::Property::SIZE, Vector2(0.0f, 200.0f));
510
511         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fit");
512         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
513         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
514         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
515         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
516
517         text.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
518         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
519         backing.Add(text);
520
521         table.Add(backing);
522       }
523       {
524         Actor backing = CreateSolidColor(Vector4(0.0f, 1.0f, 0.0f, 1.0f));
525         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
526
527         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fill");
528         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
529         text.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
530         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
531         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
532         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
533         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
534
535         backing.Add(text);
536
537         table.Add(backing);
538       }
539
540       mPopup.Add(table);
541
542       ShowPopup(mPopup);
543     }
544     else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_NATURAL1_ID)
545     {
546       mPopup = CreatePopup();
547       mPopup.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::WIDTH);
548       mPopup.SetProperty(Actor::Property::SIZE_MODE_FACTOR, Vector3(0.75f, 1.0f, 1.0f));
549       mPopup.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT);
550
551       Toolkit::TableView table = Toolkit::TableView::New(3, 1);
552       table.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
553       table.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT);
554       table.SetFitHeight(0);
555       table.SetFitHeight(1);
556       table.SetFitHeight(2);
557
558       {
559         Actor backing = CreateSolidColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
560         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
561         backing.SetProperty(Actor::Property::SIZE, Vector2(0.0f, 100.0f));
562
563         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fit");
564         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
565         text.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
566         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
567         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
568         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
569         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
570
571         backing.Add(text);
572
573         table.Add(backing);
574       }
575       {
576         Actor backing = CreateSolidColor(Vector4(1.0f, 1.0f, 0.0f, 1.0f));
577         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
578         backing.SetProperty(Actor::Property::SIZE, Vector2(0.0f, 200.0f));
579
580         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fit");
581         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
582         text.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
583         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
584         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
585         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
586         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
587
588         backing.Add(text);
589
590         table.Add(backing);
591       }
592       {
593         Actor backing = CreateSolidColor(Vector4(0.0f, 1.0f, 0.0f, 1.0f));
594         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
595         backing.SetProperty(Actor::Property::SIZE, Vector2(0.0f, 300.0f));
596
597         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fit");
598         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
599         text.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
600         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
601         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
602         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
603         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
604
605         backing.Add(text);
606
607         table.Add(backing);
608       }
609
610       mPopup.Add(table);
611
612       ShowPopup(mPopup);
613     }
614     else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_NATURAL2_ID)
615     {
616       mPopup = CreatePopup();
617       mPopup.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::WIDTH);
618       mPopup.SetProperty(Actor::Property::SIZE_MODE_FACTOR, Vector3(0.75f, 1.0f, 1.0f));
619       mPopup.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT);
620
621       Toolkit::TableView table = Toolkit::TableView::New(3, 1);
622       table.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
623       table.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT);
624       table.SetFitHeight(0);
625       table.SetFitHeight(1);
626
627       {
628         Actor backing = CreateSolidColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
629         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
630         backing.SetResizePolicy(ResizePolicy::FIXED, Dimension::HEIGHT);
631         backing.SetProperty(Actor::Property::SIZE, Vector2(0.0f, 100.0f));
632
633         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fit");
634         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
635         text.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
636         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
637         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
638         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
639         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
640
641         backing.Add(text);
642
643         table.Add(backing);
644       }
645       {
646         Actor backing = CreateSolidColor(Vector4(0.0f, 1.0f, 0.0f, 1.0f));
647         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
648         backing.SetProperty(Actor::Property::SIZE, Vector2(0.0f, 200.0f));
649
650         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fit");
651         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
652         text.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
653         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
654         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
655         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
656         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
657
658         backing.Add(text);
659
660         table.Add(backing);
661       }
662
663       mPopup.Add(table);
664
665       ShowPopup(mPopup);
666     }
667     else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_NATURAL3_ID)
668     {
669       mPopup = CreatePopup();
670       mPopup.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::WIDTH);
671       mPopup.SetProperty(Actor::Property::SIZE_MODE_FACTOR, Vector3(0.75f, 1.0f, 1.0f));
672       mPopup.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT);
673
674       Toolkit::TableView table = Toolkit::TableView::New(3, 1);
675       table.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
676       table.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT);
677       table.SetFixedHeight(0, 20.0f);
678       table.SetFitHeight(1);
679
680       {
681         Actor backing = CreateSolidColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
682         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
683
684         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fixed");
685         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
686         text.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
687         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
688         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
689         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
690         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
691
692         backing.Add(text);
693
694         table.Add(backing);
695       }
696       {
697         Actor backing = CreateSolidColor(Vector4(0.0f, 1.0f, 0.0f, 1.0f));
698         backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
699         backing.SetProperty(Actor::Property::SIZE, Vector2(0.0f, 200.0f));
700
701         Toolkit::TextLabel text = Toolkit::TextLabel::New("Fit");
702         text.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE);
703         text.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
704         text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
705         text.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
706         text.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
707         text.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
708
709         backing.Add(text);
710
711         table.Add(backing);
712       }
713       mPopup.Add(table);
714
715       ShowPopup(mPopup);
716     }
717     else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID)
718     {
719       mPopup = CreatePopup();
720       mPopup.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS);
721       mPopup.SetProperty(Actor::Property::SIZE_MODE_FACTOR, Vector3(0.75f, 0.5f, 1.0f));
722
723       Toolkit::ImageView image = Toolkit::ImageView::New(IMAGE);
724       image.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
725
726       mPopup.Add(image);
727
728       ShowPopup(mPopup);
729     }
730     else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == POPUP_BUTTON_CONTENT_IMAGE_FIT_ID)
731     {
732       mPopup = CreatePopup();
733       mPopup.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS);
734       mPopup.SetProperty(Actor::Property::SIZE_MODE_FACTOR, Vector3(0.75f, 0.5f, 1.0f));
735
736       Toolkit::ImageView image = Toolkit::ImageView::New(IMAGE);
737       image.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
738       image.SetProperty(Actor::Property::SIZE_SCALE_POLICY, SizeScalePolicy::FIT_WITH_ASPECT_RATIO);
739
740       mPopup.Add(image);
741
742       ShowPopup(mPopup);
743     }
744     else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == POPUP_BUTTON_CONTENT_IMAGE_FILL_ID)
745     {
746       mPopup = CreatePopup();
747       mPopup.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS);
748       mPopup.SetProperty(Actor::Property::SIZE_MODE_FACTOR, Vector3(0.75f, 0.5f, 1.0f));
749
750       Toolkit::ImageView image = Toolkit::ImageView::New(IMAGE);
751       image.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
752       image.SetProperty(Actor::Property::SIZE_SCALE_POLICY, SizeScalePolicy::FILL_WITH_ASPECT_RATIO);
753
754       mPopup.Add(image);
755
756       ShowPopup(mPopup);
757     }
758
759     return true;
760   }
761
762   void OnKeyEvent(const KeyEvent& event)
763   {
764     if(event.GetState() == KeyEvent::DOWN)
765     {
766       if(IsKey(event, Dali::DALI_KEY_ESCAPE) || IsKey(event, Dali::DALI_KEY_BACK))
767       {
768         // Exit application when click back or escape.
769         mApplication.Quit();
770       }
771     }
772   }
773
774 public: // From ItemFactory
775   /**
776    * @brief Return the number of items to display in the item view
777    *
778    * @return Return the number of items to display
779    */
780   virtual unsigned int GetNumberOfItems()
781   {
782     return TABLEVIEW_BUTTON_ITEMS_COUNT;
783   }
784
785   /**
786    * @brief Create a new item to populate the item view with
787    *
788    * @param[in] itemId The index of the item to create
789    * @return Return the created actor for the given ID
790    */
791   virtual Actor NewItem(unsigned int itemId)
792   {
793     Toolkit::PushButton popupButton = Toolkit::PushButton::New();
794     popupButton.SetProperty(Dali::Actor::Property::NAME, TABLEVIEW_BUTTON_ITEMS[itemId].name);
795     popupButton.SetProperty(Toolkit::Button::Property::LABEL, TABLEVIEW_BUTTON_ITEMS[itemId].text);
796     popupButton.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
797
798     popupButton.ClickedSignal().Connect(this, &SizeNegotiationController::OnButtonClicked);
799
800     return popupButton;
801   }
802
803 private:
804   Application&     mApplication;
805   Toolkit::Control mView;         ///< The View instance.
806   Toolkit::ToolBar mToolBar;      ///< The View's Toolbar.
807   Layer            mContentLayer; ///< Content layer.
808
809   Toolkit::TextLabel mTitleActor; ///< Title text.
810   Toolkit::Popup     mMenu;       ///< The navigation menu.
811   Toolkit::Popup     mPopup;      ///< The current example popup.
812
813   Toolkit::ItemView mItemView; ///< ItemView to hold test images.
814 };
815
816 int DALI_EXPORT_API main(int argc, char** argv)
817 {
818   Application               application = Application::New(&argc, &argv, DEMO_THEME_PATH);
819   SizeNegotiationController test(application);
820   application.MainLoop();
821   return 0;
822 }