From: Kingsley Stephens Date: Tue, 14 Apr 2015 13:00:34 +0000 (+0100) Subject: Size negotiation patch 4: Remove SetRelayoutEnabled X-Git-Tag: dali_1.0.39~10^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=70ee2ab38bb1aa71222e65863ebb98d395c449a2 Size negotiation patch 4: Remove SetRelayoutEnabled PushButton size negotiation fixes Change-Id: I497d3d2c357ee97e0970171f1888e5c45871abca --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp index f7926a5..75a2d85 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp @@ -218,7 +218,6 @@ int UtcDaliControlImplOnGestureMethods(void) // Check gesture actually happens { DummyControl dummy = DummyControl::New(true); - dummy.SetRelayoutEnabled( true ); dummy.SetSize( Vector2(100.0f, 100.0f ) ); dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); @@ -279,7 +278,6 @@ int UtcDaliControlImplOnGestureMethods(void) // Ensure full code coverage { DummyControl dummy = DummyControl::New(); - dummy.SetRelayoutEnabled( true ); dummy.SetSize( Vector2( 100.0f, 100.0f ) ); dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); @@ -445,7 +443,6 @@ int UtcDaliControlImplSizeSet(void) { DummyControl dummy = DummyControl::New( true ); - dummy.SetRelayoutEnabled( true ); DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); Stage::GetCurrent().Add(dummy); @@ -470,7 +467,6 @@ int UtcDaliControlImplSizeSet(void) // Ensure full code coverage { DummyControl dummy = DummyControl::New(); - dummy.SetRelayoutEnabled( true ); Stage::GetCurrent().Add(dummy); Vector2 size(100.0f, 200.0f); @@ -546,7 +542,6 @@ int UtcDaliControlImplTouchEvent(void) { DummyControl dummy = DummyControl::New( true ); - dummy.SetRelayoutEnabled( true ); DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); dummy.SetSize( Vector2( 100.0f, 100.0f ) ); @@ -571,7 +566,6 @@ int UtcDaliControlImplTouchEvent(void) // Ensure full code coverage { DummyControl dummy = DummyControl::New(); - dummy.SetRelayoutEnabled( true ); dummy.SetSize( Vector2( 100.0f, 100.0f ) ); dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); @@ -773,7 +767,6 @@ int UtcDaliControlImplMouseWheelEvent(void) { DummyControl dummy = DummyControl::New( true ); - dummy.SetRelayoutEnabled( true ); DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); dummy.SetSize( Vector2( 100.0f, 100.0f ) ); @@ -801,7 +794,6 @@ int UtcDaliControlImplMouseWheelEvent(void) // Ensure full code coverage { DummyControl dummy = DummyControl::New(); - dummy.SetRelayoutEnabled( true ); dummy.SetSize( Vector2( 100.0f, 100.0f ) ); dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-PageTurnView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-PageTurnView.cpp index 955f19d..443de6f 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-PageTurnView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-PageTurnView.cpp @@ -371,7 +371,6 @@ int UtcDaliPageTurnViewEnterLeaveEditMode(void) factory.EnableOffscreenRendering( ); PageTurnView pageTurnView = PageTurnLandscapeView::New( factory, PAGE_SIZE ); - pageTurnView.SetRelayoutEnabled( false ); pageTurnView.SetPositionInheritanceMode( USE_PARENT_POSITION ); Stage::GetCurrent().Add( pageTurnView ); @@ -423,7 +422,6 @@ int UtcDaliPageTurnViewGetHitActor(void) factory.EnableOffscreenRendering( ); PageTurnView pageTurnView = PageTurnPortraitView::New( factory, PAGE_SIZE ); - pageTurnView.SetRelayoutEnabled( false ); pageTurnView.SetParentOrigin( ParentOrigin::TOP_LEFT ); pageTurnView.SetAnchorPoint( AnchorPoint::TOP_LEFT ); Stage::GetCurrent().Add( pageTurnView ); @@ -460,7 +458,6 @@ int UtcDaliPageTurnViewRefresh(void) TestPageFactory factory(application); factory.EnableOffscreenRendering( ); PageTurnView pageTurnView = PageTurnPortraitView::New( factory, PAGE_SIZE ); - pageTurnView.SetRelayoutEnabled( false ); pageTurnView.SetParentOrigin( ParentOrigin::TOP_LEFT ); pageTurnView.SetAnchorPoint( AnchorPoint::TOP_LEFT ); Stage::GetCurrent().Add( pageTurnView ); @@ -501,7 +498,6 @@ int UtcDaliPageTurnViewSignals(void) TestPageFactory factory(application); Vector2 size = Stage::GetCurrent().GetSize(); PageTurnView portraitView = PageTurnPortraitView::New( factory, size ); - portraitView.SetRelayoutEnabled( false ); portraitView.SetPositionInheritanceMode( USE_PARENT_POSITION ); Stage::GetCurrent().Add( portraitView ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp b/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp index 0d259d9..4b62045 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp @@ -287,8 +287,7 @@ int UtcDaliPushButtonSetImages(void) application.SendNotification(); application.Render(); - // Just check if check box button size changes when a bigger image is set. - + pushButton.SetSize( Vector2( 20.0f, 20.0f ) ); pushButton.SetButtonImage( image01 ); application.SendNotification(); @@ -296,8 +295,8 @@ int UtcDaliPushButtonSetImages(void) size = pushButton.GetCurrentSize(); - DALI_TEST_EQUALS( size.width, 10.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 10.f, TEST_LOCATION ); + DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION ); + DALI_TEST_EQUALS( size.height, 20.f, TEST_LOCATION ); END_TEST; } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp index b7e662e..ed651ad 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp @@ -197,7 +197,6 @@ int UtcDaliSuperBlurViewGetBlurredImage(void) tet_infoline( "UtcDaliSuperBlurViewGetBlurredImage" ); SuperBlurView blurView = SuperBlurView::New( BLUR_LEVELS ); - blurView.SetRelayoutEnabled( false ); blurView.SetSize( 100.f,100.f ); Image inputImage = CreateSolidColorImage( application, Color::GREEN, 100, 100 ); blurView.SetImage( inputImage ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp index dc6b0af..45dd92c 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp @@ -70,8 +70,6 @@ static void SetupTableViewAndActors(TableView& tableView, Actor& actor1, Actor& tableView = TableView::New( 10, 10 ); // 10 by 10 grid. DALI_TEST_CHECK( tableView ); - tableView.SetRelayoutEnabled( true ); - Stage::GetCurrent().Add( tableView ); tableView.SetSize( Dali::Vector2( 100.0f, 100.0f ) ); @@ -79,11 +77,8 @@ static void SetupTableViewAndActors(TableView& tableView, Actor& actor1, Actor& actor2 = Actor::New(); actor3 = Actor::New(); - actor1.SetRelayoutEnabled( true ); actor1.SetSize( Dali::Vector2( 10, 10 ) ); - actor2.SetRelayoutEnabled( true ); actor2.SetSize( Dali::Vector2( 10, 10 ) ); - actor3.SetRelayoutEnabled( true ); actor3.SetSize( Dali::Vector2( 10, 10 ) ); tableView.AddChild( actor1, TableView::CellPosition( 0, 0 ) ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-View.cpp b/automated-tests/src/dali-toolkit/utc-Dali-View.cpp index ad124e1..72f32d2 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-View.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-View.cpp @@ -305,7 +305,6 @@ int UtcDaliViewOrientationChanged(void) try { View view = View::New(); - view.SetRelayoutEnabled( true ); Stage::GetCurrent().Add( view ); view.SetSize( Vector2( 480, 800 ) ); diff --git a/dali-toolkit/internal/controls/alignment/alignment-impl.cpp b/dali-toolkit/internal/controls/alignment/alignment-impl.cpp index 9713587..16d0cab 100644 --- a/dali-toolkit/internal/controls/alignment/alignment-impl.cpp +++ b/dali-toolkit/internal/controls/alignment/alignment-impl.cpp @@ -548,7 +548,7 @@ void Alignment::OnRelayout( const Vector2& size, RelayoutContainer& container ) } Alignment::Alignment( Toolkit::Alignment::Type horizontal, Toolkit::Alignment::Type vertical ) -: Control( CONTROL_BEHAVIOUR_NONE ), +: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ), mHorizontal( horizontal ), mVertical( vertical ), mScaling( Toolkit::Alignment::ScaleNone ), diff --git a/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp b/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp index df9b6ed..ac56224 100644 --- a/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp +++ b/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp @@ -126,7 +126,7 @@ const char* const COMPOSITE_FRAGMENT_SOURCE = BloomView::BloomView() - : Control( CONTROL_BEHAVIOUR_NONE ) + : Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ) , mBlurNumSamples(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_NUM_SAMPLES) , mBlurBellCurveWidth(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_BELL_CURVE_WIDTH) , mPixelFormat(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_RENDER_TARGET_PIXEL_FORMAT) @@ -148,7 +148,7 @@ BloomView::BloomView() BloomView::BloomView( const unsigned int blurNumSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat, const float downsampleWidthScale, const float downsampleHeightScale) - : Control( CONTROL_BEHAVIOUR_NONE ) + : Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ) , mBlurNumSamples(blurNumSamples) , mBlurBellCurveWidth(blurBellCurveWidth) , mPixelFormat(renderTargetPixelFormat) diff --git a/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp b/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp index 1306475..0661494 100644 --- a/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp +++ b/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp @@ -39,7 +39,7 @@ BubbleEmitter::BubbleEmitter( const Vector2& movementArea, Image shapeImage, unsigned int maximumNumberOfBubble, const Vector2& bubbleSizeRange ) -: Control( REQUIRES_TOUCH_EVENTS ), +: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS ) ), mMovementArea( movementArea ), mShapeImage( shapeImage ), mTotalNumOfBubble( maximumNumberOfBubble ), diff --git a/dali-toolkit/internal/controls/buttons/button-impl.cpp b/dali-toolkit/internal/controls/buttons/button-impl.cpp index d1f30bc..7115cec 100644 --- a/dali-toolkit/internal/controls/buttons/button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/button-impl.cpp @@ -674,6 +674,8 @@ void Button::SetButtonImage( Actor image ) } OnButtonImageSet(); + + RelayoutRequest(); } Actor Button::GetButtonImage() const @@ -709,6 +711,8 @@ void Button::SetSelectedImage( Actor image ) } OnSelectedImageSet(); + + RelayoutRequest(); } Actor Button::GetSelectedImage() const @@ -742,6 +746,8 @@ void Button::SetBackgroundImage( Actor image ) } OnBackgroundImageSet(); + + RelayoutRequest(); } Actor Button::GetBackgroundImage() const @@ -782,6 +788,8 @@ void Button::SetSelectedBackgroundImage( Actor image ) } OnSelectedBackgroundImageSet(); + + RelayoutRequest(); } Actor Button::GetSelectedBackgroundImage() const diff --git a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp index cf34f85..f07eb32 100644 --- a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp @@ -113,7 +113,6 @@ void PushButton::OnLabelSet() { label.SetAnchorPoint( AnchorPoint::CENTER ); label.SetParentOrigin( ParentOrigin::CENTER ); - label.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); Toolkit::TextLabel textLabel = Toolkit::TextLabel::DownCast( label ); if( textLabel ) @@ -122,68 +121,44 @@ void PushButton::OnLabelSet() textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); textLabel.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true ); } + + ConfigureSizeNegotiation(); } } void PushButton::OnButtonImageSet() { - Actor& buttonImage = GetButtonImage(); - - buttonImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - - buttonImage.RelayoutRequestTree(); - + ConfigureSizeNegotiation(); RelayoutRequest(); } void PushButton::OnSelectedImageSet() { - Actor& selectedImage = GetSelectedImage(); - - selectedImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - - selectedImage.RelayoutRequestTree(); - + ConfigureSizeNegotiation(); RelayoutRequest(); } void PushButton::OnBackgroundImageSet() { - Actor& backgroundImage = GetBackgroundImage(); - - backgroundImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - - backgroundImage.RelayoutRequestTree(); - + ConfigureSizeNegotiation(); RelayoutRequest(); } void PushButton::OnSelectedBackgroundImageSet() { - Actor& selectedBackgroundImage = GetSelectedBackgroundImage(); - - selectedBackgroundImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + ConfigureSizeNegotiation(); + RelayoutRequest(); } void PushButton::OnDisabledImageSet() { - Actor& disabledImage = GetDisabledImage(); - - disabledImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - - disabledImage.RelayoutRequestTree(); - + ConfigureSizeNegotiation(); RelayoutRequest(); } void PushButton::OnDisabledBackgroundImageSet() { - Actor& disabledBackgroundImage = GetDisabledBackgroundImage(); - - disabledBackgroundImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - - disabledBackgroundImage.RelayoutRequestTree(); - + ConfigureSizeNegotiation(); RelayoutRequest(); } @@ -578,27 +553,6 @@ void PushButton::OnControlSizeSet( const Vector3& targetSize ) } } -Vector3 PushButton::GetNaturalSize() -{ - Vector3 size; - - // Check Image and Background image and use the largest size as the control's Natural size. - SizeOfActorIfLarger( GetButtonImage(), size ); - SizeOfActorIfLarger( GetBackgroundImage(), size ); - - // If label, test against it's size - Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( GetLabel() ); - if( label ) - { - Vector3 labelSize = label.GetNaturalSize(); - - size.width = std::max( size.width, labelSize.width + TEXT_PADDING * 2.0f ); - size.height = std::max( size.height, labelSize.height + TEXT_PADDING * 2.0f ); - } - - return size; -} - void PushButton::StartTransitionAnimation() { if( mTransitionAnimation ) @@ -659,6 +613,103 @@ void PushButton::TransitionAnimationFinished( Dali::Animation& source ) StopTransitionAnimation(); } +Vector3 PushButton::GetNaturalSize() +{ + Vector3 size; + + // If label, test against it's size + Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( GetLabel() ); + if( label ) + { + size.width = std::max( size.width, label.GetRelayoutSize( Dimension::WIDTH ) ); + size.height = std::max( size.height, label.GetRelayoutSize( Dimension::HEIGHT ) ); + } + else + { + // Check Image and Background image and use the largest size as the control's Natural size. + SizeOfActorIfLarger( GetButtonImage(), size ); + SizeOfActorIfLarger( GetBackgroundImage(), size ); + } + + return size; +} + +void PushButton::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) +{ + ConfigureSizeNegotiation(); +} + +void PushButton::ConfigureSizeNegotiation() +{ + ActorContainer images; + images.reserve( 7 ); + + images.push_back( GetButtonImage() ); + images.push_back( GetSelectedImage() ); + images.push_back( GetSelectedBackgroundImage() ); + images.push_back( GetBackgroundImage() ); + images.push_back( GetDisabledImage() ); + images.push_back( GetDisabledSelectedImage() ); + images.push_back( GetDisabledBackgroundImage() ); + + Actor label = GetLabel(); + + for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i ) + { + ConfigureSizeNegotiationDimension( static_cast< Dimension::Type >( 1 << i ), images, label ); + } + + if( label ) + { + label.SetPadding( Padding( TEXT_PADDING, TEXT_PADDING, TEXT_PADDING, TEXT_PADDING) ); + } +} + +void PushButton::ConfigureSizeNegotiationDimension( Dimension::Type dimension, const ActorContainer& images, Actor& label ) +{ + ResizePolicy::Type imageResizePolicy = ResizePolicy::FILL_TO_PARENT; + ResizePolicy::Type labelResizePolicy = ResizePolicy::FILL_TO_PARENT; + + switch( Self().GetResizePolicy( dimension ) ) + { + case ResizePolicy::FIT_TO_CHILDREN: + { + imageResizePolicy = labelResizePolicy = ResizePolicy::USE_NATURAL_SIZE; + break; + } + case ResizePolicy::USE_NATURAL_SIZE: + { + if( label ) + { + labelResizePolicy = ResizePolicy::USE_NATURAL_SIZE; + } + else + { + imageResizePolicy = ResizePolicy::USE_NATURAL_SIZE; + } + break; + } + default: + { + break; + } + } + + if( label ) + { + label.SetResizePolicy( labelResizePolicy, dimension ); + } + + for( ActorConstIter it = images.begin(), itEnd = images.end(); it != itEnd; ++it ) + { + Actor actor = *it; + if( actor ) + { + actor.SetResizePolicy( imageResizePolicy, dimension ); + } + } +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/buttons/push-button-impl.h b/dali-toolkit/internal/controls/buttons/push-button-impl.h index 3eddddc..7a23474 100644 --- a/dali-toolkit/internal/controls/buttons/push-button-impl.h +++ b/dali-toolkit/internal/controls/buttons/push-button-impl.h @@ -137,9 +137,14 @@ private: // From Control virtual void OnControlSizeSet( const Vector3& targetSize ); /** - * @copydoc Toolkit::Control::GetNaturalSize() + * @copydoc Toolkit::Control::GetNaturalSize */ - virtual Vector3 GetNaturalSize(); + Vector3 GetNaturalSize(); + + /** + * @copydoc Toolkit::Control::OnSetResizePolicy + */ + virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ); private: @@ -172,6 +177,20 @@ private: */ void FadeOutImage( Actor& image, float opacity = 1.f, Vector3 scale = Vector3( 1.f, 1.f, 1.f ) ); + /** + * @brief Custom configuration for size negotiation + */ + void ConfigureSizeNegotiation(); + + /** + * @brief Configure size negotiation for a given dimension + * + * @param[in] dimension The dimension to configure + * @param[in] images The list of images to configure + * @param[in] label The text label to configure + */ + void ConfigureSizeNegotiationDimension( Dimension::Type dimension, const ActorContainer& images, Actor& label ); + // slots /** diff --git a/dali-toolkit/internal/controls/cluster/cluster-impl.cpp b/dali-toolkit/internal/controls/cluster/cluster-impl.cpp index e2b4297..76975b2 100644 --- a/dali-toolkit/internal/controls/cluster/cluster-impl.cpp +++ b/dali-toolkit/internal/controls/cluster/cluster-impl.cpp @@ -82,7 +82,7 @@ Dali::Toolkit::Cluster Cluster::New(Toolkit::ClusterStyle& style) } Cluster::Cluster(Toolkit::ClusterStyle& style) -: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ), +: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS | DISABLE_SIZE_NEGOTIATION ) ), mClusterStyle(style), mExpandedCount(0) { diff --git a/dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp b/dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp index 21b6e23..e0a5ea5 100644 --- a/dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp +++ b/dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp @@ -112,7 +112,7 @@ Toolkit::EffectsView EffectsView::New() } EffectsView::EffectsView() -: Control( CONTROL_BEHAVIOUR_NONE ), +: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ), mEffectType( Toolkit::EffectsView::INVALID_TYPE ), mPixelFormat( EFFECTS_VIEW_DEFAULT_PIXEL_FORMAT ), mSpread(0.0f), diff --git a/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp b/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp index 8a38163..f233cf4 100644 --- a/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp +++ b/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp @@ -116,7 +116,7 @@ const char* const GAUSSIAN_BLUR_FRAGMENT_SOURCE = GaussianBlurView::GaussianBlurView() - : Control( CONTROL_BEHAVIOUR_NONE ) + : Control( ControlBehaviour( DISABLE_SIZE_NEGOTIATION ) ) , mNumSamples(GAUSSIAN_BLUR_VIEW_DEFAULT_NUM_SAMPLES) , mBlurBellCurveWidth( 0.001f ) , mPixelFormat(GAUSSIAN_BLUR_VIEW_DEFAULT_RENDER_TARGET_PIXEL_FORMAT) @@ -138,7 +138,7 @@ GaussianBlurView::GaussianBlurView() GaussianBlurView::GaussianBlurView( const unsigned int numSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat, const float downsampleWidthScale, const float downsampleHeightScale, bool blurUserImage) - : Control( NO_SIZE_NEGOTIATION ) + : Control( ControlBehaviour( DISABLE_SIZE_NEGOTIATION ) ) , mNumSamples(numSamples) , mBlurBellCurveWidth( 0.001f ) , mPixelFormat(renderTargetPixelFormat) @@ -266,14 +266,12 @@ void GaussianBlurView::OnInitialize() // Create an ImageActor for performing a horizontal blur on the texture mImageActorHorizBlur = ImageActor::New(); - mImageActorHorizBlur.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mImageActorHorizBlur.SetParentOrigin(ParentOrigin::CENTER); mImageActorHorizBlur.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME mImageActorHorizBlur.SetShaderEffect( mHorizBlurShader ); // Create an ImageActor for performing a vertical blur on the texture mImageActorVertBlur = ImageActor::New(); - mImageActorVertBlur.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mImageActorVertBlur.SetParentOrigin(ParentOrigin::CENTER); mImageActorVertBlur.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME mImageActorVertBlur.SetShaderEffect( mVertBlurShader ); @@ -285,7 +283,6 @@ void GaussianBlurView::OnInitialize() if(!mBlurUserImage) { mImageActorComposite = ImageActor::New(); - mImageActorComposite.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mImageActorComposite.SetParentOrigin(ParentOrigin::CENTER); mImageActorComposite.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME mImageActorComposite.SetOpacity(GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_STRENGTH); // ensure alpha is enabled for this object and set default value @@ -296,7 +293,6 @@ void GaussianBlurView::OnInitialize() // Create an ImageActor for holding final result, i.e. the blurred image. This will get rendered to screen later, via default / user render task mTargetActor = ImageActor::New(); - mTargetActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mTargetActor.SetParentOrigin(ParentOrigin::CENTER); mTargetActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME diff --git a/dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp b/dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp index fc6f71a..29e5bec 100644 --- a/dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp +++ b/dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp @@ -123,7 +123,7 @@ Dali::Toolkit::Magnifier Magnifier::New() } Magnifier::Magnifier() -: Control( REQUIRES_TOUCH_EVENTS ), +: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS ) ), mPropertySourcePosition(Property::INVALID_INDEX), mDefaultCameraDistance(1000.f), mActorSize(Vector3::ZERO), @@ -247,11 +247,13 @@ void Magnifier::SetFrameVisibility(bool visible) Image image = ResourceImage::New( DEFAULT_FRAME_IMAGE_PATH ); mFrame = ImageActor::New( image ); - mFrame.SetRelayoutEnabled( false ); mFrame.SetDrawMode(DrawMode::OVERLAY); mFrame.SetStyle( ImageActor::STYLE_NINE_PATCH ); mFrame.SetPositionInheritanceMode(DONT_INHERIT_POSITION); mFrame.SetInheritScale(true); + mFrame.SetResizePolicy( ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT, Dimension::ALL_DIMENSIONS ); + Vector3 sizeOffset(IMAGE_BORDER_INDENT*2.f - 2.f, IMAGE_BORDER_INDENT*2.f - 2.f, 0.0f); + mFrame.SetSizeModeFactor( sizeOffset ); Constraint constraint = Constraint::New( mFrame, Actor::Property::POSITION, EqualToConstraint() ); constraint.AddSource( ParentSource( Actor::Property::WORLD_POSITION ) ); @@ -259,9 +261,6 @@ void Magnifier::SetFrameVisibility(bool visible) mFrame.SetNinePatchBorder( Vector4::ONE * IMAGE_BORDER_INDENT ); self.Add(mFrame); - - Vector3 sizeOffset(IMAGE_BORDER_INDENT*2.f - 2.f, IMAGE_BORDER_INDENT*2.f - 2.f, 0.0f); - mFrame.SetSize(mActorSize + sizeOffset); } else if(!visible && mFrame) { @@ -271,12 +270,6 @@ void Magnifier::SetFrameVisibility(bool visible) void Magnifier::OnControlSizeSet(const Vector3& targetSize) { - if( mFrame ) - { - Vector3 sizeOffset(IMAGE_BORDER_INDENT*2.f - 2.f, IMAGE_BORDER_INDENT*2.f - 2.f, 0.0f); - mFrame.SetSize(targetSize + sizeOffset); - } - // TODO: Once Camera/CameraActor properties function as proper animatable properties // this code can disappear. // whenever the size of the magnifier changes, the field of view needs to change diff --git a/dali-toolkit/internal/controls/navigation-frame/navigation-control-impl.cpp b/dali-toolkit/internal/controls/navigation-frame/navigation-control-impl.cpp index 26956dc..d01b8b2 100644 --- a/dali-toolkit/internal/controls/navigation-frame/navigation-control-impl.cpp +++ b/dali-toolkit/internal/controls/navigation-frame/navigation-control-impl.cpp @@ -60,7 +60,7 @@ DALI_TYPE_REGISTRATION_END() } NavigationControl::NavigationControl() -: Control( REQUIRES_TOUCH_EVENTS ), +: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS ) ), mToolBar(NULL), mTitleBar(NULL), mOrientationAngle( 0 ), diff --git a/dali-toolkit/internal/controls/navigation-frame/page-impl.cpp b/dali-toolkit/internal/controls/navigation-frame/page-impl.cpp index 7ca18c9..9d17d8c 100644 --- a/dali-toolkit/internal/controls/navigation-frame/page-impl.cpp +++ b/dali-toolkit/internal/controls/navigation-frame/page-impl.cpp @@ -45,7 +45,7 @@ DALI_TYPE_REGISTRATION_END() } // unnamed namespace Page::Page() -: Control( CONTROL_BEHAVIOUR_NONE ), +: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ), mTitle(""), mSubTitle(""), mPropertyTitle(Property::INVALID_INDEX), diff --git a/dali-toolkit/internal/controls/page-turn-view/page-turn-view-impl.cpp b/dali-toolkit/internal/controls/page-turn-view/page-turn-view-impl.cpp index fc464ad..ef4a396 100644 --- a/dali-toolkit/internal/controls/page-turn-view/page-turn-view-impl.cpp +++ b/dali-toolkit/internal/controls/page-turn-view/page-turn-view-impl.cpp @@ -259,7 +259,7 @@ const int PageTurnView::NUMBER_OF_CACHED_PAGES = NUMBER_OF_CACHED_PAGES_EACH_SID const float PageTurnView::STATIC_PAGE_INTERVAL_DISTANCE = 1.0f; PageTurnView::PageTurnView( PageFactory& pageFactory, const Vector2& pageSize ) -: Control( REQUIRES_TOUCH_EVENTS ), +: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS ) ), mPageFactory( pageFactory ), mPageSize( pageSize ), mTotalPageCount( 0 ), diff --git a/dali-toolkit/internal/controls/popup/popup-impl.cpp b/dali-toolkit/internal/controls/popup/popup-impl.cpp index a5aed9b..9e654cc 100755 --- a/dali-toolkit/internal/controls/popup/popup-impl.cpp +++ b/dali-toolkit/internal/controls/popup/popup-impl.cpp @@ -172,12 +172,6 @@ void Popup::OnInitialize() SetAsKeyboardFocusGroup(true); } -void Popup::MarkDirtyForRelayout() -{ - // Flag all the popup controls for relayout as it is about to be hidden and miss the main flagging pass - mLayer.RelayoutRequestTree(); -} - void Popup::OnPropertySet( Property::Index index, Property::Value propertyValue ) { if( index == mPropertyTitle ) @@ -302,7 +296,6 @@ void Popup::CreateFooter() // Adds bottom background mBottomBg = Actor::New(); mBottomBg.SetName( "POPUP_BOTTOM_BG" ); - mBottomBg.SetRelayoutEnabled( true ); mBottomBg.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mPopupLayout.SetFixedHeight( 2, mPopupStyle->bottomSize.height ); // Buttons diff --git a/dali-toolkit/internal/controls/popup/popup-impl.h b/dali-toolkit/internal/controls/popup/popup-impl.h index f695c74..9c67474 100755 --- a/dali-toolkit/internal/controls/popup/popup-impl.h +++ b/dali-toolkit/internal/controls/popup/popup-impl.h @@ -131,11 +131,6 @@ public: */ PopupStylePtr GetStyle() const; - /** - * @copydoc Toolkit::Popup::MarkDirtyForRelayout - */ - void MarkDirtyForRelayout(); - protected: /** diff --git a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp index a3f222e..7657f5b 100644 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp @@ -293,7 +293,7 @@ Dali::Toolkit::ItemView ItemView::New(ItemFactory& factory) } ItemView::ItemView(ItemFactory& factory) -: Scrollable(), +: Scrollable( ControlBehaviour( DISABLE_SIZE_NEGOTIATION | REQUIRES_MOUSE_WHEEL_EVENTS | REQUIRES_KEYBOARD_NAVIGATION_SUPPORT ) ), mItemFactory(factory), mActiveLayout(NULL), mAnimatingOvershootOn(false), @@ -319,17 +319,12 @@ ItemView::ItemView(ItemFactory& factory) mItemsParentOrigin( ParentOrigin::CENTER), mItemsAnchorPoint( AnchorPoint::CENTER) { - SetRequiresMouseWheelEvents(true); - SetKeyboardNavigationSupport(true); } void ItemView::OnInitialize() { Actor self = Self(); - // Disable size negotiation for item views - self.SetRelayoutEnabled( false ); - mScrollConnector = Dali::Toolkit::ScrollConnector::New(); mScrollPositionObject = mScrollConnector.GetScrollPositionObject(); mScrollConnector.ScrollPositionChangedSignal().Connect( this, &ItemView::OnScrollPositionChanged ); diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.cpp b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.cpp index 44ceade..ffc7570 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.cpp @@ -40,6 +40,13 @@ ScrollBase::ScrollBase() { } +ScrollBase::ScrollBase( ControlBehaviour behaviourFlags ) +: Scrollable( behaviourFlags ), + mParent(NULL), + mDelay(0.0f) +{ +} + void ScrollBase::SetParent(ScrollBase *parent) { mParent = parent; diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.h b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.h index d4fe048..dcc5f74 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.h +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.h @@ -191,6 +191,13 @@ protected: */ ScrollBase(); + /** + * @brief Construct a new ScrollBase. + * + * @param[in] behaviourFlags Flags to enable + */ + ScrollBase( ControlBehaviour behaviourFlags ); + protected: ScrollBase *mParent; ///< Pointer to ScrollBase parent, if exists. diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp index 496d20f..a5f009e 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp @@ -534,7 +534,7 @@ Dali::Toolkit::ScrollView ScrollView::New() } ScrollView::ScrollView() -: ScrollBase(), +: ScrollBase( ControlBehaviour( REQUIRES_MOUSE_WHEEL_EVENTS ) ), // Enable size negotiation mTouchDownTime(0u), mGestureStackDepth(0), mScrollStateFlags(0), @@ -570,7 +570,6 @@ ScrollView::ScrollView() mCanScrollHorizontal(true), mCanScrollVertical(true) { - SetRequiresMouseWheelEvents(true); } void ScrollView::OnInitialize() diff --git a/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp b/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp index 5f7cf72..166b3dd 100644 --- a/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp @@ -75,7 +75,15 @@ const float DEFAULT_OVERSHOOT_ANIMATION_SPEED(120.0f); // 120 pixels per second // Scrollable controls are not layout containers so they dont need size negotiation.. // we dont want size negotiation while scrolling if we can avoid it Scrollable::Scrollable() -: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS | NO_SIZE_NEGOTIATION ) ), +: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS | DISABLE_SIZE_NEGOTIATION ) ), + mOvershootEffectColor( DEFAULT_OVERSHOOT_COLOUR ), + mOvershootAnimationSpeed ( DEFAULT_OVERSHOOT_ANIMATION_SPEED ), + mOvershootEnabled(false) +{ +} + +Scrollable::Scrollable( ControlBehaviour behaviourFlags ) +: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS | behaviourFlags ) ), mOvershootEffectColor( DEFAULT_OVERSHOOT_COLOUR ), mOvershootAnimationSpeed ( DEFAULT_OVERSHOOT_ANIMATION_SPEED ), mOvershootEnabled(false) diff --git a/dali-toolkit/internal/controls/scrollable/scrollable-impl.h b/dali-toolkit/internal/controls/scrollable/scrollable-impl.h index eb9f377..1f876ad 100644 --- a/dali-toolkit/internal/controls/scrollable/scrollable-impl.h +++ b/dali-toolkit/internal/controls/scrollable/scrollable-impl.h @@ -182,6 +182,13 @@ protected: Scrollable(); /** + * @brief Construct a new Scrollable. + * + * @param[in] behaviourFlags Flags to enable + */ + Scrollable( ControlBehaviour behaviourFlags ); + + /** * A reference counted object may only be deleted by calling Unreference() */ virtual ~Scrollable(); diff --git a/dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp b/dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp index 2011b7f..8a24887 100644 --- a/dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp +++ b/dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp @@ -108,7 +108,7 @@ const char* const RENDER_SHADOW_FRAGMENT_SOURCE = } // namespace ShadowView::ShadowView( float downsampleWidthScale, float downsampleHeightScale ) -: Control( CONTROL_BEHAVIOUR_NONE ), +: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ), mChildrenRoot(Actor::New()), mCachedShadowColor(DEFAULT_SHADOW_COLOR), mCachedBackgroundColor(DEFAULT_SHADOW_COLOR.r, DEFAULT_SHADOW_COLOR.g, DEFAULT_SHADOW_COLOR.b, 0.0f), @@ -226,7 +226,6 @@ void ShadowView::OnInitialize() { // root actor to parent all user added actors. Used as source actor for shadow render task. mChildrenRoot.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); - mChildrenRoot.SetRelayoutEnabled( true ); mChildrenRoot.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); Vector2 stageSize = Stage::GetCurrent().GetSize(); @@ -263,7 +262,6 @@ void ShadowView::OnInitialize() mBlurRootActor = Actor::New(); mBlurRootActor.SetName( "BLUR_ROOT_ACTOR" ); - mBlurRootActor.SetRelayoutEnabled( true ); // Turn off inheritance to ensure filter renders properly mBlurRootActor.SetPositionInheritanceMode(USE_PARENT_POSITION); diff --git a/dali-toolkit/internal/controls/slider/slider-impl.cpp b/dali-toolkit/internal/controls/slider/slider-impl.cpp index 4c1b2fa..8acd72c 100755 --- a/dali-toolkit/internal/controls/slider/slider-impl.cpp +++ b/dali-toolkit/internal/controls/slider/slider-impl.cpp @@ -96,6 +96,7 @@ const float DEFAULT_WIDTH = 0.0f; const float DEFAULT_HEIGHT = 27.0f; const float DEFAULT_HIT_HEIGHT = 72.0f; const float DEFAULT_HANDLE_HEIGHT = DEFAULT_HIT_HEIGHT; +const float POPUP_TEXT_PADDING = 10.0f; const char* SKINNED_BACKING_IMAGE_NAME = DALI_IMAGE_DIR "slider-skin.9.png"; const char* SKINNED_HANDLE_IMAGE_NAME = DALI_IMAGE_DIR "slider-skin-handle.png";; @@ -400,7 +401,6 @@ Actor Slider::CreateHitRegion() ImageActor Slider::CreateBacking() { ImageActor backing = ImageActor::New(); - backing.SetRelayoutEnabled( false ); backing.SetParentOrigin( ParentOrigin::CENTER ); backing.SetAnchorPoint( AnchorPoint::CENTER ); backing.SetZ( BACKING_Z ); @@ -430,7 +430,6 @@ std::string Slider::GetBackingImageName() ImageActor Slider::CreateProgress() { ImageActor progress = ImageActor::New(); - progress.SetRelayoutEnabled( false ); progress.SetParentOrigin( ParentOrigin::CENTER_LEFT ); progress.SetAnchorPoint( AnchorPoint::CENTER_LEFT ); progress.SetZ( PROGRESS_Z ); @@ -506,7 +505,6 @@ void Slider::ResizeProgressRegion( const Vector2& region ) ImageActor Slider::CreateHandle() { ImageActor handle = ImageActor::New(); - handle.SetRelayoutEnabled( false ); handle.SetParentOrigin( ParentOrigin::CENTER_LEFT ); handle.SetAnchorPoint( AnchorPoint::CENTER ); handle.SetZ( HANDLE_Z ); @@ -517,7 +515,6 @@ ImageActor Slider::CreateHandle() ImageActor Slider::CreatePopupArrow() { ImageActor arrow = ImageActor::New(); - arrow.SetRelayoutEnabled( false ); arrow.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); arrow.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); arrow.SetZ( HANDLE_Z ); @@ -530,18 +527,21 @@ Toolkit::TextLabel Slider::CreatePopupText() Toolkit::TextLabel textLabel = Toolkit::TextLabel::New(); textLabel.SetParentOrigin( ParentOrigin::CENTER ); textLabel.SetAnchorPoint( AnchorPoint::CENTER ); + textLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); textLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); + textLabel.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, DEFAULT_POPUP_TEXT_COLOR ); textLabel.SetZ( VALUE_DISPLAY_TEXT_Z ); + textLabel.SetPadding( Padding( POPUP_TEXT_PADDING, POPUP_TEXT_PADDING, 0.0f, 0.0f ) ); return textLabel; } ImageActor Slider::CreatePopup() { ImageActor popup = ImageActor::New(); - popup.SetRelayoutEnabled( false ); popup.SetParentOrigin( ParentOrigin::TOP_CENTER ); popup.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); + popup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::WIDTH ); mValueTextLabel = CreatePopupText(); popup.Add( mValueTextLabel ); diff --git a/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp b/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp index f2b8a5f..8c6d131 100644 --- a/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp +++ b/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp @@ -104,7 +104,7 @@ DALI_TYPE_REGISTRATION_END() } // unnamed namespace SuperBlurView::SuperBlurView( unsigned int blurLevels ) -: Control( CONTROL_BEHAVIOUR_NONE ), +: Control( ControlBehaviour( DISABLE_SIZE_NEGOTIATION ) ), mBlurLevels( blurLevels ), mBlurStrengthPropertyIndex(Property::INVALID_INDEX), mResourcesCleared( true ), diff --git a/dali-toolkit/internal/controls/table-view/table-view-impl.cpp b/dali-toolkit/internal/controls/table-view/table-view-impl.cpp index ec8e324..2e933c5 100644 --- a/dali-toolkit/internal/controls/table-view/table-view-impl.cpp +++ b/dali-toolkit/internal/controls/table-view/table-view-impl.cpp @@ -1461,10 +1461,11 @@ void TableView::CalculateFixedSizes( RowColumnArray& data, Dimension::Type dimen DALI_ASSERT_DEBUG( row < mCellData.GetRows() ); DALI_ASSERT_DEBUG( column < mCellData.GetColumns() ); - Actor& actor = mCellData[ row ][ column ].actor; + const CellData& cellData = mCellData[ row ][ column ]; + const Actor& actor = cellData.actor; if( actor ) { - if( FitToChild( actor, dimension ) ) + if( FitToChild( actor, dimension ) && ( dimension == Dimension::WIDTH ) ? ( cellData.position.columnSpan == 1 ) : ( cellData.position.rowSpan == 1 ) ) { maxActorHeight = std::max( maxActorHeight, actor.GetRelayoutSize( dimension ) + cellPadding.x + cellPadding.y ); } diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp index 7347fd3..d66a70a 100644 --- a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp @@ -481,7 +481,6 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part ) option.SetName( name ); option.SetAnimationTime( 0.0f ); option.SetSize( OPTION_ICON_SIZE ); - option.SetRelayoutEnabled( false ); //option.ClickedSignal().Connect( this, &TextInputPopup::OnButtonPressed ); // 6. Set the normal option image. @@ -529,7 +528,6 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part ) Actor scrollview = Actor::New(); //todo make a scrollview scrollview.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS ); scrollview.SetParentOrigin( ParentOrigin::CENTER ); - scrollview.SetRelayoutEnabled( true ); mTableOfButtons.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); mTableOfButtons.SetFitHeight( 0 ); @@ -545,6 +543,7 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part ) void TextSelectionPopup::AddPopupOptions( bool createTail, bool showIcons, bool showCaptions ) { mContentSize = Vector2::ZERO; + // Add the options into the buttons container. // 1. Determine how many buttons are active and should be added to container. @@ -589,7 +588,7 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part ) } TextSelectionPopup::TextSelectionPopup() -: Control( ControlBehaviour( CONTROL_BEHAVIOUR_NONE ) ), +: Control( ControlBehaviour( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ) ), mMaxSize ( DEFAULT_POPUP_MAX_SIZE ), mVisiblePopUpSize( DEFAULT_POPUP_MAX_SIZE ), mRequiredPopUpSize( DEFAULT_POPUP_MAX_SIZE ), diff --git a/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp b/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp index 0bcfe26..7ba35c5 100644 --- a/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp +++ b/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp @@ -296,7 +296,7 @@ void ToolBar::RemoveControl( Actor control ) } ToolBar::ToolBar() -: Control( CONTROL_BEHAVIOUR_NONE ), +: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ), mLayout(), mLeftOffset( 0 ), mCenterBase( 1 ), diff --git a/dali-toolkit/internal/controls/view/view-impl.cpp b/dali-toolkit/internal/controls/view/view-impl.cpp index 0262bb7..4792aa4 100644 --- a/dali-toolkit/internal/controls/view/view-impl.cpp +++ b/dali-toolkit/internal/controls/view/view-impl.cpp @@ -267,7 +267,7 @@ bool View::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* trac } View::View(bool fullscreen) -: Control( CONTROL_BEHAVIOUR_NONE ), +: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ), mOrientation( -1 ), mFullScreen(fullscreen), mContentLayers(), diff --git a/dali-toolkit/internal/text/clipping/text-clipper.cpp b/dali-toolkit/internal/text/clipping/text-clipper.cpp index 7a79e4c..8b0f77f 100644 --- a/dali-toolkit/internal/text/clipping/text-clipper.cpp +++ b/dali-toolkit/internal/text/clipping/text-clipper.cpp @@ -97,7 +97,6 @@ void Clipper::Initialize( const Vector2& size ) // Create a root actor and an image actor for offscreen rendering. mOffscreenRootActor = Layer::New(); - mOffscreenRootActor.SetRelayoutEnabled( false ); mOffscreenRootActor.SetColorMode( USE_OWN_COLOR ); mOffscreenRootActor.SetPositionInheritanceMode( DONT_INHERIT_POSITION ); mOffscreenRootActor.SetInheritScale( false ); @@ -105,7 +104,6 @@ void Clipper::Initialize( const Vector2& size ) mOffscreenRootActor.SetSize( offscreenSize ); mImageActor = ImageActor::New(); - mImageActor.SetRelayoutEnabled( false ); mImageActor.SetParentOrigin( ParentOrigin::CENTER ); mImageActor.SetBlendFunc( BlendingFactor::ONE, BlendingFactor::ONE_MINUS_SRC_ALPHA, BlendingFactor::ONE, BlendingFactor::ONE ); diff --git a/dali-toolkit/internal/text/decorator/text-decorator.cpp b/dali-toolkit/internal/text/decorator/text-decorator.cpp index 3a6d7da..692b9a3 100644 --- a/dali-toolkit/internal/text/decorator/text-decorator.cpp +++ b/dali-toolkit/internal/text/decorator/text-decorator.cpp @@ -317,7 +317,6 @@ struct Decorator::Impl : public ConnectionTracker cursor = CreateSolidColorActor( Color::WHITE ); cursor.SetParentOrigin( ParentOrigin::TOP_LEFT ); // Need to set the default parent origin as CreateSolidColorActor() sets a different one. cursor.SetAnchorPoint( AnchorPoint::TOP_CENTER ); - cursor.SetRelayoutEnabled( false ); } // Add or Remove cursor(s) from parent @@ -438,12 +437,10 @@ struct Decorator::Impl : public ConnectionTracker else { mGrabArea = Actor::New(); - mGrabArea.SetRelayoutEnabled( true ); mGrabArea.SetName( "GrabArea" ); } #else mGrabArea = Actor::New(); - mGrabArea.SetRelayoutEnabled( true ); #endif mGrabArea.SetParentOrigin( ParentOrigin::TOP_CENTER ); @@ -478,7 +475,6 @@ struct Decorator::Impl : public ConnectionTracker primary.flipped = false; primary.grabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move - primary.grabArea.SetRelayoutEnabled( true ); #ifdef DECORATOR_DEBUG primary.grabArea.SetName("SelectionHandleOneGrabArea"); #endif @@ -511,7 +507,6 @@ struct Decorator::Impl : public ConnectionTracker secondary.flipped = false; secondary.grabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move - secondary.grabArea.SetRelayoutEnabled( true ); #ifdef DECORATOR_DEBUG secondary.grabArea.SetName("SelectionHandleTwoGrabArea"); #endif diff --git a/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp b/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp index 888322a..30115f6 100644 --- a/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp +++ b/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp @@ -117,8 +117,7 @@ void CubeTransitionEffect::Initialize() // helper actor to create a off-screen image using shader effect mEmptyImage = ImageActor::New( placeHolder ); - mEmptyImage.SetRelayoutEnabled( false ); - mEmptyImage.SetSize(Stage::GetCurrent().GetSize()); + mEmptyImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mEmptyImage.SetParentOrigin( ParentOrigin::CENTER ); mEmptyImage.SetAnchorPoint( AnchorPoint::CENTER ); mFullImageCreator = FullAreaImageCreator::New(); @@ -141,7 +140,6 @@ void CubeTransitionEffect::Initialize() ImageActor CubeTransitionEffect::CreateTile( Image image, const Vector4& color ) { ImageActor tile = ImageActor::New( image ); - tile.SetRelayoutEnabled( false ); tile.SetParentOrigin( ParentOrigin::CENTER ); tile.SetAnchorPoint( AnchorPoint::CENTER ); tile.SetSize( mTileSize ); diff --git a/dali-toolkit/public-api/controls/buttons/push-button.cpp b/dali-toolkit/public-api/controls/buttons/push-button.cpp index d9e395e..6d0a4bf 100644 --- a/dali-toolkit/public-api/controls/buttons/push-button.cpp +++ b/dali-toolkit/public-api/controls/buttons/push-button.cpp @@ -77,7 +77,6 @@ PushButton PushButton::DownCast( BaseHandle handle ) void PushButton::SetButtonImage( Image image ) { Actor imageActor = ImageActor::New( image ); - imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); Dali::Toolkit::GetImplementation( *this ).SetButtonImage( imageActor ); } @@ -94,7 +93,6 @@ Actor PushButton::GetButtonImage() const void PushButton::SetBackgroundImage( Image image ) { Actor imageActor = ImageActor::New( image ); - imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( imageActor ); } diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index d65c16b..6bf685e 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -130,16 +130,30 @@ Mesh CreateMesh() * Sets all the required properties for the background actor. * * @param[in] actor The actor to set the properties on. + * @param[in] color The required color of the actor. + */ +void SetupBackgroundActor( Actor actor, const Vector4& color ) +{ + actor.SetColor( color ); + actor.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION ); + actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR ); + actor.SetZ( BACKGROUND_ACTOR_Z_POSITION ); + actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); +} + +/** + * Sets all the required properties for the background actor. + * + * @param[in] actor The actor to set the properties on. * @param[in] constrainingIndex The property index to constrain the parent's size on. * @param[in] color The required color of the actor. */ -void SetupBackgroundActor( Actor actor, Property::Index constrainingIndex, const Vector4& color ) +void SetupBackgroundActorConstrained( Actor actor, Property::Index constrainingIndex, const Vector4& color ) { actor.SetColor( color ); actor.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION ); actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR ); actor.SetZ( BACKGROUND_ACTOR_Z_POSITION ); - actor.SetRelayoutEnabled( false ); Constraint constraint = Constraint::New( actor, constrainingIndex, @@ -180,7 +194,7 @@ public: mLongPressGestureDetector(), mCurrentSize(), mNaturalSize(), - mFlags( Control::CONTROL_BEHAVIOUR_NONE ), + mFlags( Control::ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ), mIsKeyboardNavigationSupported( false ), mIsKeyboardFocusGroup( false ), mInitialized( false ) @@ -376,7 +390,7 @@ public: Vector3 mCurrentSize; ///< Stores the current control's size, this is the negotiated size Vector3 mNaturalSize; ///< Stores the size set through the Actor's API. This is size the actor wants to be. Useful when reset to the initial size is needed. - ControlBehaviour mFlags :6; ///< Flags passed in from constructor. Need to increase this size when new enums are added + ControlBehaviour mFlags :CONTROL_BEHAVIOUR_FLAG_COUNT; ///< Flags passed in from constructor. bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control. bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group. bool mInitialized :1; @@ -397,7 +411,7 @@ PropertyRegistration Control::Impl::PROPERTY_4( typeRegistration, "key-input-foc Toolkit::Control Control::New() { // Create the implementation, temporarily owned on stack - IntrusivePtr controlImpl = new Control( CONTROL_BEHAVIOUR_NONE ); + IntrusivePtr controlImpl = new Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ); // Pass ownership to handle Toolkit::Control handle( *controlImpl ); @@ -540,7 +554,7 @@ void Control::SetBackgroundColor( const Vector4& color ) // Create Mesh Actor MeshActor meshActor = MeshActor::New( CreateMesh() ); - SetupBackgroundActor( meshActor, Actor::Property::SCALE, color ); + SetupBackgroundActorConstrained( meshActor, Actor::Property::SCALE, color ); // Set the background actor before adding so that we do not inform deriving classes background.actor = meshActor; @@ -571,7 +585,7 @@ void Control::SetBackgroundImage( Image image ) } ImageActor imageActor = ImageActor::New( image ); - SetupBackgroundActor( imageActor, Actor::Property::SIZE, background.color ); + SetupBackgroundActor( imageActor, background.color ); // Set the background actor before adding so that we do not inform derived classes background.actor = imageActor; @@ -742,7 +756,7 @@ bool Control::EmitKeyEventSignal( const KeyEvent& event ) } Control::Control( ControlBehaviour behaviourFlags ) -: CustomActorImpl( behaviourFlags & REQUIRES_TOUCH_EVENTS ), +: CustomActorImpl( static_cast< ActorFlags >( behaviourFlags ) ), mImpl(new Impl(*this)) { mImpl->mFlags = behaviourFlags; @@ -753,13 +767,6 @@ void Control::Initialize() // Calling deriving classes OnInitialize(); - // Test if the no size negotiation flag is not set - if( ( mImpl->mFlags & NO_SIZE_NEGOTIATION ) == 0 ) - { - // Size negotiate disabled by default, so turn it on for this actor - Self().SetRelayoutEnabled( true ); - } - if( mImpl->mFlags & REQUIRES_STYLE_CHANGE_SIGNALS ) { Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get(); @@ -771,8 +778,10 @@ void Control::Initialize() GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) ); } - SetRequiresHoverEvents(mImpl->mFlags & REQUIRES_HOVER_EVENTS); - SetRequiresMouseWheelEvents(mImpl->mFlags & REQUIRES_MOUSE_WHEEL_EVENTS); + if( mImpl->mFlags & REQUIRES_KEYBOARD_NAVIGATION_SUPPORT ) + { + SetKeyboardNavigationSupport( true ); + } mImpl->mInitialized = true; } diff --git a/dali-toolkit/public-api/controls/control-impl.h b/dali-toolkit/public-api/controls/control-impl.h index 5c29c39..966eca0 100644 --- a/dali-toolkit/public-api/controls/control-impl.h +++ b/dali-toolkit/public-api/controls/control-impl.h @@ -339,14 +339,14 @@ protected: // Flags for the constructor enum ControlBehaviour { - CONTROL_BEHAVIOUR_NONE = 0, - REQUIRES_TOUCH_EVENTS = 1<<1, ///< True if the OnTouchEvent() callback is required. - REQUIRES_STYLE_CHANGE_SIGNALS = 1<<2, ///< True if needs to monitor style change signals such as theme/font change - NO_SIZE_NEGOTIATION = 1<<3, ///< True if control does not need size negotiation, i.e. it can be skipped in the algorithm - REQUIRES_HOVER_EVENTS = 1<<4, ///< True if the OnHoverEvent() callback is required. - REQUIRES_MOUSE_WHEEL_EVENTS = 1<<5 ///< True if the OnMouseWheelEvent() callback is required. + REQUIRES_STYLE_CHANGE_SIGNALS = 1 << ( CustomActorImpl::ACTOR_FLAG_COUNT + 0 ), ///< True if needs to monitor style change signals such as theme/font change + REQUIRES_KEYBOARD_NAVIGATION_SUPPORT = 1 << ( CustomActorImpl::ACTOR_FLAG_COUNT + 1 ), ///< True if needs to support keyboard navigation + + LAST_CONTROL_BEHAVIOUR_FLAG }; + static const int CONTROL_BEHAVIOUR_FLAG_COUNT = Log< LAST_CONTROL_BEHAVIOUR_FLAG - 1 >::value + 1; ///< Total count of flags + /** * @brief Create a Control. * diff --git a/dali-toolkit/public-api/controls/popup/popup.cpp b/dali-toolkit/public-api/controls/popup/popup.cpp index b557f01..c7a8593 100644 --- a/dali-toolkit/public-api/controls/popup/popup.cpp +++ b/dali-toolkit/public-api/controls/popup/popup.cpp @@ -132,11 +132,6 @@ void Popup::HideTail() GetImpl(*this).HideTail(); } -void Popup::MarkDirtyForRelayout() -{ - GetImpl(*this).MarkDirtyForRelayout(); -} - Popup::TouchedOutsideSignalType& Popup::OutsideTouchedSignal() { return GetImpl(*this).OutsideTouchedSignal(); diff --git a/dali-toolkit/public-api/controls/popup/popup.h b/dali-toolkit/public-api/controls/popup/popup.h index 1ab708b..813ad37 100644 --- a/dali-toolkit/public-api/controls/popup/popup.h +++ b/dali-toolkit/public-api/controls/popup/popup.h @@ -244,11 +244,6 @@ public: */ void HideTail(); - /** - * @brief Flag the popup as dirty for relayout - */ - void MarkDirtyForRelayout(); - public: // Not intended for application developers /** diff --git a/docs/content/programming-guide/size-negotiation-controls.h b/docs/content/programming-guide/size-negotiation-controls.h index d0a8a93..a69d1e8 100644 --- a/docs/content/programming-guide/size-negotiation-controls.h +++ b/docs/content/programming-guide/size-negotiation-controls.h @@ -34,7 +34,7 @@ method derived from Actor when passing back controls to be negotiated using the

