Commit ae5f99de4bdabb973099ecce312c0eef127284e5
Committed by
Gerrit Code Review
Merge "Fix the scalability issue on dali-demo" into tizen
Showing
11 changed files
with
122 additions
and
170 deletions
demo/dali-table-view.cpp
| ... | ... | @@ -17,6 +17,7 @@ |
| 17 | 17 | |
| 18 | 18 | // CLASS HEADER |
| 19 | 19 | #include "dali-table-view.h" |
| 20 | +#include "examples/shared/view.h" | |
| 20 | 21 | |
| 21 | 22 | // EXTERNAL INCLUDES |
| 22 | 23 | #include <algorithm> |
| ... | ... | @@ -90,12 +91,13 @@ const Dali::PointSize TABLE_TEXT_STYLE_POINT_SIZE( 8.0f ); |
| 90 | 91 | const Dali::TextStyle::Weight TABLE_TEXT_STYLE_WEIGHT(Dali::TextStyle::LIGHT); |
| 91 | 92 | const Dali::Vector4 TABLE_TEXT_STYLE_COLOR(0.0f, 0.0f, 0.0f, 1.0f); |
| 92 | 93 | |
| 94 | + | |
| 93 | 95 | TextStyle GetDefaultTextStyle() |
| 94 | 96 | { |
| 95 | 97 | TextStyle textStyle; |
| 96 | 98 | textStyle.SetFontName(DEFAULT_TEXT_STYLE_FONT_FAMILY); |
| 97 | 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 | 101 | textStyle.SetWeight(DEFAULT_TEXT_STYLE_WEIGHT); |
| 100 | 102 | textStyle.SetTextColor(DEFAULT_TEXT_STYLE_COLOR); |
| 101 | 103 | textStyle.SetShadow( true ); |
| ... | ... | @@ -107,7 +109,7 @@ TextStyle GetTableTextStyle() |
| 107 | 109 | TextStyle textStyle; |
| 108 | 110 | textStyle.SetFontName(TABLE_TEXT_STYLE_FONT_FAMILY); |
| 109 | 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 | 113 | textStyle.SetWeight(TABLE_TEXT_STYLE_WEIGHT); |
| 112 | 114 | textStyle.SetTextColor(TABLE_TEXT_STYLE_COLOR); |
| 113 | 115 | return textStyle; |
| ... | ... | @@ -285,7 +287,15 @@ void DaliTableView::Initialize( Application& application ) |
| 285 | 287 | Stage::GetCurrent().Add( mRootActor ); |
| 286 | 288 | |
| 287 | 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 | 300 | // Add logo |
| 291 | 301 | mLogo = CreateLogo( LOGO_PATH ); |
| ... | ... | @@ -364,61 +374,6 @@ void DaliTableView::Initialize( Application& application ) |
| 364 | 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 | 377 | void DaliTableView::Populate() |
| 423 | 378 | { |
| 424 | 379 | const Vector2 stageSize = Stage::GetCurrent().GetSize(); |
| ... | ... | @@ -898,7 +853,6 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BitmapImage dis |
| 898 | 853 | Random::Range( -size.y * 0.5f - randSize, size.y * 0.5f + randSize ), |
| 899 | 854 | Random::Range(-1.0f, 0.0f) ); |
| 900 | 855 | dfActor.SetPosition( actorPos ); |
| 901 | - dfActor.SetSortModifier(size.x * 0.7f); | |
| 902 | 856 | |
| 903 | 857 | Constraint movementConstraint = Constraint::New < Vector3 > ( Actor::POSITION, |
| 904 | 858 | LocalSource( Actor::SIZE ), | ... | ... |
demo/dali-table-view.h
| ... | ... | @@ -72,27 +72,7 @@ struct Example |
| 72 | 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 | 78 | * Dali-Demo instance |
| ... | ... | @@ -276,11 +256,6 @@ private: // Application callbacks & implementation |
| 276 | 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 | 259 | * Key event handler |
| 285 | 260 | */ |
| 286 | 261 | void OnKeyEvent( const Dali::KeyEvent& event ); | ... | ... |
examples/builder/examples.cpp
| ... | ... | @@ -404,7 +404,14 @@ public: |
| 404 | 404 | { |
| 405 | 405 | TextView t = TextView::New(); |
| 406 | 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 | 415 | t.SetTextAlignment( Alignment::HorizontalLeft ); |
| 409 | 416 | return t; |
| 410 | 417 | } | ... | ... |
examples/cluster/cluster-example.cpp
| ... | ... | @@ -127,11 +127,8 @@ const float CLUSTER_RELATIVE_SIZE = 0.65f; ///< Cluster size re |
| 127 | 127 | const float CLUSTER_GROUP_DELAY_TOP = 0.25f; ///< Delay for top Clusters in seconds. |
| 128 | 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 | 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 | 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 | 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 | 134 | const float SHEAR_EFFECT_MAX_OVERSHOOT = 30.0f; ///< Max Overshoot for shear effect (in degrees). |
| ... | ... | @@ -557,7 +554,8 @@ public: |
| 557 | 554 | clusterActor.SetAnchorPoint(AnchorPoint::CENTER); |
| 558 | 555 | |
| 559 | 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 | 560 | DALI_ASSERT_ALWAYS(clusterType < CLUSTER_COUNT); |
| 563 | 561 | const char **paths = IMAGE_GROUPS[clusterType]; |
| ... | ... | @@ -650,8 +648,11 @@ public: |
| 650 | 648 | |
| 651 | 649 | int column = mClusterCount>>1; |
| 652 | 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 | 657 | Actor pageView = Actor::New(); |
| 657 | 658 | mScrollView.Add(pageView); | ... | ... |
examples/item-view/item-view-example.cpp
| ... | ... | @@ -246,9 +246,9 @@ public: |
| 246 | 246 | */ |
| 247 | 247 | void OnInit(Application& app) |
| 248 | 248 | { |
| 249 | - Stage::GetCurrent().KeyEventSignal().Connect(this, &ItemViewExample::OnKeyEvent); | |
| 250 | - | |
| 251 | 249 | Stage stage = Dali::Stage::GetCurrent(); |
| 250 | + stage.KeyEventSignal().Connect(this, &ItemViewExample::OnKeyEvent); | |
| 251 | + | |
| 252 | 252 | Vector2 stageSize = Stage::GetCurrent().GetSize(); |
| 253 | 253 | |
| 254 | 254 | // Create a border image shared by all the item actors |
| ... | ... | @@ -265,9 +265,6 @@ public: |
| 265 | 265 | |
| 266 | 266 | mView.OrientationAnimationStartedSignal().Connect( this, &ItemViewExample::OnOrientationChanged ); |
| 267 | 267 | |
| 268 | - // Set the title to the current layout | |
| 269 | - SetLayoutTitle(); | |
| 270 | - | |
| 271 | 268 | // Create an edit mode button. (left of toolbar) |
| 272 | 269 | Toolkit::PushButton editButton = Toolkit::PushButton::New(); |
| 273 | 270 | editButton.SetBackgroundImage( Image::New( EDIT_IMAGE ) ); |
| ... | ... | @@ -281,7 +278,6 @@ public: |
| 281 | 278 | mLayoutButton.ClickedSignal().Connect( this, &ItemViewExample::OnLayoutButtonClicked); |
| 282 | 279 | mLayoutButton.SetLeaveRequired( true ); |
| 283 | 280 | mToolBar.AddControl( mLayoutButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); |
| 284 | - SetLayoutImage(); | |
| 285 | 281 | |
| 286 | 282 | // Create a delete button (bottom right of screen) |
| 287 | 283 | mDeleteButton = Toolkit::PushButton::New(); |
| ... | ... | @@ -347,10 +343,13 @@ public: |
| 347 | 343 | mItemView.SetMinimumSwipeSpeed(MIN_SWIPE_SPEED); |
| 348 | 344 | |
| 349 | 345 | // Activate the spiral layout |
| 350 | - Vector3 size(stage.GetSize()); | |
| 351 | - mItemView.ActivateLayout(mCurrentLayout, size, 0.0f/*immediate*/); | |
| 346 | + UseLayout(mCurrentLayout, 0.0f); | |
| 352 | 347 | mItemView.SetKeyboardFocusable( true ); |
| 353 | 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 | 355 | Actor OnKeyboardPreFocusChange( Actor current, Actor proposed, Control::KeyboardFocusNavigationDirection direction ) |
| ... | ... | @@ -366,7 +365,7 @@ public: |
| 366 | 365 | /** |
| 367 | 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 | 370 | // Set the new orientation to the layout |
| 372 | 371 | mItemView.GetLayout(layoutId)->SetOrientation(static_cast<ControlOrientation::Type>(mOrientation / 90)); |
| ... | ... | @@ -375,15 +374,7 @@ public: |
| 375 | 374 | |
| 376 | 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 | 380 | if(layoutId == GRID_LAYOUT) |
| ... | ... | @@ -422,7 +413,7 @@ public: |
| 422 | 413 | mItemView.SetAnchoring(layoutId == DEPTH_LAYOUT); |
| 423 | 414 | |
| 424 | 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 | 430 | // Remember orientation |
| 440 | 431 | mOrientation = angle; |
| 441 | 432 | |
| 442 | - UseLayout(mCurrentLayout); | |
| 433 | + UseLayout(mCurrentLayout, mDurationSeconds); | |
| 443 | 434 | } |
| 444 | 435 | } |
| 445 | 436 | |
| ... | ... | @@ -448,7 +439,7 @@ public: |
| 448 | 439 | // Switch to the next layout |
| 449 | 440 | mCurrentLayout = (mCurrentLayout + 1) % mItemView.GetLayoutCount(); |
| 450 | 441 | |
| 451 | - UseLayout(mCurrentLayout); | |
| 442 | + UseLayout(mCurrentLayout, mDurationSeconds); | |
| 452 | 443 | |
| 453 | 444 | SetLayoutTitle(); |
| 454 | 445 | SetLayoutImage(); | ... | ... |
examples/motion/motion-blur-example.cpp
examples/motion/motion-stretch-example.cpp
examples/radial-menu/radial-menu-example.cpp
| ... | ... | @@ -121,8 +121,10 @@ RadialMenuExample::~RadialMenuExample() |
| 121 | 121 | |
| 122 | 122 | void RadialMenuExample::OnInit(Application& app) |
| 123 | 123 | { |
| 124 | + Stage stage = Dali::Stage::GetCurrent(); | |
| 125 | + | |
| 124 | 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 | 129 | // Create toolbar & view |
| 128 | 130 | Toolkit::ToolBar toolBar; |
| ... | ... | @@ -146,7 +148,14 @@ void RadialMenuExample::OnInit(Application& app) |
| 146 | 148 | DemoHelper::DEFAULT_PLAY_PADDING ); |
| 147 | 149 | |
| 148 | 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 | 160 | mRadialSweepView1 = CreateSweepView( TEST_OUTER_RING_FILENAME, Degree(-90.0f), Degree(-90.0f)); |
| 152 | 161 | mRadialSweepView2 = CreateSweepView( TEST_INNER_RING_FILENAME, Degree(90.0f), Degree(0.0f)); |
| ... | ... | @@ -162,7 +171,7 @@ void RadialMenuExample::OnInit(Application& app) |
| 162 | 171 | |
| 163 | 172 | dialLayer.Add(mDialActor); |
| 164 | 173 | dialLayer.SetPositionInheritanceMode(USE_PARENT_POSITION); |
| 165 | - dialLayer.SetSize(Stage::GetCurrent().GetSize()); | |
| 174 | + dialLayer.SetSize(stage.GetSize()); | |
| 166 | 175 | mContents.Add(dialLayer); |
| 167 | 176 | |
| 168 | 177 | mRadialSweepView1.SetScale(scale); | ... | ... |
examples/scroll-view/scroll-view-example.cpp
| ... | ... | @@ -121,7 +121,6 @@ const char * const GetNextImagePath() |
| 121 | 121 | |
| 122 | 122 | const int PAGE_COLUMNS = 10; ///< Number of Pages going across (columns) |
| 123 | 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 | 124 | const int IMAGE_ROWS = 5; ///< Number of Images going down (rows) with a Page |
| 126 | 125 | |
| 127 | 126 | // 3D Effect constants |
| ... | ... | @@ -184,14 +183,14 @@ public: |
| 184 | 183 | */ |
| 185 | 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 | 189 | // Hide the indicator bar |
| 190 | 190 | mApplication.GetWindow().ShowIndicator(Dali::Window::INVISIBLE); |
| 191 | 191 | |
| 192 | 192 | // Creates a default view with a default tool bar. |
| 193 | 193 | // The view is added to the stage. |
| 194 | - | |
| 195 | 194 | mContentLayer = DemoHelper::CreateView( app, |
| 196 | 195 | mView, |
| 197 | 196 | mToolBar, |
| ... | ... | @@ -313,11 +312,13 @@ private: |
| 313 | 312 | |
| 314 | 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 | 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 | 323 | ImageActor image = CreateImage( GetNextImagePath() ); |
| 323 | 324 | ... | ... |
examples/shadows/shadow-bone-lighting-example.cpp
| ... | ... | @@ -265,7 +265,7 @@ public: |
| 265 | 265 | mCastingLight.SetPosition( Vector3( 0.0f, 0.0f, 800.0f ) * scaleFactor ); |
| 266 | 266 | |
| 267 | 267 | TextStyle style; |
| 268 | - style.SetFontPointSize( PointSize(20.0f) ); | |
| 268 | + style.SetFontPointSize( PointSize(DemoHelper::ScalePointSize(20.0f)) ); | |
| 269 | 269 | style.SetFontName("Times New Roman"); |
| 270 | 270 | style.SetFontStyle("Book"); |
| 271 | 271 | ... | ... |
examples/shared/view.h
| ... | ... | @@ -28,22 +28,20 @@ namespace DemoHelper |
| 28 | 28 | */ |
| 29 | 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 | 32 | : mToolBarButtonPercentage( toolBarButtonPercentage ), |
| 33 | 33 | mToolBarTitlePercentage( toolBarTitlePercentage ), |
| 34 | - mDpi( dpi ), | |
| 35 | 34 | mToolBarHeight( toolBarHeight ), |
| 36 | 35 | mToolBarPadding( toolBarPadding ) |
| 37 | 36 | {} |
| 38 | 37 | |
| 39 | 38 | float mToolBarButtonPercentage; ///< The tool bar button width is a percentage of the tool bar width. |
| 40 | 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 | 46 | const char* DEFAULT_TEXT_STYLE_FONT_FAMILY("HelveticaNue"); |
| 49 | 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 | 55 | static Dali::TextStyle defaultTextStyle; |
| 58 | 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 | 65 | Dali::TextStyle& GetDefaultTextStyle() |
| 61 | 66 | { |
| 62 | 67 | if(!textStyleSet) |
| 63 | 68 | { |
| 64 | 69 | defaultTextStyle.SetFontName(DEFAULT_TEXT_STYLE_FONT_FAMILY); |
| 65 | 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 | 72 | defaultTextStyle.SetWeight(DEFAULT_TEXT_STYLE_WEIGHT); |
| 68 | 73 | defaultTextStyle.SetTextColor(DEFAULT_TEXT_STYLE_COLOR); |
| 69 | 74 | textStyleSet = true; |
| ... | ... | @@ -72,48 +77,17 @@ Dali::TextStyle& GetDefaultTextStyle() |
| 72 | 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 | 86 | Dali::Layer toolBarLayer = Dali::Layer::New(); |
| 110 | 87 | toolBarLayer.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER ); |
| 111 | 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 | 92 | // Raise tool bar layer to the top. |
| 119 | 93 | toolBarLayer.RaiseToTop(); |
| ... | ... | @@ -126,7 +100,7 @@ Dali::Layer CreateView( Dali::Application& application, |
| 126 | 100 | toolBar.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER ); |
| 127 | 101 | toolBar.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER ); |
| 128 | 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 | 104 | toolBarBackground.SetSortModifier(1.0f); |
| 131 | 105 | |
| 132 | 106 | // Add the tool bar to the too bar layer. |
| ... | ... | @@ -144,10 +118,50 @@ Dali::Layer CreateView( Dali::Application& application, |
| 144 | 118 | titleActor.SetStyleToCurrentText(textStyle); |
| 145 | 119 | |
| 146 | 120 | // Add title to the tool bar. |
| 147 | - const float padding( style.mToolBarPadding * dpi.x / style.mDpi ); | |
| 121 | + const float padding( style.mToolBarPadding ); | |
| 148 | 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 | 165 | // Create a content layer. |
| 152 | 166 | Dali::Layer contentLayer = Dali::Layer::New(); |
| 153 | 167 | contentLayer.SetAnchorPoint( Dali::AnchorPoint::CENTER ); | ... | ... |