Commit ae5f99de4bdabb973099ecce312c0eef127284e5

Authored by Adeel Kazmi
Committed by Gerrit Code Review
2 parents afbd7281 2db6299f

Merge "Fix the scalability issue on dali-demo" into tizen

demo/dali-table-view.cpp
@@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
17 17
18 // CLASS HEADER 18 // CLASS HEADER
19 #include "dali-table-view.h" 19 #include "dali-table-view.h"
  20 +#include "examples/shared/view.h"
20 21
21 // EXTERNAL INCLUDES 22 // EXTERNAL INCLUDES
22 #include <algorithm> 23 #include <algorithm>
@@ -90,12 +91,13 @@ const Dali::PointSize TABLE_TEXT_STYLE_POINT_SIZE( 8.0f ); @@ -90,12 +91,13 @@ const Dali::PointSize TABLE_TEXT_STYLE_POINT_SIZE( 8.0f );
90 const Dali::TextStyle::Weight TABLE_TEXT_STYLE_WEIGHT(Dali::TextStyle::LIGHT); 91 const Dali::TextStyle::Weight TABLE_TEXT_STYLE_WEIGHT(Dali::TextStyle::LIGHT);
91 const Dali::Vector4 TABLE_TEXT_STYLE_COLOR(0.0f, 0.0f, 0.0f, 1.0f); 92 const Dali::Vector4 TABLE_TEXT_STYLE_COLOR(0.0f, 0.0f, 0.0f, 1.0f);
92 93
  94 +
