diff --git a/com.samsung.dali-demo.xml b/com.samsung.dali-demo.xml index 028ee55..0a5488a 100644 --- a/com.samsung.dali-demo.xml +++ b/com.samsung.dali-demo.xml @@ -52,6 +52,9 @@ + + + @@ -68,7 +71,7 @@ - + @@ -85,4 +88,7 @@ + + + diff --git a/demo/dali-demo.cpp b/demo/dali-demo.cpp index a2741e8..31ddbd0 100644 --- a/demo/dali-demo.cpp +++ b/demo/dali-demo.cpp @@ -39,11 +39,15 @@ int main(int argc, char **argv) demo.AddExample(Example("refraction-effect.example", "Refraction")); demo.AddExample(Example("scroll-view.example", "Scroll View")); demo.AddExample(Example("shadow-bone-lighting.example", "Lights and shadows")); - demo.AddExample(Example("builder.example", "Script Based UI")); +// demo.AddExample(Example("builder.example", "Script Based UI")); demo.AddExample(Example("image-scaling-irregular-grid.example", "Image Scaling Modes")); demo.AddExample(Example("text-view.example", "Text View")); demo.AddExample(Example("animated-shapes.example", "Animated Shapes")); demo.AddExample(Example("path-animation.example", "Path Animation")); + demo.AddExample(Example("size-negotiation.example", "Size Negotiation")); + + demo.SortAlphabetically( true ); + app.MainLoop(); return 0; diff --git a/demo/dali-table-view.cpp b/demo/dali-table-view.cpp index bb7bc7c..8deff1c 100644 --- a/demo/dali-table-view.cpp +++ b/demo/dali-table-view.cpp @@ -55,10 +55,10 @@ const int MAX_PAGES = 256; ///< Maximum pag const int EXAMPLES_PER_ROW = 3; const int ROWS_PER_PAGE = 3; const int EXAMPLES_PER_PAGE = EXAMPLES_PER_ROW * ROWS_PER_PAGE; -const float LOGO_MARGIN_RATIO = 0.5f / 0.9f; +const float LOGO_MARGIN_RATIO = 0.1f / 0.3f; const float BOTTOM_PADDING_RATIO = 0.4f / 0.9f; const Vector3 SCROLLVIEW_RELATIVE_SIZE(0.9f, 1.0f, 0.8f ); ///< ScrollView's relative size to its parent -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. +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. const float STENCIL_RELATIVE_SIZE = 1.0f; const float EFFECT_SNAP_DURATION = 0.66f; ///< Scroll Snap Duration for Effects @@ -75,7 +75,6 @@ const float SCALE_SPEED_SIN = 0.1f; const unsigned int BACKGROUND_ANIMATION_DURATION = 15000; // 15 secs const float BACKGROUND_Z = -1.0f; -const float BACKGROUND_SIZE_SCALE = 1.0f; const Vector4 BACKGROUND_COLOR( 1.0f, 1.0f, 1.0f, 1.0f ); const float BUBBLE_MIN_Z = -1.0; @@ -124,10 +123,11 @@ ImageActor CreateBackground( std::string imagePath ) { Image image = ResourceImage::New( imagePath ); ImageActor background = ImageActor::New( image ); - + background.SetName( "BACKGROUND" ); background.SetAnchorPoint( AnchorPoint::CENTER ); background.SetParentOrigin( ParentOrigin::CENTER ); background.SetZ( -1.0f ); + background.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); return background; } @@ -139,7 +139,7 @@ const float IMAGE_BORDER_TOP = IMAGE_BORDER_LEFT; const float IMAGE_BORDER_BOTTOM = IMAGE_BORDER_LEFT; /** - * Constraint to return a position for a bubble based on the scroll value and vertical wrapping. + * Constraint to return a position for a bubble based on the scroll value and vertical wrapping */ struct AnimateBubbleConstraint { @@ -154,15 +154,15 @@ public: Vector3 operator()( const Vector3& current, const PropertyInput& scrollProperty, const PropertyInput& parentSize ) { Vector3 pos( current ); + const float parentHeight = parentSize.GetVector3().height; - // Wrap bubbles verically. - if( pos.y + mShapeSize * 0.5f < -parentSize.GetVector3().y * 0.5f ) + // Wrap bubbles vertically + if( pos.y + mShapeSize * 0.5f < -parentHeight * 0.5f ) { - pos.y += parentSize.GetVector3().y + mShapeSize; + pos.y = parentHeight * 0.5f + mShapeSize * 0.5f; } - // Bubbles X position moves parallax to horizontal - // panning by a scale factor unique to each bubble. + // Bubbles X position moves parallax to horizontal panning by a scale factor unique to each bubble pos.x = mInitialX + ( scrollProperty.GetVector3().x * mScale ); return pos; } @@ -186,7 +186,6 @@ DaliTableView::DaliTableView( Application& application ) mRootActor(), mRotateAnimation(), mBackground(), - mLogo(), mPressedAnimation(), mScrollViewLayer(), mScrollView(), @@ -242,15 +241,14 @@ void DaliTableView::Initialize( Application& application ) const Vector2 stageSize = Stage::GetCurrent().GetSize(); // Background - mBackground = CreateBackground( mBackgroundImagePath ); - // set same size as parent actor - mBackground.SetSize( stageSize ); - Stage::GetCurrent().Add( mBackground ); + Actor background = CreateBackground( mBackgroundImagePath ); + Stage::GetCurrent().Add( background ); // Render entire content as overlays, as is all on same 2D plane. mRootActor = TableView::New( 4, 1 ); mRootActor.SetAnchorPoint( AnchorPoint::CENTER ); mRootActor.SetParentOrigin( ParentOrigin::CENTER ); + mRootActor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); Stage::GetCurrent().Add( mRootActor ); // Toolbar at top @@ -262,37 +260,42 @@ void DaliTableView::Initialize( Application& application ) DemoHelper::GetDefaultTextStyle()); mRootActor.AddChild( toolBarLayer, TableView::CellPosition( 0, 0 ) ); - const float toolbarHeight = DemoHelper::DEFAULT_VIEW_STYLE.mToolBarHeight; - mRootActor.SetFixedHeight( 0, toolbarHeight ); + mRootActor.SetFitHeight( 0 ); // Add logo - mLogo = CreateLogo( LOGO_PATH ); + Dali::ImageActor logo = CreateLogo( LOGO_PATH ); + logo.SetName( "LOGO_IMAGE" ); + logo.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); const float paddingHeight = ( ( 1.f-TABLE_RELATIVE_SIZE.y ) * stageSize.y ); const float logoMargin = paddingHeight * LOGO_MARGIN_RATIO; - const float logoHeight = mLogo.GetImage().GetHeight() + logoMargin; - mRootActor.SetFixedHeight( 1, logoHeight ); // Show version in a popup when log is tapped mLogoTapDetector = TapGestureDetector::New(); - mLogoTapDetector.Attach( mLogo ); + mLogoTapDetector.Attach( logo ); mLogoTapDetector.DetectedSignal().Connect( this, &DaliTableView::OnLogoTapped ); const float bottomMargin = paddingHeight * BOTTOM_PADDING_RATIO; - mButtonsPageRelativeSize = Vector3( TABLE_RELATIVE_SIZE.x, 1.f - ( toolbarHeight + logoHeight + bottomMargin) / stageSize.height, TABLE_RELATIVE_SIZE.z ); - mRootActor.SetFixedHeight( 2, mButtonsPageRelativeSize.y * stageSize.height ); Alignment alignment = Alignment::New(); - alignment.Add(mLogo); + alignment.SetName( "LOGO_ALIGNMENT" ); + alignment.Add( logo ); + alignment.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + alignment.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT ); + Actor alignmentActor = alignment; + alignmentActor.SetPadding( Padding( 0.0f, 0.0f, logoMargin, logoMargin )); mRootActor.AddChild( alignment, TableView::CellPosition( 1, 0 ) ); + mRootActor.SetFitHeight( 1 ); // scrollview occupying the majority of the screen mScrollView = ScrollView::New(); + mScrollView.SetRelayoutEnabled( true ); mScrollView.SetAnchorPoint( AnchorPoint::CENTER ); mScrollView.SetParentOrigin( ParentOrigin::CENTER ); - // Note: Currently, changing mScrollView to use SizeMode RELATIVE_TO_PARENT - // will cause scroll ends to appear in the wrong position. - mScrollView.ApplyConstraint( Dali::Constraint::New( Dali::Actor::Property::SIZE, Dali::ParentSource( Dali::Actor::Property::SIZE ), Dali::RelativeToConstraint( SCROLLVIEW_RELATIVE_SIZE ) ) ); + mScrollView.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + const float buttonsPageMargin = ( 1.0f - TABLE_RELATIVE_SIZE.x ) * 0.5f * stageSize.width; + mScrollView.SetPadding( Padding( buttonsPageMargin, buttonsPageMargin, 0.0f, 0.0f ) ); + mScrollView.SetAxisAutoLock( true ); mScrollView.ScrollCompletedSignal().Connect( this, &DaliTableView::OnScrollComplete ); mScrollView.ScrollStartedSignal().Connect( this, &DaliTableView::OnScrollStart ); @@ -302,12 +305,36 @@ void DaliTableView::Initialize( Application& application ) mScrollViewLayer.SetAnchorPoint( AnchorPoint::CENTER ); mScrollViewLayer.SetParentOrigin( ParentOrigin::CENTER ); mScrollViewLayer.SetDrawMode( DrawMode::OVERLAY ); + mScrollViewLayer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + + // Create solid background colour. + ImageActor backgroundColourActor = Dali::Toolkit::CreateSolidColorActor( BACKGROUND_COLOR ); + backgroundColourActor.SetAnchorPoint( AnchorPoint::CENTER ); + backgroundColourActor.SetParentOrigin( ParentOrigin::CENTER ); + backgroundColourActor.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); + backgroundColourActor.SetSizeModeFactor( Vector3( 1.0f, 1.5f, 1.0f ) ); + backgroundColourActor.SetZ( BACKGROUND_Z ); + mScrollViewLayer.Add( backgroundColourActor ); // Populate background and bubbles - needs to be scrollViewLayer so scroll ends show - SetupBackground( mScrollView, mScrollViewLayer, stageSize ); + Actor bubbleContainer = Actor::New(); + bubbleContainer.SetRelayoutEnabled( true ); + bubbleContainer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + bubbleContainer.SetAnchorPoint( AnchorPoint::CENTER ); + bubbleContainer.SetParentOrigin( ParentOrigin::CENTER ); + mScrollViewLayer.Add( bubbleContainer ); + + SetupBackground( bubbleContainer ); + + Alignment buttonsAlignment = Alignment::New(); + buttonsAlignment.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + buttonsAlignment.Add( mScrollViewLayer ); mScrollViewLayer.Add( mScrollView ); - mRootActor.AddChild( mScrollViewLayer, TableView::CellPosition( 2, 0 ) ); + + mRootActor.AddChild( buttonsAlignment, TableView::CellPosition( 2, 0 ) ); + + mRootActor.SetFixedHeight( 3, bottomMargin ); // Add scroll view effect and setup constraints on pages ApplyScrollViewEffect(); @@ -333,7 +360,7 @@ void DaliTableView::Initialize( Application& application ) winHandle.ShowIndicator( Dali::Window::INVISIBLE ); - // + // Background animation mAnimationTimer = Timer::New( BACKGROUND_ANIMATION_DURATION ); mAnimationTimer.TickSignal().Connect( this, &DaliTableView::PauseBackgroundAnimation ); mAnimationTimer.Start(); @@ -349,12 +376,10 @@ void DaliTableView::ApplyCubeEffectToActors() { Actor page = *pageIter; - unsigned int numChildren = page.GetChildCount(); - Actor pageActor = page; - for( unsigned int i=0; iSetDomain( RulerDomain( 0.0f, mTotalPages * stageSize.width * mButtonsPageRelativeSize.x, true ) ); + mScrollRulerX->SetDomain( RulerDomain( 0.0f, mTotalPages * stageSize.width * TABLE_RELATIVE_SIZE.x, true ) ); mScrollRulerY->Disable(); mScrollView.SetRulerX( mScrollRulerX ); mScrollView.SetRulerY( mScrollRulerY ); @@ -478,17 +501,20 @@ void DaliTableView::Rotate( unsigned int degrees ) } mRotateAnimation = Animation::New( ROTATE_ANIMATION_TIME ); - mRotateAnimation.RotateTo( mRootActor, Degree( 360 - degrees ), Vector3::ZAXIS, AlphaFunctions::EaseOut ); - mRotateAnimation.Resize( mRootActor, targetSize, AlphaFunctions::EaseOut ); + mRotateAnimation.AnimateTo( Property( mRootActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( 360 - degrees ) ), Vector3::ZAXIS ), AlphaFunctions::EaseOut ); + mRotateAnimation.AnimateTo( Property( mRootActor, Actor::Property::SIZE ), targetSize, AlphaFunctions::EaseOut ); mRotateAnimation.Play(); } -Actor DaliTableView::CreateTile( const std::string& name, const std::string& title, const Size& parentSize, bool addBackground ) +Actor DaliTableView::CreateTile( const std::string& name, const std::string& title, const Dali::Vector3& sizeMultiplier, bool addBackground ) { - Actor tile = Actor::New(); - tile.SetName( name ); - tile.SetAnchorPoint( AnchorPoint::CENTER ); - tile.SetParentOrigin( ParentOrigin::CENTER ); + Actor content = Actor::New(); + content.SetName( name ); + content.SetAnchorPoint( AnchorPoint::CENTER ); + content.SetParentOrigin( ParentOrigin::CENTER ); + content.SetRelayoutEnabled( true ); + content.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); + content.SetSizeModeFactor( sizeMultiplier ); // create background image if( addBackground ) @@ -498,16 +524,17 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit image.SetAnchorPoint( AnchorPoint::CENTER ); image.SetParentOrigin( ParentOrigin::CENTER ); // make the image 100% of tile - image.SetSizeMode( SIZE_EQUAL_TO_PARENT ); + image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + // move image back to get text appear in front image.SetZ( -1 ); image.SetStyle( ImageActor::STYLE_NINE_PATCH ); image.SetNinePatchBorder( Vector4( IMAGE_BORDER_LEFT, IMAGE_BORDER_TOP, IMAGE_BORDER_RIGHT, IMAGE_BORDER_BOTTOM ) ); - tile.Add( image ); + content.Add( image ); // Add stencil ImageActor stencil = NewStencilImage(); - stencil.SetSizeMode( SIZE_EQUAL_TO_PARENT ); + stencil.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); image.Add( stencil ); } @@ -518,22 +545,22 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit text.SetMultilinePolicy( Toolkit::TextView::SplitByWord ); text.SetLineJustification( Toolkit::TextView::Center ); text.SetTextAlignment( Toolkit::Alignment::Type( Alignment::HorizontalCenter | Alignment::VerticalCenter ) ); - text.SetColor( Color::WHITE ); text.SetZ( 1 ); // make the text 90% of tile - text.SetSize( 0.9f * parentSize.width, 0.9f * parentSize.height ); + text.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); + text.SetSizeModeFactor( Vector3( 0.9f, 0.9f, 0.0f ) ); text.SetStyleToCurrentText( GetTableTextStyle() ); text.SetSnapshotModeEnabled( false ); - tile.Add( text ); + content.Add( text ); // Set the tile to be keyboard focusable - tile.SetKeyboardFocusable(true); + content.SetKeyboardFocusable(true); // connect to the touch events - tile.TouchedSignal().Connect( this, &DaliTableView::OnTilePressed ); - tile.HoveredSignal().Connect( this, &DaliTableView::OnTileHovered ); + content.TouchedSignal().Connect( this, &DaliTableView::OnTilePressed ); + content.HoveredSignal().Connect( this, &DaliTableView::OnTileHovered ); - return tile; + return content; } ImageActor DaliTableView::NewStencilImage() @@ -592,10 +619,10 @@ bool DaliTableView::OnTilePressed( Actor actor, const TouchEvent& event ) // scale the content actor within the Tile, as to not affect the placement within the Table. Actor content = actor.GetChildAt(0); - mPressedAnimation.ScaleTo( content, Vector3( 0.9f, 0.9f, 1.0f ), AlphaFunctions::EaseInOut, 0.0f, - BUTTON_PRESS_ANIMATION_TIME * 0.5f ); - mPressedAnimation.ScaleTo( content, Vector3::ONE, AlphaFunctions::EaseInOut, BUTTON_PRESS_ANIMATION_TIME * 0.5f, - BUTTON_PRESS_ANIMATION_TIME * 0.5f ); + mPressedAnimation.AnimateTo( Property( content, Actor::Property::SCALE ), Vector3( 0.9f, 0.9f, 1.0f ), AlphaFunctions::EaseInOut, + TimePeriod( 0.0f, BUTTON_PRESS_ANIMATION_TIME * 0.5f ) ); + mPressedAnimation.AnimateTo( Property( content, Actor::Property::SCALE ), Vector3::ONE, AlphaFunctions::EaseInOut, + TimePeriod( BUTTON_PRESS_ANIMATION_TIME * 0.5f, BUTTON_PRESS_ANIMATION_TIME * 0.5f ) ); mPressedAnimation.Play(); mPressedAnimation.FinishedSignal().Connect( this, &DaliTableView::OnPressedAnimationFinished ); } @@ -654,8 +681,6 @@ void DaliTableView::OnScrollComplete( const Dali::Vector3& position ) // move focus to 1st item of new page FocusManager focusManager = FocusManager::Get(); focusManager.SetCurrentFocusActor(mPages[mScrollView.GetCurrentPage()].GetChildAt(0) ); - - ApplyCubeEffectToActors(); } bool DaliTableView::OnScrollTouched( Actor actor, const TouchEvent& event ) @@ -721,37 +746,65 @@ void DaliTableView::OnKeyEvent( const KeyEvent& event ) } } -void DaliTableView::SetupBackground( Actor bubbleContainer, Actor backgroundLayer, const Vector2& size ) +void DaliTableView::SetupBackground( Actor bubbleContainer ) { // Create distance field shape. BufferImage distanceField; Size imageSize( 512, 512 ); CreateShapeImage( CIRCLE, imageSize, distanceField ); - // Create solid background colour. - ImageActor backgroundColourActor = Dali::Toolkit::CreateSolidColorActor( BACKGROUND_COLOR ); - backgroundColourActor.SetAnchorPoint( AnchorPoint::CENTER ); - backgroundColourActor.SetParentOrigin( ParentOrigin::CENTER ); - backgroundColourActor.SetSize( size * BACKGROUND_SIZE_SCALE ); - backgroundColourActor.SetZ( BACKGROUND_Z ); - backgroundColourActor.SetPositionInheritanceMode( DONT_INHERIT_POSITION ); - backgroundLayer.Add( backgroundColourActor ); - // Add bubbles to the bubbleContainer. // Note: The bubbleContainer is parented externally to this function. - AddBackgroundActors( bubbleContainer, NUM_BACKGROUND_IMAGES, distanceField, size ); + AddBackgroundActors( bubbleContainer, NUM_BACKGROUND_IMAGES, distanceField ); } -void DaliTableView::AddBackgroundActors( Actor layer, int count, BufferImage distanceField, const Dali::Vector2& size ) +void DaliTableView::InitialiseBackgroundActors( Actor actor ) +{ + // Delete current animations + mBackgroundAnimations.clear(); + + // Create new animations + const Vector3 size = actor.GetTargetSize(); + + for( unsigned int i = 0, childCount = actor.GetChildCount(); i < childCount; ++i ) + { + Actor child = actor.GetChildAt( i ); + + const Vector3 childSize = child.GetTargetSize(); + + // Calculate a random position + Vector3 childPos( Random::Range( -size.x * 0.5f * BACKGROUND_SPREAD_SCALE, size.x * 0.5f * BACKGROUND_SPREAD_SCALE ), + Random::Range( -size.y * 0.5f - childSize.height, size.y * 0.5f + childSize.height ), + Random::Range( BUBBLE_MIN_Z, BUBBLE_MAX_Z ) ); + + child.SetPosition( childPos ); + + // Define bubble horizontal parallax and vertical wrapping + Constraint animConstraint = Constraint::New < Vector3 > ( Actor::Property::POSITION, + Source( mScrollView, ScrollView::Property::SCROLL_POSITION ), + Dali::ParentSource( Dali::Actor::Property::SIZE ), + AnimateBubbleConstraint( childPos, Random::Range( -0.85f, 0.25f ), childSize.height ) ); + child.ApplyConstraint( animConstraint ); + + // Kickoff animation + Animation animation = Animation::New( Random::Range( 40.0f, 80.0f ) ); + animation.AnimateBy( Property( child, Actor::Property::POSITION ), Vector3( 0.0f, -1.0f, 0.0f ), AlphaFunctions::Linear ); + animation.SetLooping( true ); + animation.Play(); + mBackgroundAnimations.push_back( animation ); + } +} + +void DaliTableView::AddBackgroundActors( Actor layer, int count, BufferImage distanceField ) { for( int i = 0; i < count; ++i ) { float randSize = Random::Range( 10.0f, 400.0f ); float hue = Random::Range( 0.3f, 1.0f ); - Vector4 randColour( hue, hue*0.5, 0.0f, Random::Range( 0.3f, 0.6f )); + Vector4 randColour( hue, hue * 0.5, 0.0f, Random::Range( 0.3f, 0.6f )); ImageActor dfActor = ImageActor::New( distanceField ); - mBackgroundActors.push_back( dfActor ); + dfActor.SetRelayoutEnabled( false ); dfActor.SetSize( Vector2( randSize, randSize ) ); dfActor.SetParentOrigin( ParentOrigin::CENTER ); @@ -761,33 +814,10 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BufferImage dis effect.SetOutlineParams( Vector2( 0.55f, 0.00f ) ); effect.SetSmoothingEdge( 0.5f ); layer.Add( dfActor ); - - // Setup animation - Vector3 actorPos( - Random::Range( -size.x * 0.5f * BACKGROUND_SPREAD_SCALE, size.x * 0.5f * BACKGROUND_SPREAD_SCALE ), - Random::Range( -size.y * 0.5f - randSize, size.y * 0.5f + randSize ), - Random::Range( BUBBLE_MIN_Z, BUBBLE_MAX_Z ) ); - dfActor.SetPosition( actorPos ); - - // Define bubble horizontal parallax and vertical wrapping - Constraint animConstraint = Constraint::New < Vector3 > ( Actor::Property::POSITION, - Source( mScrollView, mScrollView.GetPropertyIndex( ScrollView::SCROLL_POSITION_PROPERTY_NAME ) ), - Dali::ParentSource( Dali::Actor::Property::SIZE ), - AnimateBubbleConstraint( actorPos, Random::Range( -0.85f, 0.25f ), randSize ) ); - dfActor.ApplyConstraint( animConstraint ); - - // Kickoff animation - Animation animation = Animation::New( Random::Range( 40.0f, 200.0f ) ); - KeyFrames keyframes = KeyFrames::New(); - keyframes.Add( 0.0f, actorPos ); - Vector3 toPos( actorPos ); - toPos.y -= ( size.y + randSize ); - keyframes.Add( 1.0f, toPos ); - animation.AnimateBetween( Property( dfActor, Actor::Property::POSITION ), keyframes ); - animation.SetLooping( true ); - animation.Play(); - mBackgroundAnimations.push_back( animation ); } + + // Positioning will occur when the layer is relaid out + layer.OnRelayoutSignal().Connect( this, &DaliTableView::InitialiseBackgroundActors ); } void DaliTableView::CreateShapeImage( ShapeType shapeType, const Size& size, BufferImage& distanceFieldOut ) @@ -860,7 +890,7 @@ ImageActor DaliTableView::CreateLogo( std::string imagePath ) ImageActor logo = ImageActor::New( image ); logo.SetAnchorPoint( AnchorPoint::CENTER ); - logo.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); + logo.SetParentOrigin( ParentOrigin::CENTER ); return logo; } @@ -994,14 +1024,17 @@ void DaliTableView::OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap stream << "DALi Toolkit: " << TOOLKIT_MAJOR_VERSION << "." << TOOLKIT_MINOR_VERSION << "." << TOOLKIT_MICRO_VERSION << std::endl << "(" << TOOLKIT_BUILD_DATE << ")"; mVersionPopup = Dali::Toolkit::Popup::New(); - mVersionPopup.SetTitle( stream.str() ); mVersionPopup.SetParentOrigin( ParentOrigin::CENTER ); mVersionPopup.SetAnchorPoint( AnchorPoint::CENTER ); + mVersionPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, WIDTH ); + mVersionPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) ); + mVersionPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT ); + mVersionPopup.SetTitle( stream.str() ); mVersionPopup.HideTail(); mVersionPopup.OutsideTouchedSignal().Connect( this, &DaliTableView::HideVersionPopup ); mVersionPopup.HiddenSignal().Connect( this, &DaliTableView::PopupHidden ); - Dali::Stage::GetCurrent().Add( mVersionPopup ); + mVersionPopup.MarkDirtyForRelayout(); } mVersionPopup.Show(); diff --git a/demo/dali-table-view.h b/demo/dali-table-view.h index fbaa2ea..05640ef 100644 --- a/demo/dali-table-view.h +++ b/demo/dali-table-view.h @@ -165,7 +165,7 @@ private: // Application callbacks & implementation * * @return The Actor for the created tile. */ - Dali::Actor CreateTile( const std::string& name, const std::string& title, const Dali::Size& parentSize, bool addBackground ); + Dali::Actor CreateTile( const std::string& name, const std::string& title, const Dali::Vector3& sizeMultiplier, bool addBackground ); /** * Create a stencil image @@ -276,9 +276,8 @@ private: // Application callbacks & implementation * Create a depth field background * * @param[in] bubbleLayer Add the graphics to this layer - * @param[in] backgroundLayer Add the background to this layer */ - void SetupBackground( Dali::Actor bubbleLayer, Dali::Actor backgroundLayer, const Dali::Vector2& size ); + void SetupBackground( Dali::Actor bubbleLayer ); /** * Create background actors for the given layer @@ -286,9 +285,8 @@ private: // Application callbacks & implementation * @param[in] layer The layer to add the actors to * @param[in] count The number of actors to generate * @param[in] distanceField The distance field bitmap to use - * @param[in] size The size of the actor */ - void AddBackgroundActors( Dali::Actor layer, int count, Dali::BufferImage distanceField, const Dali::Vector2& size ); + void AddBackgroundActors( Dali::Actor layer, int count, Dali::BufferImage distanceField ); /** * Create a bitmap with the specified shape and also output a distance field @@ -378,6 +376,20 @@ private: // Application callbacks & implementation */ void PopupHidden(); + /* + * @brief Callback called when the buttons page actor is relaid out + * + * @param[in] actor The page actor + */ + void OnButtonsPageRelayout( const Dali::Actor& actor ); + + /** + * @brief Callback called to set up background actors + * + * @param[in] actor The actor raising the callback + */ + void InitialiseBackgroundActors( Dali::Actor actor ); + private: Dali::Application& mApplication; ///< Application instance. @@ -385,7 +397,6 @@ private: Dali::Toolkit::TableView mRootActor; ///< All content (excluding background is anchored to this Actor) Dali::Animation mRotateAnimation; ///< Animation to rotate and resize mRootActor. Dali::ImageActor mBackground; ///< Background's static image. - Dali::ImageActor mLogo; ///< Logo's static image. Dali::Animation mPressedAnimation; ///< Button press scaling animation. Dali::Layer mScrollViewLayer; ///< ScrollView resides on a separate layer. Dali::Toolkit::ScrollView mScrollView; ///< ScrollView container (for all Examples) @@ -413,6 +424,7 @@ private: bool mSortAlphabetically:1; ///< Sort examples alphabetically. bool mBackgroundAnimsPlaying:1; ///< Are background animations playing bool mVersionPopupShown:1; ///< Whehter the version popup is shown or not + }; #endif // __DALI_DEMO_H__ diff --git a/examples/animated-shapes/animated-shapes-example.cpp b/examples/animated-shapes/animated-shapes-example.cpp index b7a5a72..fa98009 100644 --- a/examples/animated-shapes/animated-shapes-example.cpp +++ b/examples/animated-shapes/animated-shapes-example.cpp @@ -52,6 +52,7 @@ public: //Create a view mView = Dali::Toolkit::View::New(); + mView.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); stage.Add( mView ); //Set background image for the view @@ -161,7 +162,7 @@ public: k0.Add( 1.0f, Vector3( -radius, 0.0f, 0.0f) ); animation.AnimateBetween( Property(shader, shader.GetPointPropertyName(10)),k0,AlphaFunctions::EaseInOutSine ); - animation.RotateBy(meshActor,Degree(90.0f), Vector3::ZAXIS ); + animation.AnimateBy( Property( meshActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(90.0f) ), Vector3::ZAXIS ) ); animation.SetLooping( true ); animation.Play(); } @@ -342,7 +343,7 @@ public: k0.Add( 1.0f, Vector3( -radius*2.0, 0.0f, 0.0f) ); animation.AnimateBetween( Property(shader, shader.GetPointPropertyName(10)),k0,AlphaFunctions::EaseInOutSine ); - animation.RotateBy(meshActor,Degree(-90.0f), Vector3::ZAXIS ); + animation.AnimateBy( Property( meshActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(-90.0f) ), Vector3::ZAXIS ) ); animation.SetLooping( true ); animation.Play(); } diff --git a/examples/blocks/blocks-example.cpp b/examples/blocks/blocks-example.cpp index cf1ceae..5412b0d 100644 --- a/examples/blocks/blocks-example.cpp +++ b/examples/blocks/blocks-example.cpp @@ -421,7 +421,8 @@ private: mLevelContainer = Actor::New(); mLevelContainer.SetAnchorPoint( AnchorPoint::CENTER ); mLevelContainer.SetParentOrigin( ParentOrigin::CENTER ); - mLevelContainer.SetSizeMode( SIZE_EQUAL_TO_PARENT ); + mLevelContainer.SetRelayoutEnabled( true ); + mLevelContainer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); mContentLayer.Add( mLevelContainer ); mBrickCount = 0; @@ -593,6 +594,7 @@ private: ImageActor brick = ImageActor::New(img); brick.SetParentOrigin(ParentOrigin::TOP_LEFT); brick.SetAnchorPoint(AnchorPoint::CENTER); + brick.SetRelayoutEnabled( false ); brick.SetSize( brickSize ); brick.SetPosition( Vector3( position ) ); @@ -625,6 +627,7 @@ private: ImageActor actor = ImageActor::New(img); actor.SetParentOrigin(ParentOrigin::TOP_LEFT); actor.SetAnchorPoint(AnchorPoint::CENTER); + actor.SetRelayoutEnabled( false ); return actor; } diff --git a/examples/builder/examples.cpp b/examples/builder/examples.cpp index bac5840..41d2162 100644 --- a/examples/builder/examples.cpp +++ b/examples/builder/examples.cpp @@ -290,6 +290,7 @@ public: mFiles.clear(); mItemView = ItemView::New(*this); + mItemView.SetRelayoutEnabled( false ); stage.Add( mItemView ); mItemView.SetParentOrigin(ParentOrigin::CENTER); mItemView.SetAnchorPoint(AnchorPoint::CENTER); @@ -396,6 +397,7 @@ public: Actor MenuItem(const std::string& text) { TextView t = TextView::New(); + t.SetResizePolicy( FILL_TO_PARENT, WIDTH ); t.SetMarkupProcessingEnabled(true); int size = static_cast(DemoHelper::ScalePointSize(6)); @@ -480,6 +482,8 @@ public: builder.AddActors( layer ); + // Force relayout on layer + layer.RelayoutRequestTree(); } diff --git a/examples/buttons/buttons-example.cpp b/examples/buttons/buttons-example.cpp index 37ede2b..d4a03a6 100644 --- a/examples/buttons/buttons-example.cpp +++ b/examples/buttons/buttons-example.cpp @@ -127,6 +127,7 @@ class ButtonsController: public ConnectionTracker radioGroup2Background.SetAnchorPoint( AnchorPoint::TOP_LEFT ); radioGroup2Background.SetParentOrigin( ParentOrigin::TOP_LEFT ); radioGroup2Background.SetPosition( DP(MARGIN_SIZE), DP(yPos) ); + radioGroup2Background.SetRelayoutEnabled( true ); radioGroup2Background.SetSize( DP(348), DP(GROUP2_HEIGHT) ); mContentLayer.Add( radioGroup2Background ); @@ -134,6 +135,7 @@ class ButtonsController: public ConnectionTracker radioButtonsGroup2.SetParentOrigin( ParentOrigin::TOP_LEFT ); radioButtonsGroup2.SetAnchorPoint( AnchorPoint::TOP_LEFT ); radioButtonsGroup2.SetPosition( DP(MARGIN_SIZE), DP(MARGIN_SIZE) ); + radioButtonsGroup2.SetRelayoutEnabled( true ); radioButtonsGroup2.SetSize( DP(100), DP(160) ); radioGroup2Background.Add( radioButtonsGroup2 ); @@ -188,7 +190,7 @@ class ButtonsController: public ConnectionTracker mUpdateButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); mUpdateButton.SetAnchorPoint( AnchorPoint::TOP_CENTER ); mUpdateButton.SetPosition( 0, DP(MARGIN_SIZE) ); - mUpdateButton.SetLabel("Select"); + mUpdateButton.SetLabel( "Select" ); mUpdateButton.SetSize( DP(100), DP(BUTTON_HEIGHT) ); mUpdateButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) ); @@ -218,6 +220,7 @@ class ButtonsController: public ConnectionTracker radioGroup1Background.SetAnchorPoint( AnchorPoint::TOP_LEFT ); radioGroup1Background.SetParentOrigin( ParentOrigin::TOP_LEFT ); radioGroup1Background.SetPosition( DP(MARGIN_SIZE), DP(yPos) ); + radioGroup1Background.SetRelayoutEnabled( true ); radioGroup1Background.SetSize( DP(348), DP(GROUP1_HEIGHT) ); mContentLayer.Add( radioGroup1Background ); @@ -232,17 +235,17 @@ class ButtonsController: public ConnectionTracker // First radio button { Toolkit::TableView tableView = Toolkit::TableView::New( 1, 2 ); - tableView.SetSize( DP(260), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); + tableView.SetSize( DP(260), 0.0f ); + tableView.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT ); Toolkit::TextView textView = Toolkit::TextView::New( "Select enabled" ); - Toolkit::Alignment alignment = Toolkit::Alignment::New( Toolkit::Alignment::HorizontalLeft ); - alignment.Add( textView ); - tableView.AddChild( alignment, Toolkit::TableView::CellPosition( 0, 0 ) ); + tableView.AddChild( textView, Toolkit::TableView::CellPosition( 0, 0 ) ); ImageActor imageActor = ImageActor::New( ResourceImage::New( ENABLED_IMAGE ) ); imageActor.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); + imageActor.SetResizePolicy( FIXED, ALL_DIMENSIONS ); + imageActor.SetPadding( Padding( DP(20.0f), 0.0f, 0.0f, 0.0f ) ); tableView.AddChild( imageActor, Toolkit::TableView::CellPosition( 0, 1 ) ); - tableView.SetFixedWidth( 1, DP(RADIO_LABEL_THUMBNAIL_SIZE) ); Toolkit::RadioButton radioButton = Dali::Toolkit::RadioButton::New( tableView ); radioButton.SetName( "radio-select-enable" ); @@ -276,6 +279,7 @@ class ButtonsController: public ConnectionTracker checkBoxBackground.SetAnchorPoint( AnchorPoint::TOP_LEFT ); checkBoxBackground.SetParentOrigin( ParentOrigin::TOP_LEFT ); checkBoxBackground.SetPosition( DP(MARGIN_SIZE), DP(yPos) ); + checkBoxBackground.SetRelayoutEnabled( true ); checkBoxBackground.SetSize( DP(430), DP(GROUP3_HEIGHT) ); mContentLayer.Add( checkBoxBackground ); @@ -336,6 +340,7 @@ class ButtonsController: public ConnectionTracker toggleBackground.SetAnchorPoint( AnchorPoint::TOP_LEFT ); toggleBackground.SetParentOrigin( ParentOrigin::TOP_LEFT ); toggleBackground.SetPosition( DP(MARGIN_SIZE), DP(yPos) ); + toggleBackground.SetRelayoutEnabled( true ); toggleBackground.SetSize( DP(150 + MARGIN_SIZE * 2), DP(GROUP4_HEIGHT) ); mContentLayer.Add( toggleBackground ); diff --git a/examples/cluster/cluster-example.cpp b/examples/cluster/cluster-example.cpp index 50b6d4d..6053b7a 100644 --- a/examples/cluster/cluster-example.cpp +++ b/examples/cluster/cluster-example.cpp @@ -477,6 +477,7 @@ public: // create and setup the scroll view... mScrollView = ScrollView::New(); + mScrollView.SetRelayoutEnabled( false ); mScrollView.SetSize(stageSize); // attach Wobble Effect to ScrollView @@ -488,7 +489,8 @@ public: mScrollView.SetParentOrigin(ParentOrigin::CENTER); // Scale ScrollView to fit parent (mContentLayer) - mScrollView.SetSizeMode( SIZE_EQUAL_TO_PARENT ); + mScrollView.SetRelayoutEnabled( true ); + mScrollView.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); // Add the scroll view to the content layer mContentLayer.Add(mScrollView); @@ -515,6 +517,7 @@ public: Cluster clusterActor = Cluster::New(style); clusterActor.SetParentOrigin(ParentOrigin::CENTER); clusterActor.SetAnchorPoint(AnchorPoint::CENTER); + clusterActor.SetRelayoutEnabled( false ); Vector2 stageSize = Dali::Stage::GetCurrent().GetSize(); float minStageDimension = std::min(stageSize.x, stageSize.y); @@ -533,6 +536,7 @@ public: backgroundAttributes.SetScalingMode( Dali::ImageAttributes::ShrinkToFit ); Image bg = ResourceImage::New( CLUSTER_BACKGROUND_IMAGE_PATH ); ImageActor image = ImageActor::New(bg); + image.SetRelayoutEnabled( false ); clusterActor.SetBackgroundImage(image); // Add actors (pictures) as the children of the cluster @@ -576,7 +580,7 @@ public: shadowActor.SetPosition(Vector3(0.0f, 0.0f, -1.0f)); // Apply size-relative mode to auto-size the image shadow - shadowActor.SetSizeMode( SIZE_RELATIVE_TO_PARENT ); + shadowActor.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); shadowActor.SetSizeModeFactor( ShadowProperty::SIZE_SCALE ); actor.Add( shadowActor ); @@ -585,7 +589,7 @@ public: ImageActor imageActor = ImageActor::New( image ); imageActor.SetParentOrigin( ParentOrigin::CENTER ); imageActor.SetAnchorPoint( AnchorPoint::CENTER ); - imageActor.SetSizeMode( SIZE_EQUAL_TO_PARENT ); + imageActor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); actor.Add( imageActor ); // Add a border image child actor (with a fixed size offset from parent). @@ -595,7 +599,7 @@ public: borderActor.SetStyle( ImageActor::STYLE_NINE_PATCH ); borderActor.SetNinePatchBorder( CLUSTER_IMAGE_BORDER_ABSOLUTE ); borderActor.SetPosition( Vector3( 0.0f, 0.0f, 1.0f ) ); - borderActor.SetSizeMode( SIZE_FIXED_OFFSET_FROM_PARENT ); + borderActor.SetResizePolicy( SIZE_FIXED_OFFSET_FROM_PARENT, ALL_DIMENSIONS ); borderActor.SetSizeModeFactor( Vector3( CLUSTER_IMAGE_BORDER_INDENT - 1.0f, CLUSTER_IMAGE_BORDER_INDENT - 1.0f, 0.0f ) * 2.0f ); actor.Add( borderActor ); @@ -625,7 +629,8 @@ public: mScrollView.Add(pageView); pageView.SetParentOrigin(ParentOrigin::CENTER); pageView.SetPosition(Vector3(stageSize.width * column, 0.0f, 0.0f)); - pageView.SetSizeMode( SIZE_EQUAL_TO_PARENT ); + pageView.SetRelayoutEnabled( true ); + pageView.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); // Create cluster actors, add them to scroll view, and set the shear effect with the given center point. Cluster cluster = CreateClusterActor(clusterType, style); diff --git a/examples/cube-transition-effect/cube-transition-effect-example.cpp b/examples/cube-transition-effect/cube-transition-effect-example.cpp index 7fa1545..aa146e6 100644 --- a/examples/cube-transition-effect/cube-transition-effect-example.cpp +++ b/examples/cube-transition-effect/cube-transition-effect-example.cpp @@ -182,7 +182,6 @@ private: ImageActor mNextImage; unsigned int mIndex; bool mIsImageLoading; - Constraint mImageConstraint; PanGestureDetector mPanGestureDetector; @@ -283,11 +282,10 @@ void CubeTransitionApp::OnInit( Application& application ) mViewTimer.TickSignal().Connect( this, &CubeTransitionApp::OnTimerTick ); // show the first image - mImageConstraint = Constraint::New( Actor::Property::SCALE, LocalSource( Actor::Property::SIZE ), ParentSource( Actor::Property::SIZE ), ScaleToFitKeepAspectRatioConstraint() ); - mCurrentImage = ImageActor::New( LoadStageFillingImage( IMAGES[mIndex] ) ); mCurrentImage.SetPositionInheritanceMode( USE_PARENT_POSITION ); - mCurrentImage.ApplyConstraint( mImageConstraint ); + mCurrentImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + mCurrentImage.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO ); mParent.Add( mCurrentImage ); mCurrentEffect = mCubeWaveEffect; @@ -331,7 +329,9 @@ void CubeTransitionApp::GoToNextImage() mNextImage = ImageActor::New( image ); mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION); - mNextImage.ApplyConstraint( mImageConstraint ); + mNextImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + mNextImage.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO ); + mNextImage.SetRelayoutEnabled( false ); mCurrentEffect.SetTargetImage(mNextImage); if( image.GetLoadingState() == ResourceLoadingSucceeded ) { diff --git a/examples/dissolve-effect/dissolve-effect-example.cpp b/examples/dissolve-effect/dissolve-effect-example.cpp index ac4e699..8d0f90f 100644 --- a/examples/dissolve-effect/dissolve-effect-example.cpp +++ b/examples/dissolve-effect/dissolve-effect-example.cpp @@ -163,7 +163,6 @@ private: ImageActor mCurrentImage; ImageActor mNextImage; unsigned int mIndex; - Constraint mSizeConstraint; Toolkit::DissolveEffect mCurrentImageEffect; Toolkit::DissolveEffect mNextImageEffect; @@ -251,12 +250,12 @@ void DissolveEffectApp::OnInit( Application& application ) mParent.SetPositionInheritanceMode( USE_PARENT_POSITION ); mContent.Add( mParent ); - mSizeConstraint= Constraint::New( Actor::Property::SCALE, LocalSource( Actor::Property::SIZE ), ParentSource( Actor::Property::SIZE ), ScaleToFitKeepAspectRatioConstraint() ); - // show the first image mCurrentImage = ImageActor::New( LoadStageFillingImage( IMAGES[mIndex] ) ); + mCurrentImage.SetRelayoutEnabled( false ); mCurrentImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION); - mCurrentImage.ApplyConstraint( mSizeConstraint ); + mCurrentImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + mCurrentImage.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO ); mParent.Add( mCurrentImage ); mPanGestureDetector.Attach( mCurrentImage ); @@ -284,8 +283,10 @@ void DissolveEffectApp::OnPanGesture( Actor actor, const PanGesture& gesture ) Image image = LoadStageFillingImage( IMAGES[ mIndex ] ); mNextImage = ImageActor::New( image ); + mNextImage.SetRelayoutEnabled( false ); mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION); - mNextImage.ApplyConstraint( mSizeConstraint ); + mNextImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + mNextImage.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO ); mNextImage.SetZ(INITIAL_DEPTH); mParent.Add( mNextImage ); Vector2 size = Vector2( mCurrentImage.GetCurrentSize() ); @@ -303,7 +304,7 @@ void DissolveEffectApp::StartTransition(Vector2 position, Vector2 displacement) mAnimation.AnimateTo( Property(mCurrentImageEffect, mCurrentImageEffect.GetDistortionPropertyName()), 1.0f, AlphaFunctions::Linear ); mNextImage.SetOpacity(0.0f); - mAnimation.OpacityTo( mNextImage, 1.0, AlphaFunctions::Linear ); + mAnimation.AnimateTo( Property( mNextImage, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunctions::Linear ); if(mUseHighPrecision) { @@ -314,7 +315,7 @@ void DissolveEffectApp::StartTransition(Vector2 position, Vector2 displacement) } else { - mAnimation.MoveTo(mNextImage, Vector3(0.0f, 0.0f, 0.0f), AlphaFunctions::Linear); + mAnimation.AnimateTo( Property( mNextImage, Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), AlphaFunctions::Linear ); } mAnimation.FinishedSignal().Connect( this, &DissolveEffectApp::OnTransitionCompleted ); @@ -397,7 +398,8 @@ bool DissolveEffectApp::OnTimerTick() Image image = LoadStageFillingImage( IMAGES[ mIndex ] ); mNextImage = ImageActor::New( image ); mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION); - mNextImage.ApplyConstraint( mSizeConstraint ); + mNextImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + mNextImage.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO ); mNextImage.SetZ(INITIAL_DEPTH); mParent.Add( mNextImage ); switch( mCentralLineIndex%4 ) diff --git a/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp b/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp index 09bfe9e..3b9e0df 100644 --- a/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp +++ b/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp @@ -421,7 +421,8 @@ public: // coordinates in a frame defined by a parent actor: Actor gridActor = Actor::New(); - gridActor.SetSizeMode( SIZE_EQUAL_TO_PARENT ); + gridActor.SetRelayoutEnabled( true ); + gridActor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); gridActor.SetParentOrigin( ParentOrigin::CENTER ); gridActor.SetAnchorPoint( AnchorPoint::CENTER ); @@ -467,7 +468,7 @@ public: { // Spin the image a few times: Animation animation = Animation::New(SPIN_DURATION); - animation.RotateBy( actor, Degree(360.0f * SPIN_DURATION), Vector3::XAXIS, AlphaFunctions::EaseOut); + animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(360.0f * SPIN_DURATION) ), Vector3::XAXIS ), AlphaFunctions::EaseOut ); animation.Play(); // Change the scaling mode: diff --git a/examples/item-view/item-view-example.cpp b/examples/item-view/item-view-example.cpp index d86306e..54c49af 100644 --- a/examples/item-view/item-view-example.cpp +++ b/examples/item-view/item-view-example.cpp @@ -279,9 +279,9 @@ public: mDeleteButton.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); mDeleteButton.SetPosition( BUTTON_BORDER, BUTTON_BORDER ); mDeleteButton.SetDrawMode( DrawMode::OVERLAY ); - mDeleteButton.SetBackgroundImage( ResourceImage::New( TOOLBAR_IMAGE ) ); mDeleteButton.SetButtonImage( ResourceImage::New( DELETE_IMAGE ) ); - mDeleteButton.SetSize( stageSize.width * 0.15f, stageSize.width * 0.15f ); + mDeleteButton.SetBackgroundImage( ResourceImage::New( TOOLBAR_IMAGE ) ); + mDeleteButton.SetSize( Vector2( stageSize.width * 0.15f, stageSize.width * 0.15f ) ); mDeleteButton.ClickedSignal().Connect( this, &ItemViewExample::OnDeleteButtonClicked); mDeleteButton.SetLeaveRequired( true ); mDeleteButton.SetVisible( false ); @@ -293,8 +293,8 @@ public: mInsertButton.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); mInsertButton.SetPosition( BUTTON_BORDER, BUTTON_BORDER ); mInsertButton.SetDrawMode( DrawMode::OVERLAY ); - mInsertButton.SetBackgroundImage( ResourceImage::New( TOOLBAR_IMAGE ) ); mInsertButton.SetButtonImage( ResourceImage::New( INSERT_IMAGE ) ); + mInsertButton.SetBackgroundImage( ResourceImage::New( TOOLBAR_IMAGE ) ); mInsertButton.SetSize( stageSize.width * 0.15f, stageSize.width * 0.15f ); mInsertButton.ClickedSignal().Connect( this, &ItemViewExample::OnInsertButtonClicked); mInsertButton.SetLeaveRequired( true ); @@ -307,8 +307,8 @@ public: mReplaceButton.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); mReplaceButton.SetPosition( BUTTON_BORDER, BUTTON_BORDER ); mReplaceButton.SetDrawMode( DrawMode::OVERLAY ); - mReplaceButton.SetBackgroundImage( ResourceImage::New( TOOLBAR_IMAGE ) ); mReplaceButton.SetButtonImage( ResourceImage::New( REPLACE_IMAGE ) ); + mReplaceButton.SetBackgroundImage( ResourceImage::New( TOOLBAR_IMAGE ) ); mReplaceButton.SetSize( stageSize.width * 0.15f, stageSize.width * 0.15f ); mReplaceButton.ClickedSignal().Connect( this, &ItemViewExample::OnReplaceButtonClicked); mReplaceButton.SetLeaveRequired( true ); @@ -318,6 +318,7 @@ public: // Create the item view actor mImageAtlas = CreateImageAtlas(); mItemView = ItemView::New(*this); + mItemView.SetRelayoutEnabled( false ); mItemView.SetParentOrigin(ParentOrigin::CENTER); mItemView.SetAnchorPoint(AnchorPoint::CENTER); @@ -897,7 +898,7 @@ public: // From ItemFactory borderActor.SetStyle( ImageActor::STYLE_NINE_PATCH ); borderActor.SetNinePatchBorder( Vector4( ITEM_IMAGE_BORDER_LEFT, ITEM_IMAGE_BORDER_TOP, ITEM_IMAGE_BORDER_RIGHT, ITEM_IMAGE_BORDER_BOTTOM ) ); borderActor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR ); // darken with parent image-actor - borderActor.SetSizeMode( SIZE_FIXED_OFFSET_FROM_PARENT ); + borderActor.SetResizePolicy( SIZE_FIXED_OFFSET_FROM_PARENT, ALL_DIMENSIONS ); borderActor.SetSizeModeFactor( ITEM_BORDER_MARGIN_SIZE ); actor.Add(borderActor); actor.SetKeyboardFocusable( true ); @@ -908,6 +909,7 @@ public: // From ItemFactory // Add a checkbox child actor; invisible until edit-mode is enabled ImageActor checkbox = ImageActor::New( mWhiteImage ); + checkbox.SetRelayoutEnabled( false ); checkbox.SetName( "CheckBox" ); checkbox.SetColor( Vector4(0.0f,0.0f,0.0f,0.6f) ); checkbox.SetParentOrigin( ParentOrigin::TOP_RIGHT ); @@ -924,6 +926,7 @@ public: // From ItemFactory actor.Add( checkbox ); ImageActor tick = ImageActor::New( ResourceImage::New(SELECTED_IMAGE) ); + tick.SetRelayoutEnabled( false ); tick.SetColorMode( USE_OWN_COLOR ); tick.SetName( "Tick" ); tick.SetParentOrigin( ParentOrigin::TOP_RIGHT ); @@ -988,12 +991,11 @@ private: mMenu = Toolkit::Popup::New(); mMenu.SetParentOrigin( ParentOrigin::BOTTOM_LEFT ); mMenu.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT ); + mMenu.SetSize( popupWidth, MENU_OPTION_HEIGHT * 2 ); mMenu.OutsideTouchedSignal().Connect( this, &ItemViewExample::HideMenu ); - stage.Add( mMenu ); TableView tableView = TableView::New( 0, 0 ); - Vector2 tableSize = Vector2( popupWidth, MENU_OPTION_HEIGHT * 2 ); - tableView.SetSize( tableSize ); + tableView.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); mMenu.Add( tableView ); Slider slider = Slider::New(); @@ -1002,9 +1004,9 @@ private: slider.SetProperty( Slider::Property::VALUE, mDurationSeconds ); slider.SetProperty( Slider::Property::VALUE_PRECISION, 2 ); slider.SetProperty( Slider::Property::SHOW_POPUP, true ); + slider.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); slider.ValueChangedSignal().Connect( this, &ItemViewExample::SliderValueChange ); tableView.AddChild( slider, TableView::CellPosition( 0, 0 ) ); - tableView.SetRelativeHeight( 0, 0.5f ); TextStyle defaultTextStyle; defaultTextStyle.SetFontName(DEFAULT_TEXT_STYLE_FONT_FAMILY); @@ -1018,19 +1020,20 @@ private: text.SetParentOrigin( ParentOrigin::TOP_LEFT ); text.SetTextAlignment( Dali::Toolkit::Alignment::HorizontalLeft ); text.SetStyleToCurrentText( defaultTextStyle ); + text.SetResizePolicy( FILL_TO_PARENT, WIDTH ); text.SetSize( 0.0f, LABEL_TEXT_SIZE_Y ); - text.ApplyConstraint( Dali::Constraint::New( Dali::Actor::Property::SIZE_WIDTH, Dali::ParentSource( Dali::Actor::Property::SIZE_WIDTH ), Dali::EqualToConstraint() ) ); text.SetZ( -0.9f ); slider.Add( text ); Actor textContainer = Actor::New(); + textContainer.SetRelayoutEnabled( true ); + textContainer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); mAlphaFunctionText = TextView::New( ALPHA_FUNCTIONS_TEXT[mAlphaFuncIndex] ); mAlphaFunctionText.SetAnchorPoint( ParentOrigin::CENTER ); mAlphaFunctionText.SetParentOrigin( ParentOrigin::CENTER ); mAlphaFunctionText.SetTextAlignment( Toolkit::Alignment::VerticalCenter ); textContainer.Add( mAlphaFunctionText ); tableView.AddChild( textContainer, TableView::CellPosition( 1, 0 ) ); - tableView.SetRelativeHeight( 0, 0.5f ); mTapDetector = TapGestureDetector::New(); mTapDetector.Attach(mAlphaFunctionText); @@ -1041,10 +1044,11 @@ private: text.SetParentOrigin( ParentOrigin::TOP_LEFT ); text.SetTextAlignment( Dali::Toolkit::Alignment::HorizontalLeft ); text.SetStyleToCurrentText( defaultTextStyle ); + text.SetResizePolicy( FILL_TO_PARENT, WIDTH ); text.SetSize( 0.0f, LABEL_TEXT_SIZE_Y ); - text.ApplyConstraint( Dali::Constraint::New( Dali::Actor::Property::SIZE_WIDTH, Dali::ParentSource( Dali::Actor::Property::SIZE_WIDTH ), Dali::EqualToConstraint() ) ); textContainer.Add( text ); + mMenu.MarkDirtyForRelayout(); mMenu.Show(); mMenuShown = true; } diff --git a/examples/logging/logging-example.cpp b/examples/logging/logging-example.cpp index 94f7ac0..0c44ed1 100644 --- a/examples/logging/logging-example.cpp +++ b/examples/logging/logging-example.cpp @@ -275,7 +275,7 @@ class LoggingController: public ConnectionTracker mContentLayer.Add( createGroupBackground ); int buttonXDP = DP(MARGIN_SIZE); - int buttonWidthDP = (createGroupBackground.GetSize().width - DP(MARGIN_SIZE) * 3) / 2; + int buttonWidthDP = (createGroupBackground.GetTargetSize().width - DP(MARGIN_SIZE) * 3) / 2; { Toolkit::PushButton button = Toolkit::PushButton::New(); @@ -326,7 +326,7 @@ class LoggingController: public ConnectionTracker mContentLayer.Add( timingGroupBackground ); buttonXDP = DP(MARGIN_SIZE); - buttonWidthDP = (timingGroupBackground.GetSize().width - DP(MARGIN_SIZE) * 3) / 2; + buttonWidthDP = (timingGroupBackground.GetTargetSize().width - DP(MARGIN_SIZE) * 3) / 2; { Toolkit::PushButton button = Toolkit::PushButton::New(); @@ -377,7 +377,7 @@ class LoggingController: public ConnectionTracker mContentLayer.Add( enableGroupBackground ); buttonXDP = DP(MARGIN_SIZE); - buttonWidthDP = (enableGroupBackground.GetSize().width - DP(MARGIN_SIZE) * 3) / 2; + buttonWidthDP = (enableGroupBackground.GetTargetSize().width - DP(MARGIN_SIZE) * 3) / 2; { Toolkit::PushButton button = Toolkit::PushButton::New(); @@ -509,7 +509,7 @@ class LoggingController: public ConnectionTracker mContentLayer.Add( vsyncGroupBackground ); buttonXDP = DP(MARGIN_SIZE); - buttonWidthDP = vsyncGroupBackground.GetSize().width - DP(MARGIN_SIZE) * 2; + buttonWidthDP = vsyncGroupBackground.GetTargetSize().width - DP(MARGIN_SIZE) * 2; { Toolkit::PushButton button = Toolkit::PushButton::New(); diff --git a/examples/magnifier/magnifier-example.cpp b/examples/magnifier/magnifier-example.cpp index ebaa264..f28529b 100644 --- a/examples/magnifier/magnifier-example.cpp +++ b/examples/magnifier/magnifier-example.cpp @@ -227,12 +227,14 @@ public: // Create magnifier (controlled by human touch) Layer overlay = Layer::New(); + overlay.SetRelayoutEnabled( false ); overlay.SetSensitive(false); overlay.SetParentOrigin( ParentOrigin::CENTER ); overlay.SetSize(mStageSize); Stage::GetCurrent().Add(overlay); mMagnifier = Toolkit::Magnifier::New(); + mMagnifier.SetRelayoutEnabled( false ); mMagnifier.SetSourceActor( mView.GetBackgroundLayer() ); mMagnifier.SetSize( MAGNIFIER_SIZE * mStageSize.width ); // Size of magnifier is in relation to stage width mMagnifier.SetMagnificationFactor( MAGNIFICATION_FACTOR ); @@ -251,6 +253,7 @@ public: // Create bouncing magnifier automatically bounces around screen. mBouncingMagnifier = Toolkit::Magnifier::New(); + mBouncingMagnifier.SetRelayoutEnabled( false ); mBouncingMagnifier.SetSourceActor( mView.GetBackgroundLayer() ); mBouncingMagnifier.SetSize( MAGNIFIER_SIZE * mStageSize.width ); // Size of magnifier is in relation to stage width mBouncingMagnifier.SetMagnificationFactor( MAGNIFICATION_FACTOR ); diff --git a/examples/motion-blur/motion-blur-example.cpp b/examples/motion-blur/motion-blur-example.cpp index 02032c7..2e695b4 100644 --- a/examples/motion-blur/motion-blur-example.cpp +++ b/examples/motion-blur/motion-blur-example.cpp @@ -326,8 +326,9 @@ public: { // has parent so we expect it to be on stage, start animation mRotateAnimation = Animation::New( ORIENTATION_DURATION ); - mRotateAnimation.RotateTo( mView, Degree( -orientation ), Vector3::ZAXIS, AlphaFunctions::EaseOut ); - mRotateAnimation.Resize( mView, targetSize.width, targetSize.height ); + mRotateAnimation.AnimateTo( Property( mView, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( -orientation ) ), Vector3::ZAXIS ), AlphaFunctions::EaseOut ); + mRotateAnimation.AnimateTo( Property( mView, Actor::Property::SIZE_WIDTH ), targetSize.width ); + mRotateAnimation.AnimateTo( Property( mView, Actor::Property::SIZE_HEIGHT ), targetSize.height ); mRotateAnimation.Play(); } else @@ -386,7 +387,7 @@ public: { float animDuration = 1.0f; mActorAnimation = Animation::New(animDuration); - mActorAnimation.RotateBy(mMotionBlurImageActor, Degree(720), Vector3::YAXIS, AlphaFunctions::EaseInOut); + mActorAnimation.AnimateBy( Property( mMotionBlurImageActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(360.0f) ), Vector3::YAXIS ), AlphaFunctions::EaseInOut ); mActorAnimation.SetEndAction( Animation::Bake ); mActorAnimation.Play(); } @@ -397,7 +398,7 @@ public: { float animDuration = 1.0f; mActorAnimation = Animation::New(animDuration); - mActorAnimation.RotateBy(mMotionBlurImageActor, Degree(720), Vector3::ZAXIS, AlphaFunctions::EaseInOut); + mActorAnimation.AnimateBy( Property( mMotionBlurImageActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(360.0f) ), Vector3::ZAXIS ), AlphaFunctions::EaseInOut ); mActorAnimation.SetEndAction( Animation::Bake ); mActorAnimation.Play(); } @@ -408,8 +409,8 @@ public: { float animDuration = 1.0f; mActorAnimation = Animation::New(animDuration); - mActorAnimation.RotateBy(mMotionBlurImageActor, Degree(360), Vector3::YAXIS, AlphaFunctions::EaseInOut); - mActorAnimation.RotateBy(mMotionBlurImageActor, Degree(360), Vector3::ZAXIS, AlphaFunctions::EaseInOut); + mActorAnimation.AnimateBy( Property( mMotionBlurImageActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(360.0f) ), Vector3::YAXIS ), AlphaFunctions::EaseInOut ); + mActorAnimation.AnimateBy( Property( mMotionBlurImageActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(360.0f) ), Vector3::ZAXIS ), AlphaFunctions::EaseInOut ); mActorAnimation.SetEndAction( Animation::Bake ); mActorAnimation.Play(); } @@ -420,7 +421,7 @@ public: { float animDuration = 1.0f; mActorAnimation = Animation::New(animDuration); - mActorAnimation.ScaleBy(mMotionBlurImageActor, Vector3(2.0f, 2.0f, 2.0f), AlphaFunctions::Bounce, 0.0f, 1.0f); + mActorAnimation.AnimateBy( Property( mMotionBlurImageActor, Actor::Property::SCALE ), Vector3(2.0f, 2.0f, 2.0f), AlphaFunctions::Bounce, TimePeriod( 0.0f, 1.0f ) ); mActorAnimation.SetEndAction( Animation::Bake ); mActorAnimation.Play(); } diff --git a/examples/motion-stretch/motion-stretch-example.cpp b/examples/motion-stretch/motion-stretch-example.cpp index a7fc7d4..7d22589 100644 --- a/examples/motion-stretch/motion-stretch-example.cpp +++ b/examples/motion-stretch/motion-stretch-example.cpp @@ -218,8 +218,9 @@ public: { // has parent so we expect it to be on stage, start animation mRotateAnimation = Animation::New( ORIENTATION_DURATION ); - mRotateAnimation.RotateTo( mView, Degree( -orientation ), Vector3::ZAXIS, AlphaFunctions::EaseOut ); - mRotateAnimation.Resize( mView, targetSize.width, targetSize.height ); + mRotateAnimation.AnimateTo( Property( mView, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( -orientation ) ), Vector3::ZAXIS ), AlphaFunctions::EaseOut ); + mRotateAnimation.AnimateTo( Property( mView, Actor::Property::SIZE_WIDTH ), targetSize.width ); + mRotateAnimation.AnimateTo( Property( mView, Actor::Property::SIZE_HEIGHT ), targetSize.height ); mRotateAnimation.Play(); } else @@ -277,7 +278,7 @@ public: { float animDuration = 1.0f; mActorAnimation = Animation::New(animDuration); - mActorAnimation.RotateBy(mMotionStretchImageActor, Degree(720), Vector3::YAXIS, AlphaFunctions::EaseInOut); + mActorAnimation.AnimateBy( Property( mMotionStretchImageActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(360.0f) ), Vector3::YAXIS ), AlphaFunctions::EaseInOut ); mActorAnimation.SetEndAction( Animation::Bake ); mActorAnimation.Play(); } @@ -288,7 +289,7 @@ public: { float animDuration = 1.0f; mActorAnimation = Animation::New(animDuration); - mActorAnimation.RotateBy(mMotionStretchImageActor, Degree(720), Vector3::ZAXIS, AlphaFunctions::EaseInOut); + mActorAnimation.AnimateBy( Property( mMotionStretchImageActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(360.0f) ), Vector3::ZAXIS ), AlphaFunctions::EaseInOut ); mActorAnimation.SetEndAction( Animation::Bake ); mActorAnimation.Play(); } @@ -299,8 +300,8 @@ public: { float animDuration = 1.0f; mActorAnimation = Animation::New(animDuration); - mActorAnimation.RotateBy(mMotionStretchImageActor, Degree(360), Vector3::YAXIS, AlphaFunctions::EaseInOut); - mActorAnimation.RotateBy(mMotionStretchImageActor, Degree(360), Vector3::ZAXIS, AlphaFunctions::EaseInOut); + mActorAnimation.AnimateBy( Property( mMotionStretchImageActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(360.0f) ), Vector3::YAXIS ), AlphaFunctions::EaseInOut ); + mActorAnimation.AnimateBy( Property( mMotionStretchImageActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(360.0f) ), Vector3::ZAXIS ), AlphaFunctions::EaseInOut ); mActorAnimation.SetEndAction( Animation::Bake ); mActorAnimation.Play(); } @@ -311,7 +312,7 @@ public: { float animDuration = 1.0f; mActorAnimation = Animation::New(animDuration); - mActorAnimation.ScaleBy(mMotionStretchImageActor, Vector3(2.0f, 2.0f, 2.0f), AlphaFunctions::Bounce, 0.0f, 1.0f); + mActorAnimation.AnimateBy( Property( mMotionStretchImageActor, Actor::Property::SCALE ), Vector3(2.0f, 2.0f, 2.0f), AlphaFunctions::Bounce, TimePeriod( 0.0f, 1.0f ) ); mActorAnimation.SetEndAction( Animation::Bake ); mActorAnimation.Play(); } diff --git a/examples/page-turn-view/page-turn-view-example.cpp b/examples/page-turn-view/page-turn-view-example.cpp index fa412ad..8f5d147 100644 --- a/examples/page-turn-view/page-turn-view-example.cpp +++ b/examples/page-turn-view/page-turn-view-example.cpp @@ -78,14 +78,20 @@ class PortraitPageFactory : public PageFactory */ virtual Actor NewPage( unsigned int pageId ) { + ImageActor page; + if( pageId == 0 ) { - return ImageActor::New( ResourceImage::New( BOOK_COVER_PORTRAIT ) ); + page = ImageActor::New( ResourceImage::New( BOOK_COVER_PORTRAIT ) ); } else { - return ImageActor::New( ResourceImage::New( PAGE_IMAGES_PORTRAIT[ (pageId-1) % NUMBER_OF_PORTRAIT_IMAGE ] ) ); + page = ImageActor::New( ResourceImage::New( PAGE_IMAGES_PORTRAIT[ (pageId-1) % NUMBER_OF_PORTRAIT_IMAGE ] ) ); } + + page.SetRelayoutEnabled( false ); + + return page; } }; @@ -120,6 +126,10 @@ class LandscapePageFactory : public PageFactory pageBack = ImageActor::New( ResourceImage::New( PAGE_IMAGES_LANDSCAPE[ (imageId+1) % NUMBER_OF_LANDSCAPE_IMAGE ] ) ); } pageFront.Add(pageBack); + + pageFront.SetRelayoutEnabled( false ); + pageBack.SetRelayoutEnabled( false ); + return pageFront; } }; @@ -223,6 +233,7 @@ void PageTurnController::OnInit( Application& app ) // Create default View. mView = View::New(); + mView.SetRelayoutEnabled( false ); stage.Add( mView ); Dali::Window winHandle = app.GetWindow(); @@ -236,6 +247,7 @@ void PageTurnController::OnInit( Application& app ) mView.OrientationAnimationStartedSignal().Connect( this, &PageTurnController::OnOrientationAnimationStarted ); mPageTurnPortraitView = PageTurnPortraitView::New( mPortraitPageFactory, stageSize ); + mPageTurnPortraitView.SetRelayoutEnabled( false ); mPageTurnPortraitView.SetSpineShadowParameter( Vector2(70.f, 30.f) ); mPageTurnPortraitView.PageTurnStartedSignal().Connect( this, &PageTurnController::OnPageStartedTurn ); mPageTurnPortraitView.PageTurnFinishedSignal().Connect( this, &PageTurnController::OnPageFinishedTurn ); @@ -244,6 +256,7 @@ void PageTurnController::OnInit( Application& app ) mPageTurnPortraitView.SetPositionInheritanceMode( USE_PARENT_POSITION ); mPageTurnLandscapeView = PageTurnLandscapeView::New( mLandscapePageFactory, Vector2(stageSize.y*0.5f, stageSize.x) ); + mPageTurnLandscapeView.SetRelayoutEnabled( false ); mPageTurnLandscapeView.PageTurnStartedSignal().Connect( this, &PageTurnController::OnPageStartedTurn ); mPageTurnLandscapeView.PageTurnFinishedSignal().Connect( this, &PageTurnController::OnPageFinishedTurn ); mPageTurnLandscapeView.PagePanStartedSignal().Connect( this, &PageTurnController::OnPageStartedPan ); diff --git a/examples/path-animation/path-animation.cpp b/examples/path-animation/path-animation.cpp index 2611be4..c602254 100644 --- a/examples/path-animation/path-animation.cpp +++ b/examples/path-animation/path-animation.cpp @@ -69,6 +69,7 @@ public: textActor.SetSize(size.y,size.y,0.0f); Slider slider = Slider::New(); + slider.SetRelayoutEnabled( false ); slider.SetAnchorPoint( AnchorPoint::CENTER_LEFT); slider.SetParentOrigin( ParentOrigin::CENTER_RIGHT); slider.SetProperty(Slider::Property::LOWER_BOUND, -1.0f ); @@ -100,6 +101,7 @@ public: //TextInput Dali::Layer controlsLayer = Dali::Layer::New(); + controlsLayer.SetRelayoutEnabled( false ); controlsLayer.SetSize( stage.GetSize().x, stage.GetSize().y*0.3f, 0.0 ); controlsLayer.SetPosition( 0.0f, stage.GetSize().y*0.8f, 0.0f ); controlsLayer.SetAnchorPoint( AnchorPoint::TOP_LEFT); @@ -199,6 +201,7 @@ public: if( !mControlPoint[index] ) { mControlPoint[index] = Toolkit::CreateSolidColorActor(Vector4(1.0f,1.0f,1.0f,1.0f)); + mControlPoint[index].SetRelayoutEnabled( false ); mControlPoint[index].SetParentOrigin( ParentOrigin::TOP_LEFT); mControlPoint[index].SetAnchorPoint( AnchorPoint::CENTER ); mControlPoint[index].SetSize( 20.0f, 20.0f ); @@ -220,6 +223,7 @@ public: if( !mControlPoint[index]) { mControlPoint[index] = Toolkit::CreateSolidColorActor(Vector4(1.0f,1.0f,1.0f,1.0f)); + mControlPoint[index].SetRelayoutEnabled( false ); mControlPoint[index].SetParentOrigin( ParentOrigin::TOP_LEFT); mControlPoint[index].SetAnchorPoint( AnchorPoint::CENTER ); mControlPoint[index].SetSize( 20.0f, 20.0f ); @@ -470,6 +474,7 @@ public: ImageAttributes attributes; Image img = ResourceImage::New(ACTOR_IMAGE, attributes ); mActor = ImageActor::New( img ); + mActor.SetRelayoutEnabled( false ); mActor.SetAnchorPoint( AnchorPoint::CENTER ); mActor.SetSize( 100, 50, 1 ); stage.Add( mActor ); diff --git a/examples/radial-menu/radial-menu-example.cpp b/examples/radial-menu/radial-menu-example.cpp index f022eb0..40bf308 100644 --- a/examples/radial-menu/radial-menu-example.cpp +++ b/examples/radial-menu/radial-menu-example.cpp @@ -165,6 +165,7 @@ void RadialMenuExample::OnInit(Application& app) Image dial = ResourceImage::New( TEST_DIAL_FILENAME ); mDialActor = ImageActor::New( dial ); + mDialActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); mDialActor.SetPositionInheritanceMode(USE_PARENT_POSITION); mDialActor.SetScale(scale); Layer dialLayer = Layer::New(); @@ -189,8 +190,8 @@ void RadialMenuExample::StartAnimation() mRadialSweepView1.Activate(mAnimation, 0.0f, 3.0f); mRadialSweepView2.Activate(mAnimation, 1.5f, 3.0f); mRadialSweepView3.Activate(mAnimation, 3.0f, 3.0f); - mAnimation.OpacityTo(mDialActor, 1.0f, AlphaFunctions::EaseIn, 0.0f, 0.8f); - mAnimation.OpacityTo(mRadialSweepView1, 1.0f, AlphaFunctions::EaseIn, 0.0f, 0.5f); + mAnimation.AnimateTo( Property( mDialActor, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunctions::EaseIn, TimePeriod( 0.0f, 0.8f ) ); + mAnimation.AnimateTo( Property( mRadialSweepView1, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunctions::EaseIn, TimePeriod( 0.0f, 0.5f ) ); mAnimation.FinishedSignal().Connect( this, &RadialMenuExample::OnAnimationFinished ); mAnimationState = PLAYING; @@ -242,6 +243,7 @@ RadialSweepView RadialMenuExample::CreateSweepView( std::string imageName, mImageActor = ImageActor::New(image); mImageActor.SetParentOrigin(ParentOrigin::CENTER); mImageActor.SetAnchorPoint(AnchorPoint::CENTER); + mImageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); // Create the stencil Vector2 imageSize = ResourceImage::GetImageSize(imageName); diff --git a/examples/radial-menu/radial-sweep-view-impl.cpp b/examples/radial-menu/radial-sweep-view-impl.cpp index 02a44b6..6289962 100644 --- a/examples/radial-menu/radial-sweep-view-impl.cpp +++ b/examples/radial-menu/radial-sweep-view-impl.cpp @@ -280,13 +280,13 @@ void RadialSweepViewImpl::Activate( Animation anim, float offsetTime, float dura Actor actor = mLayer.GetChildAt(i); if( actor != mStencilActor ) { - anim.RotateTo( actor, mInitialActorAngle, Vector3::ZAXIS ); + anim.AnimateTo( Property( actor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( mInitialActorAngle ) ), Vector3::ZAXIS ) ); } } } - anim.AnimateTo( Property( mStencilActor, mRotationAngleIndex ), static_cast(mFinalSector), mEasingFunction, TimePeriod( offsetTime, duration) ); - anim.RotateTo( mStencilActor, mFinalAngle, Vector3::ZAXIS, mEasingFunction, offsetTime, duration ); + anim.AnimateTo( Property( mStencilActor, mRotationAngleIndex ), static_cast(mFinalSector), mEasingFunction, TimePeriod( offsetTime, duration ) ); + anim.AnimateTo( Property( mStencilActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( mFinalAngle ) ), Vector3::ZAXIS ), mEasingFunction, TimePeriod( offsetTime, duration ) ); if( mRotateActorsWithStencil ) { @@ -295,7 +295,7 @@ void RadialSweepViewImpl::Activate( Animation anim, float offsetTime, float dura Actor actor = mLayer.GetChildAt(i); if( actor != mStencilActor ) { - anim.RotateTo( actor, Degree(mFinalAngle - mInitialAngle), Vector3::ZAXIS, mEasingFunction, offsetTime, duration ); + anim.AnimateTo( Property( actor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( mFinalAngle - mInitialAngle ) ), Vector3::ZAXIS ), mEasingFunction, TimePeriod( offsetTime, duration ) ); } } } @@ -306,7 +306,7 @@ void RadialSweepViewImpl::Activate( Animation anim, float offsetTime, float dura Actor actor = mLayer.GetChildAt(i); if( actor != mStencilActor ) { - anim.RotateTo( actor, mFinalActorAngle, Vector3::ZAXIS, mEasingFunction, offsetTime, duration ); + anim.AnimateTo( Property( actor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( mFinalActorAngle ) ), Vector3::ZAXIS ), mEasingFunction, TimePeriod( offsetTime, duration ) ); } } } diff --git a/examples/scripting/launcher.cpp b/examples/scripting/launcher.cpp new file mode 100644 index 0000000..6c11537 --- /dev/null +++ b/examples/scripting/launcher.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include "launcher.h" + +// EXTERNAL INCLUDES +#include +#include +#include + + + +using namespace Dali; + +#define TOKEN_STRING(x) #x + +namespace +{ +std::string GetFileContents(const std::string& filename) +{ + std::ifstream t(filename.c_str()); + return std::string((std::istreambuf_iterator(t)), + std::istreambuf_iterator()); +}; + +} // unnamed namespace + +Launcher::Launcher( Dali::Application application, std::string layoutFileName, std::string scriptFileName ) +: mApplication( application ), + mJSONFileName(layoutFileName ), + mJavaScriptFileName( scriptFileName ) +{ + + mApplication.InitSignal().Connect( this, &Launcher::Create ); +} + +Launcher::~Launcher() +{ +} + +void Launcher::Create( Dali::Application& application ) +{ + TextActor textActor = TextActor::New( "JSON & JavaScript Launcher..." ); + + // Reposition the actor + textActor.SetParentOrigin( ParentOrigin::TOP_LEFT ); + textActor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + textActor.SetPosition( 20, 0 ); + + // Get a handle to the stage + Stage stage = Stage::GetCurrent(); + + // Display the actor on the stage + stage.Add( textActor ); + + // change the background color to purple + Stage::GetCurrent().SetBackgroundColor( Vector4(0.2,0.2,0.4,1.0) ); + + // Try loading a JSON file + if( !mJSONFileName.empty() ) + { + mBuilder = Toolkit::Builder::New(); + + Property::Map defaultDirs; + defaultDirs[ TOKEN_STRING(DALI_IMAGE_DIR) ] = DALI_IMAGE_DIR; + defaultDirs[ TOKEN_STRING(DALI_MODEL_DIR) ] = DALI_MODEL_DIR; + defaultDirs[ TOKEN_STRING(DALI_SCRIPT_DIR) ] = DALI_SCRIPT_DIR; + mBuilder.AddConstants( defaultDirs ); + + std::string json_data(GetFileContents( mJSONFileName )); + mBuilder.LoadFromString(json_data); + mBuilder.AddActors( stage.GetRootLayer() ); + } + + // Try load a JavaScript file + if( !mJavaScriptFileName.empty() ) + { + // execute the script + mScript = Toolkit::Script::New(); + + mScript.ExecuteFile( mJavaScriptFileName); + } +} + +void Launcher::MainLoop() +{ + mApplication.MainLoop(); +} diff --git a/examples/scripting/launcher.h b/examples/scripting/launcher.h new file mode 100644 index 0000000..dc56b42 --- /dev/null +++ b/examples/scripting/launcher.h @@ -0,0 +1,66 @@ +#ifndef DALI_APP_H +#define DALI_APP_H + +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include +#include + +/** + * Example app that can load both JSON and JavaScript files from command line + * E.g. scripting.example my-first.js my-first.json + * See dali-demo/resources/scripts for example JSON and JavaScript files + */ +class Launcher: public Dali::ConnectionTracker +{ +public: + + /** + * @brief Construcctor + * @param application application + * @param layoutFileName JSON file to run + * @param scriptFileName JavaScript file to run + */ + Launcher( Dali::Application application, std::string layoutFileName, std::string scriptFileName ); + + /** + * @brief destructor + */ + ~Launcher(); + + /** + * @brief create app + */ + void Create( Dali::Application& application ); + + /** + * @brief run application MainLoop + */ + void MainLoop(); + +private: + + Dali::Toolkit::Script mScript; ///< Used to load and execute JavaScript + Dali::Toolkit::Builder mBuilder; ///< Used to parse JSON + Dali::Application mApplication; ///< application + std::string mJSONFileName; ///< JSON filename + std::string mJavaScriptFileName; ///< JavaScript filename +}; + +#endif // header diff --git a/examples/scripting/scripting-example.cpp b/examples/scripting/scripting-example.cpp new file mode 100644 index 0000000..6a9c4b9 --- /dev/null +++ b/examples/scripting/scripting-example.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include +#include +#include +#include + +// INTERNAL INCLUDES +#include "launcher.h" + +namespace +{ +bool CheckIfFileExists( const std::string& filename ) +{ + struct stat buf; + // fstat returns -1 on error + if (stat( filename.c_str(), &buf) != -1) + { + return true; + } + return false; +} + +} +int main( int argc, char* argv[] ) +{ + // pull out the JSON file and JavaScript file from the command line arguments + std::string javaScriptFileName; + std::string jSONFileName; + + for( int i = 1 ; i < argc ; ++i ) + { + std::string arg( argv[i] ); + + size_t idx = std::string::npos; + + idx = arg.find( ".json" ); + if( idx != std::string::npos ) + { + jSONFileName = arg; + } + else + { + idx = arg.find( ".js" ); + if( idx != std::string::npos ) + { + javaScriptFileName = arg; + } + } + } + + if( !jSONFileName.empty() ) + { + bool exists = CheckIfFileExists( jSONFileName ); + if( !exists ) + { + DALI_ASSERT_ALWAYS( 0 && "JSON file not found ") + } + } + if( !javaScriptFileName.empty() ) + { + bool exists = CheckIfFileExists( javaScriptFileName ); + if( !exists ) + { + DALI_ASSERT_ALWAYS( 0 && "JavaScript file not found ") + } + } + if( jSONFileName.empty() && javaScriptFileName.empty() ) + { + printf("Please specify a JSON and/or JavaScript file to load, e.g. scripting.example mylayout.json my-test.js\n"); + return -1; + } + + + Launcher daliApplication( Dali::Application::New( &argc, &argv ), jSONFileName, javaScriptFileName ); + + daliApplication.MainLoop(); + + return 0; +} diff --git a/examples/scroll-view/scroll-view-example.cpp b/examples/scroll-view/scroll-view-example.cpp index b69ea83..d8d7fa1 100644 --- a/examples/scroll-view/scroll-view-example.cpp +++ b/examples/scroll-view/scroll-view-example.cpp @@ -141,7 +141,7 @@ const Vector3 ANCHOR_3DEFFECT_STYLE1(65.0f, -70.0f, -300.0f); ///< Rotation Anch const unsigned int IMAGE_THUMBNAIL_WIDTH = 256; ///< Width of Thumbnail Image in texels const unsigned int IMAGE_THUMBNAIL_HEIGHT = 256; ///< Height of Thumbnail Image in texels -const float SPIN_DURATION = 5.0f; ///< Times to spin an Image by upon touching, each spin taking a second. +const float SPIN_DURATION = 1.0f; ///< Times to spin an Image by upon touching, each spin taking a second. const float EFFECT_SNAP_DURATION(0.66f); ///< Scroll Snap Duration for Effects const float EFFECT_FLICK_DURATION(0.5f); ///< Scroll Flick Duration for Effects @@ -226,6 +226,7 @@ private: Vector2 stageSize = stage.GetSize(); mScrollView = ScrollView::New(); + mScrollView.SetRelayoutEnabled( false ); mScrollView.SetAnchorPoint(AnchorPoint::CENTER); mScrollView.SetParentOrigin(ParentOrigin::CENTER); mContentLayer.Add( mScrollView ); @@ -298,7 +299,8 @@ private: Actor CreatePage() { Actor page = Actor::New(); - page.SetSizeMode( SIZE_EQUAL_TO_PARENT ); + page.SetRelayoutEnabled( true ); + page.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); page.SetParentOrigin( ParentOrigin::CENTER ); page.SetAnchorPoint( AnchorPoint::CENTER ); @@ -450,7 +452,8 @@ private: void ApplyEffectToPage(Actor page) { page.RemoveConstraints(); - page.SetSizeMode( SIZE_EQUAL_TO_PARENT ); + page.SetRelayoutEnabled( true ); + page.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); switch( mEffectMode ) { @@ -566,6 +569,7 @@ private: attributes.SetFilterMode( ImageAttributes::BoxThenLinear ); Image img = ResourceImage::New(filename, attributes); ImageActor actor = ImageActor::New(img); + actor.SetRelayoutEnabled( false ); actor.SetName( filename ); actor.SetParentOrigin(ParentOrigin::CENTER); actor.SetAnchorPoint(AnchorPoint::CENTER); @@ -609,7 +613,7 @@ private: { // Spin the Image a few times. Animation animation = Animation::New(SPIN_DURATION); - animation.RotateBy( actor, Degree(360.0f * SPIN_DURATION), Vector3::XAXIS, AlphaFunctions::EaseOut); + animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(360.0f * SPIN_DURATION) ), Vector3::XAXIS ), AlphaFunctions::EaseOut ); animation.Play(); } } diff --git a/examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp b/examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp index 6b8b917..8aa17a2 100644 --- a/examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp +++ b/examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp @@ -213,7 +213,8 @@ public: mShadowView.SetName("Container"); mShadowView.SetParentOrigin(ParentOrigin::CENTER); mShadowView.SetAnchorPoint(AnchorPoint::CENTER); - mShadowView.SetSizeMode( SIZE_EQUAL_TO_PARENT ); + mShadowView.SetRelayoutEnabled( true ); + mShadowView.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); mShadowView.SetPointLightFieldOfView( Math::PI / 2.0f); mContents.Add(mShadowView); @@ -271,6 +272,9 @@ public: mImageActor2 = ImageActor::New( ResourceImage::New(SCENE_IMAGE_2) ); mImageActor3 = ImageActor::New( ResourceImage::New(SCENE_IMAGE_3) ); + mImageActor1.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); + mImageActor2.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); + mImageActor3.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); mImageActor2.SetParentOrigin(ParentOrigin::CENTER); diff --git a/examples/size-negotiation/size-negotiation-example.cpp b/examples/size-negotiation/size-negotiation-example.cpp new file mode 100644 index 0000000..473f16a --- /dev/null +++ b/examples/size-negotiation/size-negotiation-example.cpp @@ -0,0 +1,1322 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "shared/view.h" +#include +#include + +using namespace Dali; + +// Define this so that it is interchangeable +// "DP" stands for Device independent Pixels +#define DP(x) DemoHelper::ScalePointSize(x) + +struct ButtonItem +{ + const char* name; + const char* text; +}; + + +namespace +{ + +const char* const BACKGROUND_IMAGE = DALI_IMAGE_DIR "background-gradient.jpg"; +const char* const TOOLBAR_IMAGE = DALI_IMAGE_DIR "top-bar.png"; + +const char* const TOOLBAR_TITLE = "Size Negotiation"; +const int TOOLBAR_HEIGHT = 62; + +const char* MENU_ICON_IMAGE = DALI_IMAGE_DIR "icon-cluster-none.png"; + +const char* const PUSHBUTTON_BUTTON_IMAGE = DALI_IMAGE_DIR "button-up.9.png"; +const char* const PUSHBUTTON_PRESS_IMAGE = DALI_IMAGE_DIR "button-down.9.png"; + +const char* const POPUPS_MENU_ID = "POPUPS_MENU"; +const char* const TABLEVIEW_MENU_ID = "TABLEVIEW_MENU"; + +const char* const POPUP_BUTTON_EMPTY_ID = "POPUP_BUTTON_EMPTY"; +const char* const POPUP_BUTTON_TITLE_ID = "POPUP_BUTTON_TITLE"; +const char* const POPUP_BUTTON_BUTTONS_1_ID = "POPUP_BUTTON_BUTTONS_1"; +const char* const POPUP_BUTTON_BUTTONS_2_ID = "POPUP_BUTTON_BUTTONS_2"; +const char* const POPUP_BUTTON_TITLE_BUTTONS_ID = "POPUP_BUTTON_TITLE_BUTTONS"; +const char* const POPUP_BUTTON_CONTENT_TEXT_ID = "POPUP_BUTTON_CONTENT_TEXT"; +const char* const POPUP_BUTTON_CONTENT_IMAGE_ID = "POPUP_BUTTON_CONTENT_IMAGE"; +const char* const POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID = "POPUP_BUTTON_CONTENT_IMAGE_SCALE"; +const char* const POPUP_BUTTON_CONTENT_IMAGE_FIT_ID = "POPUP_BUTTON_CONTENT_IMAGE_FIT"; +const char* const POPUP_BUTTON_CONTENT_IMAGE_FILL_ID = "POPUP_BUTTON_CONTENT_IMAGE_FILL"; +const char* const POPUP_BUTTON_TITLE_CONTENT_TEXT_ID = "POPUP_BUTTON_TITLE_CONTENT_TEXT"; +const char* const POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS_ID = "POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS"; +const char* const POPUP_BUTTON_COMPLEX_ID = "POPUP_BUTTON_COMPLEX"; + +const char* const TABLEVIEW_BUTTON_EMPTY_ID = "TABLEVIEW_BUTTON_EMPTY"; +const char* const TABLEVIEW_BUTTON_1CELL_ID = "TABLEVIEW_BUTTON_1CELL"; +const char* const TABLEVIEW_BUTTON_3CELL_ID = "TABLEVIEW_BUTTON_3CELL"; +const char* const TABLEVIEW_BUTTON_3X3CELL_ID = "TABLEVIEW_BUTTON_3X3CELL"; +const char* const TABLEVIEW_BUTTON_FIXED1_ID = "TABLEVIEW_BUTTON_FIXED1"; +const char* const TABLEVIEW_BUTTON_FIXED2_ID = "TABLEVIEW_BUTTON_FIXED2"; +const char* const TABLEVIEW_BUTTON_FIT1_ID = "TABLEVIEW_BUTTON_FIT1"; +const char* const TABLEVIEW_BUTTON_FIT2_ID = "TABLEVIEW_BUTTON_FIT2"; +const char* const TABLEVIEW_BUTTON_NATURAL1_ID = "TABLEVIEW_BUTTON_NATURAL1"; +const char* const TABLEVIEW_BUTTON_NATURAL2_ID = "TABLEVIEW_BUTTON_NATURAL2"; +const char* const TABLEVIEW_BUTTON_NATURAL3_ID = "TABLEVIEW_BUTTON_NATURAL3"; + +const char* const OKAY_BUTTON_ID = "OKAY_BUTTON"; +const char* const CANCEL_BUTTON_ID = "CANCEL_BUTTON"; + +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."; +const char* const IMAGE1 = DALI_IMAGE_DIR "gallery-medium-5.jpg"; +const char* const IMAGE2 = DALI_IMAGE_DIR "background-magnifier.jpg"; +const char* const CHECKBOX_UNCHECKED_IMAGE = DALI_IMAGE_DIR "checkbox-unselected.png"; +const char* const CHECKBOX_CHECKED_IMAGE = DALI_IMAGE_DIR "checkbox-selected.png"; + +const ButtonItem MENU_ITEMS[] = { + { POPUPS_MENU_ID, "Popups" }, + { TABLEVIEW_MENU_ID, "TableView" } +}; + +const unsigned int MENU_ITEMS_COUNT = sizeof( MENU_ITEMS ) / sizeof( MENU_ITEMS[0] ); + +const ButtonItem POPUP_BUTTON_ITEMS[] = { + { POPUP_BUTTON_COMPLEX_ID, "Complex" }, + { POPUP_BUTTON_EMPTY_ID, "Empty" }, + { POPUP_BUTTON_TITLE_ID, "Title" }, + { POPUP_BUTTON_BUTTONS_1_ID, "1 Button" }, + { POPUP_BUTTON_BUTTONS_2_ID, "2 Buttons" }, + { POPUP_BUTTON_TITLE_BUTTONS_ID, "Title & Buttons" }, + { POPUP_BUTTON_CONTENT_TEXT_ID, "Text" }, + { POPUP_BUTTON_CONTENT_IMAGE_ID, "Image" }, + { POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID, "Image Scale" }, + { POPUP_BUTTON_CONTENT_IMAGE_FIT_ID, "Image Fit" }, + { POPUP_BUTTON_CONTENT_IMAGE_FILL_ID, "Image Fill" }, + { POPUP_BUTTON_TITLE_CONTENT_TEXT_ID, "Title Text" }, + { POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS_ID, "Title, text, buttons" } + +}; + +const int POPUP_BUTTON_ITEMS_COUNT = sizeof( POPUP_BUTTON_ITEMS ) / sizeof( POPUP_BUTTON_ITEMS[0] ); + +const ButtonItem TABLEVIEW_BUTTON_ITEMS[] = { + { TABLEVIEW_BUTTON_EMPTY_ID, "Empty" }, + { TABLEVIEW_BUTTON_1CELL_ID, "1 Cell" }, + { TABLEVIEW_BUTTON_3CELL_ID, "3 Cell" }, + { TABLEVIEW_BUTTON_3X3CELL_ID, "3x3 Cells" }, + { TABLEVIEW_BUTTON_FIXED1_ID, "Fixed 1" }, + { TABLEVIEW_BUTTON_FIXED2_ID, "Fixed 2" }, + { TABLEVIEW_BUTTON_FIT1_ID, "Fit Top Bottom" }, + { TABLEVIEW_BUTTON_FIT2_ID, "Fit Middle" }, + { TABLEVIEW_BUTTON_NATURAL1_ID, "Natural 1" }, + { TABLEVIEW_BUTTON_NATURAL2_ID, "Natural 2" }, + { TABLEVIEW_BUTTON_NATURAL3_ID, "Natural 3" }, +}; + +const unsigned int TABLEVIEW_BUTTON_ITEMS_COUNT = sizeof( TABLEVIEW_BUTTON_ITEMS ) / sizeof( TABLEVIEW_BUTTON_ITEMS[0] ); + +} // namespace + + + +/** + * This example shows the usage of size negotiation. + */ +class SizeNegotiationController: public ConnectionTracker, public Toolkit::ItemFactory +{ +public: + + SizeNegotiationController( Application& application ) + : mApplication( application ), + mMenuShown( false ), + mDemoState( POPUP ) + { + // Connect to the Application's Init signal + mApplication.InitSignal().Connect( this, &SizeNegotiationController::Create ); + } + + ~SizeNegotiationController() + { + // Nothing to do here + } + + void Create( Application& application ) + { + // The Init signal is received once (only) during the Application lifetime + + Stage stage = Stage::GetCurrent(); + + // Respond to key events + stage.KeyEventSignal().Connect(this, &SizeNegotiationController::OnKeyEvent); + + // Creates a default view with a default tool bar. + // The view is added to the stage. + mContentLayer = DemoHelper::CreateView( application, + mView, + mToolBar, + BACKGROUND_IMAGE, + TOOLBAR_IMAGE, + std::string("") ); + + mTitleActor = Dali::Toolkit::TextView::New(); + mTitleActor.SetName( "CUSTOM_TOOLBAR_TITLE" ); + + SetTitle(); + + // Create menu button + Toolkit::PushButton viewButton = Toolkit::PushButton::New(); + viewButton.SetBackgroundImage( ResourceImage::New( MENU_ICON_IMAGE ) ); + viewButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnMenu ); + mToolBar.AddControl( viewButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); + + // Add title to the tool bar. + const float padding( DemoHelper::DEFAULT_VIEW_STYLE.mToolBarPadding ); + mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter, Toolkit::Alignment::Padding( padding, padding, padding, padding ) ); + + mItemView = Toolkit::ItemView::New( *this ); + mItemView.SetParentOrigin( ParentOrigin::CENTER ); + mItemView.SetAnchorPoint( AnchorPoint::CENTER ); + mItemView.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + + // Use a grid layout for tests + Toolkit::GridLayoutPtr gridLayout = Toolkit::GridLayout::New(); + gridLayout->SetNumberOfColumns( 2 ); + gridLayout->SetTopMargin( DP(TOOLBAR_HEIGHT) + DP(20.0f) ); + gridLayout->SetBottomMargin( DP(100.0f) ); + gridLayout->SetRowSpacing( DP(20.0f) ); + mItemView.AddLayout( *gridLayout ); + + Vector2 stageSize = stage.GetSize(); + float layoutWidth = Toolkit::IsHorizontal( gridLayout->GetOrientation() ) ? stageSize.height : stageSize.width; + float gridItemSize = ( layoutWidth / gridLayout->GetNumberOfColumns() ) * 0.5f; + gridLayout->SetScrollSpeedFactor( gridLayout->GetNumberOfColumns() / gridItemSize * 0.5f ); + + mItemView.ActivateLayout( 0, Vector3(stageSize.x, stageSize.y, stageSize.x), 0.0f ); + + mContentLayer.Add( mItemView ); + } + + void SetTitle() + { + std::string subTitle = ""; + + switch( mDemoState ) + { + case POPUP: + { + subTitle = "Popups"; + break; + } + + case TABLEVIEW: + { + subTitle = "TableView"; + break; + } + + default: + { + break; + } + } + + mTitleActor.SetText( std::string( TOOLBAR_TITLE ) + ": " + subTitle ); + mTitleActor.SetStyleToCurrentText( DemoHelper::GetDefaultTextStyle() ); + } + + bool OnMenu( Toolkit::Button button ) + { + ShowMenu(); + return true; + } + + void ShowMenu() + { + Stage stage = Stage::GetCurrent(); + const float popupWidth = stage.GetSize().x * 0.5f; + + mMenu = Toolkit::Popup::New(); + mMenu.SetParentOrigin( ParentOrigin::TOP_LEFT ); + mMenu.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mMenu.HideTail(); + mMenu.OutsideTouchedSignal().Connect( this, &SizeNegotiationController::HideMenu ); + mMenu.SetSize( popupWidth, 0.0f ); + mMenu.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT ); + + Toolkit::TableView tableView = Toolkit::TableView::New( 0, 0 ); + tableView.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + tableView.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT ); + mMenu.Add( tableView ); + + for( unsigned int i = 0; i < MENU_ITEMS_COUNT; ++i ) + { + Toolkit::PushButton menuButton = Toolkit::PushButton::New(); + menuButton.SetName( MENU_ITEMS[ i ].name ); + menuButton.SetLabel( MENU_ITEMS[ i ].text ); + menuButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnMenuSelect ); + + tableView.Add( menuButton ); + tableView.SetFitHeight( i ); + } + + // Show the menu + mMenu.Show(); + mMenuShown = true; + } + + void HideMenu() + { + if( mMenu ) + { + mMenu.Hide(); + mMenu.Reset(); + } + + mMenuShown = false; + } + + bool OnMenuSelect( Toolkit::Button button ) + { + bool refresh = false; + + if( button.GetName() == POPUPS_MENU_ID ) + { + if( mDemoState != POPUP ) + { + refresh = true; + mDemoState = POPUP; + } + } + else if( button.GetName() == TABLEVIEW_MENU_ID ) + { + if( mDemoState != TABLEVIEW ) + { + refresh = true; + mDemoState = TABLEVIEW; + } + } + + if( refresh ) + { + SetTitle(); + + mItemView.Refresh(); + } + + HideMenu(); + return true; + } + + Toolkit::Popup CreatePopup() + { + Stage stage = Stage::GetCurrent(); + const float POPUP_WIDTH_DP = stage.GetSize().width * 0.75f; + + Toolkit::Popup popup = Toolkit::Popup::New(); + popup.SetName( "POPUP" ); + popup.SetParentOrigin( ParentOrigin::CENTER ); + popup.SetAnchorPoint( AnchorPoint::CENTER ); + popup.SetSize( POPUP_WIDTH_DP, 0.0f ); + popup.HideTail(); + + popup.OutsideTouchedSignal().Connect( this, &SizeNegotiationController::OnPopupOutsideTouched ); + + return popup; + } + + bool OnButtonClicked( Toolkit::Button button ) + { + if( button.GetName() == POPUP_BUTTON_EMPTY_ID ) + { + mPopup = CreatePopup(); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == POPUP_BUTTON_TITLE_ID ) + { + mPopup = CreatePopup(); + mPopup.SetTitle( "Popup!" ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == POPUP_BUTTON_BUTTONS_1_ID ) + { + mPopup = CreatePopup(); + + Toolkit::PushButton okayButton = Toolkit::PushButton::New(); + okayButton.SetName( OKAY_BUTTON_ID ); + okayButton.SetLabel( "OK!" ); + okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) ); + okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) ); + + okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); + + mPopup.AddButton( okayButton ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == POPUP_BUTTON_BUTTONS_2_ID ) + { + mPopup = CreatePopup(); + + Toolkit::PushButton cancelButton = Toolkit::PushButton::New(); + cancelButton.SetName( CANCEL_BUTTON_ID ); + cancelButton.SetLabel( "Cancel" ); + cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) ); + cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) ); + + cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); + + mPopup.AddButton( cancelButton ); + + Toolkit::PushButton okayButton = Toolkit::PushButton::New(); + okayButton.SetName( OKAY_BUTTON_ID ); + okayButton.SetLabel( "OK!" ); + okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) ); + okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) ); + + okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); + + mPopup.AddButton( okayButton ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == POPUP_BUTTON_TITLE_BUTTONS_ID ) + { + mPopup = CreatePopup(); + mPopup.SetTitle( "Popup!" ); + + Toolkit::PushButton cancelButton = Toolkit::PushButton::New(); + cancelButton.SetName( CANCEL_BUTTON_ID ); + cancelButton.SetLabel( "Cancel" ); + cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) ); + cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) ); + + cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); + + mPopup.AddButton( cancelButton ); + + Toolkit::PushButton okayButton = Toolkit::PushButton::New(); + okayButton.SetName( OKAY_BUTTON_ID ); + okayButton.SetLabel( "OK!" ); + okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) ); + okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) ); + + okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); + + mPopup.AddButton( okayButton ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == POPUP_BUTTON_CONTENT_TEXT_ID ) + { + mPopup = CreatePopup(); + + Toolkit::TextView text = Toolkit::TextView::New(); + text.SetName( "POPUP_CONTENT_TEXT" ); + text.SetText( CONTENT_TEXT ); + text.SetMultilinePolicy( Toolkit::TextView::SplitByWord ); + text.SetWidthExceedPolicy( Toolkit::TextView::Split ); + text.SetLineJustification( Toolkit::TextView::Center ); + text.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); + text.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) ); + + mPopup.Add( text ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_ID ) + { + mPopup = CreatePopup(); + + ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) ); + image.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + image.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); + image.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) ); + + mPopup.Add( image ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_SCALE_ID ) + { + mPopup = CreatePopup(); + + mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); + mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); + + ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) ); + image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + + mPopup.Add( image ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FIT_ID ) + { + mPopup = CreatePopup(); + + mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); + mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); + + ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) ); + image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + image.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO ); + + mPopup.Add( image ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == POPUP_BUTTON_CONTENT_IMAGE_FILL_ID ) + { + mPopup = CreatePopup(); + + mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); + mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); + + ImageActor image = ImageActor::New( ResourceImage::New( IMAGE2 ) ); + image.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + image.SetSizeScalePolicy( FILL_WITH_ASPECT_RATIO ); + + mPopup.Add( image ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_ID ) + { + mPopup = CreatePopup(); + mPopup.SetTitle( "Popup!" ); + + Toolkit::TextView text = Toolkit::TextView::New(); + text.SetName( "POPUP_CONTENT_TEXT" ); + text.SetText( CONTENT_TEXT ); + text.SetMultilinePolicy( Toolkit::TextView::SplitByWord ); + text.SetWidthExceedPolicy( Toolkit::TextView::Split ); + text.SetLineJustification( Toolkit::TextView::Center ); + text.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); + text.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) ); + + mPopup.Add( text ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == POPUP_BUTTON_TITLE_CONTENT_TEXT_BUTTONS_ID ) + { + mPopup = CreatePopup(); + mPopup.SetTitle( "Popup!" ); + + Toolkit::TextView text = Toolkit::TextView::New(); + text.SetName( "POPUP_CONTENT_TEXT" ); + text.SetText( CONTENT_TEXT ); + text.SetMultilinePolicy( Toolkit::TextView::SplitByWord ); + text.SetWidthExceedPolicy( Toolkit::TextView::Split ); + text.SetLineJustification( Toolkit::TextView::Left ); + text.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); + text.SetPadding( Padding( 10.0f, 10.0f, 20.0f, 0.0f ) ); + + mPopup.Add( text ); + + Toolkit::PushButton cancelButton = Toolkit::PushButton::New(); + cancelButton.SetName( CANCEL_BUTTON_ID ); + cancelButton.SetLabel( "Cancel" ); + cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) ); + cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) ); + + cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); + + mPopup.AddButton( cancelButton ); + + Toolkit::PushButton okayButton = Toolkit::PushButton::New(); + okayButton.SetName( OKAY_BUTTON_ID ); + okayButton.SetLabel( "OK!" ); + okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) ); + okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) ); + + okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); + + mPopup.AddButton( okayButton ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == POPUP_BUTTON_COMPLEX_ID ) + { + mPopup = CreatePopup(); + mPopup.SetTitle( "Warning" ); + + // Content + Toolkit::TableView content = Toolkit::TableView::New( 2, 2 ); + content.SetName( "COMPLEX_TABLEVIEW" ); + content.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + content.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT ); + content.SetFitHeight( 0 ); + content.SetFitHeight( 1 ); + content.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 0.0f ) ); + + // Text + { + Toolkit::TextView text = Toolkit::TextView::New(); + text.SetText( "Do you really want to quit?" ); + text.SetMultilinePolicy( Toolkit::TextView::SplitByWord ); + text.SetWidthExceedPolicy( Toolkit::TextView::Split ); + text.SetLineJustification( Toolkit::TextView::Left ); + text.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); + + content.AddChild( text, Toolkit::TableView::CellPosition( 0, 0 ) ); + } + + // Image + { + ImageActor image = ImageActor::New( ResourceImage::New( IMAGE1 ) ); + image.SetName( "COMPLEX_IMAGE" ); + image.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + image.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); + image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) ); + content.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) ); + } + + // Text 2 + { + Toolkit::TableView root = Toolkit::TableView::New( 1, 2 ); + root.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + root.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT ); + root.SetFitHeight( 0 ); + root.SetFitWidth( 0 ); + root.SetPadding( Padding( 0.0f, 0.0f, 0.0f, 20.0f ) ); + + Dali::Image unchecked = Dali::ResourceImage::New( CHECKBOX_UNCHECKED_IMAGE ); + Dali::Image checked = Dali::ResourceImage::New( CHECKBOX_CHECKED_IMAGE ); + Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New(); + checkBox.SetBackgroundImage( unchecked ); + checkBox.SetSelectedImage( checked ); + checkBox.SetSize( 48, 48 ); + + root.AddChild( checkBox, Toolkit::TableView::CellPosition( 0, 0 ) ); + + Toolkit::TextView text = Toolkit::TextView::New(); + text.SetText( "Don't show again" ); + text.SetLineJustification( Toolkit::TextView::Left ); + Actor textActor = text; + textActor.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 10.0f ) ); + + root.AddChild( text, Toolkit::TableView::CellPosition( 0, 1 ) ); + + content.AddChild( root, Toolkit::TableView::CellPosition( 1, 0, 0, 2 ) ); // Column span 2 + } + + mPopup.Add( content ); + + // Buttons + Toolkit::PushButton cancelButton = Toolkit::PushButton::New(); + cancelButton.SetName( CANCEL_BUTTON_ID ); + cancelButton.SetLabel( "Cancel" ); + cancelButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) ); + cancelButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) ); + + cancelButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); + + mPopup.AddButton( cancelButton ); + + Toolkit::PushButton okayButton = Toolkit::PushButton::New(); + okayButton.SetName( OKAY_BUTTON_ID ); + okayButton.SetLabel( "OK!" ); + okayButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) ); + okayButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) ); + + okayButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); + + mPopup.AddButton( okayButton ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == TABLEVIEW_BUTTON_EMPTY_ID ) + { + mPopup = CreatePopup(); + mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); + mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); + + + Toolkit::TableView table = Toolkit::TableView::New( 0, 0 ); + table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + + mPopup.Add( table ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == TABLEVIEW_BUTTON_1CELL_ID ) + { + mPopup = CreatePopup(); + mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); + mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); + + + Toolkit::TableView table = Toolkit::TableView::New( 0, 0 ); + table.SetName( "TABLEVIEW_BUTTON_1CELL_ID" ); + table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + table.Add( backing ); + + mPopup.Add( table ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == TABLEVIEW_BUTTON_3CELL_ID ) + { + mPopup = CreatePopup(); + mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); + mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); + + + Toolkit::TableView table = Toolkit::TableView::New( 0, 0 ); + table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + table.Add( backing ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + table.Add( backing ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + table.Add( backing ); + } + + mPopup.Add( table ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == TABLEVIEW_BUTTON_3X3CELL_ID ) + { + mPopup = CreatePopup(); + mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); + mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); + + + Toolkit::TableView table = Toolkit::TableView::New( 3, 3 ); + table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + + // Column 0 + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 0 ) ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 0 ) ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 0 ) ); + } + + // Column 1 + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 1 ) ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 1 ) ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 0.0f, 1.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 1 ) ); + } + + // Column 2 + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + table.AddChild( backing, Toolkit::TableView::CellPosition( 0, 2 ) ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.5f, 0.5f, 0.5f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + table.AddChild( backing, Toolkit::TableView::CellPosition( 1, 2 ) ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.5f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + table.AddChild( backing, Toolkit::TableView::CellPosition( 2, 2 ) ); + } + + mPopup.Add( table ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == TABLEVIEW_BUTTON_FIXED1_ID ) + { + mPopup = CreatePopup(); + mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); + mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); + + + Toolkit::TableView table = Toolkit::TableView::New( 3, 1 ); + table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + table.SetFixedHeight( 0, 50.0f ); + + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + TextActor text = TextActor::New( "Fixed" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + table.Add( backing ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + TextActor text = TextActor::New( "Fill" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + table.Add( backing ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + TextActor text = TextActor::New( "Fill" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + table.Add( backing ); + } + + mPopup.Add( table ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == TABLEVIEW_BUTTON_FIXED2_ID ) + { + mPopup = CreatePopup(); + mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); + mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); + + + Toolkit::TableView table = Toolkit::TableView::New( 3, 1 ); + table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + table.SetFixedHeight( 0, 50.0f ); + table.SetFixedHeight( 2, 50.0f ); + + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + TextActor text = TextActor::New( "Fixed" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + table.Add( backing ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + TextActor text = TextActor::New( "Fill" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + table.Add( backing ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + TextActor text = TextActor::New( "Fixed" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + table.Add( backing ); + } + + mPopup.Add( table ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == TABLEVIEW_BUTTON_FIT1_ID ) + { + mPopup = CreatePopup(); + mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); + mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); + + + Toolkit::TableView table = Toolkit::TableView::New( 3, 1 ); + table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + table.SetFitHeight( 0 ); + table.SetFitHeight( 2 ); + + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + backing.SetSize( 0.0f, 100.0f ); + + TextActor text = TextActor::New( "Fit" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + + table.Add( backing ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + + TextActor text = TextActor::New( "Fill" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + + table.Add( backing ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + backing.SetSize( 0.0f, 100.0f ); + + TextActor text = TextActor::New( "Fit" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + + table.Add( backing ); + } + + mPopup.Add( table ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == TABLEVIEW_BUTTON_FIT2_ID ) + { + mPopup = CreatePopup(); + mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); + mPopup.SetSizeModeFactor( Vector3( 0.75f, 0.5f, 1.0f ) ); + + Toolkit::TableView table = Toolkit::TableView::New( 3, 1 ); + table.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + table.SetFitHeight( 1 ); + + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + + TextActor text = TextActor::New( "Fill" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + + table.Add( backing ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + backing.SetSize( 0.0f, 200.0f ); + + TextActor text = TextActor::New( "Fit" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + + table.Add( backing ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + + TextActor text = TextActor::New( "Fill" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + + table.Add( backing ); + } + + mPopup.Add( table ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL1_ID ) + { + mPopup = CreatePopup(); + mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, WIDTH ); + mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) ); + mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT ); + + Toolkit::TableView table = Toolkit::TableView::New( 3, 1 ); + table.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT ); + table.SetFitHeight( 0 ); + table.SetFitHeight( 1 ); + table.SetFitHeight( 2 ); + + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + backing.SetSize( 0.0f, 100.0f ); + + TextActor text = TextActor::New( "Fit" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + + table.Add( backing ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + backing.SetSize( 0.0f, 200.0f ); + + TextActor text = TextActor::New( "Fit" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + + table.Add( backing ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + backing.SetSize( 0.0f, 300.0f ); + + TextActor text = TextActor::New( "Fit" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + + table.Add( backing ); + } + + mPopup.Add( table ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL2_ID ) + { + mPopup = CreatePopup(); + mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, WIDTH ); + mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) ); + mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT ); + + Toolkit::TableView table = Toolkit::TableView::New( 3, 1 ); + table.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT ); + table.SetFitHeight( 0 ); + table.SetFitHeight( 1 ); + + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + backing.SetResizePolicy( FIXED, HEIGHT ); + backing.SetSize( 0.0f, 100.0f ); + + TextActor text = TextActor::New( "Fit" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + + table.Add( backing ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + backing.SetSize( 0.0f, 200.0f ); + + TextActor text = TextActor::New( "Fit" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + + table.Add( backing ); + } + + mPopup.Add( table ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == TABLEVIEW_BUTTON_NATURAL3_ID ) + { + mPopup = CreatePopup(); + mPopup.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, WIDTH ); + mPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) ); + mPopup.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT ); + + Toolkit::TableView table = Toolkit::TableView::New( 3, 1 ); + table.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + table.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT ); + table.SetFixedHeight( 0, 20.0f ); + table.SetFitHeight( 1 ); + + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + + TextActor text = TextActor::New( "Fixed" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + + table.Add( backing ); + } + { + Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) ); + backing.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + backing.SetSize( 0.0f, 200.0f ); + + TextActor text = TextActor::New( "Fit" ); + text.SetAnchorPoint( AnchorPoint::CENTER ); + text.SetParentOrigin( ParentOrigin::CENTER ); + backing.Add( text ); + + table.Add( backing ); + } + + mPopup.Add( table ); + + // The popup is not yet on the stage so needs to be flaged as dirty + mPopup.MarkDirtyForRelayout(); + + mPopup.Show(); + } + else if( button.GetName() == OKAY_BUTTON_ID || button.GetName() == CANCEL_BUTTON_ID ) + { + if( mPopup ) + { + mPopup.Hide(); + } + } + + return true; + } + + void OnPopupOutsideTouched() + { + if( mPopup ) + { + mPopup.Hide(); + } + } + + void OnKeyEvent( const KeyEvent& event ) + { + if( event.state == KeyEvent::Down ) + { + if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) + { + // Exit application when click back or escape. + mApplication.Quit(); + } + } + } + +public: // From ItemFactory + + /** + * @brief Return the number of items to display in the item view + * + * @return Return the number of items to display + */ + virtual unsigned int GetNumberOfItems() + { + switch( mDemoState ) + { + case POPUP: + { + return POPUP_BUTTON_ITEMS_COUNT; + } + + case TABLEVIEW: + { + return TABLEVIEW_BUTTON_ITEMS_COUNT; + } + + default: + { + break; + } + } + + return 0; + } + + /** + * @brief Create a new item to populate the item view with + * + * @param[in] itemId The index of the item to create + * @return Return the created actor for the given ID + */ + virtual Actor NewItem(unsigned int itemId) + { + const ButtonItem* buttonDataArray = NULL; + switch( mDemoState ) + { + case POPUP: + { + buttonDataArray = POPUP_BUTTON_ITEMS; + break; + } + + case TABLEVIEW: + { + buttonDataArray = TABLEVIEW_BUTTON_ITEMS; + break; + } + + default: + { + break; + } + } + + if( buttonDataArray ) + { + Toolkit::PushButton popupButton = Toolkit::PushButton::New(); + popupButton.SetName( buttonDataArray[ itemId ].name ); + popupButton.SetLabel( buttonDataArray[ itemId ].text ); + popupButton.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); + + popupButton.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) ); + popupButton.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) ); + + popupButton.ClickedSignal().Connect( this, &SizeNegotiationController::OnButtonClicked ); + + return popupButton; + } + + return Actor(); + } + +private: + + enum DemoState + { + POPUP, + TABLEVIEW + }; + + Application& mApplication; + Toolkit::View mView; ///< The View instance. + Toolkit::ToolBar mToolBar; ///< The View's Toolbar. + Layer mContentLayer; ///< Content layer + + Toolkit::TextView mTitleActor; ///< Title text + + Toolkit::Popup mMenu; ///< The navigation menu + bool mMenuShown; ///< If the navigation menu is currently being displayed or not + + Toolkit::Popup mPopup; + + Toolkit::ItemView mItemView; ///< ItemView to hold test images + + DemoState mDemoState; +}; + +void RunTest( Application& application ) +{ + SizeNegotiationController test( application ); + + application.MainLoop(); +} + +// Entry point for Linux & SLP applications +// +int main( int argc, char **argv ) +{ + Application application = Application::New( &argc, &argv ); + + RunTest( application ); + + return 0; +} diff --git a/examples/text-view/text-view-example.cpp b/examples/text-view/text-view-example.cpp index 155a8c4..c90b227 100644 --- a/examples/text-view/text-view-example.cpp +++ b/examples/text-view/text-view-example.cpp @@ -75,14 +75,14 @@ const TableString TABLE_STRINGS[] = { { "HelveticaNue", "Regular", 8.0f, { "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 } }, { "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 } }, { "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 } }, - { "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 } }, + { "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 } }, { "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 } }, - { "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 } }, + { "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 } }, { "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 } }, { "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 } }, { "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 } }, { "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 } }, - { "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 } }, + { "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 } }, { "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 } } }; @@ -151,10 +151,12 @@ public: Toolkit::TextView textView = Toolkit::TextView::New( tableString.text ); textView.SetStyleToCurrentText( textStyle ); textView.SetOrientation( Dali::Degree( tableString.orientation ), Vector3( 0.0f, 0.0f, 1.0f ) ); + textView.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); Toolkit::Alignment alignmentContainer = Toolkit::Alignment::New( tableString.horizontalAlignment, tableString.verticalAlignment ); - alignmentContainer.SetPadding( Toolkit::Alignment::Padding( tableString.padding, tableString.padding, tableString.padding, tableString.padding ) ); - alignmentContainer.SetScaling( Toolkit::Alignment::ScaleToFill ); + Actor alignmentContainerActor = alignmentContainer; + alignmentContainerActor.SetPadding( Padding( tableString.padding, tableString.padding, tableString.padding, tableString.padding ) ); + alignmentContainer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); alignmentContainer.Add( textView ); textContainer.AddChild( alignmentContainer, Toolkit::TableView::CellPosition( tableString.cellPosition.row, tableString.cellPosition.column, tableString.cellPosition.rowSpan, tableString.cellPosition.columnSpan ) ); diff --git a/packaging/com.samsung.dali-demo.spec b/packaging/com.samsung.dali-demo.spec index 2822056..a24fa0a 100755 --- a/packaging/com.samsung.dali-demo.spec +++ b/packaging/com.samsung.dali-demo.spec @@ -2,7 +2,7 @@ Name: com.samsung.dali-demo Summary: The OpenGLES Canvas Core Demo -Version: 1.0.35 +Version: 1.0.36 Release: 1 Group: System/Libraries License: Apache-2.0 diff --git a/resources/scripts/animated-buttons.json b/resources/scripts/animated-buttons.json index 234b80e..19af1d3 100644 --- a/resources/scripts/animated-buttons.json +++ b/resources/scripts/animated-buttons.json @@ -3,6 +3,7 @@ { "type": "ImageActor", "name": "On", + "relayout-enabled": false, "position": [ 374, 215, @@ -11,7 +12,7 @@ "size": [ 144, 144, - 1 + 1 ], "sizeAspectRatio": false, "color": [ @@ -33,6 +34,7 @@ { "type": "ImageActor", "name": "Off", + "relayout-enabled": false, "position": [ 129, 215, @@ -41,7 +43,7 @@ "size": [ 144, 144, - 1 + 1 ], "sizeAspectRatio": false, "color": [ @@ -63,6 +65,7 @@ { "type": "ImageActor", "name": "Right", + "relayout-enabled": false, "position": [ 418.5, 214.5, @@ -71,7 +74,7 @@ "size": [ 85, 161, - 1 + 1 ], "sizeAspectRatio": false, "visible": true, @@ -94,6 +97,7 @@ { "type": "ImageActor", "name": "Left", + "relayout-enabled": false, "position": [ 331, 214.5, @@ -102,7 +106,7 @@ "size": [ 88, 161, - 1 + 1 ], "sizeAspectRatio": false, "visible": true, @@ -125,6 +129,7 @@ { "type": "ImageActor", "name": "Middle", + "relayout-enabled": false, "position": [ 375.5, 214.5, @@ -138,7 +143,7 @@ "size": [ 1, 161, - 1 + 1 ], "sizeAspectRatio": false, "color": [ @@ -160,6 +165,7 @@ { "type": "ImageActor", "name": "Jelly", + "relayout-enabled": false, "position": [ 374, 215, @@ -168,7 +174,7 @@ "size": [ 144, 144, - 1 + 1 ], "sizeAspectRatio": false, "color": [ @@ -190,6 +196,7 @@ { "type": "Control", "name": "Left Black", + "relayout-enabled": false, "position": [ 144.5, 218.5, @@ -198,7 +205,7 @@ "size": [ 275, 243, - 1 + 1 ], "sizeAspectRatio": false, "background-color": [ @@ -218,6 +225,7 @@ { "type": "Control", "name": "Right Black", + "relayout-enabled": false, "position": [ 629.5, 218.5, @@ -226,7 +234,7 @@ "size": [ 335, 243, - 1 + 1 ], "sizeAspectRatio": false, "background-color": [ @@ -246,6 +254,7 @@ { "type": "ImageActor", "name": "JellyOff", + "relayout-enabled": false, "position": [ 121, -117, @@ -254,7 +263,7 @@ "size": [ 144, 144, - 1 + 1 ], "sizeAspectRatio": false, "color": [ @@ -276,6 +285,7 @@ { "type": "Control", "name": "Control On", + "relayout-enabled": false, "position": [ 371.26116838487997, 217.33333333333331, @@ -284,7 +294,7 @@ "size": [ 196, 184, - 1 + 1 ], "sizeAspectRatio": false, "scale": [ @@ -310,6 +320,7 @@ { "type": "Control", "name": "Control Off", + "relayout-enabled": false, "position": [ 123.5, -117, @@ -318,7 +329,7 @@ "size": [ 193, 182, - 1 + 1 ], "sizeAspectRatio": false, "color": [ diff --git a/resources/scripts/animated-colors.json b/resources/scripts/animated-colors.json index 923ec75..2b930e8 100644 --- a/resources/scripts/animated-colors.json +++ b/resources/scripts/animated-colors.json @@ -18,9 +18,11 @@ "stage": [ { "type": "Control", + "relayout-enabled": false, "actors": [ { "type": "Control", + "relayout-enabled": true, "actors": [], "name": "Control 8", "position": [ @@ -60,9 +62,11 @@ }, { "type": "Control", + "relayout-enabled": false, "actors": [ { "type": "Control", + "relayout-enabled": false, "actors": [], "name": "Container 2", "position": [ @@ -102,9 +106,11 @@ }, { "type": "Control", + "relayout-enabled": false, "actors": [ { "type": "Control", + "relayout-enabled": false, "actors": [], "name": "Container 4", "position": [ @@ -181,9 +187,11 @@ }, { "type": "Control", + "relayout-enabled": false, "actors": [ { "type": "Control", + "relayout-enabled": false, "actors": [], "name": "Container 5", "position": [ @@ -223,9 +231,11 @@ }, { "type": "Control", + "relayout-enabled": false, "actors": [ { "type": "Control", + "relayout-enabled": false, "actors": [], "name": "Container 7", "position": [ @@ -302,9 +312,11 @@ }, { "type": "Control", + "relayout-enabled": false, "actors": [ { "type": "Control", + "relayout-enabled": false, "actors": [], "name": "Container 8", "position": [ @@ -344,9 +356,11 @@ }, { "type": "Control", + "relayout-enabled": false, "actors": [ { "type": "Control", + "relayout-enabled": false, "actors": [], "name": "Container 10", "position": [ @@ -534,9 +548,11 @@ }, { "type": "Control", + "relayout-enabled": false, "actors": [ { "type": "Control", + "relayout-enabled": false, "actors": [], "name": "Control 4", "position": [ @@ -613,9 +629,11 @@ }, { "type": "Control", + "relayout-enabled": false, "actors": [ { "type": "Control", + "relayout-enabled": false, "actors": [ { "type": "Control", @@ -695,6 +713,7 @@ }, { "type": "Control", + "relayout-enabled": false, "actors": [], "name": "Container 11", "position": [ @@ -734,12 +753,15 @@ }, { "type": "Control", + "relayout-enabled": false, "actors": [ { "type": "Control", + "relayout-enabled": false, "actors": [ { "type": "Control", + "relayout-enabled": false, "actors": [], "name": "Container 15", "position": [ @@ -816,6 +838,7 @@ }, { "type": "Control", + "relayout-enabled": false, "actors": [], "name": "Container 16", "position": [ diff --git a/resources/scripts/animation.json b/resources/scripts/animation.json index ad13fd1..7a5f8aa 100644 --- a/resources/scripts/animation.json +++ b/resources/scripts/animation.json @@ -122,6 +122,7 @@ "image": { "filename": "{DALI_IMAGE_DIR}gallery-large-21.jpg" }, + "relayout-enabled": false, "position": [0, 200, 0], "size": [200, 200, 1], "signals": [{ diff --git a/resources/scripts/background-color.json b/resources/scripts/background-color.json index d8d97b8..dcf8103 100644 --- a/resources/scripts/background-color.json +++ b/resources/scripts/background-color.json @@ -29,6 +29,7 @@ // A container with a yellow background { "type": "Control", + "relayout-enabled": false, "parent-origin": "CENTER", "anchor-point": "BOTTOM_CENTER", "background-color": [1, 1, 0, 1], @@ -38,10 +39,11 @@ // A container with an image { "type": "Control", + "relayout-enabled": false, "parent-origin": "CENTER", "anchor-point": "TOP_CENTER", "size": [400, 150, 1], - "background": { + "background-image": { "image": { "filename": "{DALI_IMAGE_DIR}button-background.png" } @@ -51,11 +53,12 @@ // A container with the same image blended in with a blue background { "type": "Control", + "relayout-enabled": false, "parent-origin": "BOTTOM_CENTER", "anchor-point": "BOTTOM_CENTER", "size": [400, 150, 1], "background-color": [0, 0, 1, 1], - "background": { + "background-image": { "image": { "filename": "{DALI_IMAGE_DIR}button-background.png" } diff --git a/resources/scripts/simple-image-wall.js b/resources/scripts/simple-image-wall.js new file mode 100644 index 0000000..2620865 --- /dev/null +++ b/resources/scripts/simple-image-wall.js @@ -0,0 +1,108 @@ +// Image Wall example +// +// Example usage of Dali API +// +// +// +// get the dali-demo image directory path +// hard code for the device to /usr/apps/com.samsung.dali-demo/images/ +var imageDir = dali.DALI_DATA_DIRECTORY; + +if (imageDir != "/usr/share/dali//") { + imageDir = imageDir.substring(0, imageDir.lastIndexOf("dali/")); + imageDir += "com.samsung.dali-demo/images/"; +} else // on device +{ + imageDir = "/usr/apps/com.samsung.dali-demo/images/"; +} + + +var NUMBER_OF_IMAGES = 40; // for now use 16 ( demo files go up to 30) +var DEMO_IMAGES = []; // array to store Dali Images +var VIDEO_WALL_ACTORS = []; // array to store Image actors +var VIDEO_WALL_ROWS = 7; // use 3 rows for the video wall +var VIDEO_WALL_COLUMNS = 12; // use 12 columns for the video wall +var VIDEO_WALL_TOTAL_ITEMS = VIDEO_WALL_COLUMNS * VIDEO_WALL_ROWS; // total items +var VIDEO_WALL_ITEM_SIZE = 128; // width / height of a item in the video wall +var BORDER_SIZE = 5; +var VIDEO_WALL_ITEM_SIZE_NO_BORDER = VIDEO_WALL_ITEM_SIZE - BORDER_SIZE; +var VIDEO_WALL_WIDTH = VIDEO_WALL_COLUMNS * VIDEO_WALL_ITEM_SIZE; +var VIDEO_WALL_HEIGHT = VIDEO_WALL_ROWS * VIDEO_WALL_ITEM_SIZE; + +var daliApp = {}; + +var wallRootActor; // the root actor of the video wall + +// we want demo images of format gallery-small-1.jpg +daliApp.getFileName = function(index) { + fileName = "gallery-small-" + (index+1) + ".jpg"; + return fileName; +} + +// load the images +daliApp.loadImages = function() { + for (index = 0; index < NUMBER_OF_IMAGES; ++index) { + fileName = imageDir + daliApp.getFileName(index); + DEMO_IMAGES[index] = new dali.ResourceImage( { url:fileName } ); + } +} + +daliApp.createRootActor = function() { + wallRootActor = new dali.Actor(); + wallRootActor.parentOrigin = dali.CENTER; + wallRootActor.anchorPoint = dali.CENTER; + dali.stage.add(wallRootActor); +} + + + +daliApp.getWallActorIndex = function(x, y) { + return x + y * VIDEO_WALL_COLUMNS; +} + +daliApp.createActors = function() { + daliApp.createRootActor(); + + for (y = 0; y < VIDEO_WALL_ROWS; ++y) { + for (x = 0; x < VIDEO_WALL_COLUMNS; ++x) { + + var actorIndex = daliApp.getWallActorIndex(x, y); + var imageActor = new dali.ImageActor(); + + // wrap image index between 0 and NUMBER_OF_IMAGES + var imageIndex = actorIndex % NUMBER_OF_IMAGES; + + imageActor.setImage(DEMO_IMAGES[imageIndex]); + + imageActor.parentOrigin = dali.CENTER; + imageActor.anchorPoint = dali.CENTER; + imageActor.size = [VIDEO_WALL_ITEM_SIZE_NO_BORDER, VIDEO_WALL_ITEM_SIZE_NO_BORDER, 1.0]; // start with zero size so it zooms up + + var xPosition = x * VIDEO_WALL_ITEM_SIZE; + // as the middle the wall is at zero (relative to wallRootActor), we need to subtract half the wall width. + // + add half item size because the item anchor point is the center of the wallRootActor. + xPosition = xPosition - (VIDEO_WALL_WIDTH / 2) + (VIDEO_WALL_ITEM_SIZE / 2); + + var yPosition = y * VIDEO_WALL_ITEM_SIZE; + yPosition = yPosition - (VIDEO_WALL_HEIGHT / 2) + (VIDEO_WALL_ITEM_SIZE / 2); + + imageActor.position = [xPosition, yPosition, 0.0]; + // store the actor + VIDEO_WALL_ACTORS[actorIndex] = imageActor; + + // Add to the video wall root actor. + wallRootActor.add(imageActor); + } + } +} + +function Initialise() { + + daliApp.loadImages(); + + daliApp.createActors(); + + +} + +Initialise(); diff --git a/shared/view.h b/shared/view.h index aba2d2d..f456182 100644 --- a/shared/view.h +++ b/shared/view.h @@ -84,10 +84,11 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar, const Dali::TextStyle& textStyle ) { Dali::Layer toolBarLayer = Dali::Layer::New(); + toolBarLayer.SetName( "TOOLBAR_LAYER" ); toolBarLayer.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER ); toolBarLayer.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER ); - toolBarLayer.ApplyConstraint( Dali::Constraint::New( Dali::Actor::Property::SIZE, Dali::ParentSource( Dali::Actor::Property::SIZE ), Dali::SourceWidthFixedHeight( style.mToolBarHeight ) ) ); toolBarLayer.SetSize( 0.0f, style.mToolBarHeight ); + toolBarLayer.SetResizePolicy( Dali::FILL_TO_PARENT, Dali::WIDTH ); // Raise tool bar layer to the top. toolBarLayer.RaiseToTop(); @@ -95,12 +96,14 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar, // Tool bar Dali::Image image = Dali::ResourceImage::New( toolbarImagePath ); Dali::ImageActor toolBarBackground = Dali::ImageActor::New( image ); + toolBarBackground.SetName( "TOOLBAR_BACKGROUND" ); + toolBarBackground.SetResizePolicy( Dali::FILL_TO_PARENT, Dali::ALL_DIMENSIONS ); toolBar = Dali::Toolkit::ToolBar::New(); + toolBar.SetName( "TOOLBAR" ); toolBar.SetBackground( toolBarBackground ); toolBar.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER ); toolBar.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER ); - toolBar.SetSize( 0.0f, style.mToolBarHeight ); - toolBar.SetSizeMode( Dali::SIZE_EQUAL_TO_PARENT ); + toolBar.SetResizePolicy( Dali::FILL_TO_PARENT, Dali::ALL_DIMENSIONS ); toolBarBackground.SetSortModifier(1.0f); // Add the tool bar to the too bar layer. @@ -112,7 +115,7 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar, if( !title.empty() ) { Dali::Toolkit::TextView titleActor = Dali::Toolkit::TextView::New(); - titleActor.SetName( "ToolbarTitle" ); + titleActor.SetName( "TOOLBAR_TITLE" ); titleActor.SetText( title ); titleActor.SetSize( font.MeasureText( title ) ); titleActor.SetStyleToCurrentText(textStyle); @@ -138,6 +141,7 @@ Dali::Layer CreateView( Dali::Application& application, // Create default View. view = Dali::Toolkit::View::New(); + view.SetResizePolicy( Dali::FILL_TO_PARENT, Dali::ALL_DIMENSIONS ); // Add the view to the stage before setting the background. stage.Add( view ); @@ -164,13 +168,11 @@ Dali::Layer CreateView( Dali::Application& application, // Add tool bar layer to the view. view.AddContentLayer( toolBarLayer ); - - // Create a content layer. Dali::Layer contentLayer = Dali::Layer::New(); contentLayer.SetAnchorPoint( Dali::AnchorPoint::CENTER ); contentLayer.SetParentOrigin( Dali::ParentOrigin::CENTER ); - contentLayer.SetSizeMode( Dali::SIZE_EQUAL_TO_PARENT ); + contentLayer.SetResizePolicy( Dali::FILL_TO_PARENT, Dali::ALL_DIMENSIONS ); view.AddContentLayer( contentLayer ); contentLayer.LowerBelow( toolBarLayer );