2 * Copyright (c) 2014 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>
24 using Dali::Toolkit::TextLabel;
26 // Define this so that it is interchangeable
27 // "DP" stands for Device independent Pixels
28 #define DP(x) DemoHelper::ScalePointSize(x)
40 const char* const BACKGROUND_IMAGE = DALI_IMAGE_DIR "background-gradient.jpg";
41 const char* const TOOLBAR_IMAGE = DALI_IMAGE_DIR "top-bar.png";
43 const char* const TOOLBAR_TITLE = "Size Negotiation";
44 const int TOOLBAR_HEIGHT = 62;
46 const char* MENU_ICON_IMAGE = DALI_IMAGE_DIR "icon-cluster-none.png";
48 const char* const PUSHBUTTON_BUTTON_IMAGE = DALI_IMAGE_DIR "button-up.9.png";
49 const char* const PUSHBUTTON_PRESS_IMAGE = DALI_IMAGE_DIR "button-down.9.png";
51 const char* const POPUPS_MENU_ID = "POPUPS_MENU";
52 const char* const TABLEVIEW_MENU_ID = "TABLEVIEW_MENU";
54 const char* const POPUP_BUTTON_EMPTY_ID = "POPUP_BUTTON_EMPTY";
55 const char* const POPUP_BUTTON_TITLE_ID = "POPUP_BUTTON_TITLE";
56 const char* const POPUP_BUTTON_BUTTONS_1_ID = "POPUP_BUTTON_BUTTONS_1";
57 const char* const POPUP_BUTTON_BUTTONS_2_ID = "POPUP_BUTTON_BUTTONS_2";
58 const char* const POPUP_BUTTON_TITLE_BUTTONS_ID = "POPUP_BUTTON_TITLE_BUTTONS";
59 const char* const POPUP_BUTTON_CONTENT_TEXT_ID = "POPUP_BUTTON_CONTENT_TEXT";
60 const char* const POPUP_BUTTON_CONTENT_IMAGE_ID = "POPUP_BUTTON_CONTENT_IMAGE";
61 const char* const POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID = "POPUP_BUTTON_CONTENT_IMAGE_SCALE";
62 const char* const POPUP_BUTTON_CONTENT_IMAGE_FIT_ID = "POPUP_BUTTON_CONTENT_IMAGE_FIT";
63 const char* const POPUP_BUTTON_CONTENT_IMAGE_FILL_ID = "POPUP_BUTTON_CONTENT_IMAGE_FILL";
64 const char* const POPUP_BUTTON_TITLE_CONTENT_TEXT_ID = "POPUP_BUTTON_TITLE_CONTENT_TEXT";
65 const char* const POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS_ID = "POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS";
66 const char* const POPUP_BUTTON_COMPLEX_ID = "POPUP_BUTTON_COMPLEX";
68 const char* const TABLEVIEW_BUTTON_EMPTY_ID = "TABLEVIEW_BUTTON_EMPTY";
69 const char* const TABLEVIEW_BUTTON_1CELL_ID = "TABLEVIEW_BUTTON_1CELL";
70 const char* const TABLEVIEW_BUTTON_3CELL_ID = "TABLEVIEW_BUTTON_3CELL";
71 const char* const TABLEVIEW_BUTTON_3X3CELL_ID = "TABLEVIEW_BUTTON_3X3CELL";
72 const char* const TABLEVIEW_BUTTON_FIXED1_ID = "TABLEVIEW_BUTTON_FIXED1";
73 const char* const TABLEVIEW_BUTTON_FIXED2_ID = "TABLEVIEW_BUTTON_FIXED2";
74 const char* const TABLEVIEW_BUTTON_FIT1_ID = "TABLEVIEW_BUTTON_FIT1";
75 const char* const TABLEVIEW_BUTTON_FIT2_ID = "TABLEVIEW_BUTTON_FIT2";
76 const char* const TABLEVIEW_BUTTON_NATURAL1_ID = "TABLEVIEW_BUTTON_NATURAL1";
77 const char* const TABLEVIEW_BUTTON_NATURAL2_ID = "TABLEVIEW_BUTTON_NATURAL2";
78 const char* const TABLEVIEW_BUTTON_NATURAL3_ID = "TABLEVIEW_BUTTON_NATURAL3";
80 const char* const OKAY_BUTTON_ID = "OKAY_BUTTON";
81 const char* const CANCEL_BUTTON_ID = "CANCEL_BUTTON";
83 const char* const CONTENT_TEXT = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
84 const char* const IMAGE1 = DALI_IMAGE_DIR "gallery-medium-5.jpg";
85 const char* const IMAGE2 = DALI_IMAGE_DIR "background-magnifier.jpg";
86 const char* const CHECKBOX_UNCHECKED_IMAGE = DALI_IMAGE_DIR "checkbox-unselected.png";
87 const char* const CHECKBOX_CHECKED_IMAGE = DALI_IMAGE_DIR "checkbox-selected.png";
89 const ButtonItem MENU_ITEMS[] = {
90 { POPUPS_MENU_ID, "Popups" },
91 { TABLEVIEW_MENU_ID, "TableView" }
94 const unsigned int MENU_ITEMS_COUNT = sizeof( MENU_ITEMS ) / sizeof( MENU_ITEMS[0] );
96 const ButtonItem POPUP_BUTTON_ITEMS[] = {
97 { POPUP_BUTTON_COMPLEX_ID, "Complex" },
98 { POPUP_BUTTON_EMPTY_ID, "Empty" },
99 { POPUP_BUTTON_TITLE_ID, "Title" },
100 { POPUP_BUTTON_BUTTONS_1_ID, "1 Button" },
101 { POPUP_BUTTON_BUTTONS_2_ID, "2 Buttons" },
102 { POPUP_BUTTON_TITLE_BUTTONS_ID, "Title & Buttons" },
103 { POPUP_BUTTON_CONTENT_TEXT_ID, "Text" },
104 { POPUP_BUTTON_CONTENT_IMAGE_ID, "Image" },
105 { POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID, "Image Scale" },
106 { POPUP_BUTTON_CONTENT_IMAGE_FIT_ID, "Image Fit" },
107 { POPUP_BUTTON_CONTENT_IMAGE_FILL_ID, "Image Fill" },
108 { POPUP_BUTTON_TITLE_CONTENT_TEXT_ID, "Title Text" },
109 { POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS_ID, "Title, text, buttons" }
113 const int POPUP_BUTTON_ITEMS_COUNT = sizeof( POPUP_BUTTON_ITEMS ) / sizeof( POPUP_BUTTON_ITEMS[0] );
115 const ButtonItem TABLEVIEW_BUTTON_ITEMS[] = {
116 { TABLEVIEW_BUTTON_EMPTY_ID, "Empty" },
117 { TABLEVIEW_BUTTON_1CELL_ID, "1 Cell" },
118 { TABLEVIEW_BUTTON_3CELL_ID, "3 Cell" },
119 { TABLEVIEW_BUTTON_3X3CELL_ID, "3x3 Cells" },
120 { TABLEVIEW_BUTTON_FIXED1_ID, "Fixed 1" },
121 { TABLEVIEW_BUTTON_FIXED2_ID, "Fixed 2" },
122 { TABLEVIEW_BUTTON_FIT1_ID, "Fit Top Bottom" },
123 { TABLEVIEW_BUTTON_FIT2_ID, "Fit Middle" },
124 { TABLEVIEW_BUTTON_NATURAL1_ID, "Natural 1" },
125 { TABLEVIEW_BUTTON_NATURAL2_ID, "Natural 2" },
126 { TABLEVIEW_BUTTON_NATURAL3_ID, "Natural 3" },
129 const unsigned int TABLEVIEW_BUTTON_ITEMS_COUNT = sizeof( TABLEVIEW_BUTTON_ITEMS ) / sizeof( TABLEVIEW_BUTTON_ITEMS[0] );
136 * This example shows the usage of size negotiation.
138 class SizeNegotiationController: public ConnectionTracker, public Toolkit::ItemFactory
142 SizeNegotiationController( Application& application )
143 : mApplication( application ),
147 // Connect to the Application's Init signal
148 mApplication.InitSignal().Connect( this, &SizeNegotiationController::Create );
151 ~SizeNegotiationController()
153 // Nothing to do here
156 void Create( Application& application )
158 // The Init signal is received once (only) during the Application lifetime
160 DemoHelper::RequestThemeChange();
162 Stage stage = Stage::GetCurrent();
164 // Respond to key events
165 stage.KeyEventSignal().Connect(this, &SizeNegotiationController::OnKeyEvent);
167 // Creates a default view with a default tool bar.
168 // The view is added to the stage.
169 mContentLayer = DemoHelper::CreateView( application,
176 mTitleActor = DemoHelper::CreateToolBarLabel( "CUSTOM_TOOLBAR_TITLE" );
180 // Create menu button
181 Toolkit::PushButton viewButton = Toolkit::PushButton::New();
182 viewButton.SetBackgroundImage( ResourceImage::New( MENU_ICON_IMAGE ) );
183 viewButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnMenu );
184 mToolBar.AddControl( viewButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
186 // Add title to the tool bar.
187 const float padding( DemoHelper::DEFAULT_VIEW_STYLE.mToolBarPadding );
188 mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::Padding( padding, padding, padding, padding ) );
190 mItemView = Toolkit::ItemView::New( *this );
191 mItemView.SetParentOrigin( ParentOrigin::CENTER );
192 mItemView.SetAnchorPoint( AnchorPoint::CENTER );
193 mItemView.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
195 // Use a grid layout for tests
196 Toolkit::GridLayoutPtr gridLayout = Toolkit::GridLayout::New();
197 gridLayout->SetNumberOfColumns( 2 );
198 gridLayout->SetTopMargin( DP(TOOLBAR_HEIGHT) + DP(20.0f) );
199 gridLayout->SetBottomMargin( DP(100.0f) );
200 gridLayout->SetRowSpacing( DP(20.0f) );
201 mItemView.AddLayout( *gridLayout );
203 Vector2 stageSize = stage.GetSize();
204 float layoutWidth = Toolkit::IsHorizontal( gridLayout->GetOrientation() ) ? stageSize.height : stageSize.width;
205 float gridItemSize = ( layoutWidth / gridLayout->GetNumberOfColumns() ) * 0.5f;
206 gridLayout->SetScrollSpeedFactor( gridLayout->GetNumberOfColumns() / gridItemSize * 0.5f );
208 mItemView.ActivateLayout( 0, Vector3(stageSize.x, stageSize.y, stageSize.x), 0.0f );
210 mContentLayer.Add( mItemView );
215 std::string subTitle = "";
227 subTitle = "TableView";
237 mTitleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, std::string( std::string( TOOLBAR_TITLE ) + ": " + subTitle ) );
240 bool OnMenu( Toolkit::Button button )
248 Stage stage = Stage::GetCurrent();
249 const float popupWidth = stage.GetSize().x * 0.5f;
251 mMenu = Toolkit::Popup::New();
252 mMenu.SetParentOrigin( ParentOrigin::TOP_LEFT );
253 mMenu.SetAnchorPoint( AnchorPoint::TOP_LEFT );
255 mMenu.OutsideTouchedSignal().Connect( this, &SizeNegotiationController::HideMenu );
256 mMenu.SetSize( popupWidth, 0.0f );
257 mMenu.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
259 Toolkit::TableView tableView = Toolkit::TableView::New( 0, 0 );
260 tableView.SetResizePolicy( FILL_TO_PARENT, WIDTH );
261 tableView.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
262 mMenu.Add( tableView );
264 for( unsigned int i = 0; i < MENU_ITEMS_COUNT; ++i )
266 Toolkit::PushButton menuButton = Toolkit::PushButton::New();
267 menuButton.SetName( MENU_ITEMS[ i ].name );
268 menuButton.SetLabel( MENU_ITEMS[ i ].text );
269 menuButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnMenuSelect );
271 tableView.Add( menuButton );
272 tableView.SetFitHeight( i );
291 bool OnMenuSelect( Toolkit::Button button )
293 bool refresh = false;
295 if( button.GetName() == POPUPS_MENU_ID )
297 if( mDemoState != POPUP )
303 else if( button.GetName() == TABLEVIEW_MENU_ID )
305 if( mDemoState != TABLEVIEW )
308 mDemoState = TABLEVIEW;
323 Toolkit::Popup CreatePopup()
325 Stage stage = Stage::GetCurrent();
326 const float POPUP_WIDTH_DP = stage.GetSize().width * 0.75f;
328 Toolkit::Popup popup = Toolkit::Popup::New();
329 popup.SetName( "POPUP" );
330 popup.SetParentOrigin( ParentOrigin::CENTER );
331 popup.SetAnchorPoint( AnchorPoint::CENTER );
332 popup.SetSize( POPUP_WIDTH_DP, 0.0f );
335 popup.OutsideTouchedSignal().Connect( this, &SizeNegotiationController::OnPopupOutsideTouched );
340 bool OnButtonClicked( Toolkit::Button button )
342 if( button.GetName() == POPUP_BUTTON_EMPTY_ID )
344 mPopup = CreatePopup();
346 // The popup is not yet on the stage so needs to be flaged as dirty
347 mPopup.MarkDirtyForRelayout();
351 else if( button.GetName() == POPUP_BUTTON_TITLE_ID )
353 mPopup = CreatePopup();
354 mPopup.SetTitle( "Popup!" );
356 // The popup is not yet on the stage so needs to be flaged as dirty
357 mPopup.MarkDirtyForRelayout();
361 else if( button.GetName() == POPUP_BUTTON_BUTTONS_1_ID )
363 mPopup = CreatePopup();
365 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
366 okayButton.SetName( OKAY_BUTTON_ID );
367 okayButton.SetLabel( "OK!" );
368 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
369 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
371 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
373 mPopup.AddButton( okayButton );
375 // The popup is not yet on the stage so needs to be flaged as dirty
376 mPopup.MarkDirtyForRelayout();
380 else if( button.GetName() == POPUP_BUTTON_BUTTONS_2_ID )
382 mPopup = CreatePopup();
384 Toolkit::PushButton cancelButton = Toolkit::PushButton::New();
385 cancelButton.SetName( CANCEL_BUTTON_ID );
386 cancelButton.SetLabel( "Cancel" );
387 cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
388 cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
390 cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
392 mPopup.AddButton( cancelButton );
394 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
395 okayButton.SetName( OKAY_BUTTON_ID );
396 okayButton.SetLabel( "OK!" );
397 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
398 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
400 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
402 mPopup.AddButton( okayButton );
404 // The popup is not yet on the stage so needs to be flaged as dirty
405 mPopup.MarkDirtyForRelayout();
409 else if( button.GetName() == POPUP_BUTTON_TITLE_BUTTONS_ID )
411 mPopup = CreatePopup();
412 mPopup.SetTitle( "Popup!" );
414 Toolkit::PushButton cancelButton = Toolkit::PushButton::New();
415 cancelButton.SetName( CANCEL_BUTTON_ID );
416 cancelButton.SetLabel( "Cancel" );
417 cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
418 cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
420 cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
422 mPopup.AddButton( cancelButton );
424 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
425 okayButton.SetName( OKAY_BUTTON_ID );
426 okayButton.SetLabel( "OK!" );
427 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
428 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
430 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
432 mPopup.AddButton( okayButton );
434 // The popup is not yet on the stage so needs to be flaged as dirty
435 mPopup.MarkDirtyForRelayout();
439 else if( button.GetName() == POPUP_BUTTON_CONTENT_TEXT_ID )
441 mPopup = CreatePopup();
443 TextLabel text = TextLabel::New( CONTENT_TEXT );
444 text.SetName( "POPUP_CONTENT_TEXT" );
445 text.SetProperty( TextLabel::Property::MULTI_LINE, true );
446 text.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
447 text.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
448 text.SetResizePolicy( FILL_TO_PARENT, Dali::HEIGHT );
449 text.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) );
453 // The popup is not yet on the stage so needs to be flaged as dirty
454 mPopup.MarkDirtyForRelayout();
458 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_ID )
460 mPopup = CreatePopup();
462 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
463 image.SetResizePolicy( FILL_TO_PARENT, WIDTH );
464 image.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
465 image.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) );
469 // The popup is not yet on the stage so needs to be flaged as dirty
470 mPopup.MarkDirtyForRelayout();
474 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID )
476 mPopup = CreatePopup();
478 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
479 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
481 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
482 image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
486 // The popup is not yet on the stage so needs to be flaged as dirty
487 mPopup.MarkDirtyForRelayout();
491 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FIT_ID )
493 mPopup = CreatePopup();
495 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
496 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
498 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
499 image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
500 image.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO );
504 // The popup is not yet on the stage so needs to be flaged as dirty
505 mPopup.MarkDirtyForRelayout();
509 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FILL_ID )
511 mPopup = CreatePopup();
513 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
514 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
516 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
517 image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
518 image.SetSizeScalePolicy( FILL_WITH_ASPECT_RATIO );
522 // The popup is not yet on the stage so needs to be flaged as dirty
523 mPopup.MarkDirtyForRelayout();
527 else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_ID )
529 mPopup = CreatePopup();
530 mPopup.SetTitle( "Popup!" );
532 Toolkit::TextLabel text = Toolkit::TextLabel::New( CONTENT_TEXT );
533 text.SetName( "POPUP_CONTENT_TEXT" );
534 text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
535 text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
536 text.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) );
540 // The popup is not yet on the stage so needs to be flaged as dirty
541 mPopup.MarkDirtyForRelayout();
545 else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS_ID )
547 mPopup = CreatePopup();
548 mPopup.SetTitle( "Popup!" );
550 Toolkit::TextLabel text = Toolkit::TextLabel::New( CONTENT_TEXT );
551 text.SetName( "POPUP_CONTENT_TEXT" );
552 text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
553 text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
554 text.SetPadding( Padding( 10.0f, 10.0f, 20.0f, 0.0f ) );
558 Toolkit::PushButton cancelButton = Toolkit::PushButton::New();
559 cancelButton.SetName( CANCEL_BUTTON_ID );
560 cancelButton.SetLabel( "Cancel" );
561 cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
562 cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
564 cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
566 mPopup.AddButton( cancelButton );
568 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
569 okayButton.SetName( OKAY_BUTTON_ID );
570 okayButton.SetLabel( "OK!" );
571 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
572 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
574 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
576 mPopup.AddButton( okayButton );
578 // The popup is not yet on the stage so needs to be flaged as dirty
579 mPopup.MarkDirtyForRelayout();
583 else if( button.GetName() == POPUP_BUTTON_COMPLEX_ID )
585 mPopup = CreatePopup();
586 mPopup.SetTitle( "Warning" );
589 Toolkit::TableView content = Toolkit::TableView::New( 2, 2 );
590 content.SetName( "COMPLEX_TABLEVIEW" );
591 content.SetResizePolicy( FILL_TO_PARENT, WIDTH );
592 content.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
593 content.SetFitHeight( 0 );
594 content.SetFitHeight( 1 );
595 content.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 0.0f ) );
599 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Do you really want to quit?" );
600 text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
601 text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
603 content.AddChild( text, Toolkit::TableView::CellPosition( 0, 0 ) );
608 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE1 ) );
609 image.SetName( "COMPLEX_IMAGE" );
610 image.SetResizePolicy( FILL_TO_PARENT, WIDTH );
611 image.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
612 image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) );
613 content.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) );
618 Toolkit::TableView root = Toolkit::TableView::New( 1, 2 );
619 root.SetResizePolicy( FILL_TO_PARENT, WIDTH );
620 root.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
621 root.SetFitHeight( 0 );
622 root.SetFitWidth( 0 );
623 root.SetPadding( Padding( 0.0f, 0.0f, 0.0f, 20.0f ) );
625 Dali::Image unchecked = Dali::ResourceImage::New( CHECKBOX_UNCHECKED_IMAGE );
626 Dali::Image checked = Dali::ResourceImage::New( CHECKBOX_CHECKED_IMAGE );
627 Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New();
628 checkBox.SetBackgroundImage( unchecked );
629 checkBox.SetSelectedImage( checked );
630 checkBox.SetSize( 48, 48 );
632 root.AddChild( checkBox, Toolkit::TableView::CellPosition( 0, 0 ) );
634 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Don't show again" );
635 Actor textActor = text;
636 textActor.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 10.0f ) );
638 root.AddChild( text, Toolkit::TableView::CellPosition( 0, 1 ) );
640 content.AddChild( root, Toolkit::TableView::CellPosition( 1, 0, 0, 2 ) ); // Column span 2
643 mPopup.Add( content );
646 Toolkit::PushButton cancelButton = Toolkit::PushButton::New();
647 cancelButton.SetName( CANCEL_BUTTON_ID );
648 cancelButton.SetLabel( "Cancel" );
649 cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
650 cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
652 cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
654 mPopup.AddButton( cancelButton );
656 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
657 okayButton.SetName( OKAY_BUTTON_ID );
658 okayButton.SetLabel( "OK!" );
659 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
660 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
662 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
664 mPopup.AddButton( okayButton );
666 // The popup is not yet on the stage so needs to be flaged as dirty
667 mPopup.MarkDirtyForRelayout();
671 else if( button.GetName() == TABLEVIEW_BUTTON_EMPTY_ID )
673 mPopup = CreatePopup();
674 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
675 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
678 Toolkit::TableView table = Toolkit::TableView::New( 0, 0 );
679 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
683 // The popup is not yet on the stage so needs to be flaged as dirty
684 mPopup.MarkDirtyForRelayout();
688 else if( button.GetName() == TABLEVIEW_BUTTON_1CELL_ID )
690 mPopup = CreatePopup();
691 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
692 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
695 Toolkit::TableView table = Toolkit::TableView::New( 0, 0 );
696 table.SetName( "TABLEVIEW_BUTTON_1CELL_ID" );
697 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
699 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
700 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
701 table.Add( backing );
705 // The popup is not yet on the stage so needs to be flaged as dirty
706 mPopup.MarkDirtyForRelayout();
710 else if( button.GetName() == TABLEVIEW_BUTTON_3CELL_ID )
712 mPopup = CreatePopup();
713 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
714 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
717 Toolkit::TableView table = Toolkit::TableView::New( 0, 0 );
718 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
721 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
722 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
723 table.Add( backing );
726 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
727 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
728 table.Add( backing );
731 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
732 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
733 table.Add( backing );
738 // The popup is not yet on the stage so needs to be flaged as dirty
739 mPopup.MarkDirtyForRelayout();
743 else if( button.GetName() == TABLEVIEW_BUTTON_3X3CELL_ID )
745 mPopup = CreatePopup();
746 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
747 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
750 Toolkit::TableView table = Toolkit::TableView::New( 3, 3 );
751 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
755 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
756 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
757 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 0 ) );
760 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
761 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
762 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 0 ) );
765 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
766 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
767 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 0 ) );
772 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) );
773 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
774 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 1 ) );
777 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
778 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
779 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 1 ) );
782 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 0.0f, 1.0f, 1.0f ) );
783 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
784 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 1 ) );
789 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) );
790 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
791 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 2 ) );
794 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.5f, 0.5f, 0.5f, 1.0f ) );
795 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
796 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 2 ) );
799 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.5f, 0.0f, 1.0f ) );
800 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
801 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 2 ) );
806 // The popup is not yet on the stage so needs to be flaged as dirty
807 mPopup.MarkDirtyForRelayout();
811 else if( button.GetName() == TABLEVIEW_BUTTON_FIXED1_ID )
813 mPopup = CreatePopup();
814 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
815 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
818 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
819 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
820 table.SetFixedHeight( 0, 50.0f );
823 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
824 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
825 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
826 text.SetAnchorPoint( AnchorPoint::CENTER );
827 text.SetParentOrigin( ParentOrigin::CENTER );
829 table.Add( backing );
832 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
833 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
834 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
835 text.SetAnchorPoint( AnchorPoint::CENTER );
836 text.SetParentOrigin( ParentOrigin::CENTER );
838 table.Add( backing );
841 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
842 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
843 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
844 text.SetAnchorPoint( AnchorPoint::CENTER );
845 text.SetParentOrigin( ParentOrigin::CENTER );
847 table.Add( backing );
852 // The popup is not yet on the stage so needs to be flaged as dirty
853 mPopup.MarkDirtyForRelayout();
857 else if( button.GetName() == TABLEVIEW_BUTTON_FIXED2_ID )
859 mPopup = CreatePopup();
860 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
861 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
864 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
865 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
866 table.SetFixedHeight( 0, 50.0f );
867 table.SetFixedHeight( 2, 50.0f );
870 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
871 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
872 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
873 text.SetAnchorPoint( AnchorPoint::CENTER );
874 text.SetParentOrigin( ParentOrigin::CENTER );
876 table.Add( backing );
879 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
880 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
881 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
882 text.SetAnchorPoint( AnchorPoint::CENTER );
883 text.SetParentOrigin( ParentOrigin::CENTER );
885 table.Add( backing );
888 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
889 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
890 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
891 text.SetAnchorPoint( AnchorPoint::CENTER );
892 text.SetParentOrigin( ParentOrigin::CENTER );
894 table.Add( backing );
899 // The popup is not yet on the stage so needs to be flaged as dirty
900 mPopup.MarkDirtyForRelayout();
904 else if( button.GetName() == TABLEVIEW_BUTTON_FIT1_ID )
906 mPopup = CreatePopup();
907 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
908 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
911 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
912 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
913 table.SetFitHeight( 0 );
914 table.SetFitHeight( 2 );
917 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
918 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
919 backing.SetSize( 0.0f, 100.0f );
921 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
922 text.SetAnchorPoint( AnchorPoint::CENTER );
923 text.SetParentOrigin( ParentOrigin::CENTER );
926 table.Add( backing );
929 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
930 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
932 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
933 text.SetAnchorPoint( AnchorPoint::CENTER );
934 text.SetParentOrigin( ParentOrigin::CENTER );
937 table.Add( backing );
940 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
941 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
942 backing.SetSize( 0.0f, 100.0f );
944 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
945 text.SetAnchorPoint( AnchorPoint::CENTER );
946 text.SetParentOrigin( ParentOrigin::CENTER );
949 table.Add( backing );
954 // The popup is not yet on the stage so needs to be flaged as dirty
955 mPopup.MarkDirtyForRelayout();
959 else if( button.GetName() == TABLEVIEW_BUTTON_FIT2_ID )
961 mPopup = CreatePopup();
962 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
963 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
965 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
966 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
967 table.SetFitHeight( 1 );
970 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
971 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
973 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
974 text.SetAnchorPoint( AnchorPoint::CENTER );
975 text.SetParentOrigin( ParentOrigin::CENTER );
978 table.Add( backing );
981 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
982 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
983 backing.SetSize( 0.0f, 200.0f );
985 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
986 text.SetAnchorPoint( AnchorPoint::CENTER );
987 text.SetParentOrigin( ParentOrigin::CENTER );
990 table.Add( backing );
993 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
994 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
996 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
997 text.SetAnchorPoint( AnchorPoint::CENTER );
998 text.SetParentOrigin( ParentOrigin::CENTER );
1001 table.Add( backing );
1004 mPopup.Add( table );
1006 // The popup is not yet on the stage so needs to be flaged as dirty
1007 mPopup.MarkDirtyForRelayout();
1011 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL1_ID )
1013 mPopup = CreatePopup();
1014 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, WIDTH );
1015 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
1016 mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
1018 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
1019 table.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1020 table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
1021 table.SetFitHeight( 0 );
1022 table.SetFitHeight( 1 );
1023 table.SetFitHeight( 2 );
1026 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1027 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1028 backing.SetSize( 0.0f, 100.0f );
1030 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1031 text.SetAnchorPoint( AnchorPoint::CENTER );
1032 text.SetParentOrigin( ParentOrigin::CENTER );
1033 backing.Add( text );
1035 table.Add( backing );
1038 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
1039 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1040 backing.SetSize( 0.0f, 200.0f );
1042 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1043 text.SetAnchorPoint( AnchorPoint::CENTER );
1044 text.SetParentOrigin( ParentOrigin::CENTER );
1045 backing.Add( text );
1047 table.Add( backing );
1050 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1051 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1052 backing.SetSize( 0.0f, 300.0f );
1054 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1055 text.SetAnchorPoint( AnchorPoint::CENTER );
1056 text.SetParentOrigin( ParentOrigin::CENTER );
1057 backing.Add( text );
1059 table.Add( backing );
1062 mPopup.Add( table );
1064 // The popup is not yet on the stage so needs to be flaged as dirty
1065 mPopup.MarkDirtyForRelayout();
1069 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL2_ID )
1071 mPopup = CreatePopup();
1072 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, WIDTH );
1073 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
1074 mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
1076 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
1077 table.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1078 table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
1079 table.SetFitHeight( 0 );
1080 table.SetFitHeight( 1 );
1083 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1084 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1085 backing.SetResizePolicy( FIXED, HEIGHT );
1086 backing.SetSize( 0.0f, 100.0f );
1088 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1089 text.SetAnchorPoint( AnchorPoint::CENTER );
1090 text.SetParentOrigin( ParentOrigin::CENTER );
1091 backing.Add( text );
1093 table.Add( backing );
1096 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1097 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1098 backing.SetSize( 0.0f, 200.0f );
1100 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1101 text.SetAnchorPoint( AnchorPoint::CENTER );
1102 text.SetParentOrigin( ParentOrigin::CENTER );
1103 backing.Add( text );
1105 table.Add( backing );
1108 mPopup.Add( table );
1110 // The popup is not yet on the stage so needs to be flaged as dirty
1111 mPopup.MarkDirtyForRelayout();
1115 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL3_ID )
1117 mPopup = CreatePopup();
1118 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, WIDTH );
1119 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
1120 mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
1122 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
1123 table.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1124 table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
1125 table.SetFixedHeight( 0, 20.0f );
1126 table.SetFitHeight( 1 );
1129 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1130 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
1132 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
1133 text.SetAnchorPoint( AnchorPoint::CENTER );
1134 text.SetParentOrigin( ParentOrigin::CENTER );
1135 backing.Add( text );
1137 table.Add( backing );
1140 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1141 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1142 backing.SetSize( 0.0f, 200.0f );
1144 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1145 text.SetAnchorPoint( AnchorPoint::CENTER );
1146 text.SetParentOrigin( ParentOrigin::CENTER );
1147 backing.Add( text );
1149 table.Add( backing );
1152 mPopup.Add( table );
1154 // The popup is not yet on the stage so needs to be flaged as dirty
1155 mPopup.MarkDirtyForRelayout();
1159 else if( button.GetName() == OKAY_BUTTON_ID || button.GetName() == CANCEL_BUTTON_ID )
1170 void OnPopupOutsideTouched()
1178 void OnKeyEvent( const KeyEvent& event )
1180 if( event.state == KeyEvent::Down )
1182 if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) )
1184 // Exit application when click back or escape.
1185 mApplication.Quit();
1190 public: // From ItemFactory
1193 * @brief Return the number of items to display in the item view
1195 * @return Return the number of items to display
1197 virtual unsigned int GetNumberOfItems()
1199 switch( mDemoState )
1203 return POPUP_BUTTON_ITEMS_COUNT;
1208 return TABLEVIEW_BUTTON_ITEMS_COUNT;
1221 * @brief Create a new item to populate the item view with
1223 * @param[in] itemId The index of the item to create
1224 * @return Return the created actor for the given ID
1226 virtual Actor NewItem(unsigned int itemId)
1228 const ButtonItem* buttonDataArray = NULL;
1229 switch( mDemoState )
1233 buttonDataArray = POPUP_BUTTON_ITEMS;
1239 buttonDataArray = TABLEVIEW_BUTTON_ITEMS;
1249 if( buttonDataArray )
1251 Toolkit::PushButton popupButton = Toolkit::PushButton::New();
1252 popupButton.SetName( buttonDataArray[ itemId ].name );
1253 popupButton.SetLabel( buttonDataArray[ itemId ].text );
1254 popupButton.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
1256 popupButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
1257 popupButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
1259 popupButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
1275 Application& mApplication;
1276 Toolkit::View mView; ///< The View instance.
1277 Toolkit::ToolBar mToolBar; ///< The View's Toolbar.
1278 Layer mContentLayer; ///< Content layer
1280 Toolkit::TextLabel mTitleActor; ///< Title text
1282 Toolkit::Popup mMenu; ///< The navigation menu
1283 bool mMenuShown; ///< If the navigation menu is currently being displayed or not
1285 Toolkit::Popup mPopup;
1287 Toolkit::ItemView mItemView; ///< ItemView to hold test images
1289 DemoState mDemoState;
1292 void RunTest( Application& application )
1294 SizeNegotiationController test( application );
1296 application.MainLoop();
1299 // Entry point for Linux & SLP applications
1301 int main( int argc, char **argv )
1303 Application application = Application::New( &argc, &argv );
1305 RunTest( application );