93 TextStyle GetDefaultTextStyle() 95 TextStyle GetDefaultTextStyle()
94 { 96 {
95 TextStyle textStyle; 97 TextStyle textStyle;
96 textStyle.SetFontName(DEFAULT_TEXT_STYLE_FONT_FAMILY); 98 textStyle.SetFontName(DEFAULT_TEXT_STYLE_FONT_FAMILY);
97 textStyle.SetFontStyle(DEFAULT_TEXT_STYLE_FONT_STYLE); 99 textStyle.SetFontStyle(DEFAULT_TEXT_STYLE_FONT_STYLE);
98 - textStyle.SetFontPointSize(DEFAULT_TEXT_STYLE_POINT_SIZE); 100 + textStyle.SetFontPointSize( Dali::PointSize(DemoHelper::ScalePointSize(DEFAULT_TEXT_STYLE_POINT_SIZE)));
99 textStyle.SetWeight(DEFAULT_TEXT_STYLE_WEIGHT); 101 textStyle.SetWeight(DEFAULT_TEXT_STYLE_WEIGHT);
100 textStyle.SetTextColor(DEFAULT_TEXT_STYLE_COLOR); 102 textStyle.SetTextColor(DEFAULT_TEXT_STYLE_COLOR);
101 textStyle.SetShadow( true ); 103 textStyle.SetShadow( true );
@@ -107,7 +109,7 @@ TextStyle GetTableTextStyle() @@ -107,7 +109,7 @@ TextStyle GetTableTextStyle()
107 TextStyle textStyle; 109 TextStyle textStyle;
108 textStyle.SetFontName(TABLE_TEXT_STYLE_FONT_FAMILY); 110 textStyle.SetFontName(TABLE_TEXT_STYLE_FONT_FAMILY);
109 textStyle.SetFontStyle(TABLE_TEXT_STYLE_FONT_STYLE); 111 textStyle.SetFontStyle(TABLE_TEXT_STYLE_FONT_STYLE);
110 - textStyle.SetFontPointSize(TABLE_TEXT_STYLE_POINT_SIZE); 112 + textStyle.SetFontPointSize( Dali::PointSize(DemoHelper::ScalePointSize(TABLE_TEXT_STYLE_POINT_SIZE)));
111 textStyle.SetWeight(TABLE_TEXT_STYLE_WEIGHT); 113 textStyle.SetWeight(TABLE_TEXT_STYLE_WEIGHT);
112 textStyle.SetTextColor(TABLE_TEXT_STYLE_COLOR); 114 textStyle.SetTextColor(TABLE_TEXT_STYLE_COLOR);
113 return textStyle; 115 return textStyle;
@@ -285,7 +287,15 @@ void DaliTableView::Initialize( Application&amp; application ) @@ -285,7 +287,15 @@ void DaliTableView::Initialize( Application&amp; application )
285 Stage::GetCurrent().Add( mRootActor ); 287 Stage::GetCurrent().Add( mRootActor );
286 288
287 // Toolbar at top 289 // Toolbar at top
288 - CreateToolbar( mRootActor, DEFAULT_TOOLBAR_TEXT, DEFAULT_TOOLBAR_IMAGE_PATH ); 290 + Dali::Toolkit::ToolBar toolbar;
  291 + Dali::Layer toolBarLayer = DemoHelper::CreateToolbar(toolbar,
  292 + DEFAULT_TOOLBAR_IMAGE_PATH,
  293 + DEFAULT_TOOLBAR_TEXT,
  294 + DemoHelper::DEFAULT_VIEW_STYLE,
  295 + DemoHelper::GetDefaultTextStyle());
  296 +
  297 + mRootActor.AddChild( toolBarLayer, TableView::CellPosition( 0, 0 ) );
  298 + mRootActor.SetFixedHeight( 0, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarHeight );
289 299
290 // Add logo 300 // Add logo
291 mLogo = CreateLogo( LOGO_PATH ); 301 mLogo = CreateLogo( LOGO_PATH );
@@ -364,61 +374,6 @@ void DaliTableView::Initialize( Application&amp; application ) @@ -364,61 +374,6 @@ void DaliTableView::Initialize( Application&amp; application )
364 KeyboardFocusManager::Get().FocusedActorActivatedSignal().Connect( this, &DaliTableView::OnFocusedActorActivated ); 374 KeyboardFocusManager::Get().FocusedActorActivatedSignal().Connect( this, &DaliTableView::OnFocusedActorActivated );
365 } 375 }
366 376
367 -void DaliTableView::CreateToolbar( TableView root, const std::string& title, const std::string& toolbarImagePath,  
368 - const ViewStyle& style )  
369 -{  
370 - // Create default ToolBar  
371 - Dali::Stage stage = Dali::Stage::GetCurrent();  
372 - Dali::Vector2 dpi = stage.GetDpi();  
373 -  
374 - // Create toolbar layer.  
375 - Dali::Layer toolBarLayer = Dali::Layer::New();  
376 - toolBarLayer.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER );  
377 - toolBarLayer.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER );  
378 - toolBarLayer.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ), Dali::SourceWidthFixedHeight( style.mToolBarHeight * dpi.y / style.mDpi ) ) );  
379 - float toolBarLayerHeight = style.mToolBarHeight * dpi.y / style.mDpi;  
380 - toolBarLayer.SetSize( 0.0f, toolBarLayerHeight );  
381 -  
382 - // Add tool bar layer to the view.  
383 - root.AddChild( toolBarLayer, TableView::CellPosition( 0, 0 ) );  
384 - root.SetFixedHeight( 0, toolBarLayerHeight );  
385 -  
386 - // Raise tool bar layer to the top.  
387 - toolBarLayer.RaiseToTop();  
388 -  
389 - // Tool bar  
390 - Dali::Image image = Dali::Image::New( toolbarImagePath );  
391 - Dali::ImageActor toolBarBackground = Dali::ImageActor::New( image );  
392 - Dali::Toolkit::ToolBar toolBar = Dali::Toolkit::ToolBar::New();  
393 - toolBar.SetBackground( toolBarBackground );  
394 - toolBar.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER );  
395 - toolBar.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER );  
396 - toolBar.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ), Dali::EqualToConstraint() ) );  
397 - toolBar.SetSize( 0.0f, style.mToolBarHeight * dpi.y / style.mDpi );  
398 - toolBarBackground.SetZ( -1.0f );  
399 -  
400 - // Add the tool bar to the too bar layer.  
401 - toolBarLayer.Add( toolBar );  
402 -  
403 - Dali::Font font = Dali::Font::New();  
404 -  
405 - // Tool bar text.  
406 - if( !title.empty() )  
407 - {  
408 - Dali::Toolkit::TextView titleActor = Dali::Toolkit::TextView::New();  
409 - titleActor.SetName( "ToolbarTitle" );  
410 - titleActor.SetText( title );  
411 - titleActor.SetSize( font.MeasureText( title ) );  
412 - titleActor.SetStyleToCurrentText( GetDefaultTextStyle() );  
413 - titleActor.SetZ( 1.0f );  
414 -  
415 - // Add title to the tool bar.  
416 - const float padding( style.mToolBarPadding * dpi.x / style.mDpi );  
417 - toolBar.AddControl( titleActor, style.mToolBarTitlePercentage, Dali::Toolkit::Alignment::HorizontalCenter,  
418 - Dali::Toolkit::Alignment::Padding( padding, padding, padding, padding ) );  
419 - }  
420 -}  
421 -  
422 void DaliTableView::Populate() 377 void DaliTableView::Populate()
423 { 378 {
424 const Vector2 stageSize = Stage::GetCurrent().GetSize(); 379 const Vector2 stageSize = Stage::GetCurrent().GetSize();
@@ -898,7 +853,6 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BitmapImage dis @@ -898,7 +853,6 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BitmapImage dis
898 Random::Range( -size.y * 0.5f - randSize, size.y * 0.5f + randSize ), 853 Random::Range( -size.y * 0.5f - randSize, size.y * 0.5f + randSize ),
899 Random::Range(-1.0f, 0.0f) ); 854 Random::Range(-1.0f, 0.0f) );
900 dfActor.SetPosition( actorPos ); 855 dfActor.SetPosition( actorPos );
901 - dfActor.SetSortModifier(size.x * 0.7f);  
902 856
903 Constraint movementConstraint = Constraint::New < Vector3 > ( Actor::POSITION, 857 Constraint movementConstraint = Constraint::New < Vector3 > ( Actor::POSITION,
904 LocalSource( Actor::SIZE ), 858 LocalSource( Actor::SIZE ),
demo/dali-table-view.h
@@ -72,27 +72,7 @@ struct Example @@ -72,27 +72,7 @@ struct Example
72 std::string title; ///< title (caption) of example to appear on tile button. 72 std::string title; ///< title (caption) of example to appear on tile button.
73 }; 73 };
74 74
75 -/**  
76 - * Provide a style for the view and its tool bar.  
77 - */  
78 -struct ViewStyle  
79 -{  
80 - ViewStyle( float toolBarButtonPercentage, float toolBarTitlePercentage, float dpi, float toolBarHeight, float toolBarPadding )  
81 - : mToolBarButtonPercentage( toolBarButtonPercentage ),  
82 - mToolBarTitlePercentage( toolBarTitlePercentage ),  
83 - mDpi( dpi ),  
84 - mToolBarHeight( toolBarHeight ),  
85 - mToolBarPadding( toolBarPadding )  
86 - {}  
87 -  
88 - float mToolBarButtonPercentage; ///< The tool bar button width is a percentage of the tool bar width.  
89 - float mToolBarTitlePercentage; ///< The tool bar title width is a percentage of the tool bar width.  
90 - float mDpi; ///< This style is indented for the given dpi.  
91 - float mToolBarHeight; ///< The tool bar height for the given dpi above.  
92 - float mToolBarPadding; ///< The tool bar padding between controls for the given dpi above.  
93 -};  
94 75
95 -const ViewStyle DEFAULT_VIEW_STYLE( 0.1f, 0.7f, 315.f, 80.f, 4.f );  
96 76
97 /** 77 /**
98 * Dali-Demo instance 78 * Dali-Demo instance
@@ -276,11 +256,6 @@ private: // Application callbacks &amp; implementation @@ -276,11 +256,6 @@ private: // Application callbacks &amp; implementation
276 void ApplyEffectToTileContent(Dali::Actor tileContent); 256 void ApplyEffectToTileContent(Dali::Actor tileContent);
277 257
278 /** 258 /**
279 - * Create a toolbar  
280 - */  
281 - void CreateToolbar(Dali::Toolkit::TableView root, const std::string& title, const std::string& toolbarImagePath, const ViewStyle& style = DEFAULT_VIEW_STYLE);  
282 -  
283 - /**  
284 * Key event handler 259 * Key event handler
285 */ 260 */
286 void OnKeyEvent( const Dali::KeyEvent& event ); 261 void OnKeyEvent( const Dali::KeyEvent& event );
examples/builder/examples.cpp
@@ -404,7 +404,14 @@ public: @@ -404,7 +404,14 @@ public:
404 { 404 {
405 TextView t = TextView::New(); 405 TextView t = TextView::New();
406 t.SetMarkupProcessingEnabled(true); 406 t.SetMarkupProcessingEnabled(true);
407 - t.SetText( std::string("<font size=6>") + ShortName( text ) + std::string("</font>") ); 407 +
  408 + int size = static_cast<int>(DemoHelper::ScalePointSize(6));
  409 +
  410 + std::ostringstream fontString;
  411 + fontString << "<font size="<< size <<">"<< ShortName( text ) << "</font>";
  412 +
  413 + t.SetText( fontString.str() );
  414 +
408 t.SetTextAlignment( Alignment::HorizontalLeft ); 415 t.SetTextAlignment( Alignment::HorizontalLeft );
409 return t; 416 return t;
410 } 417 }
examples/cluster/cluster-example.cpp
@@ -127,11 +127,8 @@ const float CLUSTER_RELATIVE_SIZE = 0.65f; ///&lt; Cluster size re @@ -127,11 +127,8 @@ const float CLUSTER_RELATIVE_SIZE = 0.65f; ///&lt; Cluster size re
127 const float CLUSTER_GROUP_DELAY_TOP = 0.25f; ///< Delay for top Clusters in seconds. 127 const float CLUSTER_GROUP_DELAY_TOP = 0.25f; ///< Delay for top Clusters in seconds.
128 const float CLUSTER_GROUP_DELAY_BOTTOM = 0.0f; ///< Delay for bottom Clusters in seconds. 128 const float CLUSTER_GROUP_DELAY_BOTTOM = 0.0f; ///< Delay for bottom Clusters in seconds.
129 129
130 -const float CLUSTER_COLUMN_SPACING = 1.0f; ///< Spacing in screen coordinates.  
131 const float CLUSTER_COLUMN_INDENT = 0.1f; ///< Left Indentation in screen coordinates. 130 const float CLUSTER_COLUMN_INDENT = 0.1f; ///< Left Indentation in screen coordinates.
132 -const float CLUSTER_ROW_SPACING = 0.42f; ///< Spacing in screen coordinates.  
133 const float CLUSTER_ROW_INDENT = 0.13f; ///< Top Indentation in screen coordinates. 131 const float CLUSTER_ROW_INDENT = 0.13f; ///< Top Indentation in screen coordinates.
134 -const float CLUSTER_BOTTOM_SHIFT = 0.15f; ///< Bottom row is shifted right by 15% of screen width.  
135 132
136 const Vector3 SHEAR_EFFECT_ANCHOR_POINT(0.5f, 1.0f, 0.5f); ///< Anchor Point used for the shear effect (extends outside of Cluster) 133 const Vector3 SHEAR_EFFECT_ANCHOR_POINT(0.5f, 1.0f, 0.5f); ///< Anchor Point used for the shear effect (extends outside of Cluster)
137 const float SHEAR_EFFECT_MAX_OVERSHOOT = 30.0f; ///< Max Overshoot for shear effect (in degrees). 134 const float SHEAR_EFFECT_MAX_OVERSHOOT = 30.0f; ///< Max Overshoot for shear effect (in degrees).
@@ -557,7 +554,8 @@ public: @@ -557,7 +554,8 @@ public:
557 clusterActor.SetAnchorPoint(AnchorPoint::CENTER); 554 clusterActor.SetAnchorPoint(AnchorPoint::CENTER);
558 555
559 Vector2 stageSize = Dali::Stage::GetCurrent().GetSize(); 556 Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
560 - clusterActor.SetSize(stageSize.x * CLUSTER_RELATIVE_SIZE, stageSize.x * CLUSTER_RELATIVE_SIZE, 0.0f); 557 + float minStageDimension = min(stageSize.x, stageSize.y);
  558 + clusterActor.SetSize(minStageDimension * CLUSTER_RELATIVE_SIZE, minStageDimension * CLUSTER_RELATIVE_SIZE, 0.0f);
