2 * Copyright (c) 2016 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 "shared/view.h"
19 #include <dali/dali.h>
20 #include <dali-toolkit/dali-toolkit.h>
21 #include <dali-toolkit/devel-api/controls/popup/popup.h>
25 using Dali::Toolkit::TextLabel;
36 const char* const BACKGROUND_IMAGE = DEMO_IMAGE_DIR "background-gradient.jpg";
37 const char* const TOOLBAR_IMAGE = DEMO_IMAGE_DIR "top-bar.png";
38 const char* const IMAGE = DEMO_IMAGE_DIR "background-magnifier.jpg";
40 const char* const TOOLBAR_TITLE = "Negotiate Size";
42 // This example contains size negotiation tests for TableView and Popup.
43 const char* const TABLEVIEW_BUTTON_1CELL_ID = "TABLEVIEW_BUTTON_1CELL";
44 const char* const TABLEVIEW_BUTTON_3CELL_ID = "TABLEVIEW_BUTTON_3CELL";
45 const char* const TABLEVIEW_BUTTON_3X3CELL_ID = "TABLEVIEW_BUTTON_3X3CELL";
46 const char* const TABLEVIEW_BUTTON_FIXED1_ID = "TABLEVIEW_BUTTON_FIXED1";
47 const char* const TABLEVIEW_BUTTON_FIXED2_ID = "TABLEVIEW_BUTTON_FIXED2";
48 const char* const TABLEVIEW_BUTTON_FIT1_ID = "TABLEVIEW_BUTTON_FIT1";
49 const char* const TABLEVIEW_BUTTON_FIT2_ID = "TABLEVIEW_BUTTON_FIT2";
50 const char* const TABLEVIEW_BUTTON_NATURAL1_ID = "TABLEVIEW_BUTTON_NATURAL1";
51 const char* const TABLEVIEW_BUTTON_NATURAL2_ID = "TABLEVIEW_BUTTON_NATURAL2";
52 const char* const TABLEVIEW_BUTTON_NATURAL3_ID = "TABLEVIEW_BUTTON_NATURAL3";
53 const char* const POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID = "POPUP_BUTTON_CONTENT_IMAGE_SCALE";
54 const char* const POPUP_BUTTON_CONTENT_IMAGE_FIT_ID = "POPUP_BUTTON_CONTENT_IMAGE_FIT";
55 const char* const POPUP_BUTTON_CONTENT_IMAGE_FILL_ID = "POPUP_BUTTON_CONTENT_IMAGE_FILL";
57 const ButtonItem TABLEVIEW_BUTTON_ITEMS[] = {
58 { TABLEVIEW_BUTTON_1CELL_ID, "1 Cell" },
59 { TABLEVIEW_BUTTON_3CELL_ID, "3 Cell" },
60 { TABLEVIEW_BUTTON_3X3CELL_ID, "3x3 Cells" },
61 { TABLEVIEW_BUTTON_FIXED1_ID, "Fixed 1" },
62 { TABLEVIEW_BUTTON_FIXED2_ID, "Fixed 2" },
63 { TABLEVIEW_BUTTON_FIT1_ID, "Fit Top Bottom" },
64 { TABLEVIEW_BUTTON_FIT2_ID, "Fit Middle" },
65 { TABLEVIEW_BUTTON_NATURAL1_ID, "Natural 1" },
66 { TABLEVIEW_BUTTON_NATURAL2_ID, "Natural 2" },
67 { TABLEVIEW_BUTTON_NATURAL3_ID, "Natural 3" },
68 { POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID, "Image Scale" },
69 { POPUP_BUTTON_CONTENT_IMAGE_FIT_ID, "Image Fit" },
70 { POPUP_BUTTON_CONTENT_IMAGE_FILL_ID, "Image Fill" },
73 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
92 * This example shows the usage of size negotiation.
94 class SizeNegotiationController: public ConnectionTracker, public Toolkit::ItemFactory
98 SizeNegotiationController( Application& application )
99 : mApplication( application )
101 // Connect to the Application's Init signal
102 mApplication.InitSignal().Connect( this, &SizeNegotiationController::Create );
105 ~SizeNegotiationController()
107 // Nothing to do here
110 void Create( Application& application )
112 // The Init signal is received once (only) during the Application lifetime
113 Stage stage = Stage::GetCurrent();
115 // Respond to key events
116 stage.KeyEventSignal().Connect(this, &SizeNegotiationController::OnKeyEvent);
118 // Creates a default view with a default tool bar.
119 // The view is added to the stage.
120 mContentLayer = DemoHelper::CreateView( application,
127 mTitleActor = DemoHelper::CreateToolBarLabel( "CUSTOM_TOOLBAR_TITLE" );
128 mTitleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, TOOLBAR_TITLE );
130 // Add title to the tool bar.
131 const float padding( DemoHelper::DEFAULT_VIEW_STYLE.mToolBarPadding );
132 mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::Padding( padding, padding, padding, padding ) );
134 mItemView = Toolkit::ItemView::New( *this );
135 mItemView.SetParentOrigin( ParentOrigin::CENTER );
136 mItemView.SetAnchorPoint( AnchorPoint::CENTER );
137 mItemView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
139 // Use a grid layout for tests
140 Vector2 stageSize = stage.GetSize();
141 Toolkit::ItemLayoutPtr gridLayout = Toolkit::DefaultItemLayout::New( Toolkit::DefaultItemLayout::LIST );
143 gridLayout->GetItemSize( 0, Vector3( stageSize ), itemSize );
144 itemSize.height = stageSize.y / 10;
145 gridLayout->SetItemSize( itemSize );
146 mItemView.AddLayout( *gridLayout );
148 mItemView.ActivateLayout( 0, Vector3(stageSize.x, stageSize.y, stageSize.x), 0.0f );
150 mContentLayer.Add( mItemView );
153 void StagePopup( Toolkit::Popup popup )
155 Stage::GetCurrent().Add( popup );
156 popup.SetDisplayState( Toolkit::Popup::SHOWN );
159 void OnPopupOutsideTouched()
163 mPopup.SetDisplayState( Toolkit::Popup::HIDDEN );
176 Toolkit::Popup CreatePopup()
178 Stage stage = Stage::GetCurrent();
179 const float POPUP_WIDTH_DP = stage.GetSize().width * 0.75f;
181 Toolkit::Popup popup = Toolkit::Popup::New();
182 popup.SetName( "popup" );
183 popup.SetParentOrigin( ParentOrigin::CENTER );
184 popup.SetAnchorPoint( AnchorPoint::CENTER );
185 popup.SetSize( POPUP_WIDTH_DP, 0.0f );
186 popup.SetProperty( Toolkit::Popup::Property::TAIL_VISIBILITY, false );
188 popup.OutsideTouchedSignal().Connect( this, &SizeNegotiationController::OnPopupOutsideTouched );
189 popup.HiddenSignal().Connect( this, &SizeNegotiationController::PopupHidden );
194 bool OnButtonClicked( Toolkit::Button button )
196 if( button.GetName() == TABLEVIEW_BUTTON_1CELL_ID )
198 mPopup = CreatePopup();
199 mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
200 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
202 Toolkit::TableView table = Toolkit::TableView::New( 0, 0 );
203 table.SetName( "TABLEVIEW_BUTTON_1CELL_ID" );
204 table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
206 Actor backing = CreateSolidColor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
207 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
208 table.Add( backing );
212 StagePopup( mPopup );
214 else if( button.GetName() == TABLEVIEW_BUTTON_3CELL_ID )
216 mPopup = CreatePopup();
217 mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
218 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
220 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
221 table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
224 Actor backing = CreateSolidColor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
225 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
226 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 0 ) );
229 Actor backing = CreateSolidColor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
230 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
231 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 0 ) );
234 Actor backing = CreateSolidColor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
235 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
236 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 0 ) );
239 mPopup.SetContent( table );
241 StagePopup( mPopup );
243 else if( button.GetName() == TABLEVIEW_BUTTON_3X3CELL_ID )
245 mPopup = CreatePopup();
246 mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
247 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
249 Toolkit::TableView table = Toolkit::TableView::New( 3, 3 );
250 table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
254 Actor backing = CreateSolidColor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
255 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
256 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 0 ) );
259 Actor backing = CreateSolidColor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
260 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
261 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 0 ) );
264 Actor backing = CreateSolidColor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
265 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
266 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 0 ) );
271 Actor backing = CreateSolidColor( Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) );
272 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
273 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 1 ) );
276 Actor backing = CreateSolidColor( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
277 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
278 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 1 ) );
281 Actor backing = CreateSolidColor( Vector4( 0.0f, 0.0f, 1.0f, 1.0f ) );
282 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
283 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 1 ) );
288 Actor backing = CreateSolidColor( Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) );
289 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
290 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 2 ) );
293 Actor backing = CreateSolidColor( Vector4( 0.5f, 0.5f, 0.5f, 1.0f ) );
294 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
295 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 2 ) );
298 Actor backing = CreateSolidColor( Vector4( 1.0f, 0.5f, 0.0f, 1.0f ) );
299 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
300 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 2 ) );
305 StagePopup( mPopup );
307 else if( button.GetName() == TABLEVIEW_BUTTON_FIXED1_ID )
309 mPopup = CreatePopup();
310 mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
311 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
313 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
314 table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
315 table.SetFixedHeight( 0, 50.0f );
318 Actor backing = CreateSolidColor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
319 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
320 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
321 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
322 text.SetParentOrigin( ParentOrigin::CENTER );
323 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
324 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
325 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
327 table.Add( backing );
330 Actor backing = CreateSolidColor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
331 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
332 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
333 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
334 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
335 text.SetParentOrigin( ParentOrigin::CENTER );
336 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
337 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
339 table.Add( backing );
342 Actor backing = CreateSolidColor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
343 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
344 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
345 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
346 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
347 text.SetParentOrigin( ParentOrigin::CENTER );
348 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
349 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
351 table.Add( backing );
356 StagePopup( mPopup );
358 else if( button.GetName() == TABLEVIEW_BUTTON_FIXED2_ID )
360 mPopup = CreatePopup();
361 mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
362 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
364 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
365 table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
366 table.SetFixedHeight( 0, 50.0f );
367 table.SetFixedHeight( 2, 50.0f );
370 Actor backing = CreateSolidColor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
371 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
372 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
373 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
374 text.SetAnchorPoint( AnchorPoint::CENTER );
375 text.SetParentOrigin( ParentOrigin::CENTER );
376 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
377 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
378 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
381 table.Add( backing );
384 Actor backing = CreateSolidColor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
385 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
386 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
387 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
388 text.SetAnchorPoint( AnchorPoint::CENTER );
389 text.SetParentOrigin( ParentOrigin::CENTER );
390 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
391 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
392 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
395 table.Add( backing );
398 Actor backing = CreateSolidColor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
399 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
400 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
401 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
402 text.SetAnchorPoint( AnchorPoint::CENTER );
403 text.SetParentOrigin( ParentOrigin::CENTER );
404 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
405 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
406 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
409 table.Add( backing );
414 StagePopup( mPopup );
416 else if( button.GetName() == TABLEVIEW_BUTTON_FIT1_ID )
418 mPopup = CreatePopup();
419 mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
420 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
422 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
423 table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
424 table.SetFitHeight( 0 );
425 table.SetFitHeight( 2 );
428 Actor backing = CreateSolidColor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
429 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
430 backing.SetSize( 0.0f, 100.0f );
432 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
433 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
434 text.SetAnchorPoint( AnchorPoint::CENTER );
435 text.SetParentOrigin( ParentOrigin::CENTER );
436 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
437 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
438 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
442 table.Add( backing );
445 Actor backing = CreateSolidColor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
446 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
448 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
449 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
450 text.SetAnchorPoint( AnchorPoint::CENTER );
451 text.SetParentOrigin( ParentOrigin::CENTER );
452 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
453 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
454 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
458 table.Add( backing );
461 Actor backing = CreateSolidColor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
462 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
463 backing.SetSize( 0.0f, 100.0f );
465 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
466 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
467 text.SetAnchorPoint( AnchorPoint::CENTER );
468 text.SetParentOrigin( ParentOrigin::CENTER );
469 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
470 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
471 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
475 table.Add( backing );
480 StagePopup( mPopup );
482 else if( button.GetName() == TABLEVIEW_BUTTON_FIT2_ID )
484 mPopup = CreatePopup();
485 mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
486 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
488 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
489 table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
490 table.SetFitHeight( 1 );
493 Actor backing = CreateSolidColor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
494 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
496 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
497 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
498 text.SetAnchorPoint( AnchorPoint::CENTER );
499 text.SetParentOrigin( ParentOrigin::CENTER );
500 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
501 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
502 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
506 table.Add( backing );
509 Actor backing = CreateSolidColor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
510 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
511 backing.SetSize( 0.0f, 200.0f );
513 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
514 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
515 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
516 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
517 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
519 text.SetAnchorPoint( AnchorPoint::CENTER );
520 text.SetParentOrigin( ParentOrigin::CENTER );
523 table.Add( backing );
526 Actor backing = CreateSolidColor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
527 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
529 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
530 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
531 text.SetAnchorPoint( AnchorPoint::CENTER );
532 text.SetParentOrigin( ParentOrigin::CENTER );
533 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
534 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
535 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
539 table.Add( backing );
544 StagePopup( mPopup );
546 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL1_ID )
548 mPopup = CreatePopup();
549 mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::WIDTH );
550 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
551 mPopup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT );
553 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
554 table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
555 table.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
556 table.SetFitHeight( 0 );
557 table.SetFitHeight( 1 );
558 table.SetFitHeight( 2 );
561 Actor backing = CreateSolidColor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
562 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
563 backing.SetSize( 0.0f, 100.0f );
565 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
566 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
567 text.SetAnchorPoint( AnchorPoint::CENTER );
568 text.SetParentOrigin( ParentOrigin::CENTER );
569 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
570 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
571 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
575 table.Add( backing );
578 Actor backing = CreateSolidColor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
579 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
580 backing.SetSize( 0.0f, 200.0f );
582 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
583 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
584 text.SetAnchorPoint( AnchorPoint::CENTER );
585 text.SetParentOrigin( ParentOrigin::CENTER );
586 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
587 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
588 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
592 table.Add( backing );
595 Actor backing = CreateSolidColor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
596 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
597 backing.SetSize( 0.0f, 300.0f );
599 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
600 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
601 text.SetAnchorPoint( AnchorPoint::CENTER );
602 text.SetParentOrigin( ParentOrigin::CENTER );
603 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
604 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
605 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
609 table.Add( backing );
614 StagePopup( mPopup );
616 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL2_ID )
618 mPopup = CreatePopup();
619 mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::WIDTH );
620 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
621 mPopup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT );
623 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
624 table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
625 table.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
626 table.SetFitHeight( 0 );
627 table.SetFitHeight( 1 );
630 Actor backing = CreateSolidColor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
631 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
632 backing.SetResizePolicy( ResizePolicy::FIXED, Dimension::HEIGHT );
633 backing.SetSize( 0.0f, 100.0f );
635 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
636 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
637 text.SetAnchorPoint( AnchorPoint::CENTER );
638 text.SetParentOrigin( ParentOrigin::CENTER );
639 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
640 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
641 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
645 table.Add( backing );
648 Actor backing = CreateSolidColor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
649 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
650 backing.SetSize( 0.0f, 200.0f );
652 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
653 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
654 text.SetAnchorPoint( AnchorPoint::CENTER );
655 text.SetParentOrigin( ParentOrigin::CENTER );
656 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
657 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
658 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
662 table.Add( backing );
667 StagePopup( mPopup );
669 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL3_ID )
671 mPopup = CreatePopup();
672 mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::WIDTH );
673 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
674 mPopup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT );
676 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
677 table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
678 table.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
679 table.SetFixedHeight( 0, 20.0f );
680 table.SetFitHeight( 1 );
683 Actor backing = CreateSolidColor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
684 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
686 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
687 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
688 text.SetAnchorPoint( AnchorPoint::CENTER );
689 text.SetParentOrigin( ParentOrigin::CENTER );
690 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
691 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
692 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
696 table.Add( backing );
699 Actor backing = CreateSolidColor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
700 backing.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
701 backing.SetSize( 0.0f, 200.0f );
703 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
704 text.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE );
705 text.SetAnchorPoint( AnchorPoint::CENTER );
706 text.SetParentOrigin( ParentOrigin::CENTER );
707 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
708 text.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
709 text.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
713 table.Add( backing );
717 StagePopup( mPopup );
719 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID )
721 mPopup = CreatePopup();
722 mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
723 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
725 Toolkit::ImageView image = Toolkit::ImageView::New( IMAGE );
726 image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
730 StagePopup( mPopup );
732 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FIT_ID )
734 mPopup = CreatePopup();
735 mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
736 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
738 Toolkit::ImageView image = Toolkit::ImageView::New( IMAGE );
739 image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
740 image.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
744 StagePopup( mPopup );
746 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FILL_ID )
748 mPopup = CreatePopup();
749 mPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
750 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
752 Toolkit::ImageView image = Toolkit::ImageView::New( IMAGE );
753 image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
754 image.SetSizeScalePolicy( SizeScalePolicy::FILL_WITH_ASPECT_RATIO );
758 StagePopup( mPopup );
764 void OnKeyEvent( const KeyEvent& event )
766 if( event.state == KeyEvent::Down )
768 if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) )
770 // Exit application when click back or escape.
776 public: // From ItemFactory
779 * @brief Return the number of items to display in the item view
781 * @return Return the number of items to display
783 virtual unsigned int GetNumberOfItems()
785 return TABLEVIEW_BUTTON_ITEMS_COUNT;
789 * @brief Create a new item to populate the item view with
791 * @param[in] itemId The index of the item to create
792 * @return Return the created actor for the given ID
794 virtual Actor NewItem(unsigned int itemId)
796 Toolkit::PushButton popupButton = Toolkit::PushButton::New();
797 popupButton.SetName( TABLEVIEW_BUTTON_ITEMS[ itemId ].name );
798 popupButton.SetLabelText( TABLEVIEW_BUTTON_ITEMS[ itemId ].text );
799 popupButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
801 popupButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
808 Application& mApplication;
809 Toolkit::Control mView; ///< The View instance.
810 Toolkit::ToolBar mToolBar; ///< The View's Toolbar.
811 Layer mContentLayer; ///< Content layer.
813 Toolkit::TextLabel mTitleActor; ///< Title text.
814 Toolkit::Popup mMenu; ///< The navigation menu.
815 Toolkit::Popup mPopup; ///< The current example popup.
817 Toolkit::ItemView mItemView; ///< ItemView to hold test images.
821 void RunTest( Application& application )
823 SizeNegotiationController test( application );
825 application.MainLoop();
828 // Entry point for Linux & SLP applications
829 int DALI_EXPORT_API main( int argc, char **argv )
831 Application application = Application::New( &argc, &argv, DEMO_THEME_PATH );
833 RunTest( application );