2 * Copyright (c) 2022 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.
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"
27 using Dali::Toolkit::TextLabel;
37 const char* const BACKGROUND_IMAGE = DEMO_IMAGE_DIR "background-default.png";
38 const char* const TOOLBAR_IMAGE = DEMO_IMAGE_DIR "top-bar.png";
39 const char* const IMAGE = DEMO_IMAGE_DIR "background-magnifier.jpg";
41 const char* const TOOLBAR_TITLE = "Negotiate Size";
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";
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"},
74 const unsigned int TABLEVIEW_BUTTON_ITEMS_COUNT = sizeof(TABLEVIEW_BUTTON_ITEMS) / sizeof(TABLEVIEW_BUTTON_ITEMS[0]);
76 Actor CreateSolidColor(Vector4 color)
78 Toolkit::Control control = Toolkit::Control::New();
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);
88 } // anonymous namespace
91 * This example shows the usage of size negotiation.
93 class SizeNegotiationController : public ConnectionTracker, public Toolkit::ItemFactory
96 SizeNegotiationController(Application& application)
97 : mApplication(application)
99 // Connect to the Application's Init signal
100 mApplication.InitSignal().Connect(this, &SizeNegotiationController::Create);
103 ~SizeNegotiationController()
105 // Nothing to do here
108 void Create(Application& application)
110 // The Init signal is received once (only) during the Application lifetime
111 Window window = application.GetWindow();
113 // Respond to key events if not handled
114 window.KeyEventSignal().Connect(this, &SizeNegotiationController::OnKeyEvent);
116 // Creates a default view with a default tool bar.
117 // The view is added to the window.
118 mContentLayer = DemoHelper::CreateView(application,
125 mTitleActor = DemoHelper::CreateToolBarLabel("CUSTOM_TOOLBAR_TITLE");
126 mTitleActor.SetProperty(Toolkit::TextLabel::Property::TEXT, TOOLBAR_TITLE);
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));
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);
137 // Use a grid layout for tests
138 Vector2 windowSize = window.GetSize();
139 Toolkit::ItemLayoutPtr gridLayout = Toolkit::DefaultItemLayout::New(Toolkit::DefaultItemLayout::LIST);
141 gridLayout->GetItemSize(0, Vector3(windowSize), itemSize);
142 itemSize.height = windowSize.y / 10;
143 gridLayout->SetItemSize(itemSize);
144 mItemView.AddLayout(*gridLayout);
146 mItemView.ActivateLayout(0, Vector3(windowSize.x, windowSize.y, windowSize.x), 0.0f);
148 mContentLayer.Add(mItemView);
151 void ShowPopup(Toolkit::Popup popup)
153 mApplication.GetWindow().Add(popup);
154 popup.SetDisplayState(Toolkit::Popup::SHOWN);
157 void OnPopupOutsideTouched()
161 mPopup.SetDisplayState(Toolkit::Popup::HIDDEN);
174 Toolkit::Popup CreatePopup()
176 Window window = mApplication.GetWindow();
177 const float POPUP_WIDTH_DP = window.GetSize().GetWidth() * 0.75f;
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);
186 popup.OutsideTouchedSignal().Connect(this, &SizeNegotiationController::OnPopupOutsideTouched);
187 popup.HiddenSignal().Connect(this, &SizeNegotiationController::PopupHidden);
192 bool OnButtonClicked(Toolkit::Button button)
194 if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_1CELL_ID)
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));
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);
204 Actor backing = CreateSolidColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
205 backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
212 else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_3CELL_ID)
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));
218 Toolkit::TableView table = Toolkit::TableView::New(3, 1);
219 table.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
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));
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));
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));
237 mPopup.SetContent(table);
241 else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_3X3CELL_ID)
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));
247 Toolkit::TableView table = Toolkit::TableView::New(3, 3);
248 table.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
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));
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));
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));
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));
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));
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));
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));
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));
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));
305 else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_FIXED1_ID)
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));
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);
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");
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");
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");
356 else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_FIXED2_ID)
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));
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);
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");
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");
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");
414 else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_FIT1_ID)
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));
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);
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));
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");
443 Actor backing = CreateSolidColor(Vector4(1.0f, 1.0f, 0.0f, 1.0f));
444 backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
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");
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));
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");
480 else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_FIT2_ID)
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));
486 Toolkit::TableView table = Toolkit::TableView::New(3, 1);
487 table.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
488 table.SetFitHeight(1);
491 Actor backing = CreateSolidColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
492 backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
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");
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));
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");
517 text.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
518 text.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
524 Actor backing = CreateSolidColor(Vector4(0.0f, 1.0f, 0.0f, 1.0f));
525 backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
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");
544 else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_NATURAL1_ID)
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);
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);
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));
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");
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));
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");
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));
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");
614 else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_NATURAL2_ID)
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);
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);
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));
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");
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));
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");
667 else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == TABLEVIEW_BUTTON_NATURAL3_ID)
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);
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);
681 Actor backing = CreateSolidColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
682 backing.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
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");
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));
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");
717 else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID)
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));
723 Toolkit::ImageView image = Toolkit::ImageView::New(IMAGE);
724 image.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
730 else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == POPUP_BUTTON_CONTENT_IMAGE_FIT_ID)
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));
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);
744 else if(button.GetProperty<std::string>(Dali::Actor::Property::NAME) == POPUP_BUTTON_CONTENT_IMAGE_FILL_ID)
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));
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);
762 void OnKeyEvent(const KeyEvent& event)
764 if(event.GetState() == KeyEvent::DOWN)
766 if(IsKey(event, Dali::DALI_KEY_ESCAPE) || IsKey(event, Dali::DALI_KEY_BACK))
768 // Exit application when click back or escape.
774 public: // From ItemFactory
776 * @brief Return the number of items to display in the item view
778 * @return Return the number of items to display
780 virtual unsigned int GetNumberOfItems()
782 return TABLEVIEW_BUTTON_ITEMS_COUNT;
786 * @brief Create a new item to populate the item view with
788 * @param[in] itemId The index of the item to create
789 * @return Return the created actor for the given ID
791 virtual Actor NewItem(unsigned int itemId)
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);
798 popupButton.ClickedSignal().Connect(this, &SizeNegotiationController::OnButtonClicked);
804 Application& mApplication;
805 Toolkit::Control mView; ///< The View instance.
806 Toolkit::ToolBar mToolBar; ///< The View's Toolbar.
807 Layer mContentLayer; ///< Content layer.
809 Toolkit::TextLabel mTitleActor; ///< Title text.
810 Toolkit::Popup mMenu; ///< The navigation menu.
811 Toolkit::Popup mPopup; ///< The current example popup.
813 Toolkit::ItemView mItemView; ///< ItemView to hold test images.
816 int DALI_EXPORT_API main(int argc, char** argv)
818 Application application = Application::New(&argc, &argv, DEMO_THEME_PATH);
819 SizeNegotiationController test(application);
820 application.MainLoop();