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.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 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.SetDimensionDependency( HEIGHT, WIDTH );
449 text.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) );
453 // The popup is not yet on the stage so needs to be flaged as dirty
454 mPopup.MarkDirtyForRelayout();
458 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_ID )
460 mPopup = CreatePopup();
462 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
463 image.SetResizePolicy( FILL_TO_PARENT, WIDTH );
464 image.SetDimensionDependency( HEIGHT, WIDTH );
465 image.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) );
469 // The popup is not yet on the stage so needs to be flaged as dirty
470 mPopup.MarkDirtyForRelayout();
474 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID )
476 mPopup = CreatePopup();
478 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
479 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
480 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
482 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
483 image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
487 // The popup is not yet on the stage so needs to be flaged as dirty
488 mPopup.MarkDirtyForRelayout();
492 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FIT_ID )
494 mPopup = CreatePopup();
496 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
497 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
498 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
500 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
501 image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
502 image.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO );
506 // The popup is not yet on the stage so needs to be flaged as dirty
507 mPopup.MarkDirtyForRelayout();
511 else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FILL_ID )
513 mPopup = CreatePopup();
515 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
516 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
517 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
519 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) );
520 image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
521 image.SetSizeScalePolicy( FILL_WITH_ASPECT_RATIO );
525 // The popup is not yet on the stage so needs to be flaged as dirty
526 mPopup.MarkDirtyForRelayout();
530 else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_ID )
532 mPopup = CreatePopup();
533 mPopup.SetTitle( "Popup!" );
535 Toolkit::TextView text = Toolkit::TextView::New();
536 text.SetName( "POPUP_CONTENT_TEXT" );
537 text.SetText( CONTENT_TEXT );
538 text.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
539 text.SetWidthExceedPolicy( Toolkit::TextView::Split );
540 text.SetLineJustification( Toolkit::TextView::Center );
541 text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
542 text.SetDimensionDependency( HEIGHT, WIDTH );
543 text.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) );
547 // The popup is not yet on the stage so needs to be flaged as dirty
548 mPopup.MarkDirtyForRelayout();
552 else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS_ID )
554 mPopup = CreatePopup();
555 mPopup.SetTitle( "Popup!" );
557 Toolkit::TextView text = Toolkit::TextView::New();
558 text.SetName( "POPUP_CONTENT_TEXT" );
559 text.SetText( CONTENT_TEXT );
560 text.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
561 text.SetWidthExceedPolicy( Toolkit::TextView::Split );
562 text.SetLineJustification( Toolkit::TextView::Left );
563 text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
564 text.SetDimensionDependency( HEIGHT, WIDTH );
565 text.SetPadding( Padding( 10.0f, 10.0f, 20.0f, 0.0f ) );
569 Toolkit::PushButton cancelButton = Toolkit::PushButton::New();
570 cancelButton.SetName( CANCEL_BUTTON_ID );
571 cancelButton.SetLabel( "Cancel" );
572 cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
573 cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
575 cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
577 mPopup.AddButton( cancelButton );
579 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
580 okayButton.SetName( OKAY_BUTTON_ID );
581 okayButton.SetLabel( "OK!" );
582 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
583 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
585 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
587 mPopup.AddButton( okayButton );
589 // The popup is not yet on the stage so needs to be flaged as dirty
590 mPopup.MarkDirtyForRelayout();
594 else if( button.GetName() == POPUP_BUTTON_COMPLEX_ID )
596 mPopup = CreatePopup();
597 mPopup.SetTitle( "Warning" );
600 Toolkit::TableView content = Toolkit::TableView::New( 2, 2 );
601 content.SetName( "COMPLEX_TABLEVIEW" );
602 content.SetResizePolicy( FILL_TO_PARENT, WIDTH );
603 content.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
604 content.SetFitHeight( 0 );
605 content.SetFitHeight( 1 );
606 content.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 0.0f ) );
610 Toolkit::TextView text = Toolkit::TextView::New();
611 text.SetText( "Do you really want to quit?" );
612 text.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
613 text.SetWidthExceedPolicy( Toolkit::TextView::Split );
614 text.SetLineJustification( Toolkit::TextView::Left );
615 text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
616 text.SetDimensionDependency( HEIGHT, WIDTH );
618 content.AddChild( text, Toolkit::TableView::CellPosition( 0, 0 ) );
623 ImageActor image = ImageActor::New( ResourceImage::New( IMAGE1 ) );
624 image.SetName( "COMPLEX_IMAGE" );
625 image.SetResizePolicy( FILL_TO_PARENT, WIDTH );
626 image.SetDimensionDependency( HEIGHT, WIDTH );
627 image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) );
628 content.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) );
633 Toolkit::TableView root = Toolkit::TableView::New( 1, 2 );
634 root.SetResizePolicy( FILL_TO_PARENT, WIDTH );
635 root.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
636 root.SetFitHeight( 0 );
637 root.SetFitWidth( 0 );
638 root.SetPadding( Padding( 0.0f, 0.0f, 0.0f, 20.0f ) );
640 Dali::Image unchecked = Dali::ResourceImage::New( CHECKBOX_UNCHECKED_IMAGE );
641 Dali::Image checked = Dali::ResourceImage::New( CHECKBOX_CHECKED_IMAGE );
642 Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New();
643 checkBox.SetBackgroundImage( unchecked );
644 checkBox.SetSelectedImage( checked );
645 checkBox.SetPreferredSize( Vector2( 48, 48 ) );
646 checkBox.SetResizePolicy( FIXED, ALL_DIMENSIONS );
648 root.AddChild( checkBox, Toolkit::TableView::CellPosition( 0, 0 ) );
650 Toolkit::TextView text = Toolkit::TextView::New();
651 text.SetText( "Don't show again" );
652 text.SetLineJustification( Toolkit::TextView::Left );
653 Actor textActor = text;
654 textActor.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 10.0f ) );
656 root.AddChild( text, Toolkit::TableView::CellPosition( 0, 1 ) );
658 content.AddChild( root, Toolkit::TableView::CellPosition( 1, 0, 0, 2 ) ); // Column span 2
661 mPopup.Add( content );
664 Toolkit::PushButton cancelButton = Toolkit::PushButton::New();
665 cancelButton.SetName( CANCEL_BUTTON_ID );
666 cancelButton.SetLabel( "Cancel" );
667 cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
668 cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
670 cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
672 mPopup.AddButton( cancelButton );
674 Toolkit::PushButton okayButton = Toolkit::PushButton::New();
675 okayButton.SetName( OKAY_BUTTON_ID );
676 okayButton.SetLabel( "OK!" );
677 okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
678 okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
680 okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
682 mPopup.AddButton( okayButton );
684 // The popup is not yet on the stage so needs to be flaged as dirty
685 mPopup.MarkDirtyForRelayout();
689 else if( button.GetName() == TABLEVIEW_BUTTON_EMPTY_ID )
691 mPopup = CreatePopup();
692 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
693 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
694 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
697 Toolkit::TableView table = Toolkit::TableView::New( 0, 0 );
698 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
702 // The popup is not yet on the stage so needs to be flaged as dirty
703 mPopup.MarkDirtyForRelayout();
707 else if( button.GetName() == TABLEVIEW_BUTTON_1CELL_ID )
709 mPopup = CreatePopup();
710 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
711 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
712 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
715 Toolkit::TableView table = Toolkit::TableView::New( 0, 0 );
716 table.SetName( "TABLEVIEW_BUTTON_1CELL_ID" );
717 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
719 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
720 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
721 table.Add( backing );
725 // The popup is not yet on the stage so needs to be flaged as dirty
726 mPopup.MarkDirtyForRelayout();
730 else if( button.GetName() == TABLEVIEW_BUTTON_3CELL_ID )
732 mPopup = CreatePopup();
733 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
734 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
735 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
738 Toolkit::TableView table = Toolkit::TableView::New( 0, 0 );
739 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
742 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
743 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
744 table.Add( backing );
747 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
748 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
749 table.Add( backing );
752 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
753 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
754 table.Add( backing );
759 // The popup is not yet on the stage so needs to be flaged as dirty
760 mPopup.MarkDirtyForRelayout();
764 else if( button.GetName() == TABLEVIEW_BUTTON_3X3CELL_ID )
766 mPopup = CreatePopup();
767 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
768 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
769 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
772 Toolkit::TableView table = Toolkit::TableView::New( 3, 3 );
773 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
777 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
778 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
779 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 0 ) );
782 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
783 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
784 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 0 ) );
787 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
788 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
789 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 0 ) );
794 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) );
795 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
796 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 1 ) );
799 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
800 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
801 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 1 ) );
804 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 0.0f, 1.0f, 1.0f ) );
805 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
806 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 1 ) );
811 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) );
812 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
813 table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 2 ) );
816 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.5f, 0.5f, 0.5f, 1.0f ) );
817 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
818 table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 2 ) );
821 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.5f, 0.0f, 1.0f ) );
822 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
823 table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 2 ) );
828 // The popup is not yet on the stage so needs to be flaged as dirty
829 mPopup.MarkDirtyForRelayout();
833 else if( button.GetName() == TABLEVIEW_BUTTON_FIXED1_ID )
835 mPopup = CreatePopup();
836 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
837 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
838 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
841 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
842 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
843 table.SetFixedHeight( 0, 50.0f );
846 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
847 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
848 TextActor text = TextActor::New( "Fixed" );
849 text.SetAnchorPoint( AnchorPoint::CENTER );
850 text.SetParentOrigin( ParentOrigin::CENTER );
852 table.Add( backing );
855 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.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 );
864 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
865 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
866 TextActor text = TextActor::New( "Fill" );
867 text.SetAnchorPoint( AnchorPoint::CENTER );
868 text.SetParentOrigin( ParentOrigin::CENTER );
870 table.Add( backing );
875 // The popup is not yet on the stage so needs to be flaged as dirty
876 mPopup.MarkDirtyForRelayout();
880 else if( button.GetName() == TABLEVIEW_BUTTON_FIXED2_ID )
882 mPopup = CreatePopup();
883 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
884 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
885 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
888 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
889 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
890 table.SetFixedHeight( 0, 50.0f );
891 table.SetFixedHeight( 2, 50.0f );
894 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
895 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
896 TextActor text = TextActor::New( "Fixed" );
897 text.SetAnchorPoint( AnchorPoint::CENTER );
898 text.SetParentOrigin( ParentOrigin::CENTER );
900 table.Add( backing );
903 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
904 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
905 TextActor text = TextActor::New( "Fill" );
906 text.SetAnchorPoint( AnchorPoint::CENTER );
907 text.SetParentOrigin( ParentOrigin::CENTER );
909 table.Add( backing );
912 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
913 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
914 TextActor text = TextActor::New( "Fixed" );
915 text.SetAnchorPoint( AnchorPoint::CENTER );
916 text.SetParentOrigin( ParentOrigin::CENTER );
918 table.Add( backing );
923 // The popup is not yet on the stage so needs to be flaged as dirty
924 mPopup.MarkDirtyForRelayout();
928 else if( button.GetName() == TABLEVIEW_BUTTON_FIT1_ID )
930 mPopup = CreatePopup();
931 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
932 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
933 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
936 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
937 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
938 table.SetFitHeight( 0 );
939 table.SetFitHeight( 2 );
942 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
943 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
944 backing.SetResizePolicy( FIXED, HEIGHT );
945 backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
947 TextActor text = TextActor::New( "Fit" );
948 text.SetAnchorPoint( AnchorPoint::CENTER );
949 text.SetParentOrigin( ParentOrigin::CENTER );
952 table.Add( backing );
955 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
956 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
958 TextActor text = TextActor::New( "Fill" );
959 text.SetAnchorPoint( AnchorPoint::CENTER );
960 text.SetParentOrigin( ParentOrigin::CENTER );
963 table.Add( backing );
966 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
967 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
968 backing.SetResizePolicy( FIXED, HEIGHT );
969 backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
971 TextActor text = TextActor::New( "Fit" );
972 text.SetAnchorPoint( AnchorPoint::CENTER );
973 text.SetParentOrigin( ParentOrigin::CENTER );
976 table.Add( backing );
981 // The popup is not yet on the stage so needs to be flaged as dirty
982 mPopup.MarkDirtyForRelayout();
986 else if( button.GetName() == TABLEVIEW_BUTTON_FIT2_ID )
988 mPopup = CreatePopup();
989 mPopup.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
990 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
991 mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) );
994 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
995 table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
996 table.SetFitHeight( 1 );
999 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1000 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
1002 TextActor text = TextActor::New( "Fill" );
1003 text.SetAnchorPoint( AnchorPoint::CENTER );
1004 text.SetParentOrigin( ParentOrigin::CENTER );
1005 backing.Add( text );
1007 table.Add( backing );
1010 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
1011 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1012 backing.SetResizePolicy( FIXED, HEIGHT );
1013 backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
1015 TextActor text = TextActor::New( "Fit" );
1016 text.SetAnchorPoint( AnchorPoint::CENTER );
1017 text.SetParentOrigin( ParentOrigin::CENTER );
1018 backing.Add( text );
1020 table.Add( backing );
1023 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1024 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
1026 TextActor text = TextActor::New( "Fill" );
1027 text.SetAnchorPoint( AnchorPoint::CENTER );
1028 text.SetParentOrigin( ParentOrigin::CENTER );
1029 backing.Add( text );
1031 table.Add( backing );
1034 mPopup.Add( table );
1036 // The popup is not yet on the stage so needs to be flaged as dirty
1037 mPopup.MarkDirtyForRelayout();
1041 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL1_ID )
1043 mPopup = CreatePopup();
1044 mPopup.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1045 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
1046 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
1047 mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
1049 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
1050 table.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1051 table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
1052 table.SetFitHeight( 0 );
1053 table.SetFitHeight( 1 );
1054 table.SetFitHeight( 2 );
1057 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1058 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1059 backing.SetResizePolicy( FIXED, HEIGHT );
1060 backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
1062 TextActor text = TextActor::New( "Fit" );
1063 text.SetAnchorPoint( AnchorPoint::CENTER );
1064 text.SetParentOrigin( ParentOrigin::CENTER );
1065 backing.Add( text );
1067 table.Add( backing );
1070 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
1071 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1072 backing.SetResizePolicy( FIXED, HEIGHT );
1073 backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
1075 TextActor text = TextActor::New( "Fit" );
1076 text.SetAnchorPoint( AnchorPoint::CENTER );
1077 text.SetParentOrigin( ParentOrigin::CENTER );
1078 backing.Add( text );
1080 table.Add( backing );
1083 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1084 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1085 backing.SetResizePolicy( FIXED, HEIGHT );
1086 backing.SetPreferredSize( Vector2( 0.0f, 300.0f ) );
1088 TextActor text = TextActor::New( "Fit" );
1089 text.SetAnchorPoint( AnchorPoint::CENTER );
1090 text.SetParentOrigin( ParentOrigin::CENTER );
1091 backing.Add( text );
1093 table.Add( backing );
1096 mPopup.Add( table );
1098 // The popup is not yet on the stage so needs to be flaged as dirty
1099 mPopup.MarkDirtyForRelayout();
1103 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL2_ID )
1105 mPopup = CreatePopup();
1106 mPopup.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1107 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
1108 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
1109 mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
1111 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
1112 table.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1113 table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
1114 table.SetFitHeight( 0 );
1115 table.SetFitHeight( 1 );
1118 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1119 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1120 backing.SetResizePolicy( FIXED, HEIGHT );
1121 backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
1123 TextActor text = TextActor::New( "Fit" );
1124 text.SetAnchorPoint( AnchorPoint::CENTER );
1125 text.SetParentOrigin( ParentOrigin::CENTER );
1126 backing.Add( text );
1128 table.Add( backing );
1131 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1132 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1133 backing.SetResizePolicy( FIXED, HEIGHT );
1134 backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
1136 TextActor text = TextActor::New( "Fit" );
1137 text.SetAnchorPoint( AnchorPoint::CENTER );
1138 text.SetParentOrigin( ParentOrigin::CENTER );
1139 backing.Add( text );
1141 table.Add( backing );
1144 mPopup.Add( table );
1146 // The popup is not yet on the stage so needs to be flaged as dirty
1147 mPopup.MarkDirtyForRelayout();
1151 else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL3_ID )
1153 mPopup = CreatePopup();
1154 mPopup.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1155 mPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
1156 mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
1157 mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
1159 Toolkit::TableView table = Toolkit::TableView::New( 3, 1 );
1160 table.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1161 table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
1162 table.SetFixedHeight( 0, 20.0f );
1163 table.SetFitHeight( 1 );
1166 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1167 backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
1169 TextActor text = TextActor::New( "Fixed" );
1170 text.SetAnchorPoint( AnchorPoint::CENTER );
1171 text.SetParentOrigin( ParentOrigin::CENTER );
1172 backing.Add( text );
1174 table.Add( backing );
1177 Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
1178 backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
1179 backing.SetResizePolicy( FIXED, HEIGHT );
1180 backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
1182 TextActor text = TextActor::New( "Fit" );
1183 text.SetAnchorPoint( AnchorPoint::CENTER );
1184 text.SetParentOrigin( ParentOrigin::CENTER );
1185 backing.Add( text );
1187 table.Add( backing );
1190 mPopup.Add( table );
1192 // The popup is not yet on the stage so needs to be flaged as dirty
1193 mPopup.MarkDirtyForRelayout();
1197 else if( button.GetName() == OKAY_BUTTON_ID || button.GetName() == CANCEL_BUTTON_ID )
1208 void OnPopupOutsideTouched()
1216 void OnKeyEvent( const KeyEvent& event )
1218 if( event.state == KeyEvent::Down )
1220 if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) )
1222 // Exit application when click back or escape.
1223 mApplication.Quit();
1228 public: // From ItemFactory
1231 * @brief Return the number of items to display in the item view
1233 * @return Return the number of items to display
1235 virtual unsigned int GetNumberOfItems()
1237 switch( mDemoState )
1241 return POPUP_BUTTON_ITEMS_COUNT;
1246 return TABLEVIEW_BUTTON_ITEMS_COUNT;
1259 * @brief Create a new item to populate the item view with
1261 * @param[in] itemId The index of the item to create
1262 * @return Return the created actor for the given ID
1264 virtual Actor NewItem(unsigned int itemId)
1266 const ButtonItem* buttonDataArray = NULL;
1267 switch( mDemoState )
1271 buttonDataArray = POPUP_BUTTON_ITEMS;
1277 buttonDataArray = TABLEVIEW_BUTTON_ITEMS;
1287 if( buttonDataArray )
1289 Toolkit::PushButton popupButton = Toolkit::PushButton::New();
1290 popupButton.SetName( buttonDataArray[ itemId ].name );
1291 popupButton.SetLabel( buttonDataArray[ itemId ].text );
1292 popupButton.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
1294 popupButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
1295 popupButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );
1297 popupButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked );
1313 Application& mApplication;
1314 Toolkit::View mView; ///< The View instance.
1315 Toolkit::ToolBar mToolBar; ///< The View's Toolbar.
1316 Layer mContentLayer; ///< Content layer
1318 Toolkit::TextView mTitleActor; ///< Title text
1320 Toolkit::Popup mMenu; ///< The navigation menu
1321 bool mMenuShown; ///< If the navigation menu is currently being displayed or not
1323 Toolkit::Popup mPopup;
1325 Toolkit::ItemView mItemView; ///< ItemView to hold test images
1327 DemoState mDemoState;
1330 void RunTest( Application& application )
1332 SizeNegotiationController test( application );
1334 application.MainLoop();
1337 // Entry point for Linux & SLP applications
1339 int main( int argc, char **argv )
1341 Application application = Application::New( &argc, &argv );
1343 RunTest( application );