Initialization

Size negotiation is enabled on controls by default. If a control is desired to not have size negotiation enabled then simply pass in the -NO_SIZE_NEGOTIATION flag into the Control constructor. This will then call SetRelayoutEnabled( false ) on the base class. +DISABLE_SIZE_NEGOTIATION flag into the Control constructor. The other step to perform is to set default resize policies for width and height. diff --git a/docs/content/programming-guide/size-negotiation.h b/docs/content/programming-guide/size-negotiation.h index 2f64d83..92beacd 100644 --- a/docs/content/programming-guide/size-negotiation.h +++ b/docs/content/programming-guide/size-negotiation.h @@ -45,11 +45,7 @@ This section details how an actor may be used with size negotiation.

Enabling Size Negotiation

-The first thing to do is to specify whether you want an actor to be included or excluded from the relayout process. The following method is used to enable or disable the relayout -for an individual actor. Make sure this is the first thing that is called after the actor is created otherwise the actor may still be negotiated. -@code void SetRelayoutEnabled( bool enabled ) @endcode -Text and image actors have relayout enabled by default, while a plain Actor is disabled. Be aware that if desiring to use an Actor in relayout -then relayout needs to be explicitly enabled first. +Text and image actors have relayout enabled by default, while a plain Actor is disabled unless a call to SetResizePolicy is made.

