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.SetPreferredSize( Vector2( 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.SetPreferredSize( Vector2( 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.SetDimensionDependency( HEIGHT, WIDTH );
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( FILL_TO_PARENT, ALL_DIMENSIONS );
479 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
480 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
482 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
483 image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
487 // The popup is not yet on the stage so needs to be flaged as dirty
488 mPopup.MarkDirtyForRelayout();
492 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FIT_ID )
494 mPopup = CreatePopup();
496 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
497 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
498 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
500 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
501 image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
502 image.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO );
506 // The popup is not yet on the stage so needs to be flaged as dirty
507 mPopup.MarkDirtyForRelayout();
511 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FILL_ID )
513 mPopup = CreatePopup();
515 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
516 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
517 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
519 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
520 image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
521 image.SetSizeScalePolicy( FILL_WITH_ASPECT_RATIO );
525 // The popup is not yet on the stage so needs to be flaged as dirty
526 mPopup.MarkDirtyForRelayout();
530 else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_ID )
532 mPopup = CreatePopup();
533 mPopup.SetTitle( "Popup!" );
535 Toolkit::TextLabel text = Toolkit::TextLabel::New( CONTENT_TEXT );
536 text.SetName( "POPUP_CONTENT_TEXT" );
537 text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
538 text.SetDimensionDependency( HEIGHT, WIDTH );
539 text.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) );
543 // The popup is not yet on the stage so needs to be flaged as dirty
544 mPopup.MarkDirtyForRelayout();
548 else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS_ID )
550 mPopup = CreatePopup();
551 mPopup.SetTitle( "Popup!" );
553 Toolkit::TextLabel text = Toolkit::TextLabel::New( CONTENT_TEXT );
554 text.SetName( "POPUP_CONTENT_TEXT" );
555 text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
556 text.SetDimensionDependency( HEIGHT, WIDTH );
557 text.SetPadding( Padding( 10.0f, 10.0f, 20.0f, 0.0f ) );
561 Toolkit::PushButton cancelButton = Toolkit::PushButton::New();
562 cancelButton.SetName( CANCEL_BUTTON_ID );
563 cancelButton.SetLabel( "Cancel" );
564 cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
565 cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
567 cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
569 mPopup.AddButton( cancelButton );
571 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
572 okayButton.SetName( OKAY_BUTTON_ID );
573 okayButton.SetLabel( "OK!" );
574 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
575 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
577 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
579 mPopup.AddButton( okayButton );
581 // The popup is not yet on the stage so needs to be flaged as dirty
582 mPopup.MarkDirtyForRelayout();
586 else if( button.GetName() == POPUP_BUTTON_COMPLEX_ID )
588 mPopup = CreatePopup();
589 mPopup.SetTitle( "Warning" );
592 Toolkit::TableView content = Toolkit::TableView::New( 2, 2 );
593 content.SetName( "COMPLEX_TABLEVIEW" );
594 content.SetResizePolicy( FILL_TO_PARENT, WIDTH );
595 content.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
596 content.SetFitHeight( 0 );
597 content.SetFitHeight( 1 );
598 content.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 0.0f ) );
602 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Do you really want to quit?" );
603 text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
604 text.SetDimensionDependency( HEIGHT, WIDTH );
606 content.AddChild( text, Toolkit::TableView::CellPosition( 0, 0 ) );
611 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE1 ) );
612 image.SetName( "COMPLEX_IMAGE" );
613 image.SetResizePolicy( FILL_TO_PARENT, WIDTH );
614 image.SetDimensionDependency( HEIGHT, WIDTH );
615 image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) );
616 content.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) );
621 Toolkit::TableView root = Toolkit::TableView::New( 1, 2 );
622 root.SetResizePolicy( FILL_TO_PARENT, WIDTH );
623 root.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
624 root.SetFitHeight( 0 );
625 root.SetFitWidth( 0 );
626 root.SetPadding( Padding( 0.0f, 0.0f, 0.0f, 20.0f ) );
628 Dali::Image unchecked = Dali::ResourceImage::New( CHECKBOX_UNCHECKED_IMAGE );
629 Dali::Image checked = Dali::ResourceImage::New( CHECKBOX_CHECKED_IMAGE );
630 Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New();
631 checkBox.SetBackgroundImage( unchecked );
632 checkBox.SetSelectedImage( checked );
633 checkBox.SetPreferredSize( Vector2( 48, 48 ) );
634 checkBox.SetResizePolicy( FIXED, ALL_DIMENSIONS );
636 root.AddChild( checkBox, Toolkit::TableView::CellPosition( 0, 0 ) );
638 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Don't show again" );
639 Actor textActor = text;
640 textActor.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 10.0f ) );
642 root.AddChild( text, Toolkit::TableView::CellPosition( 0, 1 ) );
644 content.AddChild( root, Toolkit::TableView::CellPosition( 1, 0, 0, 2 ) ); // Column span 2
647 mPopup.Add( content );
650 Toolkit::PushButton cancelButton = Toolkit::PushButton::New();
651 cancelButton.SetName( CANCEL_BUTTON_ID );
652 cancelButton.SetLabel( "Cancel" );
653 cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
654 cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
656 cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
658 mPopup.AddButton( cancelButton );
660 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
661 okayButton.SetName( OKAY_BUTTON_ID );
662 okayButton.SetLabel( "OK!" );
663 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
664 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
666 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
668 mPopup.AddButton( okayButton );
670 // The popup is not yet on the stage so needs to be flaged as dirty
671 mPopup.MarkDirtyForRelayout();
675 else if( button.GetName() == TABLEVIEW_BUTTON_EMPTY_ID )
677 mPopup = CreatePopup();
678 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
679 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
680 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
683 Toolkit::TableView table = Toolkit::TableView::New( 0, 0 );
684 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
688 // The popup is not yet on the stage so needs to be flaged as dirty
689 mPopup.MarkDirtyForRelayout();
693 else if( button.GetName() == TABLEVIEW_BUTTON_1CELL_ID )
695 mPopup = CreatePopup();
696 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
697 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
698 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
701 Toolkit::TableView table = Toolkit::TableView::New( 0, 0 );
702 table.SetName( "TABLEVIEW_BUTTON_1CELL_ID" );
703 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
705 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
706 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
707 table.Add( backing );
711 // The popup is not yet on the stage so needs to be flaged as dirty
712 mPopup.MarkDirtyForRelayout();
716 else if( button.GetName() == TABLEVIEW_BUTTON_3CELL_ID )
718 mPopup = CreatePopup();
719 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
720 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
721 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
724 Toolkit::TableView table = Toolkit::TableView::New( 0, 0 );
725 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
728 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
729 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
730 table.Add( backing );
733 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
734 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
735 table.Add( backing );
738 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
739 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
740 table.Add( backing );
745 // The popup is not yet on the stage so needs to be flaged as dirty
746 mPopup.MarkDirtyForRelayout();
750 else if( button.GetName() == TABLEVIEW_BUTTON_3X3CELL_ID )
752 mPopup = CreatePopup();
753 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
754 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
755 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
758 Toolkit::TableView table = Toolkit::TableView::New( 3, 3 );
759 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
763 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
764 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
765 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 0 ) );
768 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
769 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
770 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 0 ) );
773 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
774 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
775 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 0 ) );
780 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) );
781 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
782 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 1 ) );
785 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
786 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
787 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 1 ) );
790 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 0.0f, 1.0f, 1.0f ) );
791 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
792 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 1 ) );
797 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) );
798 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
799 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 2 ) );
802 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.5f, 0.5f, 0.5f, 1.0f ) );
803 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
804 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 2 ) );
807 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.5f, 0.0f, 1.0f ) );
808 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
809 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 2 ) );
814 // The popup is not yet on the stage so needs to be flaged as dirty
815 mPopup.MarkDirtyForRelayout();
819 else if( button.GetName() == TABLEVIEW_BUTTON_FIXED1_ID )
821 mPopup = CreatePopup();
822 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
823 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
824 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
827 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
828 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
829 table.SetFixedHeight( 0, 50.0f );
832 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
833 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
834 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
835 text.SetAnchorPoint( AnchorPoint::CENTER );
836 text.SetParentOrigin( ParentOrigin::CENTER );
838 table.Add( backing );
841 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.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 );
850 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
851 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
852 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
853 text.SetAnchorPoint( AnchorPoint::CENTER );
854 text.SetParentOrigin( ParentOrigin::CENTER );
856 table.Add( backing );
861 // The popup is not yet on the stage so needs to be flaged as dirty
862 mPopup.MarkDirtyForRelayout();
866 else if( button.GetName() == TABLEVIEW_BUTTON_FIXED2_ID )
868 mPopup = CreatePopup();
869 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
870 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
871 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
874 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
875 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
876 table.SetFixedHeight( 0, 50.0f );
877 table.SetFixedHeight( 2, 50.0f );
880 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
881 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
882 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
883 text.SetAnchorPoint( AnchorPoint::CENTER );
884 text.SetParentOrigin( ParentOrigin::CENTER );
886 table.Add( backing );
889 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
890 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
891 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
892 text.SetAnchorPoint( AnchorPoint::CENTER );
893 text.SetParentOrigin( ParentOrigin::CENTER );
895 table.Add( backing );
898 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
899 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
900 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
901 text.SetAnchorPoint( AnchorPoint::CENTER );
902 text.SetParentOrigin( ParentOrigin::CENTER );
904 table.Add( backing );
909 // The popup is not yet on the stage so needs to be flaged as dirty
910 mPopup.MarkDirtyForRelayout();
914 else if( button.GetName() == TABLEVIEW_BUTTON_FIT1_ID )
916 mPopup = CreatePopup();
917 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
918 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
919 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
922 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
923 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
924 table.SetFitHeight( 0 );
925 table.SetFitHeight( 2 );
928 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
929 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
930 backing.SetResizePolicy( FIXED, HEIGHT );
931 backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
933 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
934 text.SetAnchorPoint( AnchorPoint::CENTER );
935 text.SetParentOrigin( ParentOrigin::CENTER );
938 table.Add( backing );
941 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
942 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
944 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
945 text.SetAnchorPoint( AnchorPoint::CENTER );
946 text.SetParentOrigin( ParentOrigin::CENTER );
949 table.Add( backing );
952 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
953 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
954 backing.SetResizePolicy( FIXED, HEIGHT );
955 backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
957 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
958 text.SetAnchorPoint( AnchorPoint::CENTER );
959 text.SetParentOrigin( ParentOrigin::CENTER );
962 table.Add( backing );
967 // The popup is not yet on the stage so needs to be flaged as dirty
968 mPopup.MarkDirtyForRelayout();
972 else if( button.GetName() == TABLEVIEW_BUTTON_FIT2_ID )
974 mPopup = CreatePopup();
975 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
976 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
977 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
980 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
981 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
982 table.SetFitHeight( 1 );
985 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
986 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
988 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
989 text.SetAnchorPoint( AnchorPoint::CENTER );
990 text.SetParentOrigin( ParentOrigin::CENTER );
993 table.Add( backing );
996 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
997 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
998 backing.SetResizePolicy( FIXED, HEIGHT );
999 backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
1001 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1002 text.SetAnchorPoint( AnchorPoint::CENTER );
1003 text.SetParentOrigin( ParentOrigin::CENTER );
1004 backing.Add( text );
1006 table.Add( backing );
1009 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1010 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
1012 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
1013 text.SetAnchorPoint( AnchorPoint::CENTER );
1014 text.SetParentOrigin( ParentOrigin::CENTER );
1015 backing.Add( text );
1017 table.Add( backing );
1020 mPopup.Add( table );
1022 // The popup is not yet on the stage so needs to be flaged as dirty
1023 mPopup.MarkDirtyForRelayout();
1027 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL1_ID )
1029 mPopup = CreatePopup();
1030 mPopup.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1031 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
1032 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
1033 mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
1035 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
1036 table.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1037 table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
1038 table.SetFitHeight( 0 );
1039 table.SetFitHeight( 1 );
1040 table.SetFitHeight( 2 );
1043 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1044 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1045 backing.SetResizePolicy( FIXED, HEIGHT );
1046 backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
1048 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1049 text.SetAnchorPoint( AnchorPoint::CENTER );
1050 text.SetParentOrigin( ParentOrigin::CENTER );
1051 backing.Add( text );
1053 table.Add( backing );
1056 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
1057 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1058 backing.SetResizePolicy( FIXED, HEIGHT );
1059 backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
1061 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1062 text.SetAnchorPoint( AnchorPoint::CENTER );
1063 text.SetParentOrigin( ParentOrigin::CENTER );
1064 backing.Add( text );
1066 table.Add( backing );
1069 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1070 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1071 backing.SetResizePolicy( FIXED, HEIGHT );
1072 backing.SetPreferredSize( Vector2( 0.0f, 300.0f ) );
1074 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1075 text.SetAnchorPoint( AnchorPoint::CENTER );
1076 text.SetParentOrigin( ParentOrigin::CENTER );
1077 backing.Add( text );
1079 table.Add( backing );
1082 mPopup.Add( table );
1084 // The popup is not yet on the stage so needs to be flaged as dirty
1085 mPopup.MarkDirtyForRelayout();
1089 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL2_ID )
1091 mPopup = CreatePopup();
1092 mPopup.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1093 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
1094 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
1095 mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
1097 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
1098 table.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1099 table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
1100 table.SetFitHeight( 0 );
1101 table.SetFitHeight( 1 );
1104 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1105 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1106 backing.SetResizePolicy( FIXED, HEIGHT );
1107 backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
1109 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1110 text.SetAnchorPoint( AnchorPoint::CENTER );
1111 text.SetParentOrigin( ParentOrigin::CENTER );
1112 backing.Add( text );
1114 table.Add( backing );
1117 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1118 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1119 backing.SetResizePolicy( FIXED, HEIGHT );
1120 backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
1122 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1123 text.SetAnchorPoint( AnchorPoint::CENTER );
1124 text.SetParentOrigin( ParentOrigin::CENTER );
1125 backing.Add( text );
1127 table.Add( backing );
1130 mPopup.Add( table );
1132 // The popup is not yet on the stage so needs to be flaged as dirty
1133 mPopup.MarkDirtyForRelayout();
1137 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL3_ID )
1139 mPopup = CreatePopup();
1140 mPopup.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1141 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
1142 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
1143 mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
1145 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
1146 table.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1147 table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
1148 table.SetFixedHeight( 0, 20.0f );
1149 table.SetFitHeight( 1 );
1152 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1153 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
1155 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
1156 text.SetAnchorPoint( AnchorPoint::CENTER );
1157 text.SetParentOrigin( ParentOrigin::CENTER );
1158 backing.Add( text );
1160 table.Add( backing );
1163 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1164 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1165 backing.SetResizePolicy( FIXED, HEIGHT );
1166 backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
1168 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1169 text.SetAnchorPoint( AnchorPoint::CENTER );
1170 text.SetParentOrigin( ParentOrigin::CENTER );
1171 backing.Add( text );
1173 table.Add( backing );
1176 mPopup.Add( table );
1178 // The popup is not yet on the stage so needs to be flaged as dirty
1179 mPopup.MarkDirtyForRelayout();
1183 else if( button.GetName() == OKAY_BUTTON_ID || button.GetName() == CANCEL_BUTTON_ID )
1194 void OnPopupOutsideTouched()
1202 void OnKeyEvent( const KeyEvent& event )
1204 if( event.state == KeyEvent::Down )
1206 if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) )
1208 // Exit application when click back or escape.
1209 mApplication.Quit();
1214 public: // From ItemFactory
1217 * @brief Return the number of items to display in the item view
1219 * @return Return the number of items to display
1221 virtual unsigned int GetNumberOfItems()
1223 switch( mDemoState )
1227 return POPUP_BUTTON_ITEMS_COUNT;
1232 return TABLEVIEW_BUTTON_ITEMS_COUNT;
1245 * @brief Create a new item to populate the item view with
1247 * @param[in] itemId The index of the item to create
1248 * @return Return the created actor for the given ID
1250 virtual Actor NewItem(unsigned int itemId)
1252 const ButtonItem* buttonDataArray = NULL;
1253 switch( mDemoState )
1257 buttonDataArray = POPUP_BUTTON_ITEMS;
1263 buttonDataArray = TABLEVIEW_BUTTON_ITEMS;
1273 if( buttonDataArray )
1275 Toolkit::PushButton popupButton = Toolkit::PushButton::New();
1276 popupButton.SetName( buttonDataArray[ itemId ].name );
1277 popupButton.SetLabel( buttonDataArray[ itemId ].text );
1278 popupButton.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
1280 popupButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
1281 popupButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
1283 popupButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
1299 Application& mApplication;
1300 Toolkit::View mView; ///< The View instance.
1301 Toolkit::ToolBar mToolBar; ///< The View's Toolbar.
1302 Layer mContentLayer; ///< Content layer
1304 Toolkit::TextLabel mTitleActor; ///< Title text
1306 Toolkit::Popup mMenu; ///< The navigation menu
1307 bool mMenuShown; ///< If the navigation menu is currently being displayed or not
1309 Toolkit::Popup mPopup;
1311 Toolkit::ItemView mItemView; ///< ItemView to hold test images
1313 DemoState mDemoState;
1316 void RunTest( Application& application )
1318 SizeNegotiationController test( application );
1320 application.MainLoop();
1323 // Entry point for Linux & SLP applications
1325 int main( int argc, char **argv )
1327 Application application = Application::New( &argc, &argv );
1329 RunTest( application );