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::TextView::New();
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.SetText( std::string( TOOLBAR_TITLE ) + ": " + subTitle );
235 mTitleActor.SetStyleToCurrentText( DemoHelper::GetDefaultTextStyle() );
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.SetSize( 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.SetSize( 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 Toolkit::TextView text = Toolkit::TextView::New();
442 text.SetName( "POPUP_CONTENT_TEXT" );
443 text.SetText( CONTENT_TEXT );
444 text.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
445 text.SetWidthExceedPolicy( Toolkit::TextView::Split );
446 text.SetLineJustification( Toolkit::TextView::Center );
447 text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
448 text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
449 text.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) );
453 // The popup is not yet on the stage so needs to be flaged as dirty
454 mPopup.MarkDirtyForRelayout();
458 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_ID )
460 mPopup = CreatePopup();
462 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
463 image.SetResizePolicy( FILL_TO_PARENT, WIDTH );
464 image.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
465 image.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) );
469 // The popup is not yet on the stage so needs to be flaged as dirty
470 mPopup.MarkDirtyForRelayout();
474 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID )
476 mPopup = CreatePopup();
478 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
479 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
481 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
482 image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
486 // The popup is not yet on the stage so needs to be flaged as dirty
487 mPopup.MarkDirtyForRelayout();
491 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FIT_ID )
493 mPopup = CreatePopup();
495 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
496 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
498 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
499 image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
500 image.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO );
504 // The popup is not yet on the stage so needs to be flaged as dirty
505 mPopup.MarkDirtyForRelayout();
509 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FILL_ID )
511 mPopup = CreatePopup();
513 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
514 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
516 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
517 image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
518 image.SetSizeScalePolicy( FILL_WITH_ASPECT_RATIO );
522 // The popup is not yet on the stage so needs to be flaged as dirty
523 mPopup.MarkDirtyForRelayout();
527 else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_ID )
529 mPopup = CreatePopup();
530 mPopup.SetTitle( "Popup!" );
532 Toolkit::TextView text = Toolkit::TextView::New();
533 text.SetName( "POPUP_CONTENT_TEXT" );
534 text.SetText( CONTENT_TEXT );
535 text.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
536 text.SetWidthExceedPolicy( Toolkit::TextView::Split );
537 text.SetLineJustification( Toolkit::TextView::Center );
538 text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
539 text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
540 text.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) );
544 // The popup is not yet on the stage so needs to be flaged as dirty
545 mPopup.MarkDirtyForRelayout();
549 else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS_ID )
551 mPopup = CreatePopup();
552 mPopup.SetTitle( "Popup!" );
554 Toolkit::TextView text = Toolkit::TextView::New();
555 text.SetName( "POPUP_CONTENT_TEXT" );
556 text.SetText( CONTENT_TEXT );
557 text.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
558 text.SetWidthExceedPolicy( Toolkit::TextView::Split );
559 text.SetLineJustification( Toolkit::TextView::Left );
560 text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
561 text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
562 text.SetPadding( Padding( 10.0f, 10.0f, 20.0f, 0.0f ) );
566 Toolkit::PushButton cancelButton = Toolkit::PushButton::New();
567 cancelButton.SetName( CANCEL_BUTTON_ID );
568 cancelButton.SetLabel( "Cancel" );
569 cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
570 cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
572 cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
574 mPopup.AddButton( cancelButton );
576 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
577 okayButton.SetName( OKAY_BUTTON_ID );
578 okayButton.SetLabel( "OK!" );
579 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
580 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
582 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
584 mPopup.AddButton( okayButton );
586 // The popup is not yet on the stage so needs to be flaged as dirty
587 mPopup.MarkDirtyForRelayout();
591 else if( button.GetName() == POPUP_BUTTON_COMPLEX_ID )
593 mPopup = CreatePopup();
594 mPopup.SetTitle( "Warning" );
597 Toolkit::TableView content = Toolkit::TableView::New( 2, 2 );
598 content.SetName( "COMPLEX_TABLEVIEW" );
599 content.SetResizePolicy( FILL_TO_PARENT, WIDTH );
600 content.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
601 content.SetFitHeight( 0 );
602 content.SetFitHeight( 1 );
603 content.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 0.0f ) );
607 Toolkit::TextView text = Toolkit::TextView::New();
608 text.SetText( "Do you really want to quit?" );
609 text.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
610 text.SetWidthExceedPolicy( Toolkit::TextView::Split );
611 text.SetLineJustification( Toolkit::TextView::Left );
612 text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
613 text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
615 content.AddChild( text, Toolkit::TableView::CellPosition( 0, 0 ) );
620 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE1 ) );
621 image.SetName( "COMPLEX_IMAGE" );
622 image.SetResizePolicy( FILL_TO_PARENT, WIDTH );
623 image.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
624 image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) );
625 content.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) );
630 Toolkit::TableView root = Toolkit::TableView::New( 1, 2 );
631 root.SetResizePolicy( FILL_TO_PARENT, WIDTH );
632 root.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
633 root.SetFitHeight( 0 );
634 root.SetFitWidth( 0 );
635 root.SetPadding( Padding( 0.0f, 0.0f, 0.0f, 20.0f ) );
637 Dali::Image unchecked = Dali::ResourceImage::New( CHECKBOX_UNCHECKED_IMAGE );
638 Dali::Image checked = Dali::ResourceImage::New( CHECKBOX_CHECKED_IMAGE );
639 Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New();
640 checkBox.SetBackgroundImage( unchecked );
641 checkBox.SetSelectedImage( checked );
642 checkBox.SetSize( 48, 48 );
644 root.AddChild( checkBox, Toolkit::TableView::CellPosition( 0, 0 ) );
646 Toolkit::TextView text = Toolkit::TextView::New();
647 text.SetText( "Don't show again" );
648 text.SetLineJustification( Toolkit::TextView::Left );
649 Actor textActor = text;
650 textActor.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 10.0f ) );
652 root.AddChild( text, Toolkit::TableView::CellPosition( 0, 1 ) );
654 content.AddChild( root, Toolkit::TableView::CellPosition( 1, 0, 0, 2 ) ); // Column span 2
657 mPopup.Add( content );
660 Toolkit::PushButton cancelButton = Toolkit::PushButton::New();
661 cancelButton.SetName( CANCEL_BUTTON_ID );
662 cancelButton.SetLabel( "Cancel" );
663 cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
664 cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
666 cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
668 mPopup.AddButton( cancelButton );
670 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
671 okayButton.SetName( OKAY_BUTTON_ID );
672 okayButton.SetLabel( "OK!" );
673 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
674 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
676 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
678 mPopup.AddButton( okayButton );
680 // The popup is not yet on the stage so needs to be flaged as dirty
681 mPopup.MarkDirtyForRelayout();
685 else if( button.GetName() == TABLEVIEW_BUTTON_EMPTY_ID )
687 mPopup = CreatePopup();
688 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
689 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
692 Toolkit::TableView table = Toolkit::TableView::New( 0, 0 );
693 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
697 // The popup is not yet on the stage so needs to be flaged as dirty
698 mPopup.MarkDirtyForRelayout();
702 else if( button.GetName() == TABLEVIEW_BUTTON_1CELL_ID )
704 mPopup = CreatePopup();
705 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
706 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
709 Toolkit::TableView table = Toolkit::TableView::New( 0, 0 );
710 table.SetName( "TABLEVIEW_BUTTON_1CELL_ID" );
711 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
713 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
714 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
715 table.Add( backing );
719 // The popup is not yet on the stage so needs to be flaged as dirty
720 mPopup.MarkDirtyForRelayout();
724 else if( button.GetName() == TABLEVIEW_BUTTON_3CELL_ID )
726 mPopup = CreatePopup();
727 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
728 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
731 Toolkit::TableView table = Toolkit::TableView::New( 0, 0 );
732 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
735 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
736 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
737 table.Add( backing );
740 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
741 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
742 table.Add( backing );
745 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
746 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
747 table.Add( backing );
752 // The popup is not yet on the stage so needs to be flaged as dirty
753 mPopup.MarkDirtyForRelayout();
757 else if( button.GetName() == TABLEVIEW_BUTTON_3X3CELL_ID )
759 mPopup = CreatePopup();
760 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
761 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
764 Toolkit::TableView table = Toolkit::TableView::New( 3, 3 );
765 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
769 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
770 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
771 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 0 ) );
774 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
775 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
776 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 0 ) );
779 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
780 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
781 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 0 ) );
786 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) );
787 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
788 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 1 ) );
791 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
792 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
793 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 1 ) );
796 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 0.0f, 1.0f, 1.0f ) );
797 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
798 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 1 ) );
803 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) );
804 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
805 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 2 ) );
808 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.5f, 0.5f, 0.5f, 1.0f ) );
809 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
810 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 2 ) );
813 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.5f, 0.0f, 1.0f ) );
814 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
815 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 2 ) );
820 // The popup is not yet on the stage so needs to be flaged as dirty
821 mPopup.MarkDirtyForRelayout();
825 else if( button.GetName() == TABLEVIEW_BUTTON_FIXED1_ID )
827 mPopup = CreatePopup();
828 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
829 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
832 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
833 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
834 table.SetFixedHeight( 0, 50.0f );
837 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
838 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
839 TextActor text = TextActor::New( "Fixed" );
840 text.SetAnchorPoint( AnchorPoint::CENTER );
841 text.SetParentOrigin( ParentOrigin::CENTER );
843 table.Add( backing );
846 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
847 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
848 TextActor text = TextActor::New( "Fill" );
849 text.SetAnchorPoint( AnchorPoint::CENTER );
850 text.SetParentOrigin( ParentOrigin::CENTER );
852 table.Add( backing );
855 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
856 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
857 TextActor text = TextActor::New( "Fill" );
858 text.SetAnchorPoint( AnchorPoint::CENTER );
859 text.SetParentOrigin( ParentOrigin::CENTER );
861 table.Add( backing );
866 // The popup is not yet on the stage so needs to be flaged as dirty
867 mPopup.MarkDirtyForRelayout();
871 else if( button.GetName() == TABLEVIEW_BUTTON_FIXED2_ID )
873 mPopup = CreatePopup();
874 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
875 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
878 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
879 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
880 table.SetFixedHeight( 0, 50.0f );
881 table.SetFixedHeight( 2, 50.0f );
884 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
885 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
886 TextActor text = TextActor::New( "Fixed" );
887 text.SetAnchorPoint( AnchorPoint::CENTER );
888 text.SetParentOrigin( ParentOrigin::CENTER );
890 table.Add( backing );
893 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
894 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
895 TextActor text = TextActor::New( "Fill" );
896 text.SetAnchorPoint( AnchorPoint::CENTER );
897 text.SetParentOrigin( ParentOrigin::CENTER );
899 table.Add( backing );
902 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
903 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
904 TextActor text = TextActor::New( "Fixed" );
905 text.SetAnchorPoint( AnchorPoint::CENTER );
906 text.SetParentOrigin( ParentOrigin::CENTER );
908 table.Add( backing );
913 // The popup is not yet on the stage so needs to be flaged as dirty
914 mPopup.MarkDirtyForRelayout();
918 else if( button.GetName() == TABLEVIEW_BUTTON_FIT1_ID )
920 mPopup = CreatePopup();
921 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
922 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
925 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
926 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
927 table.SetFitHeight( 0 );
928 table.SetFitHeight( 2 );
931 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
932 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
933 backing.SetSize( 0.0f, 100.0f );
935 TextActor text = TextActor::New( "Fit" );
936 text.SetAnchorPoint( AnchorPoint::CENTER );
937 text.SetParentOrigin( ParentOrigin::CENTER );
940 table.Add( backing );
943 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
944 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
946 TextActor text = TextActor::New( "Fill" );
947 text.SetAnchorPoint( AnchorPoint::CENTER );
948 text.SetParentOrigin( ParentOrigin::CENTER );
951 table.Add( backing );
954 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
955 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
956 backing.SetSize( 0.0f, 100.0f );
958 TextActor text = TextActor::New( "Fit" );
959 text.SetAnchorPoint( AnchorPoint::CENTER );
960 text.SetParentOrigin( ParentOrigin::CENTER );
963 table.Add( backing );
968 // The popup is not yet on the stage so needs to be flaged as dirty
969 mPopup.MarkDirtyForRelayout();
973 else if( button.GetName() == TABLEVIEW_BUTTON_FIT2_ID )
975 mPopup = CreatePopup();
976 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
977 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
979 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
980 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
981 table.SetFitHeight( 1 );
984 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
985 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
987 TextActor text = TextActor::New( "Fill" );
988 text.SetAnchorPoint( AnchorPoint::CENTER );
989 text.SetParentOrigin( ParentOrigin::CENTER );
992 table.Add( backing );
995 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
996 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
997 backing.SetSize( 0.0f, 200.0f );
999 TextActor text = TextActor::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 TextActor text = TextActor::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( SIZE_RELATIVE_TO_PARENT, WIDTH );
1029 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
1030 mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
1032 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
1033 table.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1034 table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
1035 table.SetFitHeight( 0 );
1036 table.SetFitHeight( 1 );
1037 table.SetFitHeight( 2 );
1040 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1041 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1042 backing.SetSize( 0.0f, 100.0f );
1044 TextActor text = TextActor::New( "Fit" );
1045 text.SetAnchorPoint( AnchorPoint::CENTER );
1046 text.SetParentOrigin( ParentOrigin::CENTER );
1047 backing.Add( text );
1049 table.Add( backing );
1052 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
1053 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1054 backing.SetSize( 0.0f, 200.0f );
1056 TextActor text = TextActor::New( "Fit" );
1057 text.SetAnchorPoint( AnchorPoint::CENTER );
1058 text.SetParentOrigin( ParentOrigin::CENTER );
1059 backing.Add( text );
1061 table.Add( backing );
1064 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1065 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1066 backing.SetSize( 0.0f, 300.0f );
1068 TextActor text = TextActor::New( "Fit" );
1069 text.SetAnchorPoint( AnchorPoint::CENTER );
1070 text.SetParentOrigin( ParentOrigin::CENTER );
1071 backing.Add( text );
1073 table.Add( backing );
1076 mPopup.Add( table );
1078 // The popup is not yet on the stage so needs to be flaged as dirty
1079 mPopup.MarkDirtyForRelayout();
1083 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL2_ID )
1085 mPopup = CreatePopup();
1086 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, WIDTH );
1087 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
1088 mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
1090 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
1091 table.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1092 table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
1093 table.SetFitHeight( 0 );
1094 table.SetFitHeight( 1 );
1097 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1098 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1099 backing.SetResizePolicy( FIXED, HEIGHT );
1100 backing.SetSize( 0.0f, 100.0f );
1102 TextActor text = TextActor::New( "Fit" );
1103 text.SetAnchorPoint( AnchorPoint::CENTER );
1104 text.SetParentOrigin( ParentOrigin::CENTER );
1105 backing.Add( text );
1107 table.Add( backing );
1110 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1111 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1112 backing.SetSize( 0.0f, 200.0f );
1114 TextActor text = TextActor::New( "Fit" );
1115 text.SetAnchorPoint( AnchorPoint::CENTER );
1116 text.SetParentOrigin( ParentOrigin::CENTER );
1117 backing.Add( text );
1119 table.Add( backing );
1122 mPopup.Add( table );
1124 // The popup is not yet on the stage so needs to be flaged as dirty
1125 mPopup.MarkDirtyForRelayout();
1129 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL3_ID )
1131 mPopup = CreatePopup();
1132 mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, WIDTH );
1133 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
1134 mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
1136 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
1137 table.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1138 table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
1139 table.SetFixedHeight( 0, 20.0f );
1140 table.SetFitHeight( 1 );
1143 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1144 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
1146 TextActor text = TextActor::New( "Fixed" );
1147 text.SetAnchorPoint( AnchorPoint::CENTER );
1148 text.SetParentOrigin( ParentOrigin::CENTER );
1149 backing.Add( text );
1151 table.Add( backing );
1154 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1155 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1156 backing.SetSize( 0.0f, 200.0f );
1158 TextActor text = TextActor::New( "Fit" );
1159 text.SetAnchorPoint( AnchorPoint::CENTER );
1160 text.SetParentOrigin( ParentOrigin::CENTER );
1161 backing.Add( text );
1163 table.Add( backing );
1166 mPopup.Add( table );
1168 // The popup is not yet on the stage so needs to be flaged as dirty
1169 mPopup.MarkDirtyForRelayout();
1173 else if( button.GetName() == OKAY_BUTTON_ID || button.GetName() == CANCEL_BUTTON_ID )
1184 void OnPopupOutsideTouched()
1192 void OnKeyEvent( const KeyEvent& event )
1194 if( event.state == KeyEvent::Down )
1196 if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) )
1198 // Exit application when click back or escape.
1199 mApplication.Quit();
1204 public: // From ItemFactory
1207 * @brief Return the number of items to display in the item view
1209 * @return Return the number of items to display
1211 virtual unsigned int GetNumberOfItems()
1213 switch( mDemoState )
1217 return POPUP_BUTTON_ITEMS_COUNT;
1222 return TABLEVIEW_BUTTON_ITEMS_COUNT;
1235 * @brief Create a new item to populate the item view with
1237 * @param[in] itemId The index of the item to create
1238 * @return Return the created actor for the given ID
1240 virtual Actor NewItem(unsigned int itemId)
1242 const ButtonItem* buttonDataArray = NULL;
1243 switch( mDemoState )
1247 buttonDataArray = POPUP_BUTTON_ITEMS;
1253 buttonDataArray = TABLEVIEW_BUTTON_ITEMS;
1263 if( buttonDataArray )
1265 Toolkit::PushButton popupButton = Toolkit::PushButton::New();
1266 popupButton.SetName( buttonDataArray[ itemId ].name );
1267 popupButton.SetLabel( buttonDataArray[ itemId ].text );
1268 popupButton.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
1270 popupButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
1271 popupButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
1273 popupButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
1289 Application& mApplication;
1290 Toolkit::View mView; ///< The View instance.
1291 Toolkit::ToolBar mToolBar; ///< The View's Toolbar.
1292 Layer mContentLayer; ///< Content layer
1294 Toolkit::TextView mTitleActor; ///< Title text
1296 Toolkit::Popup mMenu; ///< The navigation menu
1297 bool mMenuShown; ///< If the navigation menu is currently being displayed or not
1299 Toolkit::Popup mPopup;
1301 Toolkit::ItemView mItemView; ///< ItemView to hold test images
1303 DemoState mDemoState;
1306 void RunTest( Application& application )
1308 SizeNegotiationController test( application );
1310 application.MainLoop();
1313 // Entry point for Linux & SLP applications
1315 int main( int argc, char **argv )
1317 Application application = Application::New( &argc, &argv );
1319 RunTest( application );