Specifying Size Policies

@@ -69,7 +65,6 @@ the height of the root actor will fit to the height of the child image. @code Actor rootActor = Actor::New(); -rootActor.SetRelayoutEnabled( true ); rootActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); rootActor.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT ); ImageActor image = ImageActor::New( Image::New( MY_IMAGE_PATH ) ); diff --git a/plugins/dali-script-v8/src/actors/actor-wrapper.cpp b/plugins/dali-script-v8/src/actors/actor-wrapper.cpp index 112dfeb..4df5d5c 100644 --- a/plugins/dali-script-v8/src/actors/actor-wrapper.cpp +++ b/plugins/dali-script-v8/src/actors/actor-wrapper.cpp @@ -294,7 +294,6 @@ const ActorFunctions ActorFunctionTable[]= { "SetImage", ImageActorApi::SetImage, IMAGE_ACTOR_API }, { "GetImage", ImageActorApi::GetImage, IMAGE_ACTOR_API }, - { "SetToNaturalSize", ImageActorApi::SetToNaturalSize, IMAGE_ACTOR_API }, // ignore SetPixelArea, use imageActor.pixelArea // ignore GetPixelArea, use imageActor.pixelArea { "IsPixelAreaSet", ImageActorApi::IsPixelAreaSet, IMAGE_ACTOR_API }, diff --git a/plugins/dali-script-v8/src/actors/image-actor-api.cpp b/plugins/dali-script-v8/src/actors/image-actor-api.cpp index fa93c7f..9a30b21 100644 --- a/plugins/dali-script-v8/src/actors/image-actor-api.cpp +++ b/plugins/dali-script-v8/src/actors/image-actor-api.cpp @@ -151,28 +151,6 @@ void ImageActorApi::GetImage( const v8::FunctionCallbackInfo& args ) } /** - * Tell the image actor to use the natural size of the current image - * or future images. - * - * Calling SetSize on this actor or animating the size of the actor - * overrides this behaviour. - * - * The image actor uses the natural image size after an image - * has been loaded. - * @for ImageActor - * @method setToNaturalSize - */ -void ImageActorApi::SetToNaturalSize( const v8::FunctionCallbackInfo& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - ImageActor imageActor = GetImageActor( isolate, args ); - - imageActor.SetToNaturalSize(); - -} - -/** * Query whether a pixel area has been set. * @for ImageActor * @method isPixelAreaSet diff --git a/plugins/dali-script-v8/src/actors/image-actor-api.h b/plugins/dali-script-v8/src/actors/image-actor-api.h index 3c75cf6..d6b9f3a 100644 --- a/plugins/dali-script-v8/src/actors/image-actor-api.h +++ b/plugins/dali-script-v8/src/actors/image-actor-api.h @@ -42,7 +42,6 @@ namespace ImageActorApi */ void SetImage( const v8::FunctionCallbackInfo< v8::Value >& args ); void GetImage( const v8::FunctionCallbackInfo< v8::Value >& args ); - void SetToNaturalSize( const v8::FunctionCallbackInfo< v8::Value >& args ); void IsPixelAreaSet( const v8::FunctionCallbackInfo< v8::Value >& args ); void ClearPixelArea( const v8::FunctionCallbackInfo< v8::Value >& args ); }; // namespace ImageActorApi