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 Stage stage = Stage::GetCurrent();
162 // Respond to key events
163 stage.KeyEventSignal().Connect(this, &SizeNegotiationController::OnKeyEvent);
165 // Creates a default view with a default tool bar.
166 // The view is added to the stage.
167 mContentLayer = DemoHelper::CreateView( application,
174 mTitleActor = DemoHelper::CreateToolBarLabel( "CUSTOM_TOOLBAR_TITLE" );
178 // Create menu button
179 Toolkit::PushButton viewButton = Toolkit::PushButton::New();
180 viewButton.SetBackgroundImage( ResourceImage::New( MENU_ICON_IMAGE ) );
181 viewButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnMenu );
182 mToolBar.AddControl( viewButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
184 // Add title to the tool bar.
185 const float padding( DemoHelper::DEFAULT_VIEW_STYLE.mToolBarPadding );
186 mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::Padding( padding, padding, padding, padding ) );
188 mItemView = Toolkit::ItemView::New( *this );
189 mItemView.SetParentOrigin( ParentOrigin::CENTER );
190 mItemView.SetAnchorPoint( AnchorPoint::CENTER );
191 mItemView.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
193 // Use a grid layout for tests
194 Toolkit::GridLayoutPtr gridLayout = Toolkit::GridLayout::New();
195 gridLayout->SetNumberOfColumns( 2 );
196 gridLayout->SetTopMargin( DP(TOOLBAR_HEIGHT) + DP(20.0f) );
197 gridLayout->SetBottomMargin( DP(100.0f) );
198 gridLayout->SetRowSpacing( DP(20.0f) );
199 mItemView.AddLayout( *gridLayout );
201 Vector2 stageSize = stage.GetSize();
202 float layoutWidth = Toolkit::IsHorizontal( gridLayout->GetOrientation() ) ? stageSize.height : stageSize.width;
203 float gridItemSize = ( layoutWidth / gridLayout->GetNumberOfColumns() ) * 0.5f;
204 gridLayout->SetScrollSpeedFactor( gridLayout->GetNumberOfColumns() / gridItemSize * 0.5f );
206 mItemView.ActivateLayout( 0, Vector3(stageSize.x, stageSize.y, stageSize.x), 0.0f );
208 mContentLayer.Add( mItemView );
213 std::string subTitle = "";
225 subTitle = "TableView";
235 mTitleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, std::string( std::string( TOOLBAR_TITLE ) + ": " + subTitle ) );
238 bool OnMenu( Toolkit::Button button )
246 Stage stage = Stage::GetCurrent();
247 const float popupWidth = stage.GetSize().x * 0.5f;
249 mMenu = Toolkit::Popup::New();
250 mMenu.SetParentOrigin( ParentOrigin::TOP_LEFT );
251 mMenu.SetAnchorPoint( AnchorPoint::TOP_LEFT );
253 mMenu.OutsideTouchedSignal().Connect( this, &SizeNegotiationController::HideMenu );
254 mMenu.SetPreferredSize( Vector2( popupWidth, 0.0f ) );
255 mMenu.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
257 Toolkit::TableView tableView = Toolkit::TableView::New( 0, 0 );
258 tableView.SetResizePolicy( FILL_TO_PARENT, WIDTH );
259 tableView.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
260 mMenu.Add( tableView );
262 for( unsigned int i = 0; i < MENU_ITEMS_COUNT; ++i )
264 Toolkit::PushButton menuButton = Toolkit::PushButton::New();
265 menuButton.SetName( MENU_ITEMS[ i ].name );
266 menuButton.SetLabel( MENU_ITEMS[ i ].text );
267 menuButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnMenuSelect );
269 tableView.Add( menuButton );
270 tableView.SetFitHeight( i );
289 bool OnMenuSelect( Toolkit::Button button )
291 bool refresh = false;
293 if( button.GetName() == POPUPS_MENU_ID )
295 if( mDemoState != POPUP )
301 else if( button.GetName() == TABLEVIEW_MENU_ID )
303 if( mDemoState != TABLEVIEW )
306 mDemoState = TABLEVIEW;
321 Toolkit::Popup CreatePopup()
323 Stage stage = Stage::GetCurrent();
324 const float POPUP_WIDTH_DP = stage.GetSize().width * 0.75f;
326 Toolkit::Popup popup = Toolkit::Popup::New();
327 popup.SetName( "POPUP" );
328 popup.SetParentOrigin( ParentOrigin::CENTER );
329 popup.SetAnchorPoint( AnchorPoint::CENTER );
330 popup.SetPreferredSize( Vector2( POPUP_WIDTH_DP, 0.0f ) );
333 popup.OutsideTouchedSignal().Connect( this, &SizeNegotiationController::OnPopupOutsideTouched );
338 bool OnButtonClicked( Toolkit::Button button )
340 if( button.GetName() == POPUP_BUTTON_EMPTY_ID )
342 mPopup = CreatePopup();
344 // The popup is not yet on the stage so needs to be flaged as dirty
345 mPopup.MarkDirtyForRelayout();
349 else if( button.GetName() == POPUP_BUTTON_TITLE_ID )
351 mPopup = CreatePopup();
352 mPopup.SetTitle( "Popup!" );
354 // The popup is not yet on the stage so needs to be flaged as dirty
355 mPopup.MarkDirtyForRelayout();
359 else if( button.GetName() == POPUP_BUTTON_BUTTONS_1_ID )
361 mPopup = CreatePopup();
363 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
364 okayButton.SetName( OKAY_BUTTON_ID );
365 okayButton.SetLabel( "OK!" );
366 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
367 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
369 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
371 mPopup.AddButton( okayButton );
373 // The popup is not yet on the stage so needs to be flaged as dirty
374 mPopup.MarkDirtyForRelayout();
378 else if( button.GetName() == POPUP_BUTTON_BUTTONS_2_ID )
380 mPopup = CreatePopup();
382 Toolkit::PushButton cancelButton = Toolkit::PushButton::New();
383 cancelButton.SetName( CANCEL_BUTTON_ID );
384 cancelButton.SetLabel( "Cancel" );
385 cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
386 cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
388 cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
390 mPopup.AddButton( cancelButton );
392 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
393 okayButton.SetName( OKAY_BUTTON_ID );
394 okayButton.SetLabel( "OK!" );
395 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
396 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
398 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
400 mPopup.AddButton( okayButton );
402 // The popup is not yet on the stage so needs to be flaged as dirty
403 mPopup.MarkDirtyForRelayout();
407 else if( button.GetName() == POPUP_BUTTON_TITLE_BUTTONS_ID )
409 mPopup = CreatePopup();
410 mPopup.SetTitle( "Popup!" );
412 Toolkit::PushButton cancelButton = Toolkit::PushButton::New();
413 cancelButton.SetName( CANCEL_BUTTON_ID );
414 cancelButton.SetLabel( "Cancel" );
415 cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
416 cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
418 cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
420 mPopup.AddButton( cancelButton );
422 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
423 okayButton.SetName( OKAY_BUTTON_ID );
424 okayButton.SetLabel( "OK!" );
425 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
426 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
428 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
430 mPopup.AddButton( okayButton );
432 // The popup is not yet on the stage so needs to be flaged as dirty
433 mPopup.MarkDirtyForRelayout();
437 else if( button.GetName() == POPUP_BUTTON_CONTENT_TEXT_ID )
439 mPopup = CreatePopup();
441 TextLabel text = TextLabel::New( CONTENT_TEXT );
442 text.SetName( "POPUP_CONTENT_TEXT" );
443 text.SetProperty( TextLabel::Property::MULTI_LINE, true );
444 text.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
445 text.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
446 text.SetResizePolicy( FILL_TO_PARENT, Dali::HEIGHT );
447 text.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) );
451 // The popup is not yet on the stage so needs to be flaged as dirty
452 mPopup.MarkDirtyForRelayout();
456 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_ID )
458 mPopup = CreatePopup();
460 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
461 image.SetResizePolicy( FILL_TO_PARENT, WIDTH );
462 image.SetDimensionDependency( HEIGHT, WIDTH );
463 image.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) );
467 // The popup is not yet on the stage so needs to be flaged as dirty
468 mPopup.MarkDirtyForRelayout();
472 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID )
474 mPopup = CreatePopup();
476 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
477 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
478 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
480 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
481 image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
485 // The popup is not yet on the stage so needs to be flaged as dirty
486 mPopup.MarkDirtyForRelayout();
490 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FIT_ID )
492 mPopup = CreatePopup();
494 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
495 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
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( FILL_TO_PARENT, ALL_DIMENSIONS );
514 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
515 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
517 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
518 image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
519 image.SetSizeScalePolicy( FILL_WITH_ASPECT_RATIO );
523 // The popup is not yet on the stage so needs to be flaged as dirty
524 mPopup.MarkDirtyForRelayout();
528 else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_ID )
530 mPopup = CreatePopup();
531 mPopup.SetTitle( "Popup!" );
533 Toolkit::TextLabel text = Toolkit::TextLabel::New( CONTENT_TEXT );
534 text.SetName( "POPUP_CONTENT_TEXT" );
535 text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
536 text.SetDimensionDependency( HEIGHT, WIDTH );
537 text.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) );
541 // The popup is not yet on the stage so needs to be flaged as dirty
542 mPopup.MarkDirtyForRelayout();
546 else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS_ID )
548 mPopup = CreatePopup();
549 mPopup.SetTitle( "Popup!" );
551 Toolkit::TextLabel text = Toolkit::TextLabel::New( CONTENT_TEXT );
552 text.SetName( "POPUP_CONTENT_TEXT" );
553 text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
554 text.SetDimensionDependency( HEIGHT, WIDTH );
555 text.SetPadding( Padding( 10.0f, 10.0f, 20.0f, 0.0f ) );
559 Toolkit::PushButton cancelButton = Toolkit::PushButton::New();
560 cancelButton.SetName( CANCEL_BUTTON_ID );
561 cancelButton.SetLabel( "Cancel" );
562 cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
563 cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
565 cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
567 mPopup.AddButton( cancelButton );
569 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
570 okayButton.SetName( OKAY_BUTTON_ID );
571 okayButton.SetLabel( "OK!" );
572 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
573 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
575 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
577 mPopup.AddButton( okayButton );
579 // The popup is not yet on the stage so needs to be flaged as dirty
580 mPopup.MarkDirtyForRelayout();
584 else if( button.GetName() == POPUP_BUTTON_COMPLEX_ID )
586 mPopup = CreatePopup();
587 mPopup.SetTitle( "Warning" );
590 Toolkit::TableView content = Toolkit::TableView::New( 2, 2 );
591 content.SetName( "COMPLEX_TABLEVIEW" );
592 content.SetResizePolicy( FILL_TO_PARENT, WIDTH );
593 content.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
594 content.SetFitHeight( 0 );
595 content.SetFitHeight( 1 );
596 content.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 0.0f ) );
600 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Do you really want to quit?" );
601 text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
602 text.SetDimensionDependency( HEIGHT, WIDTH );
604 content.AddChild( text, Toolkit::TableView::CellPosition( 0, 0 ) );
609 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE1 ) );
610 image.SetName( "COMPLEX_IMAGE" );
611 image.SetResizePolicy( FILL_TO_PARENT, WIDTH );
612 image.SetDimensionDependency( HEIGHT, WIDTH );
613 image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) );
614 content.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) );
619 Toolkit::TableView root = Toolkit::TableView::New( 1, 2 );
620 root.SetResizePolicy( FILL_TO_PARENT, WIDTH );
621 root.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
622 root.SetFitHeight( 0 );
623 root.SetFitWidth( 0 );
624 root.SetPadding( Padding( 0.0f, 0.0f, 0.0f, 20.0f ) );
626 Dali::Image unchecked = Dali::ResourceImage::New( CHECKBOX_UNCHECKED_IMAGE );
627 Dali::Image checked = Dali::ResourceImage::New( CHECKBOX_CHECKED_IMAGE );
628 Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New();
629 checkBox.SetBackgroundImage( unchecked );
630 checkBox.SetSelectedImage( checked );
631 checkBox.SetPreferredSize( Vector2( 48, 48 ) );
632 checkBox.SetResizePolicy( FIXED, ALL_DIMENSIONS );
634 root.AddChild( checkBox, Toolkit::TableView::CellPosition( 0, 0 ) );
636 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Don't show again" );
637 Actor textActor = text;
638 textActor.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 10.0f ) );
640 root.AddChild( text, Toolkit::TableView::CellPosition( 0, 1 ) );
642 content.AddChild( root, Toolkit::TableView::CellPosition( 1, 0, 0, 2 ) ); // Column span 2
645 mPopup.Add( content );
648 Toolkit::PushButton cancelButton = Toolkit::PushButton::New();
649 cancelButton.SetName( CANCEL_BUTTON_ID );
650 cancelButton.SetLabel( "Cancel" );
651 cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
652 cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
654 cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
656 mPopup.AddButton( cancelButton );
658 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
659 okayButton.SetName( OKAY_BUTTON_ID );
660 okayButton.SetLabel( "OK!" );
661 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
662 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
664 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
666 mPopup.AddButton( okayButton );
668 // The popup is not yet on the stage so needs to be flaged as dirty
669 mPopup.MarkDirtyForRelayout();
673 else if( button.GetName() == TABLEVIEW_BUTTON_EMPTY_ID )
675 mPopup = CreatePopup();
676 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
677 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
678 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
681 Toolkit::TableView table = Toolkit::TableView::New( 0, 0 );
682 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
686 // The popup is not yet on the stage so needs to be flaged as dirty
687 mPopup.MarkDirtyForRelayout();
691 else if( button.GetName() == TABLEVIEW_BUTTON_1CELL_ID )
693 mPopup = CreatePopup();
694 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
695 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
696 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
699 Toolkit::TableView table = Toolkit::TableView::New( 0, 0 );
700 table.SetName( "TABLEVIEW_BUTTON_1CELL_ID" );
701 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
703 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
704 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
705 table.Add( backing );
709 // The popup is not yet on the stage so needs to be flaged as dirty
710 mPopup.MarkDirtyForRelayout();
714 else if( button.GetName() == TABLEVIEW_BUTTON_3CELL_ID )
716 mPopup = CreatePopup();
717 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
718 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
719 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
722 Toolkit::TableView table = Toolkit::TableView::New( 0, 0 );
723 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
726 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
727 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
728 table.Add( backing );
731 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
732 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
733 table.Add( backing );
736 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
737 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
738 table.Add( backing );
743 // The popup is not yet on the stage so needs to be flaged as dirty
744 mPopup.MarkDirtyForRelayout();
748 else if( button.GetName() == TABLEVIEW_BUTTON_3X3CELL_ID )
750 mPopup = CreatePopup();
751 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
752 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
753 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
756 Toolkit::TableView table = Toolkit::TableView::New( 3, 3 );
757 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
761 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
762 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
763 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 0 ) );
766 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
767 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
768 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 0 ) );
771 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
772 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
773 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 0 ) );
778 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) );
779 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
780 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 1 ) );
783 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
784 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
785 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 1 ) );
788 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 0.0f, 1.0f, 1.0f ) );
789 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
790 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 1 ) );
795 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) );
796 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
797 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 2 ) );
800 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.5f, 0.5f, 0.5f, 1.0f ) );
801 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
802 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 2 ) );
805 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.5f, 0.0f, 1.0f ) );
806 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
807 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 2 ) );
812 // The popup is not yet on the stage so needs to be flaged as dirty
813 mPopup.MarkDirtyForRelayout();
817 else if( button.GetName() == TABLEVIEW_BUTTON_FIXED1_ID )
819 mPopup = CreatePopup();
820 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
821 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
822 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
825 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
826 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
827 table.SetFixedHeight( 0, 50.0f );
830 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
831 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
832 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
833 text.SetAnchorPoint( AnchorPoint::CENTER );
834 text.SetParentOrigin( ParentOrigin::CENTER );
836 table.Add( backing );
839 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
840 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
841 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
842 text.SetAnchorPoint( AnchorPoint::CENTER );
843 text.SetParentOrigin( ParentOrigin::CENTER );
845 table.Add( backing );
848 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
849 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
850 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
851 text.SetAnchorPoint( AnchorPoint::CENTER );
852 text.SetParentOrigin( ParentOrigin::CENTER );
854 table.Add( backing );
859 // The popup is not yet on the stage so needs to be flaged as dirty
860 mPopup.MarkDirtyForRelayout();
864 else if( button.GetName() == TABLEVIEW_BUTTON_FIXED2_ID )
866 mPopup = CreatePopup();
867 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
868 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
869 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
872 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
873 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
874 table.SetFixedHeight( 0, 50.0f );
875 table.SetFixedHeight( 2, 50.0f );
878 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
879 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
880 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
881 text.SetAnchorPoint( AnchorPoint::CENTER );
882 text.SetParentOrigin( ParentOrigin::CENTER );
884 table.Add( backing );
887 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
888 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
889 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
890 text.SetAnchorPoint( AnchorPoint::CENTER );
891 text.SetParentOrigin( ParentOrigin::CENTER );
893 table.Add( backing );
896 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
897 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
898 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
899 text.SetAnchorPoint( AnchorPoint::CENTER );
900 text.SetParentOrigin( ParentOrigin::CENTER );
902 table.Add( backing );
907 // The popup is not yet on the stage so needs to be flaged as dirty
908 mPopup.MarkDirtyForRelayout();
912 else if( button.GetName() == TABLEVIEW_BUTTON_FIT1_ID )
914 mPopup = CreatePopup();
915 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
916 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
917 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
920 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
921 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
922 table.SetFitHeight( 0 );
923 table.SetFitHeight( 2 );
926 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
927 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
928 backing.SetResizePolicy( FIXED, HEIGHT );
929 backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
931 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
932 text.SetAnchorPoint( AnchorPoint::CENTER );
933 text.SetParentOrigin( ParentOrigin::CENTER );
936 table.Add( backing );
939 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
940 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
942 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
943 text.SetAnchorPoint( AnchorPoint::CENTER );
944 text.SetParentOrigin( ParentOrigin::CENTER );
947 table.Add( backing );
950 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
951 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
952 backing.SetResizePolicy( FIXED, HEIGHT );
953 backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
955 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
956 text.SetAnchorPoint( AnchorPoint::CENTER );
957 text.SetParentOrigin( ParentOrigin::CENTER );
960 table.Add( backing );
965 // The popup is not yet on the stage so needs to be flaged as dirty
966 mPopup.MarkDirtyForRelayout();
970 else if( button.GetName() == TABLEVIEW_BUTTON_FIT2_ID )
972 mPopup = CreatePopup();
973 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
974 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
975 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
978 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
979 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
980 table.SetFitHeight( 1 );
983 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
984 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
986 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
987 text.SetAnchorPoint( AnchorPoint::CENTER );
988 text.SetParentOrigin( ParentOrigin::CENTER );
991 table.Add( backing );
994 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
995 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
996 backing.SetResizePolicy( FIXED, HEIGHT );
997 backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
999 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1000 text.SetAnchorPoint( AnchorPoint::CENTER );
1001 text.SetParentOrigin( ParentOrigin::CENTER );
1002 backing.Add( text );
1004 table.Add( backing );
1007 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1008 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
1010 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
1011 text.SetAnchorPoint( AnchorPoint::CENTER );
1012 text.SetParentOrigin( ParentOrigin::CENTER );
1013 backing.Add( text );
1015 table.Add( backing );
1018 mPopup.Add( table );
1020 // The popup is not yet on the stage so needs to be flaged as dirty
1021 mPopup.MarkDirtyForRelayout();
1025 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL1_ID )
1027 mPopup = CreatePopup();
1028 mPopup.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1029 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
1030 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
1031 mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
1033 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
1034 table.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1035 table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
1036 table.SetFitHeight( 0 );
1037 table.SetFitHeight( 1 );
1038 table.SetFitHeight( 2 );
1041 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1042 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1043 backing.SetResizePolicy( FIXED, HEIGHT );
1044 backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
1046 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1047 text.SetAnchorPoint( AnchorPoint::CENTER );
1048 text.SetParentOrigin( ParentOrigin::CENTER );
1049 backing.Add( text );
1051 table.Add( backing );
1054 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
1055 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1056 backing.SetResizePolicy( FIXED, HEIGHT );
1057 backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
1059 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1060 text.SetAnchorPoint( AnchorPoint::CENTER );
1061 text.SetParentOrigin( ParentOrigin::CENTER );
1062 backing.Add( text );
1064 table.Add( backing );
1067 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1068 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1069 backing.SetResizePolicy( FIXED, HEIGHT );
1070 backing.SetPreferredSize( Vector2( 0.0f, 300.0f ) );
1072 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1073 text.SetAnchorPoint( AnchorPoint::CENTER );
1074 text.SetParentOrigin( ParentOrigin::CENTER );
1075 backing.Add( text );
1077 table.Add( backing );
1080 mPopup.Add( table );
1082 // The popup is not yet on the stage so needs to be flaged as dirty
1083 mPopup.MarkDirtyForRelayout();
1087 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL2_ID )
1089 mPopup = CreatePopup();
1090 mPopup.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1091 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
1092 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
1093 mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
1095 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
1096 table.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1097 table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
1098 table.SetFitHeight( 0 );
1099 table.SetFitHeight( 1 );
1102 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1103 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1104 backing.SetResizePolicy( FIXED, HEIGHT );
1105 backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
1107 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1108 text.SetAnchorPoint( AnchorPoint::CENTER );
1109 text.SetParentOrigin( ParentOrigin::CENTER );
1110 backing.Add( text );
1112 table.Add( backing );
1115 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1116 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1117 backing.SetResizePolicy( FIXED, HEIGHT );
1118 backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
1120 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1121 text.SetAnchorPoint( AnchorPoint::CENTER );
1122 text.SetParentOrigin( ParentOrigin::CENTER );
1123 backing.Add( text );
1125 table.Add( backing );
1128 mPopup.Add( table );
1130 // The popup is not yet on the stage so needs to be flaged as dirty
1131 mPopup.MarkDirtyForRelayout();
1135 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL3_ID )
1137 mPopup = CreatePopup();
1138 mPopup.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1139 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
1140 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
1141 mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
1143 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
1144 table.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1145 table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
1146 table.SetFixedHeight( 0, 20.0f );
1147 table.SetFitHeight( 1 );
1150 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1151 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
1153 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
1154 text.SetAnchorPoint( AnchorPoint::CENTER );
1155 text.SetParentOrigin( ParentOrigin::CENTER );
1156 backing.Add( text );
1158 table.Add( backing );
1161 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1162 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1163 backing.SetResizePolicy( FIXED, HEIGHT );
1164 backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
1166 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1167 text.SetAnchorPoint( AnchorPoint::CENTER );
1168 text.SetParentOrigin( ParentOrigin::CENTER );
1169 backing.Add( text );
1171 table.Add( backing );
1174 mPopup.Add( table );
1176 // The popup is not yet on the stage so needs to be flaged as dirty
1177 mPopup.MarkDirtyForRelayout();
1181 else if( button.GetName() == OKAY_BUTTON_ID || button.GetName() == CANCEL_BUTTON_ID )
1192 void OnPopupOutsideTouched()
1200 void OnKeyEvent( const KeyEvent& event )
1202 if( event.state == KeyEvent::Down )
1204 if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) )
1206 // Exit application when click back or escape.
1207 mApplication.Quit();
1212 public: // From ItemFactory
1215 * @brief Return the number of items to display in the item view
1217 * @return Return the number of items to display
1219 virtual unsigned int GetNumberOfItems()
1221 switch( mDemoState )
1225 return POPUP_BUTTON_ITEMS_COUNT;
1230 return TABLEVIEW_BUTTON_ITEMS_COUNT;
1243 * @brief Create a new item to populate the item view with
1245 * @param[in] itemId The index of the item to create
1246 * @return Return the created actor for the given ID
1248 virtual Actor NewItem(unsigned int itemId)
1250 const ButtonItem* buttonDataArray = NULL;
1251 switch( mDemoState )
1255 buttonDataArray = POPUP_BUTTON_ITEMS;
1261 buttonDataArray = TABLEVIEW_BUTTON_ITEMS;
1271 if( buttonDataArray )
1273 Toolkit::PushButton popupButton = Toolkit::PushButton::New();
1274 popupButton.SetName( buttonDataArray[ itemId ].name );
1275 popupButton.SetLabel( buttonDataArray[ itemId ].text );
1276 popupButton.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
1278 popupButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
1279 popupButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
1281 popupButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
1297 Application& mApplication;
1298 Toolkit::View mView; ///< The View instance.
1299 Toolkit::ToolBar mToolBar; ///< The View's Toolbar.
1300 Layer mContentLayer; ///< Content layer
1302 Toolkit::TextLabel mTitleActor; ///< Title text
1304 Toolkit::Popup mMenu; ///< The navigation menu
1305 bool mMenuShown; ///< If the navigation menu is currently being displayed or not
1307 Toolkit::Popup mPopup;
1309 Toolkit::ItemView mItemView; ///< ItemView to hold test images
1311 DemoState mDemoState;
1314 void RunTest( Application& application )
1316 SizeNegotiationController test( application );
1318 application.MainLoop();
1321 // Entry point for Linux & SLP applications
1323 int main( int argc, char **argv )
1325 Application application = Application::New( &argc, &argv );
1327 RunTest( application );