Commit 9fbfb29c51bb28cd57b4b89fd5ac837ca10bafe8
Committed by
Kingsley Stephens
1 parent
f7497d52
Size negotiation example
Change-Id: Iffcdd6753c39fa83e7f68ef927339374bc0061a2
Showing
25 changed files
with
1696 additions
and
191 deletions
com.samsung.dali-demo.xml
| ... | ... | @@ -68,7 +68,7 @@ |
| 68 | 68 | <label>Image Scaling Modes</label> |
| 69 | 69 | </ui-application> |
| 70 | 70 | <ui-application appid="buttons.example" exec="/usr/apps/com.samsung.dali-demo/bin/buttons.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 71 | - <label>Radio Buttons</label> | |
| 71 | + <label>Buttons</label> | |
| 72 | 72 | </ui-application> |
| 73 | 73 | <ui-application appid="text-view.example" exec="/usr/apps/com.samsung.dali-demo/bin/text-view.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 74 | 74 | <label>Text View</label> |
| ... | ... | @@ -85,4 +85,7 @@ |
| 85 | 85 | <ui-application appid="atlas.example" exec="/usr/apps/com.samsung.dali-demo/bin/atlas.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 86 | 86 | <label>Atlas</label> |
| 87 | 87 | </ui-application> |
| 88 | + <ui-application appid="size-negotiation.example" exec="/usr/apps/com.samsung.dali-demo/bin/size-negotiation.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | |
| 89 | + <label>Size Negotiation</label> | |
| 90 | + </ui-application> | |
| 88 | 91 | </manifest> | ... | ... |
demo/dali-demo.cpp
| ... | ... | @@ -39,11 +39,15 @@ int main(int argc, char **argv) |
| 39 | 39 | demo.AddExample(Example("refraction-effect.example", "Refraction")); |
| 40 | 40 | demo.AddExample(Example("scroll-view.example", "Scroll View")); |
| 41 | 41 | demo.AddExample(Example("shadow-bone-lighting.example", "Lights and shadows")); |
| 42 | - demo.AddExample(Example("builder.example", "Script Based UI")); | |
| 42 | +// demo.AddExample(Example("builder.example", "Script Based UI")); | |
| 43 | 43 | demo.AddExample(Example("image-scaling-irregular-grid.example", "Image Scaling Modes")); |
| 44 | 44 | demo.AddExample(Example("text-view.example", "Text View")); |
| 45 | 45 | demo.AddExample(Example("animated-shapes.example", "Animated Shapes")); |
| 46 | 46 | demo.AddExample(Example("path-animation.example", "Path Animation")); |
| 47 | + demo.AddExample(Example("size-negotiation.example", "Size Negotiation")); | |
| 48 | + | |
| 49 | + demo.SortAlphabetically( true ); | |
| 50 | + | |
| 47 | 51 | app.MainLoop(); |
| 48 | 52 | |
| 49 | 53 | return 0; | ... | ... |
demo/dali-table-view.cpp
| ... | ... | @@ -55,10 +55,10 @@ const int MAX_PAGES = 256; ///< Maximum pag |
| 55 | 55 | const int EXAMPLES_PER_ROW = 3; |
| 56 | 56 | const int ROWS_PER_PAGE = 3; |
| 57 | 57 | const int EXAMPLES_PER_PAGE = EXAMPLES_PER_ROW * ROWS_PER_PAGE; |
| 58 | -const float LOGO_MARGIN_RATIO = 0.5f / 0.9f; | |
| 58 | +const float LOGO_MARGIN_RATIO = 0.1f / 0.3f; | |
| 59 | 59 | const float BOTTOM_PADDING_RATIO = 0.4f / 0.9f; |
| 60 | 60 | const Vector3 SCROLLVIEW_RELATIVE_SIZE(0.9f, 1.0f, 0.8f ); ///< ScrollView's relative size to its parent |
| 61 | -const Vector3 TABLE_RELATIVE_SIZE(0.9f, 0.9f, 0.8f ); ///< TableView's relative size to the entire stage. The Y value means sum of the logo and table relative heights. | |
| 61 | +const Vector3 TABLE_RELATIVE_SIZE(0.95f, 0.9f, 0.8f ); ///< TableView's relative size to the entire stage. The Y value means sum of the logo and table relative heights. | |
| 62 | 62 | const float STENCIL_RELATIVE_SIZE = 1.0f; |
| 63 | 63 | |
| 64 | 64 | const float EFFECT_SNAP_DURATION = 0.66f; ///< Scroll Snap Duration for Effects |
| ... | ... | @@ -75,7 +75,6 @@ const float SCALE_SPEED_SIN = 0.1f; |
| 75 | 75 | const unsigned int BACKGROUND_ANIMATION_DURATION = 15000; // 15 secs |
| 76 | 76 | |
| 77 | 77 | const float BACKGROUND_Z = -1.0f; |
| 78 | -const float BACKGROUND_SIZE_SCALE = 1.0f; | |
| 79 | 78 | const Vector4 BACKGROUND_COLOR( 1.0f, 1.0f, 1.0f, 1.0f ); |
| 80 | 79 | |
| 81 | 80 | const float BUBBLE_MIN_Z = -1.0; |
| ... | ... | @@ -124,10 +123,11 @@ ImageActor CreateBackground( std::string imagePath ) |
| 124 | 123 | { |
| 125 | 124 | Image image = ResourceImage::New( imagePath ); |
| 126 | 125 | ImageActor background = ImageActor::New( image ); |
| 127 | - | |
| 126 | + background.SetName( "BACKGROUND" ); | |
| 128 | 127 | background.SetAnchorPoint( AnchorPoint::CENTER ); |
| 129 | 128 | background.SetParentOrigin( ParentOrigin::CENTER ); |
| 130 | 129 | background.SetZ( -1.0f ); |
| 130 | + background.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 131 | 131 | |
| 132 | 132 | return background; |
| 133 | 133 | } |
| ... | ... | @@ -139,7 +139,7 @@ const float IMAGE_BORDER_TOP = IMAGE_BORDER_LEFT; |
| 139 | 139 | const float IMAGE_BORDER_BOTTOM = IMAGE_BORDER_LEFT; |
| 140 | 140 | |
| 141 | 141 | /** |
| 142 | - * Constraint to return a position for a bubble based on the scroll value and vertical wrapping. | |
| 142 | + * Constraint to return a position for a bubble based on the scroll value and vertical wrapping | |
| 143 | 143 | */ |
| 144 | 144 | struct AnimateBubbleConstraint |
| 145 | 145 | { |
| ... | ... | @@ -154,15 +154,15 @@ public: |
| 154 | 154 | Vector3 operator()( const Vector3& current, const PropertyInput& scrollProperty, const PropertyInput& parentSize ) |
| 155 | 155 | { |
| 156 | 156 | Vector3 pos( current ); |
| 157 | + const float parentHeight = parentSize.GetVector3().height; | |
| 157 | 158 | |
| 158 | - // Wrap bubbles verically. | |
| 159 | - if( pos.y + mShapeSize * 0.5f < -parentSize.GetVector3().y * 0.5f ) | |
| 159 | + // Wrap bubbles vertically | |
| 160 | + if( pos.y + mShapeSize * 0.5f < -parentHeight * 0.5f ) | |
| 160 | 161 | { |
| 161 | - pos.y += parentSize.GetVector3().y + mShapeSize; | |
| 162 | + pos.y = parentHeight * 0.5f + mShapeSize * 0.5f; | |
| 162 | 163 | } |
| 163 | 164 | |
| 164 | - // Bubbles X position moves parallax to horizontal | |
| 165 | - // panning by a scale factor unique to each bubble. | |
| 165 | + // Bubbles X position moves parallax to horizontal panning by a scale factor unique to each bubble | |
| 166 | 166 | pos.x = mInitialX + ( scrollProperty.GetVector3().x * mScale ); |
| 167 | 167 | return pos; |
| 168 | 168 | } |
| ... | ... | @@ -186,7 +186,6 @@ DaliTableView::DaliTableView( Application& application ) |
| 186 | 186 | mRootActor(), |
| 187 | 187 | mRotateAnimation(), |
| 188 | 188 | mBackground(), |
| 189 | - mLogo(), | |
| 190 | 189 | mPressedAnimation(), |
| 191 | 190 | mScrollViewLayer(), |
| 192 | 191 | mScrollView(), |
| ... | ... | @@ -242,15 +241,14 @@ void DaliTableView::Initialize( Application& application ) |
| 242 | 241 | const Vector2 stageSize = Stage::GetCurrent().GetSize(); |
| 243 | 242 | |
| 244 | 243 | // Background |
| 245 | - mBackground = CreateBackground( mBackgroundImagePath ); | |
| 246 | - // set same size as parent actor | |
| 247 | - mBackground.SetSize( stageSize ); | |
| 248 | - Stage::GetCurrent().Add( mBackground ); | |
| 244 | + Actor background = CreateBackground( mBackgroundImagePath ); | |
| 245 | + Stage::GetCurrent().Add( background ); | |
| 249 | 246 | |
| 250 | 247 | // Render entire content as overlays, as is all on same 2D plane. |
| 251 | 248 | mRootActor = TableView::New( 4, 1 ); |
| 252 | 249 | mRootActor.SetAnchorPoint( AnchorPoint::CENTER ); |
| 253 | 250 | mRootActor.SetParentOrigin( ParentOrigin::CENTER ); |
| 251 | + mRootActor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 254 | 252 | Stage::GetCurrent().Add( mRootActor ); |
| 255 | 253 | |
| 256 | 254 | // Toolbar at top |
| ... | ... | @@ -262,37 +260,42 @@ void DaliTableView::Initialize( Application& application ) |
| 262 | 260 | DemoHelper::GetDefaultTextStyle()); |
| 263 | 261 | |
| 264 | 262 | mRootActor.AddChild( toolBarLayer, TableView::CellPosition( 0, 0 ) ); |
| 265 | - const float toolbarHeight = DemoHelper::DEFAULT_VIEW_STYLE.mToolBarHeight; | |
| 266 | - mRootActor.SetFixedHeight( 0, toolbarHeight ); | |
| 263 | + mRootActor.SetFitHeight( 0 ); | |
| 267 | 264 | |
| 268 | 265 | // Add logo |
| 269 | - mLogo = CreateLogo( LOGO_PATH ); | |
| 266 | + Dali::ImageActor logo = CreateLogo( LOGO_PATH ); | |
| 267 | + logo.SetName( "LOGO_IMAGE" ); | |
| 268 | + logo.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); | |
| 270 | 269 | const float paddingHeight = ( ( 1.f-TABLE_RELATIVE_SIZE.y ) * stageSize.y ); |
| 271 | 270 | const float logoMargin = paddingHeight * LOGO_MARGIN_RATIO; |
| 272 | - const float logoHeight = mLogo.GetImage().GetHeight() + logoMargin; | |
| 273 | - mRootActor.SetFixedHeight( 1, logoHeight ); | |
| 274 | 271 | |
| 275 | 272 | // Show version in a popup when log is tapped |
| 276 | 273 | mLogoTapDetector = TapGestureDetector::New(); |
| 277 | - mLogoTapDetector.Attach( mLogo ); | |
| 274 | + mLogoTapDetector.Attach( logo ); | |
| 278 | 275 | mLogoTapDetector.DetectedSignal().Connect( this, &DaliTableView::OnLogoTapped ); |
| 279 | 276 | |
| 280 | 277 | const float bottomMargin = paddingHeight * BOTTOM_PADDING_RATIO; |
| 281 | - mButtonsPageRelativeSize = Vector3( TABLE_RELATIVE_SIZE.x, 1.f - ( toolbarHeight + logoHeight + bottomMargin) / stageSize.height, TABLE_RELATIVE_SIZE.z ); | |
| 282 | - mRootActor.SetFixedHeight( 2, mButtonsPageRelativeSize.y * stageSize.height ); | |
| 283 | 278 | |
| 284 | 279 | Alignment alignment = Alignment::New(); |
| 285 | - alignment.Add(mLogo); | |
| 280 | + alignment.SetName( "LOGO_ALIGNMENT" ); | |
| 281 | + alignment.Add( logo ); | |
| 282 | + alignment.SetResizePolicy( FILL_TO_PARENT, WIDTH ); | |
| 283 | + alignment.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT ); | |
| 284 | + Actor alignmentActor = alignment; | |
| 285 | + alignmentActor.SetPadding( Padding( 0.0f, 0.0f, logoMargin, logoMargin )); | |
| 286 | 286 | mRootActor.AddChild( alignment, TableView::CellPosition( 1, 0 ) ); |
| 287 | + mRootActor.SetFitHeight( 1 ); | |
| 287 | 288 | |
| 288 | 289 | // scrollview occupying the majority of the screen |
| 289 | 290 | mScrollView = ScrollView::New(); |
| 291 | + mScrollView.SetRelayoutEnabled( true ); | |
| 290 | 292 | |
| 291 | 293 | mScrollView.SetAnchorPoint( AnchorPoint::CENTER ); |
| 292 | 294 | mScrollView.SetParentOrigin( ParentOrigin::CENTER ); |
| 293 | - // Note: Currently, changing mScrollView to use SizeMode RELATIVE_TO_PARENT | |
| 294 | - // will cause scroll ends to appear in the wrong position. | |
| 295 | - mScrollView.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::Property::SIZE, Dali::ParentSource( Dali::Actor::Property::SIZE ), Dali::RelativeToConstraint( SCROLLVIEW_RELATIVE_SIZE ) ) ); | |
| 295 | + mScrollView.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 296 | + const float buttonsPageMargin = ( 1.0f - TABLE_RELATIVE_SIZE.x ) * 0.5f * stageSize.width; | |
| 297 | + mScrollView.SetPadding( Padding( buttonsPageMargin, buttonsPageMargin, 0.0f, 0.0f ) ); | |
| 298 | + | |
| 296 | 299 | mScrollView.SetAxisAutoLock( true ); |
| 297 | 300 | mScrollView.ScrollCompletedSignal().Connect( this, &DaliTableView::OnScrollComplete ); |
| 298 | 301 | mScrollView.ScrollStartedSignal().Connect( this, &DaliTableView::OnScrollStart ); |
| ... | ... | @@ -302,12 +305,37 @@ void DaliTableView::Initialize( Application& application ) |
| 302 | 305 | mScrollViewLayer.SetAnchorPoint( AnchorPoint::CENTER ); |
| 303 | 306 | mScrollViewLayer.SetParentOrigin( ParentOrigin::CENTER ); |
| 304 | 307 | mScrollViewLayer.SetDrawMode( DrawMode::OVERLAY ); |
| 308 | + mScrollViewLayer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 309 | + | |
| 310 | + // Create solid background colour. | |
| 311 | + ImageActor backgroundColourActor = Dali::Toolkit::CreateSolidColorActor( BACKGROUND_COLOR ); | |
| 312 | + backgroundColourActor.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 313 | + backgroundColourActor.SetParentOrigin( ParentOrigin::CENTER ); | |
| 314 | + backgroundColourActor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 315 | + backgroundColourActor.SetSizeMode( SIZE_RELATIVE_TO_PARENT ); | |
| 316 | + backgroundColourActor.SetSizeModeFactor( Vector3( 1.0f, 1.5f, 1.0f ) ); | |
| 317 | + backgroundColourActor.SetZ( BACKGROUND_Z ); | |
| 318 | + mScrollViewLayer.Add( backgroundColourActor ); | |
| 305 | 319 | |
| 306 | 320 | // Populate background and bubbles - needs to be scrollViewLayer so scroll ends show |
| 307 | - SetupBackground( mScrollView, mScrollViewLayer, stageSize ); | |
| 321 | + Actor bubbleContainer = Actor::New(); | |
| 322 | + bubbleContainer.SetRelayoutEnabled( true ); | |
| 323 | + bubbleContainer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 324 | + bubbleContainer.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 325 | + bubbleContainer.SetParentOrigin( ParentOrigin::CENTER ); | |
| 326 | + mScrollViewLayer.Add( bubbleContainer ); | |
| 327 | + | |
| 328 | + SetupBackground( bubbleContainer ); | |
| 329 | + | |
| 330 | + Alignment buttonsAlignment = Alignment::New(); | |
| 331 | + buttonsAlignment.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 332 | + buttonsAlignment.Add( mScrollViewLayer ); | |
| 308 | 333 | |
| 309 | 334 | mScrollViewLayer.Add( mScrollView ); |
| 310 | - mRootActor.AddChild( mScrollViewLayer, TableView::CellPosition( 2, 0 ) ); | |
| 335 | + | |
| 336 | + mRootActor.AddChild( buttonsAlignment, TableView::CellPosition( 2, 0 ) ); | |
| 337 | + | |
| 338 | + mRootActor.SetFixedHeight( 3, bottomMargin ); | |
| 311 | 339 | |
| 312 | 340 | // Add scroll view effect and setup constraints on pages |
| 313 | 341 | ApplyScrollViewEffect(); |
| ... | ... | @@ -333,7 +361,7 @@ void DaliTableView::Initialize( Application& application ) |
| 333 | 361 | |
| 334 | 362 | winHandle.ShowIndicator( Dali::Window::INVISIBLE ); |
| 335 | 363 | |
| 336 | - // | |
| 364 | + // Background animation | |
| 337 | 365 | mAnimationTimer = Timer::New( BACKGROUND_ANIMATION_DURATION ); |
| 338 | 366 | mAnimationTimer.TickSignal().Connect( this, &DaliTableView::PauseBackgroundAnimation ); |
| 339 | 367 | mAnimationTimer.Start(); |
| ... | ... | @@ -349,12 +377,10 @@ void DaliTableView::ApplyCubeEffectToActors() |
| 349 | 377 | { |
| 350 | 378 | Actor page = *pageIter; |
| 351 | 379 | |
| 352 | - unsigned int numChildren = page.GetChildCount(); | |
| 353 | - Actor pageActor = page; | |
| 354 | - for( unsigned int i=0; i<numChildren; ++i) | |
| 380 | + for( unsigned int i = 0, numChildren = page.GetChildCount(); i < numChildren; ++i) | |
| 355 | 381 | { |
| 356 | 382 | // Remove old effect's manual constraints. |
| 357 | - Actor child = pageActor.GetChildAt(i); | |
| 383 | + Actor child = page.GetChildAt(i); | |
| 358 | 384 | if( child ) |
| 359 | 385 | { |
| 360 | 386 | ApplyCubeEffectToActor( child ); |
| ... | ... | @@ -362,6 +388,12 @@ void DaliTableView::ApplyCubeEffectToActors() |
| 362 | 388 | } |
| 363 | 389 | } |
| 364 | 390 | } |
| 391 | + | |
| 392 | +void DaliTableView::OnButtonsPageRelayout( const Dali::Actor& actor ) | |
| 393 | +{ | |
| 394 | + | |
| 395 | +} | |
| 396 | + | |
| 365 | 397 | void DaliTableView::Populate() |
| 366 | 398 | { |
| 367 | 399 | const Vector2 stageSize = Stage::GetCurrent().GetSize(); |
| ... | ... | @@ -382,20 +414,15 @@ void DaliTableView::Populate() |
| 382 | 414 | for( int t = 0; t < mTotalPages; t++ ) |
| 383 | 415 | { |
| 384 | 416 | // Create Table. (contains up to 9 Examples) |
| 385 | - Actor page = Actor::New(); | |
| 386 | - | |
| 387 | - // Add tableView to container. | |
| 388 | - mScrollView.Add( page ); | |
| 389 | - | |
| 417 | + TableView page = TableView::New( 3, 3 ); | |
| 390 | 418 | page.SetAnchorPoint( AnchorPoint::CENTER ); |
| 391 | 419 | page.SetParentOrigin( ParentOrigin::CENTER ); |
| 392 | - page.SetSizeMode( SIZE_EQUAL_TO_PARENT ); | |
| 393 | - | |
| 394 | - // add cells to table | |
| 395 | - const float margin = 4.0f; | |
| 420 | + page.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 421 | + mScrollView.Add( page ); | |
| 396 | 422 | |
| 397 | 423 | // Calculate the number of images going across (columns) within a page, according to the screen resolution and dpi. |
| 398 | - const Size tileSize((stageSize.x * mButtonsPageRelativeSize.x / EXAMPLES_PER_ROW) - margin, (stageSize.y * mButtonsPageRelativeSize.y / ROWS_PER_PAGE) - margin ); | |
| 424 | + const float margin = 2.0f; | |
| 425 | + const float tileParentMultiplier = 1.0f / EXAMPLES_PER_ROW; | |
| 399 | 426 | |
| 400 | 427 | for(int row = 0; row < ROWS_PER_PAGE; row++) |
| 401 | 428 | { |
| ... | ... | @@ -403,7 +430,7 @@ void DaliTableView::Populate() |
| 403 | 430 | { |
| 404 | 431 | const Example& example = ( *iter ); |
| 405 | 432 | |
| 406 | - Actor tile = CreateTile( example.name, example.title, tileSize, true ); | |
| 433 | + Actor tile = CreateTile( example.name, example.title, Vector3( tileParentMultiplier, tileParentMultiplier, 1.0f ), true ); | |
| 407 | 434 | FocusManager focusManager = FocusManager::Get(); |
| 408 | 435 | focusManager.SetFocusOrder( tile, ++exampleCount ); |
| 409 | 436 | focusManager.SetAccessibilityAttribute( tile, Dali::Toolkit::FocusManager::ACCESSIBILITY_LABEL, |
| ... | ... | @@ -412,12 +439,9 @@ void DaliTableView::Populate() |
| 412 | 439 | focusManager.SetAccessibilityAttribute( tile, Dali::Toolkit::FocusManager::ACCESSIBILITY_HINT, |
| 413 | 440 | "You can run this example" ); |
| 414 | 441 | |
| 415 | - Vector3 position( margin * 0.5f + (tileSize.x + margin) * column - stageSize.width * mButtonsPageRelativeSize.x * 0.5f, | |
| 416 | - margin * 0.5f + (tileSize.y + margin) * row - stageSize.height * mButtonsPageRelativeSize.y * 0.5f, | |
| 417 | - 0.0f); | |
| 418 | - tile.SetPosition( position + Vector3( tileSize.x, tileSize.y, 0.0f ) * 0.5f ); | |
| 419 | - tile.SetSize( tileSize ); | |
| 420 | - page.Add( tile ); | |
| 442 | + tile.SetPadding( Padding( margin, margin, margin, margin ) ); | |
| 443 | + | |
| 444 | + page.AddChild( tile, TableView::CellPosition( row, column ) ); | |
| 421 | 445 | |
| 422 | 446 | iter++; |
| 423 | 447 | |
| ... | ... | @@ -434,7 +458,7 @@ void DaliTableView::Populate() |
| 434 | 458 | } |
| 435 | 459 | |
| 436 | 460 | // Set tableview position |
| 437 | - Vector3 pagePos( stageSize.x * mButtonsPageRelativeSize.x * t, 0.0f, 0.0f ); | |
| 461 | + Vector3 pagePos( stageSize.width * TABLE_RELATIVE_SIZE.x * t, 0.0f, 0.0f ); | |
| 438 | 462 | page.SetPosition( pagePos ); |
| 439 | 463 | |
| 440 | 464 | mPages.push_back( page ); |
| ... | ... | @@ -447,9 +471,9 @@ void DaliTableView::Populate() |
| 447 | 471 | } |
| 448 | 472 | |
| 449 | 473 | // Update Ruler info. |
| 450 | - mScrollRulerX = new FixedRuler( stageSize.width * mButtonsPageRelativeSize.x ); | |
| 474 | + mScrollRulerX = new FixedRuler( stageSize.width * TABLE_RELATIVE_SIZE.x ); | |
| 451 | 475 | mScrollRulerY = new DefaultRuler(); |
| 452 | - mScrollRulerX->SetDomain( RulerDomain( 0.0f, mTotalPages * stageSize.width * mButtonsPageRelativeSize.x, true ) ); | |
| 476 | + mScrollRulerX->SetDomain( RulerDomain( 0.0f, mTotalPages * stageSize.width * TABLE_RELATIVE_SIZE.x, true ) ); | |
| 453 | 477 | mScrollRulerY->Disable(); |
| 454 | 478 | mScrollView.SetRulerX( mScrollRulerX ); |
| 455 | 479 | mScrollView.SetRulerY( mScrollRulerY ); |
| ... | ... | @@ -483,12 +507,16 @@ void DaliTableView::Rotate( unsigned int degrees ) |
| 483 | 507 | mRotateAnimation.Play(); |
| 484 | 508 | } |
| 485 | 509 | |
| 486 | -Actor DaliTableView::CreateTile( const std::string& name, const std::string& title, const Size& parentSize, bool addBackground ) | |
| 510 | +Actor DaliTableView::CreateTile( const std::string& name, const std::string& title, const Dali::Vector3& sizeMultiplier, bool addBackground ) | |
| 487 | 511 | { |
| 488 | - Actor tile = Actor::New(); | |
| 489 | - tile.SetName( name ); | |
| 490 | - tile.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 491 | - tile.SetParentOrigin( ParentOrigin::CENTER ); | |
| 512 | + Actor content = Actor::New(); | |
| 513 | + content.SetName( name ); | |
| 514 | + content.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 515 | + content.SetParentOrigin( ParentOrigin::CENTER ); | |
| 516 | + content.SetRelayoutEnabled( true ); | |
| 517 | + content.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 518 | + content.SetSizeMode( SIZE_RELATIVE_TO_PARENT ); | |
| 519 | + content.SetSizeModeFactor( sizeMultiplier ); | |
| 492 | 520 | |
| 493 | 521 | // create background image |
| 494 | 522 | if( addBackground ) |
| ... | ... | @@ -498,16 +526,17 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit |
| 498 | 526 | image.SetAnchorPoint( AnchorPoint::CENTER ); |
| 499 | 527 | image.SetParentOrigin( ParentOrigin::CENTER ); |
| 500 | 528 | // make the image 100% of tile |
| 501 | - image.SetSizeMode( SIZE_EQUAL_TO_PARENT ); | |
| 529 | + image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 530 | + | |
| 502 | 531 | // move image back to get text appear in front |
| 503 | 532 | image.SetZ( -1 ); |
| 504 | 533 | image.SetStyle( ImageActor::STYLE_NINE_PATCH ); |
| 505 | 534 | image.SetNinePatchBorder( Vector4( IMAGE_BORDER_LEFT, IMAGE_BORDER_TOP, IMAGE_BORDER_RIGHT, IMAGE_BORDER_BOTTOM ) ); |
| 506 | - tile.Add( image ); | |
| 535 | + content.Add( image ); | |
| 507 | 536 | |
| 508 | 537 | // Add stencil |
| 509 | 538 | ImageActor stencil = NewStencilImage(); |
| 510 | - stencil.SetSizeMode( SIZE_EQUAL_TO_PARENT ); | |
| 539 | + stencil.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 511 | 540 | image.Add( stencil ); |
| 512 | 541 | } |
| 513 | 542 | |
| ... | ... | @@ -518,22 +547,23 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit |
| 518 | 547 | text.SetMultilinePolicy( Toolkit::TextView::SplitByWord ); |
| 519 | 548 | text.SetLineJustification( Toolkit::TextView::Center ); |
| 520 | 549 | text.SetTextAlignment( Toolkit::Alignment::Type( Alignment::HorizontalCenter | Alignment::VerticalCenter ) ); |
| 521 | - text.SetColor( Color::WHITE ); | |
| 522 | 550 | text.SetZ( 1 ); |
| 523 | 551 | // make the text 90% of tile |
| 524 | - text.SetSize( 0.9f * parentSize.width, 0.9f * parentSize.height ); | |
| 552 | + text.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 553 | + text.SetSizeMode( SIZE_RELATIVE_TO_PARENT ); | |
| 554 | + text.SetSizeModeFactor( Vector3( 0.9f, 0.9f, 0.0f ) ); | |
| 525 | 555 | text.SetStyleToCurrentText( GetTableTextStyle() ); |
| 526 | 556 | text.SetSnapshotModeEnabled( false ); |
| 527 | - tile.Add( text ); | |
| 557 | + content.Add( text ); | |
| 528 | 558 | |
| 529 | 559 | // Set the tile to be keyboard focusable |
| 530 | - tile.SetKeyboardFocusable(true); | |
| 560 | + content.SetKeyboardFocusable(true); | |
| 531 | 561 | |
| 532 | 562 | // connect to the touch events |
| 533 | - tile.TouchedSignal().Connect( this, &DaliTableView::OnTilePressed ); | |
| 534 | - tile.HoveredSignal().Connect( this, &DaliTableView::OnTileHovered ); | |
| 563 | + content.TouchedSignal().Connect( this, &DaliTableView::OnTilePressed ); | |
| 564 | + content.HoveredSignal().Connect( this, &DaliTableView::OnTileHovered ); | |
| 535 | 565 | |
| 536 | - return tile; | |
| 566 | + return content; | |
| 537 | 567 | } |
| 538 | 568 | |
| 539 | 569 | ImageActor DaliTableView::NewStencilImage() |
| ... | ... | @@ -654,8 +684,6 @@ void DaliTableView::OnScrollComplete( const Dali::Vector3& position ) |
| 654 | 684 | // move focus to 1st item of new page |
| 655 | 685 | FocusManager focusManager = FocusManager::Get(); |
| 656 | 686 | focusManager.SetCurrentFocusActor(mPages[mScrollView.GetCurrentPage()].GetChildAt(0) ); |
| 657 | - | |
| 658 | - ApplyCubeEffectToActors(); | |
| 659 | 687 | } |
| 660 | 688 | |
| 661 | 689 | bool DaliTableView::OnScrollTouched( Actor actor, const TouchEvent& event ) |
| ... | ... | @@ -721,37 +749,65 @@ void DaliTableView::OnKeyEvent( const KeyEvent& event ) |
| 721 | 749 | } |
| 722 | 750 | } |
| 723 | 751 | |
| 724 | -void DaliTableView::SetupBackground( Actor bubbleContainer, Actor backgroundLayer, const Vector2& size ) | |
| 752 | +void DaliTableView::SetupBackground( Actor bubbleContainer ) | |
| 725 | 753 | { |
| 726 | 754 | // Create distance field shape. |
| 727 | 755 | BufferImage distanceField; |
| 728 | 756 | Size imageSize( 512, 512 ); |
| 729 | 757 | CreateShapeImage( CIRCLE, imageSize, distanceField ); |
| 730 | 758 | |
| 731 | - // Create solid background colour. | |
| 732 | - ImageActor backgroundColourActor = Dali::Toolkit::CreateSolidColorActor( BACKGROUND_COLOR ); | |
| 733 | - backgroundColourActor.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 734 | - backgroundColourActor.SetParentOrigin( ParentOrigin::CENTER ); | |
| 735 | - backgroundColourActor.SetSize( size * BACKGROUND_SIZE_SCALE ); | |
| 736 | - backgroundColourActor.SetZ( BACKGROUND_Z ); | |
| 737 | - backgroundColourActor.SetPositionInheritanceMode( DONT_INHERIT_POSITION ); | |
| 738 | - backgroundLayer.Add( backgroundColourActor ); | |
| 739 | - | |
| 740 | 759 | // Add bubbles to the bubbleContainer. |
| 741 | 760 | // Note: The bubbleContainer is parented externally to this function. |
| 742 | - AddBackgroundActors( bubbleContainer, NUM_BACKGROUND_IMAGES, distanceField, size ); | |
| 761 | + AddBackgroundActors( bubbleContainer, NUM_BACKGROUND_IMAGES, distanceField ); | |
| 762 | +} | |
| 763 | + | |
| 764 | +void DaliTableView::InitialiseBackgroundActors( Actor actor ) | |
| 765 | +{ | |
| 766 | + // Delete current animations | |
| 767 | + mBackgroundAnimations.clear(); | |
| 768 | + | |
| 769 | + // Create new animations | |
| 770 | + const Vector3 size = actor.GetTargetSize(); | |
| 771 | + | |
| 772 | + for( unsigned int i = 0, childCount = actor.GetChildCount(); i < childCount; ++i ) | |
| 773 | + { | |
| 774 | + Actor child = actor.GetChildAt( i ); | |
| 775 | + | |
| 776 | + const Vector3 childSize = child.GetTargetSize(); | |
| 777 | + | |
| 778 | + // Calculate a random position | |
| 779 | + Vector3 childPos( Random::Range( -size.x * 0.5f * BACKGROUND_SPREAD_SCALE, size.x * 0.5f * BACKGROUND_SPREAD_SCALE ), | |
| 780 | + Random::Range( -size.y * 0.5f - childSize.height, size.y * 0.5f + childSize.height ), | |
| 781 | + Random::Range( BUBBLE_MIN_Z, BUBBLE_MAX_Z ) ); | |
| 782 | + | |
| 783 | + child.SetPosition( childPos ); | |
| 784 | + | |
| 785 | + // Define bubble horizontal parallax and vertical wrapping | |
| 786 | + Constraint animConstraint = Constraint::New < Vector3 > ( Actor::Property::POSITION, | |
| 787 | + Source( mScrollView, mScrollView.GetPropertyIndex( ScrollView::SCROLL_POSITION_PROPERTY_NAME ) ), | |
| 788 | + Dali::ParentSource( Dali::Actor::Property::SIZE ), | |
| 789 | + AnimateBubbleConstraint( childPos, Random::Range( -0.85f, 0.25f ), childSize.height ) ); | |
| 790 | + child.ApplyConstraint( animConstraint ); | |
| 791 | + | |
| 792 | + // Kickoff animation | |
| 793 | + Animation animation = Animation::New( Random::Range( 40.0f, 80.0f ) ); | |
| 794 | + animation.MoveBy( child, Vector3( 0.0f, -1.0f, 0.0f ), AlphaFunctions::Linear ); | |
| 795 | + animation.SetLooping( true ); | |
| 796 | + animation.Play(); | |
| 797 | + mBackgroundAnimations.push_back( animation ); | |
| 798 | + } | |
| 743 | 799 | } |
| 744 | 800 | |
| 745 | -void DaliTableView::AddBackgroundActors( Actor layer, int count, BufferImage distanceField, const Dali::Vector2& size ) | |
| 801 | +void DaliTableView::AddBackgroundActors( Actor layer, int count, BufferImage distanceField ) | |
| 746 | 802 | { |
| 747 | 803 | for( int i = 0; i < count; ++i ) |
| 748 | 804 | { |
| 749 | 805 | float randSize = Random::Range( 10.0f, 400.0f ); |
| 750 | 806 | float hue = Random::Range( 0.3f, 1.0f ); |
| 751 | - Vector4 randColour( hue, hue*0.5, 0.0f, Random::Range( 0.3f, 0.6f )); | |
| 807 | + Vector4 randColour( hue, hue * 0.5, 0.0f, Random::Range( 0.3f, 0.6f )); | |
| 752 | 808 | |
| 753 | 809 | ImageActor dfActor = ImageActor::New( distanceField ); |
| 754 | - mBackgroundActors.push_back( dfActor ); | |
| 810 | + dfActor.SetRelayoutEnabled( false ); | |
| 755 | 811 | dfActor.SetSize( Vector2( randSize, randSize ) ); |
| 756 | 812 | dfActor.SetParentOrigin( ParentOrigin::CENTER ); |
| 757 | 813 | |
| ... | ... | @@ -761,33 +817,10 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BufferImage dis |
| 761 | 817 | effect.SetOutlineParams( Vector2( 0.55f, 0.00f ) ); |
| 762 | 818 | effect.SetSmoothingEdge( 0.5f ); |
| 763 | 819 | layer.Add( dfActor ); |
| 764 | - | |
| 765 | - // Setup animation | |
| 766 | - Vector3 actorPos( | |
| 767 | - Random::Range( -size.x * 0.5f * BACKGROUND_SPREAD_SCALE, size.x * 0.5f * BACKGROUND_SPREAD_SCALE ), | |
| 768 | - Random::Range( -size.y * 0.5f - randSize, size.y * 0.5f + randSize ), | |
| 769 | - Random::Range( BUBBLE_MIN_Z, BUBBLE_MAX_Z ) ); | |
| 770 | - dfActor.SetPosition( actorPos ); | |
| 771 | - | |
| 772 | - // Define bubble horizontal parallax and vertical wrapping | |
| 773 | - Constraint animConstraint = Constraint::New < Vector3 > ( Actor::Property::POSITION, | |
| 774 | - Source( mScrollView, mScrollView.GetPropertyIndex( ScrollView::SCROLL_POSITION_PROPERTY_NAME ) ), | |
| 775 | - Dali::ParentSource( Dali::Actor::Property::SIZE ), | |
| 776 | - AnimateBubbleConstraint( actorPos, Random::Range( -0.85f, 0.25f ), randSize ) ); | |
| 777 | - dfActor.ApplyConstraint( animConstraint ); | |
| 778 | - | |
| 779 | - // Kickoff animation | |
| 780 | - Animation animation = Animation::New( Random::Range( 40.0f, 200.0f ) ); | |
| 781 | - KeyFrames keyframes = KeyFrames::New(); | |
| 782 | - keyframes.Add( 0.0f, actorPos ); | |
| 783 | - Vector3 toPos( actorPos ); | |
| 784 | - toPos.y -= ( size.y + randSize ); | |
| 785 | - keyframes.Add( 1.0f, toPos ); | |
| 786 | - animation.AnimateBetween( Property( dfActor, Actor::Property::POSITION ), keyframes ); | |
| 787 | - animation.SetLooping( true ); | |
| 788 | - animation.Play(); | |
| 789 | - mBackgroundAnimations.push_back( animation ); | |
| 790 | 820 | } |
| 821 | + | |
| 822 | + // Positioning will occur when the layer is relaid out | |
| 823 | + layer.OnRelayoutSignal().Connect( this, &DaliTableView::InitialiseBackgroundActors ); | |
| 791 | 824 | } |
| 792 | 825 | |
| 793 | 826 | void DaliTableView::CreateShapeImage( ShapeType shapeType, const Size& size, BufferImage& distanceFieldOut ) |
| ... | ... | @@ -860,7 +893,7 @@ ImageActor DaliTableView::CreateLogo( std::string imagePath ) |
| 860 | 893 | ImageActor logo = ImageActor::New( image ); |
| 861 | 894 | |
| 862 | 895 | logo.SetAnchorPoint( AnchorPoint::CENTER ); |
| 863 | - logo.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); | |
| 896 | + logo.SetParentOrigin( ParentOrigin::CENTER ); | |
| 864 | 897 | |
| 865 | 898 | return logo; |
| 866 | 899 | } |
| ... | ... | @@ -994,14 +1027,18 @@ void DaliTableView::OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap |
| 994 | 1027 | stream << "DALi Toolkit: " << TOOLKIT_MAJOR_VERSION << "." << TOOLKIT_MINOR_VERSION << "." << TOOLKIT_MICRO_VERSION << std::endl << "(" << TOOLKIT_BUILD_DATE << ")"; |
| 995 | 1028 | |
| 996 | 1029 | mVersionPopup = Dali::Toolkit::Popup::New(); |
| 997 | - mVersionPopup.SetTitle( stream.str() ); | |
| 998 | 1030 | mVersionPopup.SetParentOrigin( ParentOrigin::CENTER ); |
| 999 | 1031 | mVersionPopup.SetAnchorPoint( AnchorPoint::CENTER ); |
| 1032 | + mVersionPopup.SetResizePolicy( FILL_TO_PARENT, WIDTH ); | |
| 1033 | + mVersionPopup.SetSizeMode( SIZE_RELATIVE_TO_PARENT ); | |
| 1034 | + mVersionPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) ); | |
| 1035 | + mVersionPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT ); | |
| 1036 | + mVersionPopup.SetTitle( stream.str() ); | |
| 1000 | 1037 | mVersionPopup.HideTail(); |
| 1001 | 1038 | mVersionPopup.OutsideTouchedSignal().Connect( this, &DaliTableView::HideVersionPopup ); |
| 1002 | 1039 | mVersionPopup.HiddenSignal().Connect( this, &DaliTableView::PopupHidden ); |
| 1003 | 1040 | |
| 1004 | - Dali::Stage::GetCurrent().Add( mVersionPopup ); | |
| 1041 | + mVersionPopup.MarkDirtyForRelayout(); | |
| 1005 | 1042 | } |
| 1006 | 1043 | |
| 1007 | 1044 | mVersionPopup.Show(); | ... | ... |
demo/dali-table-view.h
| ... | ... | @@ -165,7 +165,7 @@ private: // Application callbacks & implementation |
| 165 | 165 | * |
| 166 | 166 | * @return The Actor for the created tile. |
| 167 | 167 | */ |
| 168 | - Dali::Actor CreateTile( const std::string& name, const std::string& title, const Dali::Size& parentSize, bool addBackground ); | |
| 168 | + Dali::Actor CreateTile( const std::string& name, const std::string& title, const Dali::Vector3& sizeMultiplier, bool addBackground ); | |
| 169 | 169 | |
| 170 | 170 | /** |
| 171 | 171 | * Create a stencil image |
| ... | ... | @@ -276,9 +276,8 @@ private: // Application callbacks & implementation |
| 276 | 276 | * Create a depth field background |
| 277 | 277 | * |
| 278 | 278 | * @param[in] bubbleLayer Add the graphics to this layer |
| 279 | - * @param[in] backgroundLayer Add the background to this layer | |
| 280 | 279 | */ |
| 281 | - void SetupBackground( Dali::Actor bubbleLayer, Dali::Actor backgroundLayer, const Dali::Vector2& size ); | |
| 280 | + void SetupBackground( Dali::Actor bubbleLayer ); | |
| 282 | 281 | |
| 283 | 282 | /** |
| 284 | 283 | * Create background actors for the given layer |
| ... | ... | @@ -286,9 +285,8 @@ private: // Application callbacks & implementation |
| 286 | 285 | * @param[in] layer The layer to add the actors to |
| 287 | 286 | * @param[in] count The number of actors to generate |
| 288 | 287 | * @param[in] distanceField The distance field bitmap to use |
| 289 | - * @param[in] size The size of the actor | |
| 290 | 288 | */ |
| 291 | - void AddBackgroundActors( Dali::Actor layer, int count, Dali::BufferImage distanceField, const Dali::Vector2& size ); | |
| 289 | + void AddBackgroundActors( Dali::Actor layer, int count, Dali::BufferImage distanceField ); | |
| 292 | 290 | |
| 293 | 291 | /** |
| 294 | 292 | * Create a bitmap with the specified shape and also output a distance field |
| ... | ... | @@ -378,6 +376,20 @@ private: // Application callbacks & implementation |
| 378 | 376 | */ |
| 379 | 377 | void PopupHidden(); |
| 380 | 378 | |
| 379 | + /* | |
| 380 | + * @brief Callback called when the buttons page actor is relaid out | |
| 381 | + * | |
| 382 | + * @param[in] actor The page actor | |
| 383 | + */ | |
| 384 | + void OnButtonsPageRelayout( const Dali::Actor& actor ); | |
| 385 | + | |
| 386 | + /** | |
| 387 | + * @brief Callback called to set up background actors | |
| 388 | + * | |
| 389 | + * @param[in] actor The actor raising the callback | |
| 390 | + */ | |
| 391 | + void InitialiseBackgroundActors( Dali::Actor actor ); | |
| 392 | + | |
| 381 | 393 | private: |
| 382 | 394 | |
| 383 | 395 | Dali::Application& mApplication; ///< Application instance. |
| ... | ... | @@ -385,7 +397,6 @@ private: |
| 385 | 397 | Dali::Toolkit::TableView mRootActor; ///< All content (excluding background is anchored to this Actor) |
| 386 | 398 | Dali::Animation mRotateAnimation; ///< Animation to rotate and resize mRootActor. |
| 387 | 399 | Dali::ImageActor mBackground; ///< Background's static image. |
| 388 | - Dali::ImageActor mLogo; ///< Logo's static image. | |
| 389 | 400 | Dali::Animation mPressedAnimation; ///< Button press scaling animation. |
| 390 | 401 | Dali::Layer mScrollViewLayer; ///< ScrollView resides on a separate layer. |
| 391 | 402 | Dali::Toolkit::ScrollView mScrollView; ///< ScrollView container (for all Examples) |
| ... | ... | @@ -413,6 +424,7 @@ private: |
| 413 | 424 | bool mSortAlphabetically:1; ///< Sort examples alphabetically. |
| 414 | 425 | bool mBackgroundAnimsPlaying:1; ///< Are background animations playing |
| 415 | 426 | bool mVersionPopupShown:1; ///< Whehter the version popup is shown or not |
| 427 | + | |
| 416 | 428 | }; |
| 417 | 429 | |
| 418 | 430 | #endif // __DALI_DEMO_H__ | ... | ... |
examples/animated-shapes/animated-shapes-example.cpp
examples/blocks/blocks-example.cpp
| ... | ... | @@ -421,7 +421,8 @@ private: |
| 421 | 421 | mLevelContainer = Actor::New(); |
| 422 | 422 | mLevelContainer.SetAnchorPoint( AnchorPoint::CENTER ); |
| 423 | 423 | mLevelContainer.SetParentOrigin( ParentOrigin::CENTER ); |
| 424 | - mLevelContainer.SetSizeMode( SIZE_EQUAL_TO_PARENT ); | |
| 424 | + mLevelContainer.SetRelayoutEnabled( true ); | |
| 425 | + mLevelContainer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 425 | 426 | mContentLayer.Add( mLevelContainer ); |
| 426 | 427 | |
| 427 | 428 | mBrickCount = 0; |
| ... | ... | @@ -593,6 +594,7 @@ private: |
| 593 | 594 | ImageActor brick = ImageActor::New(img); |
| 594 | 595 | brick.SetParentOrigin(ParentOrigin::TOP_LEFT); |
| 595 | 596 | brick.SetAnchorPoint(AnchorPoint::CENTER); |
| 597 | + brick.SetRelayoutEnabled( false ); | |
| 596 | 598 | brick.SetSize( brickSize ); |
| 597 | 599 | brick.SetPosition( Vector3( position ) ); |
| 598 | 600 | |
| ... | ... | @@ -625,6 +627,7 @@ private: |
| 625 | 627 | ImageActor actor = ImageActor::New(img); |
| 626 | 628 | actor.SetParentOrigin(ParentOrigin::TOP_LEFT); |
| 627 | 629 | actor.SetAnchorPoint(AnchorPoint::CENTER); |
| 630 | + actor.SetRelayoutEnabled( false ); | |
| 628 | 631 | return actor; |
| 629 | 632 | } |
| 630 | 633 | ... | ... |
examples/builder/examples.cpp
| ... | ... | @@ -290,6 +290,7 @@ public: |
| 290 | 290 | mFiles.clear(); |
| 291 | 291 | |
| 292 | 292 | mItemView = ItemView::New(*this); |
| 293 | + mItemView.SetRelayoutEnabled( false ); | |
| 293 | 294 | stage.Add( mItemView ); |
| 294 | 295 | mItemView.SetParentOrigin(ParentOrigin::CENTER); |
| 295 | 296 | mItemView.SetAnchorPoint(AnchorPoint::CENTER); |
| ... | ... | @@ -396,6 +397,7 @@ public: |
| 396 | 397 | Actor MenuItem(const std::string& text) |
| 397 | 398 | { |
| 398 | 399 | TextView t = TextView::New(); |
| 400 | + t.SetResizePolicy( FILL_TO_PARENT, WIDTH ); | |
| 399 | 401 | t.SetMarkupProcessingEnabled(true); |
| 400 | 402 | |
| 401 | 403 | int size = static_cast<int>(DemoHelper::ScalePointSize(6)); |
| ... | ... | @@ -480,6 +482,8 @@ public: |
| 480 | 482 | |
| 481 | 483 | builder.AddActors( layer ); |
| 482 | 484 | |
| 485 | + // Force relayout on layer | |
| 486 | + layer.RelayoutRequestTree(); | |
| 483 | 487 | } |
| 484 | 488 | |
| 485 | 489 | ... | ... |
examples/buttons/buttons-example.cpp
| ... | ... | @@ -127,14 +127,16 @@ class ButtonsController: public ConnectionTracker |
| 127 | 127 | radioGroup2Background.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 128 | 128 | radioGroup2Background.SetParentOrigin( ParentOrigin::TOP_LEFT ); |
| 129 | 129 | radioGroup2Background.SetPosition( DP(MARGIN_SIZE), DP(yPos) ); |
| 130 | - radioGroup2Background.SetSize( DP(348), DP(GROUP2_HEIGHT) ); | |
| 130 | + radioGroup2Background.SetRelayoutEnabled( true ); | |
| 131 | + radioGroup2Background.SetPreferredSize( Vector2( DP(348), DP(GROUP2_HEIGHT) ) ); | |
| 131 | 132 | mContentLayer.Add( radioGroup2Background ); |
| 132 | 133 | |
| 133 | 134 | Actor radioButtonsGroup2 = Actor::New(); |
| 134 | 135 | radioButtonsGroup2.SetParentOrigin( ParentOrigin::TOP_LEFT ); |
| 135 | 136 | radioButtonsGroup2.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 136 | 137 | radioButtonsGroup2.SetPosition( DP(MARGIN_SIZE), DP(MARGIN_SIZE) ); |
| 137 | - radioButtonsGroup2.SetSize( DP(100), DP(160) ); | |
| 138 | + radioButtonsGroup2.SetRelayoutEnabled( true ); | |
| 139 | + radioButtonsGroup2.SetPreferredSize( Vector2( DP(100), DP(160) ) ); | |
| 138 | 140 | |
| 139 | 141 | radioGroup2Background.Add( radioButtonsGroup2 ); |
| 140 | 142 | |
| ... | ... | @@ -143,7 +145,7 @@ class ButtonsController: public ConnectionTracker |
| 143 | 145 | // Radio 1 |
| 144 | 146 | { |
| 145 | 147 | ImageActor imageActor = ImageActor::New( ResourceImage::New( SMALL_IMAGE_1 ) ); |
| 146 | - imageActor.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); | |
| 148 | + imageActor.SetPreferredSize( Vector2( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ) ); | |
| 147 | 149 | mRadioButtonImage1 = Dali::Toolkit::RadioButton::New( imageActor ); |
| 148 | 150 | mRadioButtonImage1.SetParentOrigin( ParentOrigin::TOP_LEFT ); |
| 149 | 151 | mRadioButtonImage1.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| ... | ... | @@ -158,7 +160,7 @@ class ButtonsController: public ConnectionTracker |
| 158 | 160 | radioY += RADIO_LABEL_THUMBNAIL_SIZE + RADIO_IMAGE_SPACING; |
| 159 | 161 | |
| 160 | 162 | ImageActor imageActor = ImageActor::New( ResourceImage::New( SMALL_IMAGE_2 ) ); |
| 161 | - imageActor.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); | |
| 163 | + imageActor.SetPreferredSize( Vector2( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ) ); | |
| 162 | 164 | |
| 163 | 165 | mRadioButtonImage2 = Dali::Toolkit::RadioButton::New( imageActor ); |
| 164 | 166 | mRadioButtonImage2.SetParentOrigin( ParentOrigin::TOP_LEFT ); |
| ... | ... | @@ -173,7 +175,7 @@ class ButtonsController: public ConnectionTracker |
| 173 | 175 | radioY += RADIO_LABEL_THUMBNAIL_SIZE + RADIO_IMAGE_SPACING; |
| 174 | 176 | |
| 175 | 177 | ImageActor imageActor = ImageActor::New( ResourceImage::New( SMALL_IMAGE_3 ) ); |
| 176 | - imageActor.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); | |
| 178 | + imageActor.SetPreferredSize( Vector2( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ) ); | |
| 177 | 179 | |
| 178 | 180 | mRadioButtonImage3 = Dali::Toolkit::RadioButton::New( imageActor ); |
| 179 | 181 | mRadioButtonImage3.SetParentOrigin( ParentOrigin::TOP_LEFT ); |
| ... | ... | @@ -188,8 +190,8 @@ class ButtonsController: public ConnectionTracker |
| 188 | 190 | mUpdateButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); |
| 189 | 191 | mUpdateButton.SetAnchorPoint( AnchorPoint::TOP_CENTER ); |
| 190 | 192 | mUpdateButton.SetPosition( 0, DP(MARGIN_SIZE) ); |
| 191 | - mUpdateButton.SetLabel("Select"); | |
| 192 | - mUpdateButton.SetSize( DP(100), DP(BUTTON_HEIGHT) ); | |
| 193 | + mUpdateButton.SetLabel( "Select" ); | |
| 194 | + mUpdateButton.SetPreferredSize( Vector2( DP(100), DP(BUTTON_HEIGHT) ) ); | |
| 193 | 195 | |
| 194 | 196 | mUpdateButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) ); |
| 195 | 197 | mUpdateButton.SetDisabledImage( Dali::ResourceImage::New( PUSHBUTTON_DISABLED_IMAGE ) ); |
| ... | ... | @@ -208,7 +210,7 @@ class ButtonsController: public ConnectionTracker |
| 208 | 210 | mImage.SetParentOrigin( ParentOrigin::TOP_RIGHT ); |
| 209 | 211 | mImage.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 210 | 212 | mImage.SetPosition( DP(MARGIN_SIZE), 0 ); |
| 211 | - mImage.SetSize( DP(218), DP(218) ); | |
| 213 | + mImage.SetPreferredSize( Vector2( DP(218), DP(218) ) ); | |
| 212 | 214 | radioButtonsGroup2.Add( mImage ); |
| 213 | 215 | |
| 214 | 216 | // The enable/disable radio group |
| ... | ... | @@ -218,7 +220,8 @@ class ButtonsController: public ConnectionTracker |
| 218 | 220 | radioGroup1Background.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 219 | 221 | radioGroup1Background.SetParentOrigin( ParentOrigin::TOP_LEFT ); |
| 220 | 222 | radioGroup1Background.SetPosition( DP(MARGIN_SIZE), DP(yPos) ); |
| 221 | - radioGroup1Background.SetSize( DP(348), DP(GROUP1_HEIGHT) ); | |
| 223 | + radioGroup1Background.SetRelayoutEnabled( true ); | |
| 224 | + radioGroup1Background.SetPreferredSize( Vector2( DP(348), DP(GROUP1_HEIGHT) ) ); | |
| 222 | 225 | mContentLayer.Add( radioGroup1Background ); |
| 223 | 226 | |
| 224 | 227 | // Radio group |
| ... | ... | @@ -232,17 +235,17 @@ class ButtonsController: public ConnectionTracker |
| 232 | 235 | // First radio button |
| 233 | 236 | { |
| 234 | 237 | Toolkit::TableView tableView = Toolkit::TableView::New( 1, 2 ); |
| 235 | - tableView.SetSize( DP(260), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); | |
| 238 | + tableView.SetPreferredSize( Vector2( DP(260), 0.0f ) ); | |
| 239 | + tableView.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT ); | |
| 236 | 240 | |
| 237 | 241 | Toolkit::TextView textView = Toolkit::TextView::New( "Select enabled" ); |
| 238 | - Toolkit::Alignment alignment = Toolkit::Alignment::New( Toolkit::Alignment::HorizontalLeft ); | |
| 239 | - alignment.Add( textView ); | |
| 240 | - tableView.AddChild( alignment, Toolkit::TableView::CellPosition( 0, 0 ) ); | |
| 242 | + tableView.AddChild( textView, Toolkit::TableView::CellPosition( 0, 0 ) ); | |
| 241 | 243 | |
| 242 | 244 | ImageActor imageActor = ImageActor::New( ResourceImage::New( ENABLED_IMAGE ) ); |
| 243 | - imageActor.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); | |
| 245 | + imageActor.SetPreferredSize( Vector2( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ) ); | |
| 246 | + imageActor.SetResizePolicy( FIXED, ALL_DIMENSIONS ); | |
| 247 | + imageActor.SetPadding( Padding( DP(20.0f), 0.0f, 0.0f, 0.0f ) ); | |
| 244 | 248 | tableView.AddChild( imageActor, Toolkit::TableView::CellPosition( 0, 1 ) ); |
| 245 | - tableView.SetFixedWidth( 1, DP(RADIO_LABEL_THUMBNAIL_SIZE) ); | |
| 246 | 249 | |
| 247 | 250 | Toolkit::RadioButton radioButton = Dali::Toolkit::RadioButton::New( tableView ); |
| 248 | 251 | radioButton.SetName( "radio-select-enable" ); |
| ... | ... | @@ -276,7 +279,8 @@ class ButtonsController: public ConnectionTracker |
| 276 | 279 | checkBoxBackground.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 277 | 280 | checkBoxBackground.SetParentOrigin( ParentOrigin::TOP_LEFT ); |
| 278 | 281 | checkBoxBackground.SetPosition( DP(MARGIN_SIZE), DP(yPos) ); |
| 279 | - checkBoxBackground.SetSize( DP(430), DP(GROUP3_HEIGHT) ); | |
| 282 | + checkBoxBackground.SetRelayoutEnabled( true ); | |
| 283 | + checkBoxBackground.SetPreferredSize( Vector2( DP(430), DP(GROUP3_HEIGHT) ) ); | |
| 280 | 284 | mContentLayer.Add( checkBoxBackground ); |
| 281 | 285 | |
| 282 | 286 | Dali::Image unselected = Dali::ResourceImage::New( CHECKBOX_UNSELECTED_IMAGE ); |
| ... | ... | @@ -336,7 +340,8 @@ class ButtonsController: public ConnectionTracker |
| 336 | 340 | toggleBackground.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 337 | 341 | toggleBackground.SetParentOrigin( ParentOrigin::TOP_LEFT ); |
| 338 | 342 | toggleBackground.SetPosition( DP(MARGIN_SIZE), DP(yPos) ); |
| 339 | - toggleBackground.SetSize( DP(150 + MARGIN_SIZE * 2), DP(GROUP4_HEIGHT) ); | |
| 343 | + toggleBackground.SetRelayoutEnabled( true ); | |
| 344 | + toggleBackground.SetPreferredSize( Vector2( DP(150 + MARGIN_SIZE * 2), DP(GROUP4_HEIGHT) ) ); | |
| 340 | 345 | mContentLayer.Add( toggleBackground ); |
| 341 | 346 | |
| 342 | 347 | Toolkit::PushButton toggleButton = Toolkit::PushButton::New(); |
| ... | ... | @@ -345,7 +350,7 @@ class ButtonsController: public ConnectionTracker |
| 345 | 350 | toggleButton.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 346 | 351 | toggleButton.SetPosition( DP(MARGIN_SIZE), DP(MARGIN_SIZE) ); |
| 347 | 352 | toggleButton.SetLabel( "Unselected" ); |
| 348 | - toggleButton.SetSize( DP(150), DP(BUTTON_HEIGHT) ); | |
| 353 | + toggleButton.SetPreferredSize( Vector2( DP(150), DP(BUTTON_HEIGHT) ) ); | |
| 349 | 354 | |
| 350 | 355 | toggleButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) ); |
| 351 | 356 | toggleButton.SetDisabledImage( Dali::ResourceImage::New( PUSHBUTTON_DISABLED_IMAGE ) ); | ... | ... |
examples/cluster/cluster-example.cpp
| ... | ... | @@ -477,6 +477,7 @@ public: |
| 477 | 477 | |
| 478 | 478 | // create and setup the scroll view... |
| 479 | 479 | mScrollView = ScrollView::New(); |
| 480 | + mScrollView.SetRelayoutEnabled( false ); | |
| 480 | 481 | mScrollView.SetSize(stageSize); |
| 481 | 482 | |
| 482 | 483 | // attach Wobble Effect to ScrollView |
| ... | ... | @@ -488,7 +489,8 @@ public: |
| 488 | 489 | mScrollView.SetParentOrigin(ParentOrigin::CENTER); |
| 489 | 490 | |
| 490 | 491 | // Scale ScrollView to fit parent (mContentLayer) |
| 491 | - mScrollView.SetSizeMode( SIZE_EQUAL_TO_PARENT ); | |
| 492 | + mScrollView.SetRelayoutEnabled( true ); | |
| 493 | + mScrollView.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 492 | 494 | |
| 493 | 495 | // Add the scroll view to the content layer |
| 494 | 496 | mContentLayer.Add(mScrollView); |
| ... | ... | @@ -515,6 +517,7 @@ public: |
| 515 | 517 | Cluster clusterActor = Cluster::New(style); |
| 516 | 518 | clusterActor.SetParentOrigin(ParentOrigin::CENTER); |
| 517 | 519 | clusterActor.SetAnchorPoint(AnchorPoint::CENTER); |
| 520 | + clusterActor.SetRelayoutEnabled( false ); | |
| 518 | 521 | |
| 519 | 522 | Vector2 stageSize = Dali::Stage::GetCurrent().GetSize(); |
| 520 | 523 | float minStageDimension = std::min(stageSize.x, stageSize.y); |
| ... | ... | @@ -533,6 +536,7 @@ public: |
| 533 | 536 | backgroundAttributes.SetScalingMode( Dali::ImageAttributes::ShrinkToFit ); |
| 534 | 537 | Image bg = ResourceImage::New( CLUSTER_BACKGROUND_IMAGE_PATH ); |
| 535 | 538 | ImageActor image = ImageActor::New(bg); |
| 539 | + image.SetRelayoutEnabled( false ); | |
| 536 | 540 | clusterActor.SetBackgroundImage(image); |
| 537 | 541 | |
| 538 | 542 | // Add actors (pictures) as the children of the cluster |
| ... | ... | @@ -576,6 +580,7 @@ public: |
| 576 | 580 | shadowActor.SetPosition(Vector3(0.0f, 0.0f, -1.0f)); |
| 577 | 581 | |
| 578 | 582 | // Apply size-relative mode to auto-size the image shadow |
| 583 | + shadowActor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 579 | 584 | shadowActor.SetSizeMode( SIZE_RELATIVE_TO_PARENT ); |
| 580 | 585 | shadowActor.SetSizeModeFactor( ShadowProperty::SIZE_SCALE ); |
| 581 | 586 | actor.Add( shadowActor ); |
| ... | ... | @@ -585,7 +590,7 @@ public: |
| 585 | 590 | ImageActor imageActor = ImageActor::New( image ); |
| 586 | 591 | imageActor.SetParentOrigin( ParentOrigin::CENTER ); |
| 587 | 592 | imageActor.SetAnchorPoint( AnchorPoint::CENTER ); |
| 588 | - imageActor.SetSizeMode( SIZE_EQUAL_TO_PARENT ); | |
| 593 | + imageActor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 589 | 594 | actor.Add( imageActor ); |
| 590 | 595 | |
| 591 | 596 | // Add a border image child actor (with a fixed size offset from parent). |
| ... | ... | @@ -595,6 +600,7 @@ public: |
| 595 | 600 | borderActor.SetStyle( ImageActor::STYLE_NINE_PATCH ); |
| 596 | 601 | borderActor.SetNinePatchBorder( CLUSTER_IMAGE_BORDER_ABSOLUTE ); |
| 597 | 602 | borderActor.SetPosition( Vector3( 0.0f, 0.0f, 1.0f ) ); |
| 603 | + borderActor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 598 | 604 | borderActor.SetSizeMode( SIZE_FIXED_OFFSET_FROM_PARENT ); |
| 599 | 605 | borderActor.SetSizeModeFactor( Vector3( CLUSTER_IMAGE_BORDER_INDENT - 1.0f, CLUSTER_IMAGE_BORDER_INDENT - 1.0f, 0.0f ) * 2.0f ); |
| 600 | 606 | actor.Add( borderActor ); |
| ... | ... | @@ -625,7 +631,8 @@ public: |
| 625 | 631 | mScrollView.Add(pageView); |
| 626 | 632 | pageView.SetParentOrigin(ParentOrigin::CENTER); |
| 627 | 633 | pageView.SetPosition(Vector3(stageSize.width * column, 0.0f, 0.0f)); |
| 628 | - pageView.SetSizeMode( SIZE_EQUAL_TO_PARENT ); | |
| 634 | + pageView.SetRelayoutEnabled( true ); | |
| 635 | + pageView.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 629 | 636 | |
| 630 | 637 | // Create cluster actors, add them to scroll view, and set the shear effect with the given center point. |
| 631 | 638 | Cluster cluster = CreateClusterActor(clusterType, style); | ... | ... |
examples/cube-transition-effect/cube-transition-effect-example.cpp
| ... | ... | @@ -288,6 +288,7 @@ void CubeTransitionApp::OnInit( Application& application ) |
| 288 | 288 | mCurrentImage = ImageActor::New( LoadStageFillingImage( IMAGES[mIndex] ) ); |
| 289 | 289 | mCurrentImage.SetPositionInheritanceMode( USE_PARENT_POSITION ); |
| 290 | 290 | mCurrentImage.ApplyConstraint( mImageConstraint ); |
| 291 | + mCurrentImage.SetRelayoutEnabled( false ); | |
| 291 | 292 | mParent.Add( mCurrentImage ); |
| 292 | 293 | |
| 293 | 294 | mCurrentEffect = mCubeWaveEffect; |
| ... | ... | @@ -332,6 +333,7 @@ void CubeTransitionApp::GoToNextImage() |
| 332 | 333 | |
| 333 | 334 | mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION); |
| 334 | 335 | mNextImage.ApplyConstraint( mImageConstraint ); |
| 336 | + mNextImage.SetRelayoutEnabled( false ); | |
| 335 | 337 | mCurrentEffect.SetTargetImage(mNextImage); |
| 336 | 338 | if( image.GetLoadingState() == ResourceLoadingSucceeded ) |
| 337 | 339 | { | ... | ... |
examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp
| ... | ... | @@ -421,7 +421,8 @@ public: |
| 421 | 421 | // coordinates in a frame defined by a parent actor: |
| 422 | 422 | |
| 423 | 423 | Actor gridActor = Actor::New(); |
| 424 | - gridActor.SetSizeMode( SIZE_EQUAL_TO_PARENT ); | |
| 424 | + gridActor.SetRelayoutEnabled( true ); | |
| 425 | + gridActor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 425 | 426 | gridActor.SetParentOrigin( ParentOrigin::CENTER ); |
| 426 | 427 | gridActor.SetAnchorPoint( AnchorPoint::CENTER ); |
| 427 | 428 | ... | ... |
examples/item-view/item-view-example.cpp
| ... | ... | @@ -281,7 +281,8 @@ public: |
| 281 | 281 | mDeleteButton.SetDrawMode( DrawMode::OVERLAY ); |
| 282 | 282 | mDeleteButton.SetBackgroundImage( ResourceImage::New( TOOLBAR_IMAGE ) ); |
| 283 | 283 | mDeleteButton.SetButtonImage( ResourceImage::New( DELETE_IMAGE ) ); |
| 284 | - mDeleteButton.SetSize( stageSize.width * 0.15f, stageSize.width * 0.15f ); | |
| 284 | + mDeleteButton.SetResizePolicy( FIXED, ALL_DIMENSIONS ); | |
| 285 | + mDeleteButton.SetPreferredSize( Vector2( stageSize.width * 0.15f, stageSize.width * 0.15f ) ); | |
| 285 | 286 | mDeleteButton.ClickedSignal().Connect( this, &ItemViewExample::OnDeleteButtonClicked); |
| 286 | 287 | mDeleteButton.SetLeaveRequired( true ); |
| 287 | 288 | mDeleteButton.SetVisible( false ); |
| ... | ... | @@ -295,7 +296,8 @@ public: |
| 295 | 296 | mInsertButton.SetDrawMode( DrawMode::OVERLAY ); |
| 296 | 297 | mInsertButton.SetBackgroundImage( ResourceImage::New( TOOLBAR_IMAGE ) ); |
| 297 | 298 | mInsertButton.SetButtonImage( ResourceImage::New( INSERT_IMAGE ) ); |
| 298 | - mInsertButton.SetSize( stageSize.width * 0.15f, stageSize.width * 0.15f ); | |
| 299 | + mInsertButton.SetResizePolicy( FIXED, ALL_DIMENSIONS ); | |
| 300 | + mInsertButton.SetPreferredSize( Vector2( stageSize.width * 0.15f, stageSize.width * 0.15f ) ); | |
| 299 | 301 | mInsertButton.ClickedSignal().Connect( this, &ItemViewExample::OnInsertButtonClicked); |
| 300 | 302 | mInsertButton.SetLeaveRequired( true ); |
| 301 | 303 | mInsertButton.SetVisible( false ); |
| ... | ... | @@ -309,7 +311,8 @@ public: |
| 309 | 311 | mReplaceButton.SetDrawMode( DrawMode::OVERLAY ); |
| 310 | 312 | mReplaceButton.SetBackgroundImage( ResourceImage::New( TOOLBAR_IMAGE ) ); |
| 311 | 313 | mReplaceButton.SetButtonImage( ResourceImage::New( REPLACE_IMAGE ) ); |
| 312 | - mReplaceButton.SetSize( stageSize.width * 0.15f, stageSize.width * 0.15f ); | |
| 314 | + mReplaceButton.SetResizePolicy( FIXED, ALL_DIMENSIONS ); | |
| 315 | + mReplaceButton.SetPreferredSize( Vector2( stageSize.width * 0.15f, stageSize.width * 0.15f ) ); | |
| 313 | 316 | mReplaceButton.ClickedSignal().Connect( this, &ItemViewExample::OnReplaceButtonClicked); |
| 314 | 317 | mReplaceButton.SetLeaveRequired( true ); |
| 315 | 318 | mReplaceButton.SetVisible( false ); |
| ... | ... | @@ -318,6 +321,7 @@ public: |
| 318 | 321 | // Create the item view actor |
| 319 | 322 | mImageAtlas = CreateImageAtlas(); |
| 320 | 323 | mItemView = ItemView::New(*this); |
| 324 | + mItemView.SetRelayoutEnabled( false ); | |
| 321 | 325 | mItemView.SetParentOrigin(ParentOrigin::CENTER); |
| 322 | 326 | mItemView.SetAnchorPoint(AnchorPoint::CENTER); |
| 323 | 327 | |
| ... | ... | @@ -897,6 +901,7 @@ public: // From ItemFactory |
| 897 | 901 | borderActor.SetStyle( ImageActor::STYLE_NINE_PATCH ); |
| 898 | 902 | borderActor.SetNinePatchBorder( Vector4( ITEM_IMAGE_BORDER_LEFT, ITEM_IMAGE_BORDER_TOP, ITEM_IMAGE_BORDER_RIGHT, ITEM_IMAGE_BORDER_BOTTOM ) ); |
| 899 | 903 | borderActor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR ); // darken with parent image-actor |
| 904 | + borderActor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 900 | 905 | borderActor.SetSizeMode( SIZE_FIXED_OFFSET_FROM_PARENT ); |
| 901 | 906 | borderActor.SetSizeModeFactor( ITEM_BORDER_MARGIN_SIZE ); |
| 902 | 907 | actor.Add(borderActor); |
| ... | ... | @@ -908,6 +913,7 @@ public: // From ItemFactory |
| 908 | 913 | // Add a checkbox child actor; invisible until edit-mode is enabled |
| 909 | 914 | |
| 910 | 915 | ImageActor checkbox = ImageActor::New( mWhiteImage ); |
| 916 | + checkbox.SetRelayoutEnabled( false ); | |
| 911 | 917 | checkbox.SetName( "CheckBox" ); |
| 912 | 918 | checkbox.SetColor( Vector4(0.0f,0.0f,0.0f,0.6f) ); |
| 913 | 919 | checkbox.SetParentOrigin( ParentOrigin::TOP_RIGHT ); |
| ... | ... | @@ -924,6 +930,7 @@ public: // From ItemFactory |
| 924 | 930 | actor.Add( checkbox ); |
| 925 | 931 | |
| 926 | 932 | ImageActor tick = ImageActor::New( ResourceImage::New(SELECTED_IMAGE) ); |
| 933 | + tick.SetRelayoutEnabled( false ); | |
| 927 | 934 | tick.SetColorMode( USE_OWN_COLOR ); |
| 928 | 935 | tick.SetName( "Tick" ); |
| 929 | 936 | tick.SetParentOrigin( ParentOrigin::TOP_RIGHT ); |
| ... | ... | @@ -988,12 +995,12 @@ private: |
| 988 | 995 | mMenu = Toolkit::Popup::New(); |
| 989 | 996 | mMenu.SetParentOrigin( ParentOrigin::BOTTOM_LEFT ); |
| 990 | 997 | mMenu.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT ); |
| 998 | + mMenu.SetResizePolicy( FIXED, ALL_DIMENSIONS ); | |
| 999 | + mMenu.SetPreferredSize( Vector2( popupWidth, MENU_OPTION_HEIGHT * 2 ) ); | |
| 991 | 1000 | mMenu.OutsideTouchedSignal().Connect( this, &ItemViewExample::HideMenu ); |
| 992 | - stage.Add( mMenu ); | |
| 993 | 1001 | |
| 994 | 1002 | TableView tableView = TableView::New( 0, 0 ); |
| 995 | - Vector2 tableSize = Vector2( popupWidth, MENU_OPTION_HEIGHT * 2 ); | |
| 996 | - tableView.SetSize( tableSize ); | |
| 1003 | + tableView.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 997 | 1004 | mMenu.Add( tableView ); |
| 998 | 1005 | |
| 999 | 1006 | Slider slider = Slider::New(); |
| ... | ... | @@ -1002,9 +1009,9 @@ private: |
| 1002 | 1009 | slider.SetProperty( Slider::Property::VALUE, mDurationSeconds ); |
| 1003 | 1010 | slider.SetProperty( Slider::Property::VALUE_PRECISION, 2 ); |
| 1004 | 1011 | slider.SetProperty( Slider::Property::SHOW_POPUP, true ); |
| 1012 | + slider.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 1005 | 1013 | slider.ValueChangedSignal().Connect( this, &ItemViewExample::SliderValueChange ); |
| 1006 | 1014 | tableView.AddChild( slider, TableView::CellPosition( 0, 0 ) ); |
| 1007 | - tableView.SetRelativeHeight( 0, 0.5f ); | |
| 1008 | 1015 | |
| 1009 | 1016 | TextStyle defaultTextStyle; |
| 1010 | 1017 | defaultTextStyle.SetFontName(DEFAULT_TEXT_STYLE_FONT_FAMILY); |
| ... | ... | @@ -1018,19 +1025,21 @@ private: |
| 1018 | 1025 | text.SetParentOrigin( ParentOrigin::TOP_LEFT ); |
| 1019 | 1026 | text.SetTextAlignment( Dali::Toolkit::Alignment::HorizontalLeft ); |
| 1020 | 1027 | text.SetStyleToCurrentText( defaultTextStyle ); |
| 1021 | - text.SetSize( 0.0f, LABEL_TEXT_SIZE_Y ); | |
| 1022 | - text.ApplyConstraint( Dali::Constraint::New<float>( Dali::Actor::Property::SIZE_WIDTH, Dali::ParentSource( Dali::Actor::Property::SIZE_WIDTH ), Dali::EqualToConstraint() ) ); | |
| 1028 | + text.SetResizePolicy( FILL_TO_PARENT, WIDTH ); | |
| 1029 | + text.SetResizePolicy( FIXED, HEIGHT ); | |
| 1030 | + text.SetPreferredSize( Vector2( 0.0f, LABEL_TEXT_SIZE_Y ) ); | |
| 1023 | 1031 | text.SetZ( -0.9f ); |
| 1024 | 1032 | slider.Add( text ); |
| 1025 | 1033 | |
| 1026 | 1034 | Actor textContainer = Actor::New(); |
| 1035 | + textContainer.SetRelayoutEnabled( true ); | |
| 1036 | + textContainer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 1027 | 1037 | mAlphaFunctionText = TextView::New( ALPHA_FUNCTIONS_TEXT[mAlphaFuncIndex] ); |
| 1028 | 1038 | mAlphaFunctionText.SetAnchorPoint( ParentOrigin::CENTER ); |
| 1029 | 1039 | mAlphaFunctionText.SetParentOrigin( ParentOrigin::CENTER ); |
| 1030 | 1040 | mAlphaFunctionText.SetTextAlignment( Toolkit::Alignment::VerticalCenter ); |
| 1031 | 1041 | textContainer.Add( mAlphaFunctionText ); |
| 1032 | 1042 | tableView.AddChild( textContainer, TableView::CellPosition( 1, 0 ) ); |
| 1033 | - tableView.SetRelativeHeight( 0, 0.5f ); | |
| 1034 | 1043 | |
| 1035 | 1044 | mTapDetector = TapGestureDetector::New(); |
| 1036 | 1045 | mTapDetector.Attach(mAlphaFunctionText); |
| ... | ... | @@ -1041,10 +1050,12 @@ private: |
| 1041 | 1050 | text.SetParentOrigin( ParentOrigin::TOP_LEFT ); |
| 1042 | 1051 | text.SetTextAlignment( Dali::Toolkit::Alignment::HorizontalLeft ); |
| 1043 | 1052 | text.SetStyleToCurrentText( defaultTextStyle ); |
| 1044 | - text.SetSize( 0.0f, LABEL_TEXT_SIZE_Y ); | |
| 1045 | - text.ApplyConstraint( Dali::Constraint::New<float>( Dali::Actor::Property::SIZE_WIDTH, Dali::ParentSource( Dali::Actor::Property::SIZE_WIDTH ), Dali::EqualToConstraint() ) ); | |
| 1053 | + text.SetResizePolicy( FILL_TO_PARENT, WIDTH ); | |
| 1054 | + text.SetResizePolicy( FIXED, HEIGHT ); | |
| 1055 | + text.SetPreferredSize( Vector2( 0.0f, LABEL_TEXT_SIZE_Y ) ); | |
| 1046 | 1056 | textContainer.Add( text ); |
| 1047 | 1057 | |
| 1058 | + mMenu.MarkDirtyForRelayout(); | |
| 1048 | 1059 | mMenu.Show(); |
| 1049 | 1060 | mMenuShown = true; |
| 1050 | 1061 | } | ... | ... |
examples/logging/logging-example.cpp
| ... | ... | @@ -275,7 +275,7 @@ class LoggingController: public ConnectionTracker |
| 275 | 275 | mContentLayer.Add( createGroupBackground ); |
| 276 | 276 | |
| 277 | 277 | int buttonXDP = DP(MARGIN_SIZE); |
| 278 | - int buttonWidthDP = (createGroupBackground.GetSize().width - DP(MARGIN_SIZE) * 3) / 2; | |
| 278 | + int buttonWidthDP = (createGroupBackground.GetTargetSize().width - DP(MARGIN_SIZE) * 3) / 2; | |
| 279 | 279 | |
| 280 | 280 | { |
| 281 | 281 | Toolkit::PushButton button = Toolkit::PushButton::New(); |
| ... | ... | @@ -326,7 +326,7 @@ class LoggingController: public ConnectionTracker |
| 326 | 326 | mContentLayer.Add( timingGroupBackground ); |
| 327 | 327 | |
| 328 | 328 | buttonXDP = DP(MARGIN_SIZE); |
| 329 | - buttonWidthDP = (timingGroupBackground.GetSize().width - DP(MARGIN_SIZE) * 3) / 2; | |
| 329 | + buttonWidthDP = (timingGroupBackground.GetTargetSize().width - DP(MARGIN_SIZE) * 3) / 2; | |
| 330 | 330 | |
| 331 | 331 | { |
| 332 | 332 | Toolkit::PushButton button = Toolkit::PushButton::New(); |
| ... | ... | @@ -377,7 +377,7 @@ class LoggingController: public ConnectionTracker |
| 377 | 377 | mContentLayer.Add( enableGroupBackground ); |
| 378 | 378 | |
| 379 | 379 | buttonXDP = DP(MARGIN_SIZE); |
| 380 | - buttonWidthDP = (enableGroupBackground.GetSize().width - DP(MARGIN_SIZE) * 3) / 2; | |
| 380 | + buttonWidthDP = (enableGroupBackground.GetTargetSize().width - DP(MARGIN_SIZE) * 3) / 2; | |
| 381 | 381 | |
| 382 | 382 | { |
| 383 | 383 | Toolkit::PushButton button = Toolkit::PushButton::New(); |
| ... | ... | @@ -509,7 +509,7 @@ class LoggingController: public ConnectionTracker |
| 509 | 509 | mContentLayer.Add( vsyncGroupBackground ); |
| 510 | 510 | |
| 511 | 511 | buttonXDP = DP(MARGIN_SIZE); |
| 512 | - buttonWidthDP = vsyncGroupBackground.GetSize().width - DP(MARGIN_SIZE) * 2; | |
| 512 | + buttonWidthDP = vsyncGroupBackground.GetTargetSize().width - DP(MARGIN_SIZE) * 2; | |
| 513 | 513 | |
| 514 | 514 | { |
| 515 | 515 | Toolkit::PushButton button = Toolkit::PushButton::New(); | ... | ... |
examples/magnifier/magnifier-example.cpp
| ... | ... | @@ -227,12 +227,14 @@ public: |
| 227 | 227 | |
| 228 | 228 | // Create magnifier (controlled by human touch) |
| 229 | 229 | Layer overlay = Layer::New(); |
| 230 | + overlay.SetRelayoutEnabled( false ); | |
| 230 | 231 | overlay.SetSensitive(false); |
| 231 | 232 | overlay.SetParentOrigin( ParentOrigin::CENTER ); |
| 232 | 233 | overlay.SetSize(mStageSize); |
| 233 | 234 | Stage::GetCurrent().Add(overlay); |
| 234 | 235 | |
| 235 | 236 | mMagnifier = Toolkit::Magnifier::New(); |
| 237 | + mMagnifier.SetRelayoutEnabled( false ); | |
| 236 | 238 | mMagnifier.SetSourceActor( mView.GetBackgroundLayer() ); |
| 237 | 239 | mMagnifier.SetSize( MAGNIFIER_SIZE * mStageSize.width ); // Size of magnifier is in relation to stage width |
| 238 | 240 | mMagnifier.SetMagnificationFactor( MAGNIFICATION_FACTOR ); |
| ... | ... | @@ -251,6 +253,7 @@ public: |
| 251 | 253 | |
| 252 | 254 | // Create bouncing magnifier automatically bounces around screen. |
| 253 | 255 | mBouncingMagnifier = Toolkit::Magnifier::New(); |
| 256 | + mBouncingMagnifier.SetRelayoutEnabled( false ); | |
| 254 | 257 | mBouncingMagnifier.SetSourceActor( mView.GetBackgroundLayer() ); |
| 255 | 258 | mBouncingMagnifier.SetSize( MAGNIFIER_SIZE * mStageSize.width ); // Size of magnifier is in relation to stage width |
| 256 | 259 | mBouncingMagnifier.SetMagnificationFactor( MAGNIFICATION_FACTOR ); | ... | ... |
examples/page-turn-view/page-turn-view-example.cpp
| ... | ... | @@ -78,14 +78,20 @@ class PortraitPageFactory : public PageFactory |
| 78 | 78 | */ |
| 79 | 79 | virtual Actor NewPage( unsigned int pageId ) |
| 80 | 80 | { |
| 81 | + ImageActor page; | |
| 82 | + | |
| 81 | 83 | if( pageId == 0 ) |
| 82 | 84 | { |
| 83 | - return ImageActor::New( ResourceImage::New( BOOK_COVER_PORTRAIT ) ); | |
| 85 | + page = ImageActor::New( ResourceImage::New( BOOK_COVER_PORTRAIT ) ); | |
| 84 | 86 | } |
| 85 | 87 | else |
| 86 | 88 | { |
| 87 | - return ImageActor::New( ResourceImage::New( PAGE_IMAGES_PORTRAIT[ (pageId-1) % NUMBER_OF_PORTRAIT_IMAGE ] ) ); | |
| 89 | + page = ImageActor::New( ResourceImage::New( PAGE_IMAGES_PORTRAIT[ (pageId-1) % NUMBER_OF_PORTRAIT_IMAGE ] ) ); | |
| 88 | 90 | } |
| 91 | + | |
| 92 | + page.SetRelayoutEnabled( false ); | |
| 93 | + | |
| 94 | + return page; | |
| 89 | 95 | } |
| 90 | 96 | }; |
| 91 | 97 | |
| ... | ... | @@ -120,6 +126,10 @@ class LandscapePageFactory : public PageFactory |
| 120 | 126 | pageBack = ImageActor::New( ResourceImage::New( PAGE_IMAGES_LANDSCAPE[ (imageId+1) % NUMBER_OF_LANDSCAPE_IMAGE ] ) ); |
| 121 | 127 | } |
| 122 | 128 | pageFront.Add(pageBack); |
| 129 | + | |
| 130 | + pageFront.SetRelayoutEnabled( false ); | |
| 131 | + pageBack.SetRelayoutEnabled( false ); | |
| 132 | + | |
| 123 | 133 | return pageFront; |
| 124 | 134 | } |
| 125 | 135 | }; |
| ... | ... | @@ -223,6 +233,7 @@ void PageTurnController::OnInit( Application& app ) |
| 223 | 233 | |
| 224 | 234 | // Create default View. |
| 225 | 235 | mView = View::New(); |
| 236 | + mView.SetRelayoutEnabled( false ); | |
| 226 | 237 | stage.Add( mView ); |
| 227 | 238 | |
| 228 | 239 | Dali::Window winHandle = app.GetWindow(); |
| ... | ... | @@ -236,6 +247,7 @@ void PageTurnController::OnInit( Application& app ) |
| 236 | 247 | mView.OrientationAnimationStartedSignal().Connect( this, &PageTurnController::OnOrientationAnimationStarted ); |
| 237 | 248 | |
| 238 | 249 | mPageTurnPortraitView = PageTurnPortraitView::New( mPortraitPageFactory, stageSize ); |
| 250 | + mPageTurnPortraitView.SetRelayoutEnabled( false ); | |
| 239 | 251 | mPageTurnPortraitView.SetSpineShadowParameter( Vector2(70.f, 30.f) ); |
| 240 | 252 | mPageTurnPortraitView.PageTurnStartedSignal().Connect( this, &PageTurnController::OnPageStartedTurn ); |
| 241 | 253 | mPageTurnPortraitView.PageTurnFinishedSignal().Connect( this, &PageTurnController::OnPageFinishedTurn ); |
| ... | ... | @@ -244,6 +256,7 @@ void PageTurnController::OnInit( Application& app ) |
| 244 | 256 | mPageTurnPortraitView.SetPositionInheritanceMode( USE_PARENT_POSITION ); |
| 245 | 257 | |
| 246 | 258 | mPageTurnLandscapeView = PageTurnLandscapeView::New( mLandscapePageFactory, Vector2(stageSize.y*0.5f, stageSize.x) ); |
| 259 | + mPageTurnLandscapeView.SetRelayoutEnabled( false ); | |
| 247 | 260 | mPageTurnLandscapeView.PageTurnStartedSignal().Connect( this, &PageTurnController::OnPageStartedTurn ); |
| 248 | 261 | mPageTurnLandscapeView.PageTurnFinishedSignal().Connect( this, &PageTurnController::OnPageFinishedTurn ); |
| 249 | 262 | mPageTurnLandscapeView.PagePanStartedSignal().Connect( this, &PageTurnController::OnPageStartedPan ); | ... | ... |
examples/path-animation/path-animation.cpp
| ... | ... | @@ -69,6 +69,7 @@ public: |
| 69 | 69 | textActor.SetSize(size.y,size.y,0.0f); |
| 70 | 70 | |
| 71 | 71 | Slider slider = Slider::New(); |
| 72 | + slider.SetRelayoutEnabled( false ); | |
| 72 | 73 | slider.SetAnchorPoint( AnchorPoint::CENTER_LEFT); |
| 73 | 74 | slider.SetParentOrigin( ParentOrigin::CENTER_RIGHT); |
| 74 | 75 | slider.SetProperty(Slider::Property::LOWER_BOUND, -1.0f ); |
| ... | ... | @@ -100,6 +101,7 @@ public: |
| 100 | 101 | |
| 101 | 102 | //TextInput |
| 102 | 103 | Dali::Layer controlsLayer = Dali::Layer::New(); |
| 104 | + controlsLayer.SetRelayoutEnabled( false ); | |
| 103 | 105 | controlsLayer.SetSize( stage.GetSize().x, stage.GetSize().y*0.3f, 0.0 ); |
| 104 | 106 | controlsLayer.SetPosition( 0.0f, stage.GetSize().y*0.8f, 0.0f ); |
| 105 | 107 | controlsLayer.SetAnchorPoint( AnchorPoint::TOP_LEFT); |
| ... | ... | @@ -199,6 +201,7 @@ public: |
| 199 | 201 | if( !mControlPoint[index] ) |
| 200 | 202 | { |
| 201 | 203 | mControlPoint[index] = Toolkit::CreateSolidColorActor(Vector4(1.0f,1.0f,1.0f,1.0f)); |
| 204 | + mControlPoint[index].SetRelayoutEnabled( false ); | |
| 202 | 205 | mControlPoint[index].SetParentOrigin( ParentOrigin::TOP_LEFT); |
| 203 | 206 | mControlPoint[index].SetAnchorPoint( AnchorPoint::CENTER ); |
| 204 | 207 | mControlPoint[index].SetSize( 20.0f, 20.0f ); |
| ... | ... | @@ -220,6 +223,7 @@ public: |
| 220 | 223 | if( !mControlPoint[index]) |
| 221 | 224 | { |
| 222 | 225 | mControlPoint[index] = Toolkit::CreateSolidColorActor(Vector4(1.0f,1.0f,1.0f,1.0f)); |
| 226 | + mControlPoint[index].SetRelayoutEnabled( false ); | |
| 223 | 227 | mControlPoint[index].SetParentOrigin( ParentOrigin::TOP_LEFT); |
| 224 | 228 | mControlPoint[index].SetAnchorPoint( AnchorPoint::CENTER ); |
| 225 | 229 | mControlPoint[index].SetSize( 20.0f, 20.0f ); |
| ... | ... | @@ -470,6 +474,7 @@ public: |
| 470 | 474 | ImageAttributes attributes; |
| 471 | 475 | Image img = ResourceImage::New(ACTOR_IMAGE, attributes ); |
| 472 | 476 | mActor = ImageActor::New( img ); |
| 477 | + mActor.SetRelayoutEnabled( false ); | |
| 473 | 478 | mActor.SetAnchorPoint( AnchorPoint::CENTER ); |
| 474 | 479 | mActor.SetSize( 100, 50, 1 ); |
| 475 | 480 | stage.Add( mActor ); | ... | ... |
examples/scroll-view/scroll-view-example.cpp
| ... | ... | @@ -226,6 +226,7 @@ private: |
| 226 | 226 | Vector2 stageSize = stage.GetSize(); |
| 227 | 227 | |
| 228 | 228 | mScrollView = ScrollView::New(); |
| 229 | + mScrollView.SetRelayoutEnabled( false ); | |
| 229 | 230 | mScrollView.SetAnchorPoint(AnchorPoint::CENTER); |
| 230 | 231 | mScrollView.SetParentOrigin(ParentOrigin::CENTER); |
| 231 | 232 | mContentLayer.Add( mScrollView ); |
| ... | ... | @@ -298,7 +299,8 @@ private: |
| 298 | 299 | Actor CreatePage() |
| 299 | 300 | { |
| 300 | 301 | Actor page = Actor::New(); |
| 301 | - page.SetSizeMode( SIZE_EQUAL_TO_PARENT ); | |
| 302 | + page.SetRelayoutEnabled( true ); | |
| 303 | + page.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 302 | 304 | page.SetParentOrigin( ParentOrigin::CENTER ); |
| 303 | 305 | page.SetAnchorPoint( AnchorPoint::CENTER ); |
| 304 | 306 | |
| ... | ... | @@ -450,7 +452,8 @@ private: |
| 450 | 452 | void ApplyEffectToPage(Actor page) |
| 451 | 453 | { |
| 452 | 454 | page.RemoveConstraints(); |
| 453 | - page.SetSizeMode( SIZE_EQUAL_TO_PARENT ); | |
| 455 | + page.SetRelayoutEnabled( true ); | |
| 456 | + page.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 454 | 457 | |
| 455 | 458 | switch( mEffectMode ) |
| 456 | 459 | { |
| ... | ... | @@ -566,6 +569,7 @@ private: |
| 566 | 569 | attributes.SetFilterMode( ImageAttributes::BoxThenLinear ); |
| 567 | 570 | Image img = ResourceImage::New(filename, attributes); |
| 568 | 571 | ImageActor actor = ImageActor::New(img); |
| 572 | + actor.SetRelayoutEnabled( false ); | |
| 569 | 573 | actor.SetName( filename ); |
| 570 | 574 | actor.SetParentOrigin(ParentOrigin::CENTER); |
| 571 | 575 | actor.SetAnchorPoint(AnchorPoint::CENTER); | ... | ... |
examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp
| ... | ... | @@ -213,7 +213,8 @@ public: |
| 213 | 213 | mShadowView.SetName("Container"); |
| 214 | 214 | mShadowView.SetParentOrigin(ParentOrigin::CENTER); |
| 215 | 215 | mShadowView.SetAnchorPoint(AnchorPoint::CENTER); |
| 216 | - mShadowView.SetSizeMode( SIZE_EQUAL_TO_PARENT ); | |
| 216 | + mShadowView.SetRelayoutEnabled( true ); | |
| 217 | + mShadowView.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 217 | 218 | mShadowView.SetPointLightFieldOfView( Math::PI / 2.0f); |
| 218 | 219 | mContents.Add(mShadowView); |
| 219 | 220 | ... | ... |
examples/size-negotiation/size-negotiation-example.cpp
0 โ 100644
| 1 | +/* | |
| 2 | + * Copyright (c) 2014 Samsung Electronics Co., Ltd. | |
| 3 | + * | |
| 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 | |
| 7 | + * | |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | + * | |
| 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. | |
| 15 | + * | |
| 16 | + */ | |
| 17 | + | |
| 18 | +#include "shared/view.h" | |
| 19 | +#include <dali/dali.h> | |
| 20 | +#include <dali-toolkit/dali-toolkit.h> | |
| 21 | + | |
| 22 | +using namespace Dali; | |
| 23 | + | |
| 24 | +// Define this so that it is interchangeable | |
| 25 | +// "DP" stands for Device independent Pixels | |
| 26 | +#define DP(x) DemoHelper::ScalePointSize(x) | |
| 27 | + | |
| 28 | +struct ButtonItem | |
| 29 | +{ | |
| 30 | + const char* name; | |
| 31 | + const char* text; | |
| 32 | +}; | |
| 33 | + | |
| 34 | + | |
| 35 | +namespace | |
| 36 | +{ | |
| 37 | + | |
| 38 | +const char* const BACKGROUND_IMAGE = DALI_IMAGE_DIR "background-gradient.jpg"; | |
| 39 | +const char* const TOOLBAR_IMAGE = DALI_IMAGE_DIR "top-bar.png"; | |
| 40 | + | |
| 41 | +const char* const TOOLBAR_TITLE = "Size Negotiation"; | |
| 42 | +const int TOOLBAR_HEIGHT = 62; | |
| 43 | + | |
| 44 | +const char* MENU_ICON_IMAGE = DALI_IMAGE_DIR "icon-cluster-none.png"; | |
| 45 | + | |
| 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"; | |
| 48 | + | |
| 49 | +const char* const POPUPS_MENU_ID = "POPUPS_MENU"; | |
| 50 | +const char* const TABLEVIEW_MENU_ID = "TABLEVIEW_MENU"; | |
| 51 | + | |
| 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"; | |
| 65 | + | |
| 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"; | |
| 77 | + | |
| 78 | +const char* const OKAY_BUTTON_ID = "OKAY_BUTTON"; | |
| 79 | +const char* const CANCEL_BUTTON_ID = "CANCEL_BUTTON"; | |
| 80 | + | |
| 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"; | |
| 86 | + | |
| 87 | +const ButtonItem MENU_ITEMS[] = { | |
| 88 | + { POPUPS_MENU_ID, "Popups" }, | |
| 89 | + { TABLEVIEW_MENU_ID, "TableView" } | |
| 90 | +}; | |
| 91 | + | |
| 92 | +const unsigned int MENU_ITEMS_COUNT = sizeof( MENU_ITEMS ) / sizeof( MENU_ITEMS[0] ); | |
| 93 | + | |
| 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" } | |
| 108 | + | |
| 109 | +}; | |
| 110 | + | |
| 111 | +const int POPUP_BUTTON_ITEMS_COUNT = sizeof( POPUP_BUTTON_ITEMS ) / sizeof( POPUP_BUTTON_ITEMS[0] ); | |
| 112 | + | |
| 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" }, | |
| 125 | +}; | |
| 126 | + | |
| 127 | +const unsigned int TABLEVIEW_BUTTON_ITEMS_COUNT = sizeof( TABLEVIEW_BUTTON_ITEMS ) / sizeof( TABLEVIEW_BUTTON_ITEMS[0] ); | |
| 128 | + | |
| 129 | +} // namespace | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | +/** | |
| 134 | + * This example shows the usage of size negotiation. | |
| 135 | + */ | |
| 136 | +class SizeNegotiationController: public ConnectionTracker, public Toolkit::ItemFactory | |
| 137 | +{ | |
| 138 | +public: | |
| 139 | + | |
| 140 | + SizeNegotiationController( Application& application ) | |
| 141 | + : mApplication( application ), | |
| 142 | + mMenuShown( false ), | |
| 143 | + mDemoState( POPUP ) | |
| 144 | + { | |
| 145 | + // Connect to the Application's Init signal | |
| 146 | + mApplication.InitSignal().Connect( this, &SizeNegotiationController::Create ); | |
| 147 | + } | |
| 148 | + | |
| 149 | + ~SizeNegotiationController() | |
| 150 | + { | |
| 151 | + // Nothing to do here | |
| 152 | + } | |
| 153 | + | |
| 154 | + void Create( Application& application ) | |
| 155 | + { | |
| 156 | + // The Init signal is received once (only) during the Application lifetime | |
| 157 | + | |
| 158 | + Stage stage = Stage::GetCurrent(); | |
| 159 | + | |
| 160 | + // Respond to key events | |
| 161 | + stage.KeyEventSignal().Connect(this, &SizeNegotiationController::OnKeyEvent); | |
| 162 | + | |
| 163 | + // Creates a default view with a default tool bar. | |
| 164 | + // The view is added to the stage. | |
| 165 | + mContentLayer = DemoHelper::CreateView( application, | |
| 166 | + mView, | |
| 167 | + mToolBar, | |
| 168 | + BACKGROUND_IMAGE, | |
| 169 | + TOOLBAR_IMAGE, | |
| 170 | + std::string("") ); | |
| 171 | + | |
| 172 | + mTitleActor = Dali::Toolkit::TextView::New(); | |
| 173 | + mTitleActor.SetName( "CUSTOM_TOOLBAR_TITLE" ); | |
| 174 | + | |
| 175 | + SetTitle(); | |
| 176 | + | |
| 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 ); | |
| 182 | + | |
| 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 ) ); | |
| 186 | + | |
| 187 | + mItemView = Toolkit::ItemView::New( *this ); | |
| 188 | + mItemView.SetParentOrigin( ParentOrigin::CENTER ); | |
| 189 | + mItemView.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 190 | + mItemView.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 191 | + | |
| 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 ); | |
| 199 | + | |
| 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 ); | |
| 204 | + | |
| 205 | + mItemView.ActivateLayout( 0, Vector3(stageSize.x, stageSize.y, stageSize.x), 0.0f ); | |
| 206 | + | |
| 207 | + mContentLayer.Add( mItemView ); | |
| 208 | + } | |
| 209 | + | |
| 210 | + void SetTitle() | |
| 211 | + { | |
| 212 | + std::string subTitle = ""; | |
| 213 | + | |
| 214 | + switch( mDemoState ) | |
| 215 | + { | |
| 216 | + case POPUP: | |
| 217 | + { | |
| 218 | + subTitle = "Popups"; | |
| 219 | + break; | |
| 220 | + } | |
| 221 | + | |
| 222 | + case TABLEVIEW: | |
| 223 | + { | |
| 224 | + subTitle = "TableView"; | |
| 225 | + break; | |
| 226 | + } | |
| 227 | + | |
| 228 | + default: | |
| 229 | + { | |
| 230 | + break; | |
| 231 | + } | |
| 232 | + } | |
| 233 | + | |
| 234 | + mTitleActor.SetText( std::string( TOOLBAR_TITLE ) + ": " + subTitle ); | |
| 235 | + mTitleActor.SetStyleToCurrentText( DemoHelper::GetDefaultTextStyle() ); | |
| 236 | + } | |
| 237 | + | |
| 238 | + bool OnMenu( Toolkit::Button button ) | |
| 239 | + { | |
| 240 | + ShowMenu(); | |
| 241 | + return true; | |
| 242 | + } | |
| 243 | + | |
| 244 | + void ShowMenu() | |
| 245 | + { | |
| 246 | + Stage stage = Stage::GetCurrent(); | |
| 247 | + const float popupWidth = stage.GetSize().x * 0.5f; | |
| 248 | + | |
| 249 | + mMenu = Toolkit::Popup::New(); | |
| 250 | + mMenu.SetParentOrigin( ParentOrigin::TOP_LEFT ); | |
| 251 | + mMenu.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | |
| 252 | + mMenu.HideTail(); | |
| 253 | + mMenu.OutsideTouchedSignal().Connect( this, &SizeNegotiationController::HideMenu ); | |
| 254 | + mMenu.SetPreferredSize( Vector2( popupWidth, 0.0f ) ); | |
| 255 | + mMenu.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT ); | |
| 256 | + | |
| 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 ); | |
| 261 | + | |
| 262 | + for( unsigned int i = 0; i < MENU_ITEMS_COUNT; ++i ) | |
| 263 | + { | |
| 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 ); | |
| 268 | + | |
| 269 | + tableView.Add( menuButton ); | |
| 270 | + tableView.SetFitHeight( i ); | |
| 271 | + } | |
| 272 | + | |
| 273 | + // Show the menu | |
| 274 | + mMenu.Show(); | |
| 275 | + mMenuShown = true; | |
| 276 | + } | |
| 277 | + | |
| 278 | + void HideMenu() | |
| 279 | + { | |
| 280 | + if( mMenu ) | |
| 281 | + { | |
| 282 | + mMenu.Hide(); | |
| 283 | + mMenu.Reset(); | |
| 284 | + } | |
| 285 | + | |
| 286 | + mMenuShown = false; | |
| 287 | + } | |
| 288 | + | |
| 289 | + bool OnMenuSelect( Toolkit::Button button ) | |
| 290 | + { | |
| 291 | + bool refresh = false; | |
| 292 | + | |
| 293 | + if( button.GetName() == POPUPS_MENU_ID ) | |
| 294 | + { | |
| 295 | + if( mDemoState != POPUP ) | |
| 296 | + { | |
| 297 | + refresh = true; | |
| 298 | + mDemoState = POPUP; | |
| 299 | + } | |
| 300 | + } | |
| 301 | + else if( button.GetName() == TABLEVIEW_MENU_ID ) | |
| 302 | + { | |
| 303 | + if( mDemoState != TABLEVIEW ) | |
| 304 | + { | |
| 305 | + refresh = true; | |
| 306 | + mDemoState = TABLEVIEW; | |
| 307 | + } | |
| 308 | + } | |
| 309 | + | |
| 310 | + if( refresh ) | |
| 311 | + { | |
| 312 | + SetTitle(); | |
| 313 | + | |
| 314 | + mItemView.Refresh(); | |
| 315 | + } | |
| 316 | + | |
| 317 | + HideMenu(); | |
| 318 | + return true; | |
| 319 | + } | |
| 320 | + | |
| 321 | + Toolkit::Popup CreatePopup() | |
| 322 | + { | |
| 323 | + Stage stage = Stage::GetCurrent(); | |
| 324 | + const float POPUP_WIDTH_DP = stage.GetSize().width * 0.75f; | |
| 325 | + | |
| 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 ) ); | |
| 331 | + popup.HideTail(); | |
| 332 | + | |
| 333 | + popup.OutsideTouchedSignal().Connect( this, &SizeNegotiationController::OnPopupOutsideTouched ); | |
| 334 | + | |
| 335 | + return popup; | |
| 336 | + } | |
| 337 | + | |
| 338 | + bool OnButtonClicked( Toolkit::Button button ) | |
| 339 | + { | |
| 340 | + if( button.GetName() == POPUP_BUTTON_EMPTY_ID ) | |
| 341 | + { | |
| 342 | + mPopup = CreatePopup(); | |
| 343 | + | |
| 344 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 345 | + mPopup.MarkDirtyForRelayout(); | |
| 346 | + | |
| 347 | + mPopup.Show(); | |
| 348 | + } | |
| 349 | + else if( button.GetName() == POPUP_BUTTON_TITLE_ID ) | |
| 350 | + { | |
| 351 | + mPopup = CreatePopup(); | |
| 352 | + mPopup.SetTitle( "Popup!" ); | |
| 353 | + | |
| 354 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 355 | + mPopup.MarkDirtyForRelayout(); | |
| 356 | + | |
| 357 | + mPopup.Show(); | |
| 358 | + } | |
| 359 | + else if( button.GetName() == POPUP_BUTTON_BUTTONS_1_ID ) | |
| 360 | + { | |
| 361 | + mPopup = CreatePopup(); | |
| 362 | + | |
| 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 ) ); | |
| 368 | + | |
| 369 | + okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); | |
| 370 | + | |
| 371 | + mPopup.AddButton( okayButton ); | |
| 372 | + | |
| 373 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 374 | + mPopup.MarkDirtyForRelayout(); | |
| 375 | + | |
| 376 | + mPopup.Show(); | |
| 377 | + } | |
| 378 | + else if( button.GetName() == POPUP_BUTTON_BUTTONS_2_ID ) | |
| 379 | + { | |
| 380 | + mPopup = CreatePopup(); | |
| 381 | + | |
| 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 ) ); | |
| 387 | + | |
| 388 | + cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); | |
| 389 | + | |
| 390 | + mPopup.AddButton( cancelButton ); | |
| 391 | + | |
| 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 ) ); | |
| 397 | + | |
| 398 | + okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); | |
| 399 | + | |
| 400 | + mPopup.AddButton( okayButton ); | |
| 401 | + | |
| 402 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 403 | + mPopup.MarkDirtyForRelayout(); | |
| 404 | + | |
| 405 | + mPopup.Show(); | |
| 406 | + } | |
| 407 | + else if( button.GetName() == POPUP_BUTTON_TITLE_BUTTONS_ID ) | |
| 408 | + { | |
| 409 | + mPopup = CreatePopup(); | |
| 410 | + mPopup.SetTitle( "Popup!" ); | |
| 411 | + | |
| 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 ) ); | |
| 417 | + | |
| 418 | + cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); | |
| 419 | + | |
| 420 | + mPopup.AddButton( cancelButton ); | |
| 421 | + | |
| 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 ) ); | |
| 427 | + | |
| 428 | + okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); | |
| 429 | + | |
| 430 | + mPopup.AddButton( okayButton ); | |
| 431 | + | |
| 432 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 433 | + mPopup.MarkDirtyForRelayout(); | |
| 434 | + | |
| 435 | + mPopup.Show(); | |
| 436 | + } | |
| 437 | + else if( button.GetName() == POPUP_BUTTON_CONTENT_TEXT_ID ) | |
| 438 | + { | |
| 439 | + mPopup = CreatePopup(); | |
| 440 | + | |
| 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 ) ); | |
| 450 | + | |
| 451 | + mPopup.Add( text ); | |
| 452 | + | |
| 453 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 454 | + mPopup.MarkDirtyForRelayout(); | |
| 455 | + | |
| 456 | + mPopup.Show(); | |
| 457 | + } | |
| 458 | + else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_ID ) | |
| 459 | + { | |
| 460 | + mPopup = CreatePopup(); | |
| 461 | + | |
| 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 ) ); | |
| 466 | + | |
| 467 | + mPopup.Add( image ); | |
| 468 | + | |
| 469 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 470 | + mPopup.MarkDirtyForRelayout(); | |
| 471 | + | |
| 472 | + mPopup.Show(); | |
| 473 | + } | |
| 474 | + else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID ) | |
| 475 | + { | |
| 476 | + mPopup = CreatePopup(); | |
| 477 | + | |
| 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 ) ); | |
| 481 | + | |
| 482 | + ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) ); | |
| 483 | + image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 484 | + | |
| 485 | + mPopup.Add( image ); | |
| 486 | + | |
| 487 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 488 | + mPopup.MarkDirtyForRelayout(); | |
| 489 | + | |
| 490 | + mPopup.Show(); | |
| 491 | + } | |
| 492 | + else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FIT_ID ) | |
| 493 | + { | |
| 494 | + mPopup = CreatePopup(); | |
| 495 | + | |
| 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 ) ); | |
| 499 | + | |
| 500 | + ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) ); | |
| 501 | + image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 502 | + image.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO ); | |
| 503 | + | |
| 504 | + mPopup.Add( image ); | |
| 505 | + | |
| 506 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 507 | + mPopup.MarkDirtyForRelayout(); | |
| 508 | + | |
| 509 | + mPopup.Show(); | |
| 510 | + } | |
| 511 | + else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FILL_ID ) | |
| 512 | + { | |
| 513 | + mPopup = CreatePopup(); | |
| 514 | + | |
| 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 ) ); | |
| 518 | + | |
| 519 | + ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) ); | |
| 520 | + image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 521 | + image.SetSizeScalePolicy( FILL_WITH_ASPECT_RATIO ); | |
| 522 | + | |
| 523 | + mPopup.Add( image ); | |
| 524 | + | |
| 525 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 526 | + mPopup.MarkDirtyForRelayout(); | |
| 527 | + | |
| 528 | + mPopup.Show(); | |
| 529 | + } | |
| 530 | + else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_ID ) | |
| 531 | + { | |
| 532 | + mPopup = CreatePopup(); | |
| 533 | + mPopup.SetTitle( "Popup!" ); | |
| 534 | + | |
| 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 ) ); | |
| 544 | + | |
| 545 | + mPopup.Add( text ); | |
| 546 | + | |
| 547 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 548 | + mPopup.MarkDirtyForRelayout(); | |
| 549 | + | |
| 550 | + mPopup.Show(); | |
| 551 | + } | |
| 552 | + else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS_ID ) | |
| 553 | + { | |
| 554 | + mPopup = CreatePopup(); | |
| 555 | + mPopup.SetTitle( "Popup!" ); | |
| 556 | + | |
| 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 ) ); | |
| 566 | + | |
| 567 | + mPopup.Add( text ); | |
| 568 | + | |
| 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 ) ); | |
| 574 | + | |
| 575 | + cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); | |
| 576 | + | |
| 577 | + mPopup.AddButton( cancelButton ); | |
| 578 | + | |
| 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 ) ); | |
| 584 | + | |
| 585 | + okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); | |
| 586 | + | |
| 587 | + mPopup.AddButton( okayButton ); | |
| 588 | + | |
| 589 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 590 | + mPopup.MarkDirtyForRelayout(); | |
| 591 | + | |
| 592 | + mPopup.Show(); | |
| 593 | + } | |
| 594 | + else if( button.GetName() == POPUP_BUTTON_COMPLEX_ID ) | |
| 595 | + { | |
| 596 | + mPopup = CreatePopup(); | |
| 597 | + mPopup.SetTitle( "Warning" ); | |
| 598 | + | |
| 599 | + // Content | |
| 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 ) ); | |
| 607 | + | |
| 608 | + // Text | |
| 609 | + { | |
| 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 ); | |
| 617 | + | |
| 618 | + content.AddChild( text, Toolkit::TableView::CellPosition( 0, 0 ) ); | |
| 619 | + } | |
| 620 | + | |
| 621 | + // Image | |
| 622 | + { | |
| 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 ) ); | |
| 629 | + } | |
| 630 | + | |
| 631 | + // Text 2 | |
| 632 | + { | |
| 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 ) ); | |
| 639 | + | |
| 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 ); | |
| 647 | + | |
| 648 | + root.AddChild( checkBox, Toolkit::TableView::CellPosition( 0, 0 ) ); | |
| 649 | + | |
| 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 ) ); | |
| 655 | + | |
| 656 | + root.AddChild( text, Toolkit::TableView::CellPosition( 0, 1 ) ); | |
| 657 | + | |
| 658 | + content.AddChild( root, Toolkit::TableView::CellPosition( 1, 0, 0, 2 ) ); // Column span 2 | |
| 659 | + } | |
| 660 | + | |
| 661 | + mPopup.Add( content ); | |
| 662 | + | |
| 663 | + // Buttons | |
| 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 ) ); | |
| 669 | + | |
| 670 | + cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); | |
| 671 | + | |
| 672 | + mPopup.AddButton( cancelButton ); | |
| 673 | + | |
| 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 ) ); | |
| 679 | + | |
| 680 | + okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); | |
| 681 | + | |
| 682 | + mPopup.AddButton( okayButton ); | |
| 683 | + | |
| 684 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 685 | + mPopup.MarkDirtyForRelayout(); | |
| 686 | + | |
| 687 | + mPopup.Show(); | |
| 688 | + } | |
| 689 | + else if( button.GetName() == TABLEVIEW_BUTTON_EMPTY_ID ) | |
| 690 | + { | |
| 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 ) ); | |
| 695 | + | |
| 696 | + | |
| 697 | + Toolkit::TableView table = Toolkit::TableView::New( 0, 0 ); | |
| 698 | + table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 699 | + | |
| 700 | + mPopup.Add( table ); | |
| 701 | + | |
| 702 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 703 | + mPopup.MarkDirtyForRelayout(); | |
| 704 | + | |
| 705 | + mPopup.Show(); | |
| 706 | + } | |
| 707 | + else if( button.GetName() == TABLEVIEW_BUTTON_1CELL_ID ) | |
| 708 | + { | |
| 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 ) ); | |
| 713 | + | |
| 714 | + | |
| 715 | + Toolkit::TableView table = Toolkit::TableView::New( 0, 0 ); | |
| 716 | + table.SetName( "TABLEVIEW_BUTTON_1CELL_ID" ); | |
| 717 | + table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 718 | + | |
| 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 ); | |
| 722 | + | |
| 723 | + mPopup.Add( table ); | |
| 724 | + | |
| 725 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 726 | + mPopup.MarkDirtyForRelayout(); | |
| 727 | + | |
| 728 | + mPopup.Show(); | |
| 729 | + } | |
| 730 | + else if( button.GetName() == TABLEVIEW_BUTTON_3CELL_ID ) | |
| 731 | + { | |
| 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 ) ); | |
| 736 | + | |
| 737 | + | |
| 738 | + Toolkit::TableView table = Toolkit::TableView::New( 0, 0 ); | |
| 739 | + table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 740 | + | |
| 741 | + { | |
| 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 ); | |
| 745 | + } | |
| 746 | + { | |
| 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 ); | |
| 750 | + } | |
| 751 | + { | |
| 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 ); | |
| 755 | + } | |
| 756 | + | |
| 757 | + mPopup.Add( table ); | |
| 758 | + | |
| 759 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 760 | + mPopup.MarkDirtyForRelayout(); | |
| 761 | + | |
| 762 | + mPopup.Show(); | |
| 763 | + } | |
| 764 | + else if( button.GetName() == TABLEVIEW_BUTTON_3X3CELL_ID ) | |
| 765 | + { | |
| 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 ) ); | |
| 770 | + | |
| 771 | + | |
| 772 | + Toolkit::TableView table = Toolkit::TableView::New( 3, 3 ); | |
| 773 | + table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 774 | + | |
| 775 | + // Column 0 | |
| 776 | + { | |
| 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 ) ); | |
| 780 | + } | |
| 781 | + { | |
| 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 ) ); | |
| 785 | + } | |
| 786 | + { | |
| 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 ) ); | |
| 790 | + } | |
| 791 | + | |
| 792 | + // Column 1 | |
| 793 | + { | |
| 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 ) ); | |
| 797 | + } | |
| 798 | + { | |
| 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 ) ); | |
| 802 | + } | |
| 803 | + { | |
| 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 ) ); | |
| 807 | + } | |
| 808 | + | |
| 809 | + // Column 2 | |
| 810 | + { | |
| 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 ) ); | |
| 814 | + } | |
| 815 | + { | |
| 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 ) ); | |
| 819 | + } | |
| 820 | + { | |
| 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 ) ); | |
| 824 | + } | |
| 825 | + | |
| 826 | + mPopup.Add( table ); | |
| 827 | + | |
| 828 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 829 | + mPopup.MarkDirtyForRelayout(); | |
| 830 | + | |
| 831 | + mPopup.Show(); | |
| 832 | + } | |
| 833 | + else if( button.GetName() == TABLEVIEW_BUTTON_FIXED1_ID ) | |
| 834 | + { | |
| 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 ) ); | |
| 839 | + | |
| 840 | + | |
| 841 | + Toolkit::TableView table = Toolkit::TableView::New( 3, 1 ); | |
| 842 | + table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 843 | + table.SetFixedHeight( 0, 50.0f ); | |
| 844 | + | |
| 845 | + { | |
| 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 ); | |
| 851 | + backing.Add( text ); | |
| 852 | + table.Add( backing ); | |
| 853 | + } | |
| 854 | + { | |
| 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 ); | |
| 860 | + backing.Add( text ); | |
| 861 | + table.Add( backing ); | |
| 862 | + } | |
| 863 | + { | |
| 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 ); | |
| 869 | + backing.Add( text ); | |
| 870 | + table.Add( backing ); | |
| 871 | + } | |
| 872 | + | |
| 873 | + mPopup.Add( table ); | |
| 874 | + | |
| 875 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 876 | + mPopup.MarkDirtyForRelayout(); | |
| 877 | + | |
| 878 | + mPopup.Show(); | |
| 879 | + } | |
| 880 | + else if( button.GetName() == TABLEVIEW_BUTTON_FIXED2_ID ) | |
| 881 | + { | |
| 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 ) ); | |
| 886 | + | |
| 887 | + | |
| 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 ); | |
| 892 | + | |
| 893 | + { | |
| 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 ); | |
| 899 | + backing.Add( text ); | |
| 900 | + table.Add( backing ); | |
| 901 | + } | |
| 902 | + { | |
| 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 ); | |
| 908 | + backing.Add( text ); | |
| 909 | + table.Add( backing ); | |
| 910 | + } | |
| 911 | + { | |
| 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 ); | |
| 917 | + backing.Add( text ); | |
| 918 | + table.Add( backing ); | |
| 919 | + } | |
| 920 | + | |
| 921 | + mPopup.Add( table ); | |
| 922 | + | |
| 923 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 924 | + mPopup.MarkDirtyForRelayout(); | |
| 925 | + | |
| 926 | + mPopup.Show(); | |
| 927 | + } | |
| 928 | + else if( button.GetName() == TABLEVIEW_BUTTON_FIT1_ID ) | |
| 929 | + { | |
| 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 ) ); | |
| 934 | + | |
| 935 | + | |
| 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 ); | |
| 940 | + | |
| 941 | + { | |
| 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 ) ); | |
| 946 | + | |
| 947 | + TextActor text = TextActor::New( "Fit" ); | |
| 948 | + text.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 949 | + text.SetParentOrigin( ParentOrigin::CENTER ); | |
| 950 | + backing.Add( text ); | |
| 951 | + | |
| 952 | + table.Add( backing ); | |
| 953 | + } | |
| 954 | + { | |
| 955 | + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) ); | |
| 956 | + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 957 | + | |
| 958 | + TextActor text = TextActor::New( "Fill" ); | |
| 959 | + text.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 960 | + text.SetParentOrigin( ParentOrigin::CENTER ); | |
| 961 | + backing.Add( text ); | |
| 962 | + | |
| 963 | + table.Add( backing ); | |
| 964 | + } | |
| 965 | + { | |
| 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 ) ); | |
| 970 | + | |
| 971 | + TextActor text = TextActor::New( "Fit" ); | |
| 972 | + text.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 973 | + text.SetParentOrigin( ParentOrigin::CENTER ); | |
| 974 | + backing.Add( text ); | |
| 975 | + | |
| 976 | + table.Add( backing ); | |
| 977 | + } | |
| 978 | + | |
| 979 | + mPopup.Add( table ); | |
| 980 | + | |
| 981 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 982 | + mPopup.MarkDirtyForRelayout(); | |
| 983 | + | |
| 984 | + mPopup.Show(); | |
| 985 | + } | |
| 986 | + else if( button.GetName() == TABLEVIEW_BUTTON_FIT2_ID ) | |
| 987 | + { | |
| 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 ) ); | |
| 992 | + | |
| 993 | + | |
| 994 | + Toolkit::TableView table = Toolkit::TableView::New( 3, 1 ); | |
| 995 | + table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 996 | + table.SetFitHeight( 1 ); | |
| 997 | + | |
| 998 | + { | |
| 999 | + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) ); | |
| 1000 | + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 1001 | + | |
| 1002 | + TextActor text = TextActor::New( "Fill" ); | |
| 1003 | + text.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 1004 | + text.SetParentOrigin( ParentOrigin::CENTER ); | |
| 1005 | + backing.Add( text ); | |
| 1006 | + | |
| 1007 | + table.Add( backing ); | |
| 1008 | + } | |
| 1009 | + { | |
| 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 ) ); | |
| 1014 | + | |
| 1015 | + TextActor text = TextActor::New( "Fit" ); | |
| 1016 | + text.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 1017 | + text.SetParentOrigin( ParentOrigin::CENTER ); | |
| 1018 | + backing.Add( text ); | |
| 1019 | + | |
| 1020 | + table.Add( backing ); | |
| 1021 | + } | |
| 1022 | + { | |
| 1023 | + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) ); | |
| 1024 | + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 1025 | + | |
| 1026 | + TextActor text = TextActor::New( "Fill" ); | |
| 1027 | + text.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 1028 | + text.SetParentOrigin( ParentOrigin::CENTER ); | |
| 1029 | + backing.Add( text ); | |
| 1030 | + | |
| 1031 | + table.Add( backing ); | |
| 1032 | + } | |
| 1033 | + | |
| 1034 | + mPopup.Add( table ); | |
| 1035 | + | |
| 1036 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 1037 | + mPopup.MarkDirtyForRelayout(); | |
| 1038 | + | |
| 1039 | + mPopup.Show(); | |
| 1040 | + } | |
| 1041 | + else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL1_ID ) | |
| 1042 | + { | |
| 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 ); | |
| 1048 | + | |
| 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 ); | |
| 1055 | + | |
| 1056 | + { | |
| 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 ) ); | |
| 1061 | + | |
| 1062 | + TextActor text = TextActor::New( "Fit" ); | |
| 1063 | + text.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 1064 | + text.SetParentOrigin( ParentOrigin::CENTER ); | |
| 1065 | + backing.Add( text ); | |
| 1066 | + | |
| 1067 | + table.Add( backing ); | |
| 1068 | + } | |
| 1069 | + { | |
| 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 ) ); | |
| 1074 | + | |
| 1075 | + TextActor text = TextActor::New( "Fit" ); | |
| 1076 | + text.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 1077 | + text.SetParentOrigin( ParentOrigin::CENTER ); | |
| 1078 | + backing.Add( text ); | |
| 1079 | + | |
| 1080 | + table.Add( backing ); | |
| 1081 | + } | |
| 1082 | + { | |
| 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 ) ); | |
| 1087 | + | |
| 1088 | + TextActor text = TextActor::New( "Fit" ); | |
| 1089 | + text.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 1090 | + text.SetParentOrigin( ParentOrigin::CENTER ); | |
| 1091 | + backing.Add( text ); | |
| 1092 | + | |
| 1093 | + table.Add( backing ); | |
| 1094 | + } | |
| 1095 | + | |
| 1096 | + mPopup.Add( table ); | |
| 1097 | + | |
| 1098 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 1099 | + mPopup.MarkDirtyForRelayout(); | |
| 1100 | + | |
| 1101 | + mPopup.Show(); | |
| 1102 | + } | |
| 1103 | + else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL2_ID ) | |
| 1104 | + { | |
| 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 ); | |
| 1110 | + | |
| 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 ); | |
| 1116 | + | |
| 1117 | + { | |
| 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 ) ); | |
| 1122 | + | |
| 1123 | + TextActor text = TextActor::New( "Fit" ); | |
| 1124 | + text.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 1125 | + text.SetParentOrigin( ParentOrigin::CENTER ); | |
| 1126 | + backing.Add( text ); | |
| 1127 | + | |
| 1128 | + table.Add( backing ); | |
| 1129 | + } | |
| 1130 | + { | |
| 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 ) ); | |
| 1135 | + | |
| 1136 | + TextActor text = TextActor::New( "Fit" ); | |
| 1137 | + text.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 1138 | + text.SetParentOrigin( ParentOrigin::CENTER ); | |
| 1139 | + backing.Add( text ); | |
| 1140 | + | |
| 1141 | + table.Add( backing ); | |
| 1142 | + } | |
| 1143 | + | |
| 1144 | + mPopup.Add( table ); | |
| 1145 | + | |
| 1146 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 1147 | + mPopup.MarkDirtyForRelayout(); | |
| 1148 | + | |
| 1149 | + mPopup.Show(); | |
| 1150 | + } | |
| 1151 | + else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL3_ID ) | |
| 1152 | + { | |
| 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 ); | |
| 1158 | + | |
| 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 ); | |
| 1164 | + | |
| 1165 | + { | |
| 1166 | + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) ); | |
| 1167 | + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 1168 | + | |
| 1169 | + TextActor text = TextActor::New( "Fixed" ); | |
| 1170 | + text.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 1171 | + text.SetParentOrigin( ParentOrigin::CENTER ); | |
| 1172 | + backing.Add( text ); | |
| 1173 | + | |
| 1174 | + table.Add( backing ); | |
| 1175 | + } | |
| 1176 | + { | |
| 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 ) ); | |
| 1181 | + | |
| 1182 | + TextActor text = TextActor::New( "Fit" ); | |
| 1183 | + text.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 1184 | + text.SetParentOrigin( ParentOrigin::CENTER ); | |
| 1185 | + backing.Add( text ); | |
| 1186 | + | |
| 1187 | + table.Add( backing ); | |
| 1188 | + } | |
| 1189 | + | |
| 1190 | + mPopup.Add( table ); | |
| 1191 | + | |
| 1192 | + // The popup is not yet on the stage so needs to be flaged as dirty | |
| 1193 | + mPopup.MarkDirtyForRelayout(); | |
| 1194 | + | |
| 1195 | + mPopup.Show(); | |
| 1196 | + } | |
| 1197 | + else if( button.GetName() == OKAY_BUTTON_ID || button.GetName() == CANCEL_BUTTON_ID ) | |
| 1198 | + { | |
| 1199 | + if( mPopup ) | |
| 1200 | + { | |
| 1201 | + mPopup.Hide(); | |
| 1202 | + } | |
| 1203 | + } | |
| 1204 | + | |
| 1205 | + return true; | |
| 1206 | + } | |
| 1207 | + | |
| 1208 | + void OnPopupOutsideTouched() | |
| 1209 | + { | |
| 1210 | + if( mPopup ) | |
| 1211 | + { | |
| 1212 | + mPopup.Hide(); | |
| 1213 | + } | |
| 1214 | + } | |
| 1215 | + | |
| 1216 | + void OnKeyEvent( const KeyEvent& event ) | |
| 1217 | + { | |
| 1218 | + if( event.state == KeyEvent::Down ) | |
| 1219 | + { | |
| 1220 | + if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) | |
| 1221 | + { | |
| 1222 | + // Exit application when click back or escape. | |
| 1223 | + mApplication.Quit(); | |
| 1224 | + } | |
| 1225 | + } | |
| 1226 | + } | |
| 1227 | + | |
| 1228 | +public: // From ItemFactory | |
| 1229 | + | |
| 1230 | + /** | |
| 1231 | + * @brief Return the number of items to display in the item view | |
| 1232 | + * | |
| 1233 | + * @return Return the number of items to display | |
| 1234 | + */ | |
| 1235 | + virtual unsigned int GetNumberOfItems() | |
| 1236 | + { | |
| 1237 | + switch( mDemoState ) | |
| 1238 | + { | |
| 1239 | + case POPUP: | |
| 1240 | + { | |
| 1241 | + return POPUP_BUTTON_ITEMS_COUNT; | |
| 1242 | + } | |
| 1243 | + | |
| 1244 | + case TABLEVIEW: | |
| 1245 | + { | |
| 1246 | + return TABLEVIEW_BUTTON_ITEMS_COUNT; | |
| 1247 | + } | |
| 1248 | + | |
| 1249 | + default: | |
| 1250 | + { | |
| 1251 | + break; | |
| 1252 | + } | |
| 1253 | + } | |
| 1254 | + | |
| 1255 | + return 0; | |
| 1256 | + } | |
| 1257 | + | |
| 1258 | + /** | |
| 1259 | + * @brief Create a new item to populate the item view with | |
| 1260 | + * | |
| 1261 | + * @param[in] itemId The index of the item to create | |
| 1262 | + * @return Return the created actor for the given ID | |
| 1263 | + */ | |
| 1264 | + virtual Actor NewItem(unsigned int itemId) | |
| 1265 | + { | |
| 1266 | + const ButtonItem* buttonDataArray = NULL; | |
| 1267 | + switch( mDemoState ) | |
| 1268 | + { | |
| 1269 | + case POPUP: | |
| 1270 | + { | |
| 1271 | + buttonDataArray = POPUP_BUTTON_ITEMS; | |
| 1272 | + break; | |
| 1273 | + } | |
| 1274 | + | |
| 1275 | + case TABLEVIEW: | |
| 1276 | + { | |
| 1277 | + buttonDataArray = TABLEVIEW_BUTTON_ITEMS; | |
| 1278 | + break; | |
| 1279 | + } | |
| 1280 | + | |
| 1281 | + default: | |
| 1282 | + { | |
| 1283 | + break; | |
| 1284 | + } | |
| 1285 | + } | |
| 1286 | + | |
| 1287 | + if( buttonDataArray ) | |
| 1288 | + { | |
| 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 ); | |
| 1293 | + | |
| 1294 | + popupButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) ); | |
| 1295 | + popupButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) ); | |
| 1296 | + | |
| 1297 | + popupButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); | |
| 1298 | + | |
| 1299 | + return popupButton; | |
| 1300 | + } | |
| 1301 | + | |
| 1302 | + return Actor(); | |
| 1303 | + } | |
| 1304 | + | |
| 1305 | +private: | |
| 1306 | + | |
| 1307 | + enum DemoState | |
| 1308 | + { | |
| 1309 | + POPUP, | |
| 1310 | + TABLEVIEW | |
| 1311 | + }; | |
| 1312 | + | |
| 1313 | + Application& mApplication; | |
| 1314 | + Toolkit::View mView; ///< The View instance. | |
| 1315 | + Toolkit::ToolBar mToolBar; ///< The View's Toolbar. | |
| 1316 | + Layer mContentLayer; ///< Content layer | |
| 1317 | + | |
| 1318 | + Toolkit::TextView mTitleActor; ///< Title text | |
| 1319 | + | |
| 1320 | + Toolkit::Popup mMenu; ///< The navigation menu | |
| 1321 | + bool mMenuShown; ///< If the navigation menu is currently being displayed or not | |
| 1322 | + | |
| 1323 | + Toolkit::Popup mPopup; | |
| 1324 | + | |
| 1325 | + Toolkit::ItemView mItemView; ///< ItemView to hold test images | |
| 1326 | + | |
| 1327 | + DemoState mDemoState; | |
| 1328 | +}; | |
| 1329 | + | |
| 1330 | +void RunTest( Application& application ) | |
| 1331 | +{ | |
| 1332 | + SizeNegotiationController test( application ); | |
| 1333 | + | |
| 1334 | + application.MainLoop(); | |
| 1335 | +} | |
| 1336 | + | |
| 1337 | +// Entry point for Linux & SLP applications | |
| 1338 | +// | |
| 1339 | +int main( int argc, char **argv ) | |
| 1340 | +{ | |
| 1341 | + Application application = Application::New( &argc, &argv ); | |
| 1342 | + | |
| 1343 | + RunTest( application ); | |
| 1344 | + | |
| 1345 | + return 0; | |
| 1346 | +} | ... | ... |
examples/text-view/text-view-example.cpp
| ... | ... | @@ -75,14 +75,14 @@ const TableString TABLE_STRINGS[] = { { "HelveticaNue", "Regular", 8.0f, |
| 75 | 75 | { "HelveticaNue", "Regular", 12.0f, Dali::TextStyle::REGULAR, Vector4( 0.5f, 1.0f, 1.0f, 1.0f ), "Hola", Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::VerticalCenter, 10.0f, 90.0f, { 2, 0, 4, 2 } }, |
| 76 | 76 | { "HelveticaNue", "Regular", 18.0f, Dali::TextStyle::BOLD, Vector4( 0.5f, 1.0f, 0.5f, 1.0f ), "Bonjour", Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::VerticalTop, 10.0f, 0.0f, { 2, 2, 2, 4 } }, |
| 77 | 77 | { "HelveticaNue", "Regular", 12.0f, Dali::TextStyle::REGULAR, Vector4( 1.0f, 1.0f, 0.5f, 1.0f ), "Ciao", Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::VerticalCenter, 10.0f, 0.0f, { 2, 7, 2, 3 } }, |
| 78 | - { "HelveticaNue", "Regular", 26.0f, Dali::TextStyle::EXTRABLACK, Vector4( 0.5f, 0.0f, 0.0f, 1.0f ), "Hello", Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::VerticalCenter, 10.0f, 0.0f, { 4, 2, 1, 6 } }, | |
| 78 | + { "HelveticaNue", "Regular", 23.0f, Dali::TextStyle::EXTRABLACK, Vector4( 0.5f, 0.0f, 0.0f, 1.0f ), "์๋ ํ์ธ์", Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::VerticalCenter, 20.0f, 0.0f, { 4, 3, 1, 6 } }, | |
| 79 | 79 | { "HelveticaNue", "Regular", 8.0f, Dali::TextStyle::DEMIBOLD, Vector4( 0.0f, 0.5f, 0.0f, 1.0f ), "Top of the morning to you", Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::VerticalCenter, 10.0f, 90.0f, { 4, 10, 8, 2 } }, |
| 80 | - { "HelveticaNue", "Regular", 13.0f, Dali::TextStyle::DEMIBOLD, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), "เคนเฅเคฒเฅ", Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::VerticalTop, 10.0f, 0.0f, { 6, 1, 1, 3 } }, | |
| 80 | + { "HelveticaNue", "Regular", 13.0f, Dali::TextStyle::DEMIBOLD, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), "เคนเฅเคฒเฅ", Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::VerticalTop, 10.0f, 0.0f, { 6, 1, 1, 3 } }, | |
| 81 | 81 | { "HelveticaNue", "Regular", 8.0f, Dali::TextStyle::DEMIBOLD, Vector4( 1.0f, 1.0f, 0.0f, 1.0f ), "เธชเธงเธฑเธชเธเธต", Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::VerticalTop, 10.0f, 90.0f, { 6, 5, 2, 1 } }, |
| 82 | 82 | { "HelveticaNue", "Regular", 18.0f, Dali::TextStyle::REGULAR, Vector4( 0.0f, 1.0f, 1.0f, 1.0f ), "ไฝ ๅฅฝ", Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::VerticalBottom, 10.0f, 0.0f, { 6, 6, 1, 3 } }, |
| 83 | 83 | { "HelveticaNue", "Regular", 34.0f, Dali::TextStyle::REGULAR, Vector4( 0.0f, 0.0f, 1.0f, 1.0f ), "G'day", Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::VerticalCenter, 10.0f, 0.0f, { 7, 0, 2, 10 } }, |
| 84 | 84 | { "HelveticaNue", "Regular", 16.0f, Dali::TextStyle::EXTRABLACK, Vector4( 0.0f, 0.5f, 1.0f, 1.0f ), "ู ุฑุญุจุง", Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::VerticalTop, 10.0f, 0.0f, { 9, 1, 2, 4 } }, |
| 85 | - { "HelveticaNue", "Regular", 10.0f, Dali::TextStyle::EXTRABLACK, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ), "ใใใซใกใฏ", Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::VerticalCenter, 10.0f, 0.0f, { 10, 0, 2, 6 } }, | |
| 85 | + { "HelveticaNue", "Regular", 10.0f, Dali::TextStyle::EXTRABLACK, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ), "ใใใซใกใฏ", Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::VerticalCenter, 10.0f, 0.0f, { 10, 0, 2, 6 } }, | |
| 86 | 86 | { "HelveticaNue", "Regular", 14.0f, Dali::TextStyle::REGULAR, Vector4( 0.0f, 1.0f, 0.0f, 1.0f ), "aloha", Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::VerticalTop, 10.0f, 0.0f, { 10, 6, 2, 4 } } |
| 87 | 87 | }; |
| 88 | 88 | |
| ... | ... | @@ -132,7 +132,7 @@ public: |
| 132 | 132 | textContainer.SetParentOrigin( ParentOrigin::TOP_LEFT ); |
| 133 | 133 | textContainer.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 134 | 134 | textContainer.SetPosition( 0, TOOLBAR_HEIGHT ); |
| 135 | - textContainer.SetSize( stage.GetSize().width, stage.GetSize().height - TOOLBAR_HEIGHT ); | |
| 135 | + textContainer.SetPreferredSize( Vector2( stage.GetSize().width, stage.GetSize().height - TOOLBAR_HEIGHT ) ); | |
| 136 | 136 | |
| 137 | 137 | mContentLayer.Add( textContainer ); |
| 138 | 138 | |
| ... | ... | @@ -151,10 +151,12 @@ public: |
| 151 | 151 | Toolkit::TextView textView = Toolkit::TextView::New( tableString.text ); |
| 152 | 152 | textView.SetStyleToCurrentText( textStyle ); |
| 153 | 153 | textView.SetOrientation( Dali::Degree( tableString.orientation ), Vector3( 0.0f, 0.0f, 1.0f ) ); |
| 154 | + textView.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); | |
| 154 | 155 | |
| 155 | 156 | Toolkit::Alignment alignmentContainer = Toolkit::Alignment::New( tableString.horizontalAlignment, tableString.verticalAlignment ); |
| 156 | - alignmentContainer.SetPadding( Toolkit::Alignment::Padding( tableString.padding, tableString.padding, tableString.padding, tableString.padding ) ); | |
| 157 | - alignmentContainer.SetScaling( Toolkit::Alignment::ScaleToFill ); | |
| 157 | + Actor alignmentContainerActor = alignmentContainer; | |
| 158 | + alignmentContainerActor.SetPadding( Padding( tableString.padding, tableString.padding, tableString.padding, tableString.padding ) ); | |
| 159 | + alignmentContainer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); | |
| 158 | 160 | alignmentContainer.Add( textView ); |
| 159 | 161 | |
| 160 | 162 | textContainer.AddChild( alignmentContainer, Toolkit::TableView::CellPosition( tableString.cellPosition.row, tableString.cellPosition.column, tableString.cellPosition.rowSpan, tableString.cellPosition.columnSpan ) ); | ... | ... |
resources/scripts/animated-buttons.json
| ... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 | { |
| 4 | 4 | "type": "ImageActor", |
| 5 | 5 | "name": "On", |
| 6 | + "relayout-enabled": false, | |
| 6 | 7 | "position": [ |
| 7 | 8 | 374, |
| 8 | 9 | 215, |
| ... | ... | @@ -11,7 +12,7 @@ |
| 11 | 12 | "size": [ |
| 12 | 13 | 144, |
| 13 | 14 | 144, |
| 14 | - 1 | |
| 15 | + 1 | |
| 15 | 16 | ], |
| 16 | 17 | "sizeAspectRatio": false, |
| 17 | 18 | "color": [ |
| ... | ... | @@ -33,6 +34,7 @@ |
| 33 | 34 | { |
| 34 | 35 | "type": "ImageActor", |
| 35 | 36 | "name": "Off", |
| 37 | + "relayout-enabled": false, | |
| 36 | 38 | "position": [ |
| 37 | 39 | 129, |
| 38 | 40 | 215, |
| ... | ... | @@ -41,7 +43,7 @@ |
| 41 | 43 | "size": [ |
| 42 | 44 | 144, |
| 43 | 45 | 144, |
| 44 | - 1 | |
| 46 | + 1 | |
| 45 | 47 | ], |
| 46 | 48 | "sizeAspectRatio": false, |
| 47 | 49 | "color": [ |
| ... | ... | @@ -63,6 +65,7 @@ |
| 63 | 65 | { |
| 64 | 66 | "type": "ImageActor", |
| 65 | 67 | "name": "Right", |
| 68 | + "relayout-enabled": false, | |
| 66 | 69 | "position": [ |
| 67 | 70 | 418.5, |
| 68 | 71 | 214.5, |
| ... | ... | @@ -71,7 +74,7 @@ |
| 71 | 74 | "size": [ |
| 72 | 75 | 85, |
| 73 | 76 | 161, |
| 74 | - 1 | |
| 77 | + 1 | |
| 75 | 78 | ], |
| 76 | 79 | "sizeAspectRatio": false, |
| 77 | 80 | "visible": true, |
| ... | ... | @@ -94,6 +97,7 @@ |
| 94 | 97 | { |
| 95 | 98 | "type": "ImageActor", |
| 96 | 99 | "name": "Left", |
| 100 | + "relayout-enabled": false, | |
| 97 | 101 | "position": [ |
| 98 | 102 | 331, |
| 99 | 103 | 214.5, |
| ... | ... | @@ -102,7 +106,7 @@ |
| 102 | 106 | "size": [ |
| 103 | 107 | 88, |
| 104 | 108 | 161, |
| 105 | - 1 | |
| 109 | + 1 | |
| 106 | 110 | ], |
| 107 | 111 | "sizeAspectRatio": false, |
| 108 | 112 | "visible": true, |
| ... | ... | @@ -125,6 +129,7 @@ |
| 125 | 129 | { |
| 126 | 130 | "type": "ImageActor", |
| 127 | 131 | "name": "Middle", |
| 132 | + "relayout-enabled": false, | |
| 128 | 133 | "position": [ |
| 129 | 134 | 375.5, |
| 130 | 135 | 214.5, |
| ... | ... | @@ -138,7 +143,7 @@ |
| 138 | 143 | "size": [ |
| 139 | 144 | 1, |
| 140 | 145 | 161, |
| 141 | - 1 | |
| 146 | + 1 | |
| 142 | 147 | ], |
| 143 | 148 | "sizeAspectRatio": false, |
| 144 | 149 | "color": [ |
| ... | ... | @@ -160,6 +165,7 @@ |
| 160 | 165 | { |
| 161 | 166 | "type": "ImageActor", |
| 162 | 167 | "name": "Jelly", |
| 168 | + "relayout-enabled": false, | |
| 163 | 169 | "position": [ |
| 164 | 170 | 374, |
| 165 | 171 | 215, |
| ... | ... | @@ -168,7 +174,7 @@ |
| 168 | 174 | "size": [ |
| 169 | 175 | 144, |
| 170 | 176 | 144, |
| 171 | - 1 | |
| 177 | + 1 | |
| 172 | 178 | ], |
| 173 | 179 | "sizeAspectRatio": false, |
| 174 | 180 | "color": [ |
| ... | ... | @@ -190,6 +196,7 @@ |
| 190 | 196 | { |
| 191 | 197 | "type": "Control", |
| 192 | 198 | "name": "Left Black", |
| 199 | + "relayout-enabled": false, | |
| 193 | 200 | "position": [ |
| 194 | 201 | 144.5, |
| 195 | 202 | 218.5, |
| ... | ... | @@ -198,7 +205,7 @@ |
| 198 | 205 | "size": [ |
| 199 | 206 | 275, |
| 200 | 207 | 243, |
| 201 | - 1 | |
| 208 | + 1 | |
| 202 | 209 | ], |
| 203 | 210 | "sizeAspectRatio": false, |
| 204 | 211 | "background-color": [ |
| ... | ... | @@ -218,6 +225,7 @@ |
| 218 | 225 | { |
| 219 | 226 | "type": "Control", |
| 220 | 227 | "name": "Right Black", |
| 228 | + "relayout-enabled": false, | |
| 221 | 229 | "position": [ |
| 222 | 230 | 629.5, |
| 223 | 231 | 218.5, |
| ... | ... | @@ -226,7 +234,7 @@ |
| 226 | 234 | "size": [ |
| 227 | 235 | 335, |
| 228 | 236 | 243, |
| 229 | - 1 | |
| 237 | + 1 | |
| 230 | 238 | ], |
| 231 | 239 | "sizeAspectRatio": false, |
| 232 | 240 | "background-color": [ |
| ... | ... | @@ -246,6 +254,7 @@ |
| 246 | 254 | { |
| 247 | 255 | "type": "ImageActor", |
| 248 | 256 | "name": "JellyOff", |
| 257 | + "relayout-enabled": false, | |
| 249 | 258 | "position": [ |
| 250 | 259 | 121, |
| 251 | 260 | -117, |
| ... | ... | @@ -254,7 +263,7 @@ |
| 254 | 263 | "size": [ |
| 255 | 264 | 144, |
| 256 | 265 | 144, |
| 257 | - 1 | |
| 266 | + 1 | |
| 258 | 267 | ], |
| 259 | 268 | "sizeAspectRatio": false, |
| 260 | 269 | "color": [ |
| ... | ... | @@ -276,6 +285,7 @@ |
| 276 | 285 | { |
| 277 | 286 | "type": "Control", |
| 278 | 287 | "name": "Control On", |
| 288 | + "relayout-enabled": false, | |
| 279 | 289 | "position": [ |
| 280 | 290 | 371.26116838487997, |
| 281 | 291 | 217.33333333333331, |
| ... | ... | @@ -284,7 +294,7 @@ |
| 284 | 294 | "size": [ |
| 285 | 295 | 196, |
| 286 | 296 | 184, |
| 287 | - 1 | |
| 297 | + 1 | |
| 288 | 298 | ], |
| 289 | 299 | "sizeAspectRatio": false, |
| 290 | 300 | "scale": [ |
| ... | ... | @@ -310,6 +320,7 @@ |
| 310 | 320 | { |
| 311 | 321 | "type": "Control", |
| 312 | 322 | "name": "Control Off", |
| 323 | + "relayout-enabled": false, | |
| 313 | 324 | "position": [ |
| 314 | 325 | 123.5, |
| 315 | 326 | -117, |
| ... | ... | @@ -318,7 +329,7 @@ |
| 318 | 329 | "size": [ |
| 319 | 330 | 193, |
| 320 | 331 | 182, |
| 321 | - 1 | |
| 332 | + 1 | |
| 322 | 333 | ], |
| 323 | 334 | "sizeAspectRatio": false, |
| 324 | 335 | "color": [ | ... | ... |
resources/scripts/animated-colors.json
| ... | ... | @@ -18,9 +18,11 @@ |
| 18 | 18 | "stage": [ |
| 19 | 19 | { |
| 20 | 20 | "type": "Control", |
| 21 | + "relayout-enabled": false, | |
| 21 | 22 | "actors": [ |
| 22 | 23 | { |
| 23 | 24 | "type": "Control", |
| 25 | + "relayout-enabled": true, | |
| 24 | 26 | "actors": [], |
| 25 | 27 | "name": "Control 8", |
| 26 | 28 | "position": [ |
| ... | ... | @@ -60,9 +62,11 @@ |
| 60 | 62 | }, |
| 61 | 63 | { |
| 62 | 64 | "type": "Control", |
| 65 | + "relayout-enabled": false, | |
| 63 | 66 | "actors": [ |
| 64 | 67 | { |
| 65 | 68 | "type": "Control", |
| 69 | + "relayout-enabled": false, | |
| 66 | 70 | "actors": [], |
| 67 | 71 | "name": "Container 2", |
| 68 | 72 | "position": [ |
| ... | ... | @@ -102,9 +106,11 @@ |
| 102 | 106 | }, |
| 103 | 107 | { |
| 104 | 108 | "type": "Control", |
| 109 | + "relayout-enabled": false, | |
| 105 | 110 | "actors": [ |
| 106 | 111 | { |
| 107 | 112 | "type": "Control", |
| 113 | + "relayout-enabled": false, | |
| 108 | 114 | "actors": [], |
| 109 | 115 | "name": "Container 4", |
| 110 | 116 | "position": [ |
| ... | ... | @@ -181,9 +187,11 @@ |
| 181 | 187 | }, |
| 182 | 188 | { |
| 183 | 189 | "type": "Control", |
| 190 | + "relayout-enabled": false, | |
| 184 | 191 | "actors": [ |
| 185 | 192 | { |
| 186 | 193 | "type": "Control", |
| 194 | + "relayout-enabled": false, | |
| 187 | 195 | "actors": [], |
| 188 | 196 | "name": "Container 5", |
| 189 | 197 | "position": [ |
| ... | ... | @@ -223,9 +231,11 @@ |
| 223 | 231 | }, |
| 224 | 232 | { |
| 225 | 233 | "type": "Control", |
| 234 | + "relayout-enabled": false, | |
| 226 | 235 | "actors": [ |
| 227 | 236 | { |
| 228 | 237 | "type": "Control", |
| 238 | + "relayout-enabled": false, | |
| 229 | 239 | "actors": [], |
| 230 | 240 | "name": "Container 7", |
| 231 | 241 | "position": [ |
| ... | ... | @@ -302,9 +312,11 @@ |
| 302 | 312 | }, |
| 303 | 313 | { |
| 304 | 314 | "type": "Control", |
| 315 | + "relayout-enabled": false, | |
| 305 | 316 | "actors": [ |
| 306 | 317 | { |
| 307 | 318 | "type": "Control", |
| 319 | + "relayout-enabled": false, | |
| 308 | 320 | "actors": [], |
| 309 | 321 | "name": "Container 8", |
| 310 | 322 | "position": [ |
| ... | ... | @@ -344,9 +356,11 @@ |
| 344 | 356 | }, |
| 345 | 357 | { |
| 346 | 358 | "type": "Control", |
| 359 | + "relayout-enabled": false, | |
| 347 | 360 | "actors": [ |
| 348 | 361 | { |
| 349 | 362 | "type": "Control", |
| 363 | + "relayout-enabled": false, | |
| 350 | 364 | "actors": [], |
| 351 | 365 | "name": "Container 10", |
| 352 | 366 | "position": [ |
| ... | ... | @@ -534,9 +548,11 @@ |
| 534 | 548 | }, |
| 535 | 549 | { |
| 536 | 550 | "type": "Control", |
| 551 | + "relayout-enabled": false, | |
| 537 | 552 | "actors": [ |
| 538 | 553 | { |
| 539 | 554 | "type": "Control", |
| 555 | + "relayout-enabled": false, | |
| 540 | 556 | "actors": [], |
| 541 | 557 | "name": "Control 4", |
| 542 | 558 | "position": [ |
| ... | ... | @@ -613,9 +629,11 @@ |
| 613 | 629 | }, |
| 614 | 630 | { |
| 615 | 631 | "type": "Control", |
| 632 | + "relayout-enabled": false, | |
| 616 | 633 | "actors": [ |
| 617 | 634 | { |
| 618 | 635 | "type": "Control", |
| 636 | + "relayout-enabled": false, | |
| 619 | 637 | "actors": [ |
| 620 | 638 | { |
| 621 | 639 | "type": "Control", |
| ... | ... | @@ -695,6 +713,7 @@ |
| 695 | 713 | }, |
| 696 | 714 | { |
| 697 | 715 | "type": "Control", |
| 716 | + "relayout-enabled": false, | |
| 698 | 717 | "actors": [], |
| 699 | 718 | "name": "Container 11", |
| 700 | 719 | "position": [ |
| ... | ... | @@ -734,12 +753,15 @@ |
| 734 | 753 | }, |
| 735 | 754 | { |
| 736 | 755 | "type": "Control", |
| 756 | + "relayout-enabled": false, | |
| 737 | 757 | "actors": [ |
| 738 | 758 | { |
| 739 | 759 | "type": "Control", |
| 760 | + "relayout-enabled": false, | |
| 740 | 761 | "actors": [ |
| 741 | 762 | { |
| 742 | 763 | "type": "Control", |
| 764 | + "relayout-enabled": false, | |
| 743 | 765 | "actors": [], |
| 744 | 766 | "name": "Container 15", |
| 745 | 767 | "position": [ |
| ... | ... | @@ -816,6 +838,7 @@ |
| 816 | 838 | }, |
| 817 | 839 | { |
| 818 | 840 | "type": "Control", |
| 841 | + "relayout-enabled": false, | |
| 819 | 842 | "actors": [], |
| 820 | 843 | "name": "Container 16", |
| 821 | 844 | "position": [ | ... | ... |
resources/scripts/animation.json
resources/scripts/background-color.json
| ... | ... | @@ -29,6 +29,7 @@ |
| 29 | 29 | // A container with a yellow background |
| 30 | 30 | { |
| 31 | 31 | "type": "Control", |
| 32 | + "relayout-enabled": false, | |
| 32 | 33 | "parent-origin": "CENTER", |
| 33 | 34 | "anchor-point": "BOTTOM_CENTER", |
| 34 | 35 | "background-color": [1, 1, 0, 1], |
| ... | ... | @@ -38,6 +39,7 @@ |
| 38 | 39 | // A container with an image |
| 39 | 40 | { |
| 40 | 41 | "type": "Control", |
| 42 | + "relayout-enabled": false, | |
| 41 | 43 | "parent-origin": "CENTER", |
| 42 | 44 | "anchor-point": "TOP_CENTER", |
| 43 | 45 | "size": [400, 150, 1], |
| ... | ... | @@ -51,6 +53,7 @@ |
| 51 | 53 | // A container with the same image blended in with a blue background |
| 52 | 54 | { |
| 53 | 55 | "type": "Control", |
| 56 | + "relayout-enabled": false, | |
| 54 | 57 | "parent-origin": "BOTTOM_CENTER", |
| 55 | 58 | "anchor-point": "BOTTOM_CENTER", |
| 56 | 59 | "size": [400, 150, 1], | ... | ... |
shared/view.h
| ... | ... | @@ -84,10 +84,12 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar, |
| 84 | 84 | const Dali::TextStyle& textStyle ) |
| 85 | 85 | { |
| 86 | 86 | Dali::Layer toolBarLayer = Dali::Layer::New(); |
| 87 | + toolBarLayer.SetName( "TOOLBAR_LAYER" ); | |
| 87 | 88 | toolBarLayer.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER ); |
| 88 | 89 | toolBarLayer.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER ); |
| 89 | - toolBarLayer.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::Property::SIZE, Dali::ParentSource( Dali::Actor::Property::SIZE ), Dali::SourceWidthFixedHeight( style.mToolBarHeight ) ) ); | |
| 90 | - toolBarLayer.SetSize( 0.0f, style.mToolBarHeight ); | |
| 90 | + toolBarLayer.SetPreferredSize( Dali::Vector2( 0.0f, style.mToolBarHeight ) ); | |
| 91 | + toolBarLayer.SetResizePolicy( Dali::FILL_TO_PARENT, Dali::WIDTH ); | |
| 92 | + toolBarLayer.SetResizePolicy( Dali::FIXED, Dali::HEIGHT ); | |
| 91 | 93 | |
| 92 | 94 | // Raise tool bar layer to the top. |
| 93 | 95 | toolBarLayer.RaiseToTop(); |
| ... | ... | @@ -95,12 +97,14 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar, |
| 95 | 97 | // Tool bar |
| 96 | 98 | Dali::Image image = Dali::ResourceImage::New( toolbarImagePath ); |
| 97 | 99 | Dali::ImageActor toolBarBackground = Dali::ImageActor::New( image ); |
| 100 | + toolBarBackground.SetName( "TOOLBAR_BACKGROUND" ); | |
| 101 | + toolBarBackground.SetResizePolicy( Dali::FILL_TO_PARENT, Dali::ALL_DIMENSIONS ); | |
| 98 | 102 | toolBar = Dali::Toolkit::ToolBar::New(); |
| 103 | + toolBar.SetName( "TOOLBAR" ); | |
| 99 | 104 | toolBar.SetBackground( toolBarBackground ); |
| 100 | 105 | toolBar.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER ); |
| 101 | 106 | toolBar.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER ); |
| 102 | - toolBar.SetSize( 0.0f, style.mToolBarHeight ); | |
| 103 | - toolBar.SetSizeMode( Dali::SIZE_EQUAL_TO_PARENT ); | |
| 107 | + toolBar.SetResizePolicy( Dali::FILL_TO_PARENT, Dali::ALL_DIMENSIONS ); | |
| 104 | 108 | toolBarBackground.SetSortModifier(1.0f); |
| 105 | 109 | |
| 106 | 110 | // Add the tool bar to the too bar layer. |
| ... | ... | @@ -112,7 +116,7 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar, |
| 112 | 116 | if( !title.empty() ) |
| 113 | 117 | { |
| 114 | 118 | Dali::Toolkit::TextView titleActor = Dali::Toolkit::TextView::New(); |
| 115 | - titleActor.SetName( "ToolbarTitle" ); | |
| 119 | + titleActor.SetName( "TOOLBAR_TITLE" ); | |
| 116 | 120 | titleActor.SetText( title ); |
| 117 | 121 | titleActor.SetSize( font.MeasureText( title ) ); |
| 118 | 122 | titleActor.SetStyleToCurrentText(textStyle); |
| ... | ... | @@ -138,6 +142,7 @@ Dali::Layer CreateView( Dali::Application& application, |
| 138 | 142 | |
| 139 | 143 | // Create default View. |
| 140 | 144 | view = Dali::Toolkit::View::New(); |
| 145 | + view.SetResizePolicy( Dali::FILL_TO_PARENT, Dali::ALL_DIMENSIONS ); | |
| 141 | 146 | |
| 142 | 147 | // Add the view to the stage before setting the background. |
| 143 | 148 | stage.Add( view ); |
| ... | ... | @@ -164,13 +169,11 @@ Dali::Layer CreateView( Dali::Application& application, |
| 164 | 169 | // Add tool bar layer to the view. |
| 165 | 170 | view.AddContentLayer( toolBarLayer ); |
| 166 | 171 | |
| 167 | - | |
| 168 | - | |
| 169 | 172 | // Create a content layer. |
| 170 | 173 | Dali::Layer contentLayer = Dali::Layer::New(); |
| 171 | 174 | contentLayer.SetAnchorPoint( Dali::AnchorPoint::CENTER ); |
| 172 | 175 | contentLayer.SetParentOrigin( Dali::ParentOrigin::CENTER ); |
| 173 | - contentLayer.SetSizeMode( Dali::SIZE_EQUAL_TO_PARENT ); | |
| 176 | + contentLayer.SetResizePolicy( Dali::FILL_TO_PARENT, Dali::ALL_DIMENSIONS ); | |
| 174 | 177 | view.AddContentLayer( contentLayer ); |
| 175 | 178 | contentLayer.LowerBelow( toolBarLayer ); |
| 176 | 179 | ... | ... |