561 559
562 DALI_ASSERT_ALWAYS(clusterType < CLUSTER_COUNT); 560 DALI_ASSERT_ALWAYS(clusterType < CLUSTER_COUNT);
563 const char **paths = IMAGE_GROUPS[clusterType]; 561 const char **paths = IMAGE_GROUPS[clusterType];
@@ -650,8 +648,11 @@ public: @@ -650,8 +648,11 @@ public:
650 648
651 int column = mClusterCount>>1; 649 int column = mClusterCount>>1;
652 int row = mClusterCount&1; 650 int row = mClusterCount&1;
653 - Vector3 clusterPosition = Vector3((CLUSTER_COLUMN_INDENT + row * CLUSTER_BOTTOM_SHIFT) * stageSize.width,  
654 - (row * CLUSTER_ROW_SPACING + CLUSTER_ROW_INDENT) * stageSize.height, 0.0f); 651 +
  652 + float minStageDimension = min(stageSize.x, stageSize.y);
  653 + float clusterRightShift = 1.0f - CLUSTER_COLUMN_INDENT * 2.0f;
  654 + Vector3 clusterPosition = Vector3(CLUSTER_COLUMN_INDENT * stageSize.width + row * (clusterRightShift * stageSize.width - minStageDimension * CLUSTER_RELATIVE_SIZE),
  655 + CLUSTER_ROW_INDENT * stageSize.height + row * (clusterRightShift * stageSize.height - minStageDimension * CLUSTER_RELATIVE_SIZE), 0.0f);
