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 // Define this so that it is interchangeable
25 // "DP" stands for Device independent Pixels
26 #define DP(x) DemoHelper::ScalePointSize(x)
38 const char* const BACKGROUND_IMAGE = DALI_IMAGE_DIR "background-gradient.jpg";
39 const char* const TOOLBAR_IMAGE = DALI_IMAGE_DIR "top-bar.png";
41 const char* const TOOLBAR_TITLE = "Size Negotiation";
42 const int TOOLBAR_HEIGHT = 62;
44 const char* MENU_ICON_IMAGE = DALI_IMAGE_DIR "icon-cluster-none.png";
46 const char* const PUSHBUTTON_BUTTON_IMAGE = DALI_IMAGE_DIR "button-up.9.png";
47 const char* const PUSHBUTTON_PRESS_IMAGE = DALI_IMAGE_DIR "button-down.9.png";
49 const char* const POPUPS_MENU_ID = "POPUPS_MENU";
50 const char* const TABLEVIEW_MENU_ID = "TABLEVIEW_MENU";
52 const char* const POPUP_BUTTON_EMPTY_ID = "POPUP_BUTTON_EMPTY";
53 const char* const POPUP_BUTTON_TITLE_ID = "POPUP_BUTTON_TITLE";
54 const char* const POPUP_BUTTON_BUTTONS_1_ID = "POPUP_BUTTON_BUTTONS_1";
55 const char* const POPUP_BUTTON_BUTTONS_2_ID = "POPUP_BUTTON_BUTTONS_2";
56 const char* const POPUP_BUTTON_TITLE_BUTTONS_ID = "POPUP_BUTTON_TITLE_BUTTONS";
57 const char* const POPUP_BUTTON_CONTENT_TEXT_ID = "POPUP_BUTTON_CONTENT_TEXT";
58 const char* const POPUP_BUTTON_CONTENT_IMAGE_ID = "POPUP_BUTTON_CONTENT_IMAGE";
59 const char* const POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID = "POPUP_BUTTON_CONTENT_IMAGE_SCALE";
60 const char* const POPUP_BUTTON_CONTENT_IMAGE_FIT_ID = "POPUP_BUTTON_CONTENT_IMAGE_FIT";
61 const char* const POPUP_BUTTON_CONTENT_IMAGE_FILL_ID = "POPUP_BUTTON_CONTENT_IMAGE_FILL";
62 const char* const POPUP_BUTTON_TITLE_CONTENT_TEXT_ID = "POPUP_BUTTON_TITLE_CONTENT_TEXT";
63 const char* const POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS_ID = "POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS";
64 const char* const POPUP_BUTTON_COMPLEX_ID = "POPUP_BUTTON_COMPLEX";
66 const char* const TABLEVIEW_BUTTON_EMPTY_ID = "TABLEVIEW_BUTTON_EMPTY";
67 const char* const TABLEVIEW_BUTTON_1CELL_ID = "TABLEVIEW_BUTTON_1CELL";
68 const char* const TABLEVIEW_BUTTON_3CELL_ID = "TABLEVIEW_BUTTON_3CELL";
69 const char* const TABLEVIEW_BUTTON_3X3CELL_ID = "TABLEVIEW_BUTTON_3X3CELL";
70 const char* const TABLEVIEW_BUTTON_FIXED1_ID = "TABLEVIEW_BUTTON_FIXED1";
71 const char* const TABLEVIEW_BUTTON_FIXED2_ID = "TABLEVIEW_BUTTON_FIXED2";
72 const char* const TABLEVIEW_BUTTON_FIT1_ID = "TABLEVIEW_BUTTON_FIT1";
73 const char* const TABLEVIEW_BUTTON_FIT2_ID = "TABLEVIEW_BUTTON_FIT2";
74 const char* const TABLEVIEW_BUTTON_NATURAL1_ID = "TABLEVIEW_BUTTON_NATURAL1";
75 const char* const TABLEVIEW_BUTTON_NATURAL2_ID = "TABLEVIEW_BUTTON_NATURAL2";
76 const char* const TABLEVIEW_BUTTON_NATURAL3_ID = "TABLEVIEW_BUTTON_NATURAL3";
78 const char* const OKAY_BUTTON_ID = "OKAY_BUTTON";
79 const char* const CANCEL_BUTTON_ID = "CANCEL_BUTTON";
81 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.";
82 const char* const IMAGE1 = DALI_IMAGE_DIR "gallery-medium-5.jpg";
83 const char* const IMAGE2 = DALI_IMAGE_DIR "background-magnifier.jpg";
84 const char* const CHECKBOX_UNCHECKED_IMAGE = DALI_IMAGE_DIR "checkbox-unselected.png";
85 const char* const CHECKBOX_CHECKED_IMAGE = DALI_IMAGE_DIR "checkbox-selected.png";
87 const ButtonItem MENU_ITEMS[] = {
88 { POPUPS_MENU_ID, "Popups" },
89 { TABLEVIEW_MENU_ID, "TableView" }
92 const unsigned int MENU_ITEMS_COUNT = sizeof( MENU_ITEMS ) / sizeof( MENU_ITEMS[0] );
94 const ButtonItem POPUP_BUTTON_ITEMS[] = {
95 { POPUP_BUTTON_COMPLEX_ID, "Complex" },
96 { POPUP_BUTTON_EMPTY_ID, "Empty" },
97 { POPUP_BUTTON_TITLE_ID, "Title" },
98 { POPUP_BUTTON_BUTTONS_1_ID, "1 Button" },
99 { POPUP_BUTTON_BUTTONS_2_ID, "2 Buttons" },
100 { POPUP_BUTTON_TITLE_BUTTONS_ID, "Title & Buttons" },
101 { POPUP_BUTTON_CONTENT_TEXT_ID, "Text" },
102 { POPUP_BUTTON_CONTENT_IMAGE_ID, "Image" },
103 { POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID, "Image Scale" },
104 { POPUP_BUTTON_CONTENT_IMAGE_FIT_ID, "Image Fit" },
105 { POPUP_BUTTON_CONTENT_IMAGE_FILL_ID, "Image Fill" },
106 { POPUP_BUTTON_TITLE_CONTENT_TEXT_ID, "Title Text" },
107 { POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS_ID, "Title, text, buttons" }
111 const int POPUP_BUTTON_ITEMS_COUNT = sizeof( POPUP_BUTTON_ITEMS ) / sizeof( POPUP_BUTTON_ITEMS[0] );
113 const ButtonItem TABLEVIEW_BUTTON_ITEMS[] = {
114 { TABLEVIEW_BUTTON_EMPTY_ID, "Empty" },
115 { TABLEVIEW_BUTTON_1CELL_ID, "1 Cell" },
116 { TABLEVIEW_BUTTON_3CELL_ID, "3 Cell" },
117 { TABLEVIEW_BUTTON_3X3CELL_ID, "3x3 Cells" },
118 { TABLEVIEW_BUTTON_FIXED1_ID, "Fixed 1" },
119 { TABLEVIEW_BUTTON_FIXED2_ID, "Fixed 2" },
120 { TABLEVIEW_BUTTON_FIT1_ID, "Fit Top Bottom" },
121 { TABLEVIEW_BUTTON_FIT2_ID, "Fit Middle" },
122 { TABLEVIEW_BUTTON_NATURAL1_ID, "Natural 1" },
123 { TABLEVIEW_BUTTON_NATURAL2_ID, "Natural 2" },
124 { TABLEVIEW_BUTTON_NATURAL3_ID, "Natural 3" },
127 const unsigned int TABLEVIEW_BUTTON_ITEMS_COUNT = sizeof( TABLEVIEW_BUTTON_ITEMS ) / sizeof( TABLEVIEW_BUTTON_ITEMS[0] );
134 * This example shows the usage of size negotiation.
136 class SizeNegotiationController: public ConnectionTracker, public Toolkit::ItemFactory
140 SizeNegotiationController( Application& application )
141 : mApplication( application ),
145 // Connect to the Application's Init signal
146 mApplication.InitSignal().Connect( this, &SizeNegotiationController::Create );
149 ~SizeNegotiationController()
151 // Nothing to do here
154 void Create( Application& application )
156 // The Init signal is received once (only) during the Application lifetime
158 Stage stage = Stage::GetCurrent();
160 // Respond to key events
161 stage.KeyEventSignal().Connect(this, &SizeNegotiationController::OnKeyEvent);
163 // Creates a default view with a default tool bar.
164 // The view is added to the stage.
165 mContentLayer = DemoHelper::CreateView( application,
172 mTitleActor = Dali::Toolkit::TextLabel::New(); // FIXME
173 mTitleActor.SetName( "CUSTOM_TOOLBAR_TITLE" );
177 // Create menu button
178 Toolkit::PushButton viewButton = Toolkit::PushButton::New();
179 viewButton.SetBackgroundImage( ResourceImage::New( MENU_ICON_IMAGE ) );
180 viewButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnMenu );
181 mToolBar.AddControl( viewButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
183 // Add title to the tool bar.
184 const float padding( DemoHelper::DEFAULT_VIEW_STYLE.mToolBarPadding );
185 mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::Padding( padding, padding, padding, padding ) );
187 mItemView = Toolkit::ItemView::New( *this );
188 mItemView.SetParentOrigin( ParentOrigin::CENTER );
189 mItemView.SetAnchorPoint( AnchorPoint::CENTER );
190 mItemView.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
192 // Use a grid layout for tests
193 Toolkit::GridLayoutPtr gridLayout = Toolkit::GridLayout::New();
194 gridLayout->SetNumberOfColumns( 2 );
195 gridLayout->SetTopMargin( DP(TOOLBAR_HEIGHT) + DP(20.0f) );
196 gridLayout->SetBottomMargin( DP(100.0f) );
197 gridLayout->SetRowSpacing( DP(20.0f) );
198 mItemView.AddLayout( *gridLayout );
200 Vector2 stageSize = stage.GetSize();
201 float layoutWidth = Toolkit::IsHorizontal( gridLayout->GetOrientation() ) ? stageSize.height : stageSize.width;
202 float gridItemSize = ( layoutWidth / gridLayout->GetNumberOfColumns() ) * 0.5f;
203 gridLayout->SetScrollSpeedFactor( gridLayout->GetNumberOfColumns() / gridItemSize * 0.5f );
205 mItemView.ActivateLayout( 0, Vector3(stageSize.x, stageSize.y, stageSize.x), 0.0f );
207 mContentLayer.Add( mItemView );
212 std::string subTitle = "";
224 subTitle = "TableView";
234 mTitleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, std::string( std::string( TOOLBAR_TITLE ) + ": " + subTitle ) );
237 bool OnMenu( Toolkit::Button button )
245 Stage stage = Stage::GetCurrent();
246 const float popupWidth = stage.GetSize().x * 0.5f;
248 mMenu = Toolkit::Popup::New();
249 mMenu.SetParentOrigin( ParentOrigin::TOP_LEFT );
250 mMenu.SetAnchorPoint( AnchorPoint::TOP_LEFT );
252 mMenu.OutsideTouchedSignal().Connect( this, &SizeNegotiationController::HideMenu );
253 mMenu.SetPreferredSize( Vector2( popupWidth, 0.0f ) );
254 mMenu.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
256 Toolkit::TableView tableView = Toolkit::TableView::New( 0, 0 );
257 tableView.SetResizePolicy( FILL_TO_PARENT, WIDTH );
258 tableView.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
259 mMenu.Add( tableView );
261 for( unsigned int i = 0; i < MENU_ITEMS_COUNT; ++i )
263 Toolkit::PushButton menuButton = Toolkit::PushButton::New();
264 menuButton.SetName( MENU_ITEMS[ i ].name );
265 menuButton.SetLabel( MENU_ITEMS[ i ].text );
266 menuButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnMenuSelect );
268 tableView.Add( menuButton );
269 tableView.SetFitHeight( i );
288 bool OnMenuSelect( Toolkit::Button button )
290 bool refresh = false;
292 if( button.GetName() == POPUPS_MENU_ID )
294 if( mDemoState != POPUP )
300 else if( button.GetName() == TABLEVIEW_MENU_ID )
302 if( mDemoState != TABLEVIEW )
305 mDemoState = TABLEVIEW;
320 Toolkit::Popup CreatePopup()
322 Stage stage = Stage::GetCurrent();
323 const float POPUP_WIDTH_DP = stage.GetSize().width * 0.75f;
325 Toolkit::Popup popup = Toolkit::Popup::New();
326 popup.SetName( "POPUP" );
327 popup.SetParentOrigin( ParentOrigin::CENTER );
328 popup.SetAnchorPoint( AnchorPoint::CENTER );
329 popup.SetPreferredSize( Vector2( POPUP_WIDTH_DP, 0.0f ) );
332 popup.OutsideTouchedSignal().Connect( this, &SizeNegotiationController::OnPopupOutsideTouched );
337 bool OnButtonClicked( Toolkit::Button button )
339 if( button.GetName() == POPUP_BUTTON_EMPTY_ID )
341 mPopup = CreatePopup();
343 // The popup is not yet on the stage so needs to be flaged as dirty
344 mPopup.MarkDirtyForRelayout();
348 else if( button.GetName() == POPUP_BUTTON_TITLE_ID )
350 mPopup = CreatePopup();
351 mPopup.SetTitle( "Popup!" );
353 // The popup is not yet on the stage so needs to be flaged as dirty
354 mPopup.MarkDirtyForRelayout();
358 else if( button.GetName() == POPUP_BUTTON_BUTTONS_1_ID )
360 mPopup = CreatePopup();
362 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
363 okayButton.SetName( OKAY_BUTTON_ID );
364 okayButton.SetLabel( "OK!" );
365 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
366 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
368 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
370 mPopup.AddButton( okayButton );
372 // The popup is not yet on the stage so needs to be flaged as dirty
373 mPopup.MarkDirtyForRelayout();
377 else if( button.GetName() == POPUP_BUTTON_BUTTONS_2_ID )
379 mPopup = CreatePopup();
381 Toolkit::PushButton cancelButton = Toolkit::PushButton::New();
382 cancelButton.SetName( CANCEL_BUTTON_ID );
383 cancelButton.SetLabel( "Cancel" );
384 cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
385 cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
387 cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
389 mPopup.AddButton( cancelButton );
391 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
392 okayButton.SetName( OKAY_BUTTON_ID );
393 okayButton.SetLabel( "OK!" );
394 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
395 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
397 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
399 mPopup.AddButton( okayButton );
401 // The popup is not yet on the stage so needs to be flaged as dirty
402 mPopup.MarkDirtyForRelayout();
406 else if( button.GetName() == POPUP_BUTTON_TITLE_BUTTONS_ID )
408 mPopup = CreatePopup();
409 mPopup.SetTitle( "Popup!" );
411 Toolkit::PushButton cancelButton = Toolkit::PushButton::New();
412 cancelButton.SetName( CANCEL_BUTTON_ID );
413 cancelButton.SetLabel( "Cancel" );
414 cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
415 cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
417 cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
419 mPopup.AddButton( cancelButton );
421 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
422 okayButton.SetName( OKAY_BUTTON_ID );
423 okayButton.SetLabel( "OK!" );
424 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
425 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
427 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
429 mPopup.AddButton( okayButton );
431 // The popup is not yet on the stage so needs to be flaged as dirty
432 mPopup.MarkDirtyForRelayout();
436 else if( button.GetName() == POPUP_BUTTON_CONTENT_TEXT_ID )
438 mPopup = CreatePopup();
442 // The popup is not yet on the stage so needs to be flaged as dirty
443 mPopup.MarkDirtyForRelayout();
447 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_ID )
449 mPopup = CreatePopup();
451 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
452 image.SetResizePolicy( FILL_TO_PARENT, WIDTH );
453 image.SetDimensionDependency( HEIGHT, WIDTH );
454 image.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) );
458 // The popup is not yet on the stage so needs to be flaged as dirty
459 mPopup.MarkDirtyForRelayout();
463 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID )
465 mPopup = CreatePopup();
467 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
468 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
469 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
471 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
472 image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
476 // The popup is not yet on the stage so needs to be flaged as dirty
477 mPopup.MarkDirtyForRelayout();
481 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FIT_ID )
483 mPopup = CreatePopup();
485 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
486 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
487 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
489 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
490 image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
491 image.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO );
495 // The popup is not yet on the stage so needs to be flaged as dirty
496 mPopup.MarkDirtyForRelayout();
500 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FILL_ID )
502 mPopup = CreatePopup();
504 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
505 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
506 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
508 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
509 image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
510 image.SetSizeScalePolicy( FILL_WITH_ASPECT_RATIO );
514 // The popup is not yet on the stage so needs to be flaged as dirty
515 mPopup.MarkDirtyForRelayout();
519 else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_ID )
521 mPopup = CreatePopup();
522 mPopup.SetTitle( "Popup!" );
526 // The popup is not yet on the stage so needs to be flaged as dirty
527 mPopup.MarkDirtyForRelayout();
531 else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS_ID )
533 mPopup = CreatePopup();
534 mPopup.SetTitle( "Popup!" );
538 Toolkit::PushButton cancelButton = Toolkit::PushButton::New();
539 cancelButton.SetName( CANCEL_BUTTON_ID );
540 cancelButton.SetLabel( "Cancel" );
541 cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
542 cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
544 cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
546 mPopup.AddButton( cancelButton );
548 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
549 okayButton.SetName( OKAY_BUTTON_ID );
550 okayButton.SetLabel( "OK!" );
551 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
552 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
554 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
556 mPopup.AddButton( okayButton );
558 // The popup is not yet on the stage so needs to be flaged as dirty
559 mPopup.MarkDirtyForRelayout();
563 else if( button.GetName() == POPUP_BUTTON_COMPLEX_ID )
565 mPopup = CreatePopup();
566 mPopup.SetTitle( "Warning" );
569 Toolkit::TableView content = Toolkit::TableView::New( 2, 2 );
570 content.SetName( "COMPLEX_TABLEVIEW" );
571 content.SetResizePolicy( FILL_TO_PARENT, WIDTH );
572 content.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
573 content.SetFitHeight( 0 );
574 content.SetFitHeight( 1 );
575 content.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 0.0f ) );
579 Toolkit::TextLabel text = Toolkit::TextLabel::New();
582 content.AddChild( text, Toolkit::TableView::CellPosition( 0, 0 ) );
587 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE1 ) );
588 image.SetName( "COMPLEX_IMAGE" );
589 image.SetResizePolicy( FILL_TO_PARENT, WIDTH );
590 image.SetDimensionDependency( HEIGHT, WIDTH );
591 image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) );
592 content.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) );
597 Toolkit::TableView root = Toolkit::TableView::New( 1, 2 );
598 root.SetResizePolicy( FILL_TO_PARENT, WIDTH );
599 root.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
600 root.SetFitHeight( 0 );
601 root.SetFitWidth( 0 );
602 root.SetPadding( Padding( 0.0f, 0.0f, 0.0f, 20.0f ) );
604 Dali::Image unchecked = Dali::ResourceImage::New( CHECKBOX_UNCHECKED_IMAGE );
605 Dali::Image checked = Dali::ResourceImage::New( CHECKBOX_CHECKED_IMAGE );
606 Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New();
607 checkBox.SetBackgroundImage( unchecked );
608 checkBox.SetSelectedImage( checked );
609 checkBox.SetPreferredSize( Vector2( 48, 48 ) );
610 checkBox.SetResizePolicy( FIXED, ALL_DIMENSIONS );
612 root.AddChild( checkBox, Toolkit::TableView::CellPosition( 0, 0 ) );
614 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Don't show again" );
616 Actor textActor = text;
617 textActor.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 10.0f ) );
619 root.AddChild( text, Toolkit::TableView::CellPosition( 0, 1 ) );
621 content.AddChild( root, Toolkit::TableView::CellPosition( 1, 0, 0, 2 ) ); // Column span 2
624 mPopup.Add( content );
627 Toolkit::PushButton cancelButton = Toolkit::PushButton::New();
628 cancelButton.SetName( CANCEL_BUTTON_ID );
629 cancelButton.SetLabel( "Cancel" );
630 cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
631 cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
633 cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
635 mPopup.AddButton( cancelButton );
637 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
638 okayButton.SetName( OKAY_BUTTON_ID );
639 okayButton.SetLabel( "OK!" );
640 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
641 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
643 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
645 mPopup.AddButton( okayButton );
647 // The popup is not yet on the stage so needs to be flaged as dirty
648 mPopup.MarkDirtyForRelayout();
652 else if( button.GetName() == TABLEVIEW_BUTTON_EMPTY_ID )
654 mPopup = CreatePopup();
655 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
656 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
657 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
660 Toolkit::TableView table = Toolkit::TableView::New( 0, 0 );
661 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
665 // The popup is not yet on the stage so needs to be flaged as dirty
666 mPopup.MarkDirtyForRelayout();
670 else if( button.GetName() == TABLEVIEW_BUTTON_1CELL_ID )
672 mPopup = CreatePopup();
673 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
674 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
675 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
678 Toolkit::TableView table = Toolkit::TableView::New( 0, 0 );
679 table.SetName( "TABLEVIEW_BUTTON_1CELL_ID" );
680 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
682 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
683 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
684 table.Add( backing );
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_3CELL_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.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 );
710 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
711 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
712 table.Add( backing );
715 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
716 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
717 table.Add( backing );
722 // The popup is not yet on the stage so needs to be flaged as dirty
723 mPopup.MarkDirtyForRelayout();
727 else if( button.GetName() == TABLEVIEW_BUTTON_3X3CELL_ID )
729 mPopup = CreatePopup();
730 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
731 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
732 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
735 Toolkit::TableView table = Toolkit::TableView::New( 3, 3 );
736 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
740 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
741 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
742 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 0 ) );
745 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
746 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
747 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 0 ) );
750 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
751 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
752 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 0 ) );
757 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) );
758 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
759 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 1 ) );
762 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
763 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
764 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 1 ) );
767 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 0.0f, 1.0f, 1.0f ) );
768 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
769 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 1 ) );
774 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) );
775 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
776 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 2 ) );
779 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.5f, 0.5f, 0.5f, 1.0f ) );
780 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
781 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 2 ) );
784 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.5f, 0.0f, 1.0f ) );
785 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
786 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 2 ) );
791 // The popup is not yet on the stage so needs to be flaged as dirty
792 mPopup.MarkDirtyForRelayout();
796 else if( button.GetName() == TABLEVIEW_BUTTON_FIXED1_ID )
798 mPopup = CreatePopup();
799 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
800 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
801 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
804 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
805 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
806 table.SetFixedHeight( 0, 50.0f );
809 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
810 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
811 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
812 text.SetAnchorPoint( AnchorPoint::CENTER );
813 text.SetParentOrigin( ParentOrigin::CENTER );
815 table.Add( backing );
818 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
819 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
820 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
821 text.SetAnchorPoint( AnchorPoint::CENTER );
822 text.SetParentOrigin( ParentOrigin::CENTER );
824 table.Add( backing );
827 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
828 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
829 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
830 text.SetAnchorPoint( AnchorPoint::CENTER );
831 text.SetParentOrigin( ParentOrigin::CENTER );
833 table.Add( backing );
838 // The popup is not yet on the stage so needs to be flaged as dirty
839 mPopup.MarkDirtyForRelayout();
843 else if( button.GetName() == TABLEVIEW_BUTTON_FIXED2_ID )
845 mPopup = CreatePopup();
846 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
847 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
848 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
851 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
852 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
853 table.SetFixedHeight( 0, 50.0f );
854 table.SetFixedHeight( 2, 50.0f );
857 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
858 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
859 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
860 text.SetAnchorPoint( AnchorPoint::CENTER );
861 text.SetParentOrigin( ParentOrigin::CENTER );
863 table.Add( backing );
866 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
867 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
868 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
869 text.SetAnchorPoint( AnchorPoint::CENTER );
870 text.SetParentOrigin( ParentOrigin::CENTER );
872 table.Add( backing );
875 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
876 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
877 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fixed" );
878 text.SetAnchorPoint( AnchorPoint::CENTER );
879 text.SetParentOrigin( ParentOrigin::CENTER );
881 table.Add( backing );
886 // The popup is not yet on the stage so needs to be flaged as dirty
887 mPopup.MarkDirtyForRelayout();
891 else if( button.GetName() == TABLEVIEW_BUTTON_FIT1_ID )
893 mPopup = CreatePopup();
894 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
895 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
896 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
899 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
900 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
901 table.SetFitHeight( 0 );
902 table.SetFitHeight( 2 );
905 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
906 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
907 backing.SetResizePolicy( FIXED, HEIGHT );
908 backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
910 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
911 text.SetAnchorPoint( AnchorPoint::CENTER );
912 text.SetParentOrigin( ParentOrigin::CENTER );
915 table.Add( backing );
918 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
919 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
921 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
922 text.SetAnchorPoint( AnchorPoint::CENTER );
923 text.SetParentOrigin( ParentOrigin::CENTER );
926 table.Add( backing );
929 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
930 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
931 backing.SetResizePolicy( FIXED, HEIGHT );
932 backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
934 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
935 text.SetAnchorPoint( AnchorPoint::CENTER );
936 text.SetParentOrigin( ParentOrigin::CENTER );
939 table.Add( backing );
944 // The popup is not yet on the stage so needs to be flaged as dirty
945 mPopup.MarkDirtyForRelayout();
949 else if( button.GetName() == TABLEVIEW_BUTTON_FIT2_ID )
951 mPopup = CreatePopup();
952 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
953 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
954 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
957 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
958 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
959 table.SetFitHeight( 1 );
962 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
963 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
965 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
966 text.SetAnchorPoint( AnchorPoint::CENTER );
967 text.SetParentOrigin( ParentOrigin::CENTER );
970 table.Add( backing );
973 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
974 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
975 backing.SetResizePolicy( FIXED, HEIGHT );
976 backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
978 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
979 text.SetAnchorPoint( AnchorPoint::CENTER );
980 text.SetParentOrigin( ParentOrigin::CENTER );
983 table.Add( backing );
986 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
987 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
989 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fill" );
990 text.SetAnchorPoint( AnchorPoint::CENTER );
991 text.SetParentOrigin( ParentOrigin::CENTER );
994 table.Add( backing );
999 // The popup is not yet on the stage so needs to be flaged as dirty
1000 mPopup.MarkDirtyForRelayout();
1004 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL1_ID )
1006 mPopup = CreatePopup();
1007 mPopup.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1008 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
1009 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
1010 mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
1012 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
1013 table.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1014 table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
1015 table.SetFitHeight( 0 );
1016 table.SetFitHeight( 1 );
1017 table.SetFitHeight( 2 );
1020 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1021 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1022 backing.SetResizePolicy( FIXED, HEIGHT );
1023 backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
1025 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1026 text.SetAnchorPoint( AnchorPoint::CENTER );
1027 text.SetParentOrigin( ParentOrigin::CENTER );
1028 backing.Add( text );
1030 table.Add( backing );
1033 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
1034 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1035 backing.SetResizePolicy( FIXED, HEIGHT );
1036 backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
1038 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1039 text.SetAnchorPoint( AnchorPoint::CENTER );
1040 text.SetParentOrigin( ParentOrigin::CENTER );
1041 backing.Add( text );
1043 table.Add( backing );
1046 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1047 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1048 backing.SetResizePolicy( FIXED, HEIGHT );
1049 backing.SetPreferredSize( Vector2( 0.0f, 300.0f ) );
1051 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1052 text.SetAnchorPoint( AnchorPoint::CENTER );
1053 text.SetParentOrigin( ParentOrigin::CENTER );
1054 backing.Add( text );
1056 table.Add( backing );
1059 mPopup.Add( table );
1061 // The popup is not yet on the stage so needs to be flaged as dirty
1062 mPopup.MarkDirtyForRelayout();
1066 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL2_ID )
1068 mPopup = CreatePopup();
1069 mPopup.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1070 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
1071 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
1072 mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
1074 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
1075 table.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1076 table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
1077 table.SetFitHeight( 0 );
1078 table.SetFitHeight( 1 );
1081 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1082 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1083 backing.SetResizePolicy( FIXED, HEIGHT );
1084 backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
1086 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1087 text.SetAnchorPoint( AnchorPoint::CENTER );
1088 text.SetParentOrigin( ParentOrigin::CENTER );
1089 backing.Add( text );
1091 table.Add( backing );
1094 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1095 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1096 backing.SetResizePolicy( FIXED, HEIGHT );
1097 backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
1099 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1100 text.SetAnchorPoint( AnchorPoint::CENTER );
1101 text.SetParentOrigin( ParentOrigin::CENTER );
1102 backing.Add( text );
1104 table.Add( backing );
1107 mPopup.Add( table );
1109 // The popup is not yet on the stage so needs to be flaged as dirty
1110 mPopup.MarkDirtyForRelayout();
1114 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL3_ID )
1116 mPopup = CreatePopup();
1117 mPopup.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1118 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
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.SetResizePolicy( FIXED, HEIGHT );
1143 backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
1145 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
1146 text.SetAnchorPoint( AnchorPoint::CENTER );
1147 text.SetParentOrigin( ParentOrigin::CENTER );
1148 backing.Add( text );
1150 table.Add( backing );
1153 mPopup.Add( table );
1155 // The popup is not yet on the stage so needs to be flaged as dirty
1156 mPopup.MarkDirtyForRelayout();
1160 else if( button.GetName() == OKAY_BUTTON_ID || button.GetName() == CANCEL_BUTTON_ID )
1171 void OnPopupOutsideTouched()
1179 void OnKeyEvent( const KeyEvent& event )
1181 if( event.state == KeyEvent::Down )
1183 if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) )
1185 // Exit application when click back or escape.
1186 mApplication.Quit();
1191 public: // From ItemFactory
1194 * @brief Return the number of items to display in the item view
1196 * @return Return the number of items to display
1198 virtual unsigned int GetNumberOfItems()
1200 switch( mDemoState )
1204 return POPUP_BUTTON_ITEMS_COUNT;
1209 return TABLEVIEW_BUTTON_ITEMS_COUNT;
1222 * @brief Create a new item to populate the item view with
1224 * @param[in] itemId The index of the item to create
1225 * @return Return the created actor for the given ID
1227 virtual Actor NewItem(unsigned int itemId)
1229 const ButtonItem* buttonDataArray = NULL;
1230 switch( mDemoState )
1234 buttonDataArray = POPUP_BUTTON_ITEMS;
1240 buttonDataArray = TABLEVIEW_BUTTON_ITEMS;
1250 if( buttonDataArray )
1252 Toolkit::PushButton popupButton = Toolkit::PushButton::New();
1253 popupButton.SetName( buttonDataArray[ itemId ].name );
1254 popupButton.SetLabel( buttonDataArray[ itemId ].text );
1255 popupButton.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
1257 popupButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
1258 popupButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
1260 popupButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
1276 Application& mApplication;
1277 Toolkit::View mView; ///< The View instance.
1278 Toolkit::ToolBar mToolBar; ///< The View's Toolbar.
1279 Layer mContentLayer; ///< Content layer
1281 Toolkit::TextLabel mTitleActor; ///< Title text
1283 Toolkit::Popup mMenu; ///< The navigation menu
1284 bool mMenuShown; ///< If the navigation menu is currently being displayed or not
1286 Toolkit::Popup mPopup;
1288 Toolkit::ItemView mItemView; ///< ItemView to hold test images
1290 DemoState mDemoState;
1293 void RunTest( Application& application )
1295 SizeNegotiationController test( application );
1297 application.MainLoop();
1300 // Entry point for Linux & SLP applications
1302 int main( int argc, char **argv )
1304 Application application = Application::New( &argc, &argv );
1306 RunTest( application );