655 656
656 Actor pageView = Actor::New(); 657 Actor pageView = Actor::New();
657 mScrollView.Add(pageView); 658 mScrollView.Add(pageView);
examples/item-view/item-view-example.cpp
@@ -246,9 +246,9 @@ public: @@ -246,9 +246,9 @@ public:
246 */ 246 */
247 void OnInit(Application& app) 247 void OnInit(Application& app)
248 { 248 {
249 - Stage::GetCurrent().KeyEventSignal().Connect(this, &ItemViewExample::OnKeyEvent);  
250 -  
251 Stage stage = Dali::Stage::GetCurrent(); 249 Stage stage = Dali::Stage::GetCurrent();
  250 + stage.KeyEventSignal().Connect(this, &ItemViewExample::OnKeyEvent);
  251 +
252 Vector2 stageSize = Stage::GetCurrent().GetSize(); 252 Vector2 stageSize = Stage::GetCurrent().GetSize();
253 253
254 // Create a border image shared by all the item actors 254 // Create a border image shared by all the item actors
@@ -265,9 +265,6 @@ public: @@ -265,9 +265,6 @@ public:
265 265
266 mView.OrientationAnimationStartedSignal().Connect( this, &ItemViewExample::OnOrientationChanged ); 266 mView.OrientationAnimationStartedSignal().Connect( this, &ItemViewExample::OnOrientationChanged );
267 267
268 - // Set the title to the current layout  
269 - SetLayoutTitle();  
270 -  
271 // Create an edit mode button. (left of toolbar) 268 // Create an edit mode button. (left of toolbar)
272 Toolkit::PushButton editButton = Toolkit::PushButton::New(); 269 Toolkit::PushButton editButton = Toolkit::PushButton::New();
273 editButton.SetBackgroundImage( Image::New( EDIT_IMAGE ) ); 270 editButton.SetBackgroundImage( Image::New( EDIT_IMAGE ) );
@@ -281,7 +278,6 @@ public: @@ -281,7 +278,6 @@ public:
281 mLayoutButton.ClickedSignal().Connect( this, &ItemViewExample::OnLayoutButtonClicked); 278 mLayoutButton.ClickedSignal().Connect( this, &ItemViewExample::OnLayoutButtonClicked);
282 mLayoutButton.SetLeaveRequired( true ); 279 mLayoutButton.SetLeaveRequired( true );
283 mToolBar.AddControl( mLayoutButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); 280 mToolBar.AddControl( mLayoutButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
284 - SetLayoutImage();  
285 281
286 // Create a delete button (bottom right of screen) 282 // Create a delete button (bottom right of screen)
287 mDeleteButton = Toolkit::PushButton::New(); 283 mDeleteButton = Toolkit::PushButton::New();
@@ -347,10 +343,13 @@ public: @@ -347,10 +343,13 @@ public:
347 mItemView.SetMinimumSwipeSpeed(MIN_SWIPE_SPEED); 343 mItemView.SetMinimumSwipeSpeed(MIN_SWIPE_SPEED);
348 344
349 // Activate the spiral layout 345 // Activate the spiral layout
350 - Vector3 size(stage.GetSize());  
351 - mItemView.ActivateLayout(mCurrentLayout, size, 0.0f/*immediate*/); 346 + UseLayout(mCurrentLayout, 0.0f);
352 mItemView.SetKeyboardFocusable( true ); 347 mItemView.SetKeyboardFocusable( true );
353 KeyboardFocusManager::Get().PreFocusChangeSignal().Connect( this, &ItemViewExample::OnKeyboardPreFocusChange ); 348 KeyboardFocusManager::Get().PreFocusChangeSignal().Connect( this, &ItemViewExample::OnKeyboardPreFocusChange );
  349 +
  350 + // Set the title and icon to the current layout
  351 + SetLayoutTitle();
  352 + SetLayoutImage();
354 } 353 }
355 354
356 Actor OnKeyboardPreFocusChange( Actor current, Actor proposed, Control::KeyboardFocusNavigationDirection direction ) 355 Actor OnKeyboardPreFocusChange( Actor current, Actor proposed, Control::KeyboardFocusNavigationDirection direction )
@@ -366,7 +365,7 @@ public: @@ -366,7 +365,7 @@ public:
366 /** 365 /**
367 * Switch to a different item view layout 366 * Switch to a different item view layout
368 */ 367 */
369 - void UseLayout(int layoutId) 368 + void UseLayout(int layoutId, float duration)
370 { 369 {
371 // Set the new orientation to the layout 370 // Set the new orientation to the layout
372 mItemView.GetLayout(layoutId)->SetOrientation(static_cast<ControlOrientation::Type>(mOrientation / 90)); 371 mItemView.GetLayout(layoutId)->SetOrientation(static_cast<ControlOrientation::Type>(mOrientation / 90));
@@ -375,15 +374,7 @@ public: @@ -375,15 +374,7 @@ public:
375 374
376 if(layoutId == SPIRAL_LAYOUT) 375 if(layoutId == SPIRAL_LAYOUT)
377 { 376 {
378 - // Set up the spiral layout according to the new orientation  
379 - if(Toolkit::IsVertical(mSpiralLayout->GetOrientation()))  
380 - {  
381 - mSpiralLayout->SetRevolutionDistance(stageSize.y / SPIRAL_LAYOUT_REVOLUTION_NUMBER_PORTRAIT);  
382 - }  
383 - else  
384 - {  
385 - mSpiralLayout->SetRevolutionDistance(stageSize.x / SPIRAL_LAYOUT_REVOLUTION_NUMBER_LANDSCAPE);  
386 - } 377 + mSpiralLayout->SetRevolutionDistance(stageSize.height / Stage::GetCurrent().GetDpi().y * 45.0f);
387 } 378 }
388 379
389 if(layoutId == GRID_LAYOUT) 380 if(layoutId == GRID_LAYOUT)
@@ -422,7 +413,7 @@ public: @@ -422,7 +413,7 @@ public:
422 mItemView.SetAnchoring(layoutId == DEPTH_LAYOUT); 413 mItemView.SetAnchoring(layoutId == DEPTH_LAYOUT);
423 414
424 // Activate the layout 415 // Activate the layout
425 - mItemView.ActivateLayout(layoutId, Vector3(stageSize.x, stageSize.y, stageSize.x), mDurationSeconds); 416 + mItemView.ActivateLayout(layoutId, Vector3(stageSize.x, stageSize.y, stageSize.x), duration);
426 } 417 }
427 418
428 /** 419 /**
@@ -439,7 +430,7 @@ public: @@ -439,7 +430,7 @@ public:
439 // Remember orientation 430 // Remember orientation
440 mOrientation = angle; 431 mOrientation = angle;
441 432
442 - UseLayout(mCurrentLayout); 433 + UseLayout(mCurrentLayout, mDurationSeconds);
443 } 434 }
444 } 435 }
445 436
@@ -448,7 +439,7 @@ public: @@ -448,7 +439,7 @@ public:
448 // Switch to the next layout 439 // Switch to the next layout
449 mCurrentLayout = (mCurrentLayout + 1) % mItemView.GetLayoutCount(); 440 mCurrentLayout = (mCurrentLayout + 1) % mItemView.GetLayoutCount();
450 441
451 - UseLayout(mCurrentLayout); 442 + UseLayout(mCurrentLayout, mDurationSeconds);
452 443
453 SetLayoutTitle(); 444 SetLayoutTitle();
454 SetLayoutImage(); 445 SetLayoutImage();
examples/motion/motion-blur-example.cpp
@@ -147,7 +147,7 @@ public: @@ -147,7 +147,7 @@ public:
147 mToolBar, 147 mToolBar,
148 BACKGROUND_IMAGE_PATH, 148 BACKGROUND_IMAGE_PATH,
149 TOOLBAR_IMAGE, 149 TOOLBAR_IMAGE,
150 - APPLICATION_TITLE); 150 + APPLICATION_TITLE );
151 151
152 //Add an effects icon on the right of the title 152 //Add an effects icon on the right of the title
153 mIconEffectsOff = Image::New( EFFECTS_OFF_ICON ); 153 mIconEffectsOff = Image::New( EFFECTS_OFF_ICON );
examples/motion/motion-stretch-example.cpp
@@ -134,7 +134,7 @@ public: @@ -134,7 +134,7 @@ public:
134 mToolBar, 134 mToolBar,
135 BACKGROUND_IMAGE_PATH, 135 BACKGROUND_IMAGE_PATH,
136 TOOLBAR_IMAGE, 136 TOOLBAR_IMAGE,
137 - APPLICATION_TITLE); 137 + APPLICATION_TITLE );
138 138
139 //Add an slideshow icon on the right of the title 139 //Add an slideshow icon on the right of the title
140 mIconEffectsOff = Image::New( EFFECTS_OFF_ICON ); 140 mIconEffectsOff = Image::New( EFFECTS_OFF_ICON );
examples/radial-menu/radial-menu-example.cpp
@@ -121,8 +121,10 @@ RadialMenuExample::~RadialMenuExample() @@ -121,8 +121,10 @@ RadialMenuExample::~RadialMenuExample()
121 121
122 void RadialMenuExample::OnInit(Application& app) 122 void RadialMenuExample::OnInit(Application& app)
123 { 123 {
  124 + Stage stage = Dali::Stage::GetCurrent();
  125 +
124 // The Init signal is received once (only) during the Application lifetime 126 // The Init signal is received once (only) during the Application lifetime
125 - Stage::GetCurrent().KeyEventSignal().Connect(this, &RadialMenuExample::OnKeyEvent); 127 + stage.KeyEventSignal().Connect(this, &RadialMenuExample::OnKeyEvent);
126 128
127 // Create toolbar & view 129 // Create toolbar & view
128 Toolkit::ToolBar toolBar; 130 Toolkit::ToolBar toolBar;
@@ -146,7 +148,14 @@ void RadialMenuExample::OnInit(Application&amp; app) @@ -146,7 +148,14 @@ void RadialMenuExample::OnInit(Application&amp; app)
146 DemoHelper::DEFAULT_PLAY_PADDING ); 148 DemoHelper::DEFAULT_PLAY_PADDING );
147 149
148 Vector2 imgSize = Image::GetImageSize(TEST_OUTER_RING_FILENAME); 150 Vector2 imgSize = Image::GetImageSize(TEST_OUTER_RING_FILENAME);
149 - float scale = Stage::GetCurrent().GetSize().width / imgSize.width; 151 + Vector2 stageSize = stage.GetSize();
  152 + float minStageDimension = std::min(stageSize.width, stageSize.height);
  153 +
  154 + if(stageSize.height <= stageSize.width)
  155 + {
  156 + minStageDimension -= DemoHelper::DEFAULT_VIEW_STYLE.mToolBarHeight * 2.0f;
  157 + }
  158 + float scale = minStageDimension / imgSize.width;
150 159
151 mRadialSweepView1 = CreateSweepView( TEST_OUTER_RING_FILENAME, Degree(-90.0f), Degree(-90.0f)); 160 mRadialSweepView1 = CreateSweepView( TEST_OUTER_RING_FILENAME, Degree(-90.0f), Degree(-90.0f));
152 mRadialSweepView2 = CreateSweepView( TEST_INNER_RING_FILENAME, Degree(90.0f), Degree(0.0f)); 161 mRadialSweepView2 = CreateSweepView( TEST_INNER_RING_FILENAME, Degree(90.0f), Degree(0.0f));
@@ -162,7 +171,7 @@ void RadialMenuExample::OnInit(Application&amp; app) @@ -162,7 +171,7 @@ void RadialMenuExample::OnInit(Application&amp; app)
162 171
163 dialLayer.Add(mDialActor); 172 dialLayer.Add(mDialActor);
164 dialLayer.SetPositionInheritanceMode(USE_PARENT_POSITION); 173 dialLayer.SetPositionInheritanceMode(USE_PARENT_POSITION);
165 - dialLayer.SetSize(Stage::GetCurrent().GetSize()); 174 + dialLayer.SetSize(stage.GetSize());
166 mContents.Add(dialLayer); 175 mContents.Add(dialLayer);
167 176
168 mRadialSweepView1.SetScale(scale); 177 mRadialSweepView1.SetScale(scale);
examples/scroll-view/scroll-view-example.cpp
@@ -121,7 +121,6 @@ const char * const GetNextImagePath() @@ -121,7 +121,6 @@ const char * const GetNextImagePath()
121 121
122 const int PAGE_COLUMNS = 10; ///< Number of Pages going across (columns) 122 const int PAGE_COLUMNS = 10; ///< Number of Pages going across (columns)
123 const int PAGE_ROWS = 1; ///< Number of Pages going down (rows) 123 const int PAGE_ROWS = 1; ///< Number of Pages going down (rows)
124 -const int IMAGE_COLUMNS = 3; ///< Number of Images going across (columns) within a Page  
125 const int IMAGE_ROWS = 5; ///< Number of Images going down (rows) with a Page 124 const int IMAGE_ROWS = 5; ///< Number of Images going down (rows) with a Page
126 125
127 // 3D Effect constants 126 // 3D Effect constants
@@ -184,14 +183,14 @@ public: @@ -184,14 +183,14 @@ public:
184 */ 183 */
185 void OnInit(Application& app) 184 void OnInit(Application& app)
186 { 185 {
187 - Stage::GetCurrent().KeyEventSignal().Connect(this, &ExampleController::OnKeyEvent); 186 + Stage stage = Dali::Stage::GetCurrent();
  187 + stage.KeyEventSignal().Connect(this, &ExampleController::OnKeyEvent);
188 188
189 // Hide the indicator bar 189 // Hide the indicator bar
190 mApplication.GetWindow().ShowIndicator(Dali::Window::INVISIBLE); 190 mApplication.GetWindow().ShowIndicator(Dali::Window::INVISIBLE);
191 191
192 // Creates a default view with a default tool bar. 192 // Creates a default view with a default tool bar.
193 // The view is added to the stage. 193 // The view is added to the stage.
194 -  
195 mContentLayer = DemoHelper::CreateView( app, 194 mContentLayer = DemoHelper::CreateView( app,
196 mView, 195 mView,
197 mToolBar, 196 mToolBar,
@@ -313,11 +312,13 @@ private: @@ -313,11 +312,13 @@ private:
313 312
314 const float margin = 10.0f; 313 const float margin = 10.0f;
315 314
316 - const Vector3 imageSize((stageSize.x / IMAGE_COLUMNS) - margin, (stageSize.y / IMAGE_ROWS) - margin, 0.0f); 315 + // Calculate the number of images going across (columns) within a page, according to the screen resolution and dpi.
  316 + int imageColumns = round(IMAGE_ROWS * (stageSize.x / stage.GetDpi().x) / (stageSize.y / stage.GetDpi().y));
  317 + const Vector3 imageSize((stageSize.x / imageColumns) - margin, (stageSize.y / IMAGE_ROWS) - margin, 0.0f);
317 318
318 for(int row = 0;row<IMAGE_ROWS;row++) 319 for(int row = 0;row<IMAGE_ROWS;row++)
319 { 320 {
320 - for(int column = 0;column<IMAGE_COLUMNS;column++) 321 + for(int column = 0;column<imageColumns;column++)
321 { 322 {
322 ImageActor image = CreateImage( GetNextImagePath() ); 323 ImageActor image = CreateImage( GetNextImagePath() );
323 324
examples/shadows/shadow-bone-lighting-example.cpp
@@ -265,7 +265,7 @@ public: @@ -265,7 +265,7 @@ public:
265 mCastingLight.SetPosition( Vector3( 0.0f, 0.0f, 800.0f ) * scaleFactor ); 265 mCastingLight.SetPosition( Vector3( 0.0f, 0.0f, 800.0f ) * scaleFactor );
266 266
267 TextStyle style; 267 TextStyle style;
268 - style.SetFontPointSize( PointSize(20.0f) ); 268 + style.SetFontPointSize( PointSize(DemoHelper::ScalePointSize(20.0f)) );
269 style.SetFontName("Times New Roman"); 269 style.SetFontName("Times New Roman");
270 style.SetFontStyle("Book"); 270 style.SetFontStyle("Book");
271 271
examples/shared/view.h
@@ -28,22 +28,20 @@ namespace DemoHelper @@ -28,22 +28,20 @@ namespace DemoHelper
28 */ 28 */
29 struct ViewStyle 29 struct ViewStyle
30 { 30 {
31 - ViewStyle( float toolBarButtonPercentage, float toolBarTitlePercentage, float dpi, float toolBarHeight, float toolBarPadding ) 31 + ViewStyle( float toolBarButtonPercentage, float toolBarTitlePercentage, float toolBarHeight, float toolBarPadding )
32 : mToolBarButtonPercentage( toolBarButtonPercentage ), 32 : mToolBarButtonPercentage( toolBarButtonPercentage ),
33 mToolBarTitlePercentage( toolBarTitlePercentage ), 33 mToolBarTitlePercentage( toolBarTitlePercentage ),
34 - mDpi( dpi ),  
35 mToolBarHeight( toolBarHeight ), 34 mToolBarHeight( toolBarHeight ),
36 mToolBarPadding( toolBarPadding ) 35 mToolBarPadding( toolBarPadding )
37 {} 36 {}
38 37
39 float mToolBarButtonPercentage; ///< The tool bar button width is a percentage of the tool bar width. 38 float mToolBarButtonPercentage; ///< The tool bar button width is a percentage of the tool bar width.
40 float mToolBarTitlePercentage; ///< The tool bar title width is a percentage of the tool bar width. 39 float mToolBarTitlePercentage; ///< The tool bar title width is a percentage of the tool bar width.
41 - float mDpi; ///< This style is indented for the given dpi.  
42 - float mToolBarHeight; ///< The tool bar height for the given dpi above.  
43 - float mToolBarPadding; ///< The tool bar padding between controls for the given dpi above. 40 + float mToolBarHeight; ///< The tool bar height (in pixels).
  41 + float mToolBarPadding; ///< The tool bar padding (in pixels)..
44 }; 42 };
45 43
46 -const ViewStyle DEFAULT_VIEW_STYLE( 0.1f, 0.7f, 315.f, 80.f, 4.f ); 44 +const ViewStyle DEFAULT_VIEW_STYLE( 0.1f, 0.7f, 80.f, 4.f );
47 45
48 const char* DEFAULT_TEXT_STYLE_FONT_FAMILY("HelveticaNue"); 46 const char* DEFAULT_TEXT_STYLE_FONT_FAMILY("HelveticaNue");
49 const char* DEFAULT_TEXT_STYLE_FONT_STYLE("Regular"); 47 const char* DEFAULT_TEXT_STYLE_FONT_STYLE("Regular");
@@ -57,13 +55,20 @@ const Dali::Toolkit::Alignment::Padding DEFAULT_MODE_SWITCH_PADDING(8.0f, 8.0f, @@ -57,13 +55,20 @@ const Dali::Toolkit::Alignment::Padding DEFAULT_MODE_SWITCH_PADDING(8.0f, 8.0f,
57 static Dali::TextStyle defaultTextStyle; 55 static Dali::TextStyle defaultTextStyle;
58 static bool textStyleSet=false; 56 static bool textStyleSet=false;
59 57
  58 +float ScalePointSize(int pointSize)
  59 +{
  60 + Dali::Vector2 dpi = Dali::Stage::GetCurrent().GetDpi();
  61 + float meanDpi = (dpi.height + dpi.width) * 0.5f;
  62 + return (pointSize * 220.0f) / meanDpi;
  63 +}
  64 +
60 Dali::TextStyle& GetDefaultTextStyle() 65 Dali::TextStyle& GetDefaultTextStyle()
61 { 66 {
62 if(!textStyleSet) 67 if(!textStyleSet)
63 { 68 {
64 defaultTextStyle.SetFontName(DEFAULT_TEXT_STYLE_FONT_FAMILY); 69 defaultTextStyle.SetFontName(DEFAULT_TEXT_STYLE_FONT_FAMILY);
65 defaultTextStyle.SetFontStyle(DEFAULT_TEXT_STYLE_FONT_STYLE); 70 defaultTextStyle.SetFontStyle(DEFAULT_TEXT_STYLE_FONT_STYLE);
66 - defaultTextStyle.SetFontPointSize(DEFAULT_TEXT_STYLE_POINT_SIZE); 71 + defaultTextStyle.SetFontPointSize(Dali::PointSize(ScalePointSize(DEFAULT_TEXT_STYLE_POINT_SIZE)));
67 defaultTextStyle.SetWeight(DEFAULT_TEXT_STYLE_WEIGHT); 72 defaultTextStyle.SetWeight(DEFAULT_TEXT_STYLE_WEIGHT);
68 defaultTextStyle.SetTextColor(DEFAULT_TEXT_STYLE_COLOR); 73 defaultTextStyle.SetTextColor(DEFAULT_TEXT_STYLE_COLOR);
69 textStyleSet = true; 74 textStyleSet = true;
@@ -72,48 +77,17 @@ Dali::TextStyle&amp; GetDefaultTextStyle() @@ -72,48 +77,17 @@ Dali::TextStyle&amp; GetDefaultTextStyle()
72 return defaultTextStyle; 77 return defaultTextStyle;
73 } 78 }
74 79
75 -Dali::Layer CreateView( Dali::Application& application,  
76 - Dali::Toolkit::View& view,  
77 - Dali::Toolkit::ToolBar& toolBar,  
78 - const std::string& backgroundImagePath,  
79 - const std::string& toolbarImagePath,  
80 - const std::string& title,  
81 - const ViewStyle& style,  
82 - const Dali::TextStyle& textStyle ) 80 +Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar,
  81 + const std::string& toolbarImagePath,
  82 + const std::string& title,
  83 + const ViewStyle& style,
  84 + const Dali::TextStyle& textStyle )
83 { 85 {
84 - Dali::Stage stage = Dali::Stage::GetCurrent();  
85 -  
86 - // Create default View.  
87 - view = Dali::Toolkit::View::New();  
88 -  
89 - // Add the view to the stage before setting the background.  
90 - stage.Add( view );  
91 -  
92 - // Set background image.  
93 - if ( ! backgroundImagePath.empty() )  
94 - {  
95 - Dali::Image backgroundImage = Dali::Image::New( backgroundImagePath );  
96 - Dali::ImageActor backgroundImageActor = Dali::ImageActor::New( backgroundImage );  
97 - view.SetBackground( backgroundImageActor );  
98 - }  
99 -  
100 - // FIXME  
101 - // Connects the orientation signal with the View::OrientationChanged method.  
102 - //application.GetOrientation().ChangedSignal().Connect( &view, &Dali::Toolkit::View::OrientationChanged );  
103 -  
104 - // Create default ToolBar  
105 -  
106 - Dali::Vector2 dpi = stage.GetDpi();  
107 -  
108 - // Create toolbar layer.  
109 Dali::Layer toolBarLayer = Dali::Layer::New(); 86 Dali::Layer toolBarLayer = Dali::Layer::New();
110 toolBarLayer.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER ); 87 toolBarLayer.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER );
111 toolBarLayer.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER ); 88 toolBarLayer.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER );
112 - toolBarLayer.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ), Dali::SourceWidthFixedHeight( style.mToolBarHeight * dpi.y / style.mDpi ) ) );  
113 - toolBarLayer.SetSize( 0.0f, style.mToolBarHeight * dpi.y / style.mDpi );  
114 -  
115 - // Add tool bar layer to the view.  
116 - view.AddContentLayer( toolBarLayer ); 89 + toolBarLayer.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ), Dali::SourceWidthFixedHeight( style.mToolBarHeight ) ) );
  90 + toolBarLayer.SetSize( 0.0f, style.mToolBarHeight );
117 91
118 // Raise tool bar layer to the top. 92 // Raise tool bar layer to the top.
119 toolBarLayer.RaiseToTop(); 93 toolBarLayer.RaiseToTop();
@@ -126,7 +100,7 @@ Dali::Layer CreateView( Dali::Application&amp; application, @@ -126,7 +100,7 @@ Dali::Layer CreateView( Dali::Application&amp; application,
126 toolBar.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER ); 100 toolBar.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER );
127 toolBar.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER ); 101 toolBar.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER );
128 toolBar.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ), Dali::EqualToConstraint() ) ); 102 toolBar.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ), Dali::EqualToConstraint() ) );
129 - toolBar.SetSize( 0.0f, style.mToolBarHeight * dpi.y / style.mDpi ); 103 + toolBar.SetSize( 0.0f, style.mToolBarHeight );
130 toolBarBackground.SetSortModifier(1.0f); 104 toolBarBackground.SetSortModifier(1.0f);
131 105
132 // Add the tool bar to the too bar layer. 106 // Add the tool bar to the too bar layer.
@@ -144,10 +118,50 @@ Dali::Layer CreateView( Dali::Application&amp; application, @@ -144,10 +118,50 @@ Dali::Layer CreateView( Dali::Application&amp; application,
144 titleActor.SetStyleToCurrentText(textStyle); 118 titleActor.SetStyleToCurrentText(textStyle);
145 119
146 // Add title to the tool bar. 120 // Add title to the tool bar.
147 - const float padding( style.mToolBarPadding * dpi.x / style.mDpi ); 121 + const float padding( style.mToolBarPadding );
148 toolBar.AddControl( titleActor, style.mToolBarTitlePercentage, Dali::Toolkit::Alignment::HorizontalCenter, Dali::Toolkit::Alignment::Padding( padding, padding, padding, padding ) ); 122 toolBar.AddControl( titleActor, style.mToolBarTitlePercentage, Dali::Toolkit::Alignment::HorizontalCenter, Dali::Toolkit::Alignment::Padding( padding, padding, padding, padding ) );
149 } 123 }
150 124
  125 + return toolBarLayer;
  126 +}
  127 +
  128 +Dali::Layer CreateView( Dali::Application& application,
  129 + Dali::Toolkit::View& view,
  130 + Dali::Toolkit::ToolBar& toolBar,
  131 + const std::string& backgroundImagePath,
  132 + const std::string& toolbarImagePath,
  133 + const std::string& title,
  134 + const ViewStyle& style,
  135 + const Dali::TextStyle& textStyle )
  136 +{
  137 + Dali::Stage stage = Dali::Stage::GetCurrent();
  138 +
  139 + // Create default View.
  140 + view = Dali::Toolkit::View::New();
  141 +
  142 + // Add the view to the stage before setting the background.
  143 + stage.Add( view );
  144 +
  145 + // Set background image.
  146 + if ( ! backgroundImagePath.empty() )
  147 + {
  148 + Dali::Image backgroundImage = Dali::Image::New( backgroundImagePath );
  149 + Dali::ImageActor backgroundImageActor = Dali::ImageActor::New( backgroundImage );
  150 + view.SetBackground( backgroundImageActor );
  151 + }
  152 +
  153 + // FIXME
  154 + // Connects the orientation signal with the View::OrientationChanged method.
  155 + //application.GetOrientation().ChangedSignal().Connect( &view, &Dali::Toolkit::View::OrientationChanged );
  156 +
  157 + // Create default ToolBar
  158 + Dali::Layer toolBarLayer = CreateToolbar( toolBar, toolbarImagePath, title, style, textStyle );
  159 +
  160 + // Add tool bar layer to the view.
  161 + view.AddContentLayer( toolBarLayer );
  162 +
  163 +
  164 +
151 // Create a content layer. 165 // Create a content layer.
152 Dali::Layer contentLayer = Dali::Layer::New(); 166 Dali::Layer contentLayer = Dali::Layer::New();
153 contentLayer.SetAnchorPoint( Dali::AnchorPoint::CENTER ); 167 contentLayer.SetAnchorPoint( Dali::AnchorPoint::CENTER );