From: Kimmo Hoikka Date: Tue, 14 Apr 2015 10:52:41 +0000 (-0700) Subject: Merge "Size negotiation patch 3: Scope size negotiation enums" into tizen X-Git-Tag: dali_1.0.38~3 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=935e800159c04fa5d389628add6183eb68f778ee;hp=b46395d404c2b437c4679975e0ed2c073949ba61 Merge "Size negotiation patch 3: Scope size negotiation enums" into tizen --- diff --git a/dali-toolkit/internal/controls/buttons/button-impl.cpp b/dali-toolkit/internal/controls/buttons/button-impl.cpp index 4765f44..d1f30bc 100644 --- a/dali-toolkit/internal/controls/buttons/button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/button-impl.cpp @@ -617,11 +617,6 @@ float Button::GetAnimationTime() const void Button::SetLabel( const std::string& label ) { Toolkit::TextLabel textLabel = Toolkit::TextLabel::New( label ); - textLabel.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); - textLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); - textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); - textLabel.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true ); - SetLabel( textLabel ); } diff --git a/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp b/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp index cc90db8..88e5364 100644 --- a/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp @@ -80,7 +80,7 @@ CheckBoxButton::~CheckBoxButton() void CheckBoxButton::OnButtonInitialize() { // Wrap around all children - Self().SetResizePolicy( FIT_TO_CHILDREN, ALL_DIMENSIONS ); + Self().SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS ); } void CheckBoxButton::OnLabelSet() diff --git a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp index 3910e43..cf34f85 100644 --- a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp @@ -62,8 +62,8 @@ void SizeOfActorIfLarger( Actor root, Vector3& size ) if ( root ) { // RelayoutSize retreived for Actor to use any padding set to it. - size.width = std::max( root.GetRelayoutSize( WIDTH ), size.width ); - size.height = std::max( root.GetRelayoutSize( HEIGHT ), size.height ); + size.width = std::max( root.GetRelayoutSize( Dimension::WIDTH ), size.width ); + size.height = std::max( root.GetRelayoutSize( Dimension::HEIGHT ), size.height ); } } @@ -102,7 +102,7 @@ void PushButton::OnButtonInitialize() self.SetLeaveRequired( true ); // Set resize policy to natural size so that buttons will resize to background images - self.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); + self.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); } void PushButton::OnLabelSet() @@ -113,7 +113,15 @@ void PushButton::OnLabelSet() { label.SetAnchorPoint( AnchorPoint::CENTER ); label.SetParentOrigin( ParentOrigin::CENTER ); - label.SetSize( mSize ); + label.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + + Toolkit::TextLabel textLabel = Toolkit::TextLabel::DownCast( label ); + if( textLabel ) + { + textLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); + textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); + textLabel.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true ); + } } } @@ -121,7 +129,7 @@ void PushButton::OnButtonImageSet() { Actor& buttonImage = GetButtonImage(); - buttonImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + buttonImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); buttonImage.RelayoutRequestTree(); @@ -132,7 +140,7 @@ void PushButton::OnSelectedImageSet() { Actor& selectedImage = GetSelectedImage(); - selectedImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + selectedImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); selectedImage.RelayoutRequestTree(); @@ -143,7 +151,7 @@ void PushButton::OnBackgroundImageSet() { Actor& backgroundImage = GetBackgroundImage(); - backgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + backgroundImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); backgroundImage.RelayoutRequestTree(); @@ -154,14 +162,14 @@ void PushButton::OnSelectedBackgroundImageSet() { Actor& selectedBackgroundImage = GetSelectedBackgroundImage(); - selectedBackgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + selectedBackgroundImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); } void PushButton::OnDisabledImageSet() { Actor& disabledImage = GetDisabledImage(); - disabledImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + disabledImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); disabledImage.RelayoutRequestTree(); @@ -172,7 +180,7 @@ void PushButton::OnDisabledBackgroundImageSet() { Actor& disabledBackgroundImage = GetDisabledBackgroundImage(); - disabledBackgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + disabledBackgroundImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); disabledBackgroundImage.RelayoutRequestTree(); diff --git a/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp b/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp index 96b588c..81b6a5d 100644 --- a/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp @@ -77,7 +77,7 @@ void RadioButton::OnButtonInitialize() Actor self = Self(); // Wrap size of radio button around all its children - self.SetResizePolicy( FIT_TO_CHILDREN, ALL_DIMENSIONS ); + self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS ); Image buttonImage = Dali::ResourceImage::New( UNSELECTED_BUTTON_IMAGE_DIR ); Image selectedImage = Dali::ResourceImage::New( SELECTED_BUTTON_IMAGE_DIR ); @@ -109,6 +109,12 @@ void RadioButton::OnLabelSet() label.SetParentOrigin( ParentOrigin::CENTER_LEFT ); label.SetAnchorPoint( AnchorPoint::CENTER_LEFT ); + // Radio button width is FIT_TO_CHILDREN, so the label must have a sensible policy to fill out the space + if( label.GetResizePolicy( Dimension::WIDTH ) == ResizePolicy::FILL_TO_PARENT ) + { + label.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::WIDTH ); + } + if( IsSelected() ) { label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL ); 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 239d94e..8a38163 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 @@ -266,14 +266,14 @@ void GaussianBlurView::OnInitialize() // Create an ImageActor for performing a horizontal blur on the texture mImageActorHorizBlur = ImageActor::New(); - mImageActorHorizBlur.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + 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( FILL_TO_PARENT, ALL_DIMENSIONS ); + 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 +285,7 @@ void GaussianBlurView::OnInitialize() if(!mBlurUserImage) { mImageActorComposite = ImageActor::New(); - mImageActorComposite.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + 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 +296,7 @@ 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( FILL_TO_PARENT, ALL_DIMENSIONS ); + 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/popup/popup-impl.cpp b/dali-toolkit/internal/controls/popup/popup-impl.cpp index 42fac71..a5aed9b 100755 --- a/dali-toolkit/internal/controls/popup/popup-impl.cpp +++ b/dali-toolkit/internal/controls/popup/popup-impl.cpp @@ -122,14 +122,14 @@ void Popup::OnInitialize() Actor self = Self(); self.SetSensitive(false); // Reisize to fit the height of children - self.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT ); + self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT ); // Create Layer mLayer = Layer::New(); mLayer.SetName( "POPUP_LAYER" ); mLayer.SetParentOrigin(ParentOrigin::CENTER); mLayer.SetAnchorPoint(AnchorPoint::CENTER); - mLayer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + mLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mLayer.SetDrawMode( DrawMode::OVERLAY ); // Any content after this point which is added to Self() will be reparented to @@ -148,8 +148,8 @@ void Popup::OnInitialize() mPopupLayout.SetName( "POPUP_LAYOUT_TABLE" ); mPopupLayout.SetParentOrigin(ParentOrigin::CENTER); mPopupLayout.SetAnchorPoint(AnchorPoint::CENTER); - mPopupLayout.SetResizePolicy( FILL_TO_PARENT, WIDTH ); - mPopupLayout.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT ); + mPopupLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + mPopupLayout.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); mPopupLayout.SetFitHeight( 0 ); // Set row to fit mPopupLayout.SetFitHeight( 1 ); // Set row to fit self.Add( mPopupLayout ); @@ -224,7 +224,7 @@ void Popup::SetBackgroundImage( Actor image ) // OnDialogTouched only consume the event. It prevents the touch event to be caught by the backing. mBackgroundImage.TouchedSignal().Connect( this, &Popup::OnDialogTouched ); - mBackgroundImage.SetResizePolicy( SIZE_FIXED_OFFSET_FROM_PARENT, ALL_DIMENSIONS ); + mBackgroundImage.SetResizePolicy( ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT, Dimension::ALL_DIMENSIONS ); mBackgroundImage.SetAnchorPoint( AnchorPoint::CENTER ); mBackgroundImage.SetParentOrigin( ParentOrigin::CENTER ); @@ -251,7 +251,7 @@ void Popup::SetButtonAreaImage( Actor image ) // OnDialogTouched only consume the event. It prevents the touch event to be caught by the backing. mButtonAreaImage.TouchedSignal().Connect( this, &Popup::OnDialogTouched ); - mButtonAreaImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + mButtonAreaImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mButtonAreaImage.SetAnchorPoint( AnchorPoint::CENTER ); mButtonAreaImage.SetParentOrigin( ParentOrigin::CENTER ); @@ -277,8 +277,8 @@ void Popup::SetTitle( const std::string& text ) if( mPopupLayout ) { mTitle.SetPadding( Padding( 0.0f, 0.0f, mPopupStyle->margin, mPopupStyle->margin ) ); - mTitle.SetResizePolicy( FILL_TO_PARENT, WIDTH ); - mTitle.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); + mTitle.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + mTitle.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); mPopupLayout.AddChild( mTitle, Toolkit::TableView::CellPosition( 0, 0 ) ); } @@ -303,7 +303,7 @@ void Popup::CreateFooter() mBottomBg = Actor::New(); mBottomBg.SetName( "POPUP_BOTTOM_BG" ); mBottomBg.SetRelayoutEnabled( true ); - mBottomBg.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + mBottomBg.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mPopupLayout.SetFixedHeight( 2, mPopupStyle->bottomSize.height ); // Buttons mPopupLayout.AddChild( mBottomBg, Toolkit::TableView::CellPosition( 2, 0 ) ); @@ -313,7 +313,7 @@ void Popup::CreateFooter() void Popup::AddButton( Toolkit::Button button ) { mButtons.push_back( button ); - button.SetResizePolicy( USE_ASSIGNED_SIZE, ALL_DIMENSIONS ); // Size will be assigned to it + button.SetResizePolicy( ResizePolicy::USE_ASSIGNED_SIZE, Dimension::ALL_DIMENSIONS ); // Size will be assigned to it // If this is the first button added if( mButtons.size() == 1 ) @@ -423,7 +423,7 @@ void Popup::CreateBacking() mBacking = Dali::Toolkit::CreateSolidColorActor( mPopupStyle->backingColor ); mBacking.SetName( "POPUP_BACKING" ); - mBacking.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + mBacking.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mBacking.SetSensitive(true); mLayer.Add( mBacking ); @@ -688,23 +688,23 @@ void Popup::OnRelayout( const Vector2& size, RelayoutContainer& container ) } } -void Popup::OnSetResizePolicy( ResizePolicy policy, Dimension dimension ) +void Popup::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) { if( mPopupLayout ) { - if( policy == FIT_TO_CHILDREN ) + if( policy == ResizePolicy::FIT_TO_CHILDREN ) { - mPopupLayout.SetResizePolicy( USE_NATURAL_SIZE, dimension ); - if( dimension & HEIGHT ) + mPopupLayout.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, dimension ); + if( dimension & Dimension::HEIGHT ) { mPopupLayout.SetFitHeight( 1 ); } } else { - mPopupLayout.SetResizePolicy( FILL_TO_PARENT, dimension ); + mPopupLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, dimension ); // Make the content cell fill the whole of the available space - if( dimension & HEIGHT ) + if( dimension & Dimension::HEIGHT ) { mPopupLayout.SetRelativeHeight( 1, 1.0f ); } diff --git a/dali-toolkit/internal/controls/popup/popup-impl.h b/dali-toolkit/internal/controls/popup/popup-impl.h index efdac51..f695c74 100755 --- a/dali-toolkit/internal/controls/popup/popup-impl.h +++ b/dali-toolkit/internal/controls/popup/popup-impl.h @@ -259,7 +259,7 @@ private: /** * @copydoc Control::OnSetResizePolicy() */ - virtual void OnSetResizePolicy( ResizePolicy policy, Dimension dimension ); + virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ); /** * @copydoc Control::OnKeyEvent() 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 67b5262..2011b7f 100644 --- a/dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp +++ b/dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp @@ -169,9 +169,9 @@ void ShadowView::SetShadowPlane(Actor shadowPlane) ConstrainCamera(); - mShadowPlane.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + mShadowPlane.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - mBlurRootActor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + mBlurRootActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); } void ShadowView::SetPointLight(Actor pointLight) @@ -227,7 +227,7 @@ 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( FILL_TO_PARENT, ALL_DIMENSIONS ); + mChildrenRoot.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); Vector2 stageSize = Stage::GetCurrent().GetSize(); mCameraActor = CameraActor::New(stageSize); 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 624e973..f2b8a5f 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 @@ -143,7 +143,7 @@ void SuperBlurView::OnInitialize() for(unsigned int i=0; i<=mBlurLevels;i++) { mImageActors[i] = ImageActor::New( ); - mImageActors[i].SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + mImageActors[i].SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mImageActors[i].SetParentOrigin( ParentOrigin::CENTER ); mImageActors[i].SetZ(-static_cast(i)*0.01f); mImageActors[i].SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA ); 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 db2910a..ec8e324 100644 --- a/dali-toolkit/internal/controls/table-view/table-view-impl.cpp +++ b/dali-toolkit/internal/controls/table-view/table-view-impl.cpp @@ -38,9 +38,9 @@ namespace * @param[in] actor The child actor to test against * @param[dimension] The dimnesion to test against */ -bool FitToChild( Actor actor, Dimension dimension ) +bool FitToChild( Actor actor, Dimension::Type dimension ) { - return actor.GetResizePolicy( dimension ) != FILL_TO_PARENT && actor.GetRelayoutSize( dimension ) > 0.0f; + return actor.GetResizePolicy( dimension ) != ResizePolicy::FILL_TO_PARENT && actor.GetRelayoutSize( dimension ) > 0.0f; } #if defined(DEBUG_ENABLED) @@ -671,29 +671,29 @@ void TableView::CalculateRowColumnData() } } -void TableView::OnCalculateRelayoutSize( Dimension dimension ) +void TableView::OnCalculateRelayoutSize( Dimension::Type dimension ) { CalculateRowColumnData(); - if( dimension & WIDTH ) + if( dimension & Dimension::WIDTH ) { - CalculateFixedSizes( mColumnData, WIDTH ); + CalculateFixedSizes( mColumnData, Dimension::WIDTH ); mFixedTotals.width = CalculateTotalFixedSize( mColumnData ); } - if( dimension & HEIGHT ) + if( dimension & Dimension::HEIGHT ) { - CalculateFixedSizes( mRowData, HEIGHT ); + CalculateFixedSizes( mRowData, Dimension::HEIGHT ); mFixedTotals.height = CalculateTotalFixedSize( mRowData ); } } -void TableView::OnLayoutNegotiated( float size, Dimension dimension ) +void TableView::OnLayoutNegotiated( float size, Dimension::Type dimension ) { CalculateRowColumnData(); // Calculate the value of all relative sized rows and columns - if( dimension & WIDTH ) + if( dimension & Dimension::WIDTH ) { float remainingSize = size - mFixedTotals.width; if( remainingSize < 0.0f ) @@ -704,7 +704,7 @@ void TableView::OnLayoutNegotiated( float size, Dimension dimension ) CalculateRelativeSizes( mColumnData, remainingSize ); } - if( dimension & HEIGHT ) + if( dimension & Dimension::HEIGHT ) { float remainingSize = size - mFixedTotals.height; if( remainingSize < 0.0f ) @@ -1234,7 +1234,7 @@ Vector3 TableView::GetNaturalSize() return Vector3( mFixedTotals.width, mFixedTotals.height, 1.0f ); } -float TableView::CalculateChildSize( const Actor& child, Dimension dimension ) +float TableView::CalculateChildSize( const Actor& child, Dimension::Type dimension ) { CalculateRowColumnData(); @@ -1258,7 +1258,7 @@ float TableView::CalculateChildSize( const Actor& child, Dimension dimension ) { switch( dimension ) { - case WIDTH: + case Dimension::WIDTH: { float cellSize = 0.0f; @@ -1279,7 +1279,7 @@ float TableView::CalculateChildSize( const Actor& child, Dimension dimension ) return cellSize; } - case HEIGHT: + case Dimension::HEIGHT: { float cellSize = 0.0f; @@ -1313,7 +1313,7 @@ float TableView::CalculateChildSize( const Actor& child, Dimension dimension ) return 0.0f; // Child not found } -bool TableView::RelayoutDependentOnChildren( Dimension dimension ) +bool TableView::RelayoutDependentOnChildren( Dimension::Type dimension ) { if ( Control::RelayoutDependentOnChildren( dimension ) ) { @@ -1416,8 +1416,31 @@ float TableView::CalculateTotalFixedSize( const RowColumnArray& data ) return totalSize; } -void TableView::CalculateFixedSizes( RowColumnArray& data, Dimension dimension ) +Vector2 TableView::GetCellPadding( Dimension::Type dimension ) { + switch( dimension ) + { + case Dimension::WIDTH: + { + return Vector2( mPadding.x, mPadding.x ); + } + case Dimension::HEIGHT: + { + return Vector2( mPadding.y, mPadding.y ); + } + default: + { + break; + } + } + + return Vector2(); +} + +void TableView::CalculateFixedSizes( RowColumnArray& data, Dimension::Type dimension ) +{ + Vector2 cellPadding = GetCellPadding( dimension ); + const unsigned int dataCount = data.Size(); for( unsigned int i = 0; i < dataCount; ++i ) @@ -1429,12 +1452,12 @@ void TableView::CalculateFixedSizes( RowColumnArray& data, Dimension dimension ) // Find the size of the biggest actor in the row or column float maxActorHeight = 0.0f; - unsigned int fitCount = ( dimension == WIDTH ) ? mCellData.GetRows() : mCellData.GetColumns(); + unsigned int fitCount = ( dimension == Dimension::WIDTH ) ? mCellData.GetRows() : mCellData.GetColumns(); for( unsigned int j = 0; j < fitCount; ++j ) { - unsigned int row = ( dimension == WIDTH ) ? j : i; - unsigned int column = ( dimension == WIDTH ) ? i : j; + unsigned int row = ( dimension == Dimension::WIDTH ) ? j : i; + unsigned int column = ( dimension == Dimension::WIDTH ) ? i : j; DALI_ASSERT_DEBUG( row < mCellData.GetRows() ); DALI_ASSERT_DEBUG( column < mCellData.GetColumns() ); @@ -1443,7 +1466,7 @@ void TableView::CalculateFixedSizes( RowColumnArray& data, Dimension dimension ) { if( FitToChild( actor, dimension ) ) { - maxActorHeight = std::max( maxActorHeight, actor.GetRelayoutSize( dimension ) ); + maxActorHeight = std::max( maxActorHeight, actor.GetRelayoutSize( dimension ) + cellPadding.x + cellPadding.y ); } } } diff --git a/dali-toolkit/internal/controls/table-view/table-view-impl.h b/dali-toolkit/internal/controls/table-view/table-view-impl.h index 55a7d7b..be41e47 100644 --- a/dali-toolkit/internal/controls/table-view/table-view-impl.h +++ b/dali-toolkit/internal/controls/table-view/table-view-impl.h @@ -251,7 +251,7 @@ private: // From Control /** * @copydoc Control::CalculateChildSize */ - virtual float CalculateChildSize( const Actor& child, Dimension dimension ); + virtual float CalculateChildSize( const Actor& child, Dimension::Type dimension ); /** * @copydoc Control::OnInitialize() @@ -271,17 +271,17 @@ private: // From Control /** * @copydoc Control::RelayoutDependentOnChildren() */ - virtual bool RelayoutDependentOnChildren( Dimension dimension = ALL_DIMENSIONS ); + virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ); /** * @copydoc Control::OnCalculateRelayoutSize */ - virtual void OnCalculateRelayoutSize( Dimension dimension ); + virtual void OnCalculateRelayoutSize( Dimension::Type dimension ); /** * @copydoc Control::OnLayoutNegotiated */ - virtual void OnLayoutNegotiated( float size, Dimension dimension ); + virtual void OnLayoutNegotiated( float size, Dimension::Type dimension ); private: // Implementation @@ -404,9 +404,9 @@ private: * @brief Calculate the fixed sizes for a row or column * * @param[in] data The row or column data to process - * @param[in] dimension The dimension being calculated: row == HEIGHT, column == WIDTH + * @param[in] dimension The dimension being calculated: row == Dimension::HEIGHT, column == Dimension::WIDTH */ - void CalculateFixedSizes( RowColumnArray& data, Dimension dimension ); + void CalculateFixedSizes( RowColumnArray& data, Dimension::Type dimension ); /** * @brief Calculate the value of the relative sizes @@ -430,6 +430,14 @@ private: void CalculateRowColumnData(); /** + * @brief Return the cell padding for a given dimension + * + * @param[in] dimension The dimension to return the padding for + * @return Return the padding (x = low, y = high) + */ + Vector2 GetCellPadding( Dimension::Type dimension ); + + /** * A reference counted object may only be deleted by calling Unreference() */ virtual ~TableView(); diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index f189207..f17ea34 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -426,8 +426,8 @@ void TextField::OnInitialize() } // Fill-parent area by default - self.SetResizePolicy( FILL_TO_PARENT, WIDTH ); - self.SetResizePolicy( FILL_TO_PARENT, HEIGHT ); + self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); } void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change ) diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index 60ca46e..0cfec05 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -400,8 +400,8 @@ void TextLabel::OnInitialize() mController = Text::Controller::New( *this ); // Use height-for-width negotiation by default - self.SetResizePolicy( FILL_TO_PARENT, WIDTH ); - self.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); + self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + self.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); } void TextLabel::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change ) 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 6db6845..01ede36 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 @@ -439,23 +439,19 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part ) // Both containers will be added to a button. Actor optionContainer = Actor::New(); optionContainer.SetRelayoutEnabled( true ); - optionContainer.SetResizePolicy( FIXED, ALL_DIMENSIONS ); optionContainer.SetDrawMode( DrawMode::OVERLAY ); optionContainer.SetAnchorPoint( AnchorPoint::TOP_LEFT ); ImageActor optionPressedContainer = Toolkit::CreateSolidColorActor( mBackgroundPressedColor ); - optionPressedContainer.SetResizePolicy( FIXED, ALL_DIMENSIONS ); optionPressedContainer.SetDrawMode( DrawMode::OVERLAY ); optionPressedContainer.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // 2. Add text. Toolkit::TextLabel captionTextLabel = Toolkit::TextLabel::New(); - captionTextLabel.SetResizePolicy( FIXED, ALL_DIMENSIONS ); captionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption ); // optionContainer.Add( captionTextLabel ); Temporary removed. Toolkit::TextLabel pressedCaptionTextLabel = Toolkit::TextLabel::New(); - pressedCaptionTextLabel.SetResizePolicy( FIXED, ALL_DIMENSIONS ); pressedCaptionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption ); // optionPressedContainer.Add( pressedCaptionTextLabel ); Temporary removed. @@ -518,7 +514,6 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part ) // 5. Create a option. Toolkit::PushButton option = Toolkit::PushButton::New(); - option.SetResizePolicy( FIXED, ALL_DIMENSIONS ); option.SetSize( optionSize ); option.SetAnchorPoint( AnchorPoint::TOP_LEFT ); option.SetX( mContentSize.width ); @@ -544,7 +539,6 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part ) const Size size( POPUP_DIVIDER_WIDTH, mContentSize.height ); ImageActor divider = Toolkit::CreateSolidColorActor( Color::WHITE ); - divider.SetResizePolicy( FIXED, ALL_DIMENSIONS ); divider.SetSize( size ); divider.SetParentOrigin( ParentOrigin::TOP_LEFT ); divider.SetAnchorPoint( AnchorPoint::TOP_LEFT ); @@ -565,15 +559,13 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part ) Actor scrollview = Actor::New(); //todo make a scrollview stencil.SetRelayoutEnabled( true ); - self.SetResizePolicy( FIXED, ALL_DIMENSIONS ); self.SetSize( mRequiredPopUpSize ); // control matches stencil size - mStencilLayer.SetResizePolicy( FIXED, ALL_DIMENSIONS ); mStencilLayer.SetSize( size ); // matches stencil size - stencil.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); - scrollview.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); - mButtons.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + stencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + scrollview.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + mButtons.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mStencilLayer.SetAnchorPoint(AnchorPoint::TOP_LEFT); scrollview.SetAnchorPoint(AnchorPoint::TOP_LEFT); 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 274ca56..0bcfe26 100644 --- a/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp +++ b/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp @@ -125,9 +125,9 @@ void ToolBar::AddControl( Actor control, float relativeSize, Toolkit::Alignment: // Create an alignment container where to place the control. Toolkit::Alignment alignmentContainer = Toolkit::Alignment::New( alignment ); - alignmentContainer.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO ); + alignmentContainer.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); alignmentContainer.SetPadding( padding ); - alignmentContainer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + alignmentContainer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); alignmentContainer.Add( control ); // Insert the control in the table view. @@ -322,7 +322,7 @@ void ToolBar::OnInitialize() // Layout mLayout = Toolkit::TableView::New( 1, 1 ); mLayout.SetName( "TOOLBAR_LAYOUT" ); - mLayout.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + mLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mLayout.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); Self().Add( mLayout ); diff --git a/dali-toolkit/internal/controls/view/view-impl.cpp b/dali-toolkit/internal/controls/view/view-impl.cpp index 3b2ff0b..19dd781 100644 --- a/dali-toolkit/internal/controls/view/view-impl.cpp +++ b/dali-toolkit/internal/controls/view/view-impl.cpp @@ -133,7 +133,7 @@ void View::SetBackground( ImageActor backgroundImage ) mBackgroundLayer = Layer::New(); mBackgroundLayer.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); - mBackgroundLayer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + mBackgroundLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); // Add background layer to custom actor. Self().Add( mBackgroundLayer ); @@ -153,8 +153,8 @@ void View::SetBackground( ImageActor backgroundImage ) } backgroundImage.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); - backgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); - backgroundImage.SetSizeScalePolicy( FILL_WITH_ASPECT_RATIO ); + backgroundImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + backgroundImage.SetSizeScalePolicy( SizeScalePolicy::FILL_WITH_ASPECT_RATIO ); mBackgroundLayer.Add( backgroundImage ); RelayoutRequest(); diff --git a/dali-toolkit/internal/focus-manager/focus-manager-impl.cpp b/dali-toolkit/internal/focus-manager/focus-manager-impl.cpp index 1dee2b2..b1f3c14 100644 --- a/dali-toolkit/internal/focus-manager/focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/focus-manager-impl.cpp @@ -675,7 +675,7 @@ void FocusManager::CreateDefaultFocusIndicatorActor() focusIndicator.SetPosition(Vector3(0.0f, 0.0f, 1.0f)); // Apply size constraint to the focus indicator - focusIndicator.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + focusIndicator.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); SetFocusIndicatorActor(focusIndicator); } diff --git a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp index 8e02311..5b0bcb5 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp @@ -478,7 +478,7 @@ void KeyboardFocusManager::CreateDefaultFocusIndicatorActor() focusIndicator.SetPosition(Vector3(0.0f, 0.0f, 1.0f)); // Apply size constraint to the focus indicator - focusIndicator.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + focusIndicator.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); SetFocusIndicatorActor(focusIndicator); } diff --git a/dali-toolkit/internal/text/decorator/text-decorator.cpp b/dali-toolkit/internal/text/decorator/text-decorator.cpp index d834e48..67ae642 100644 --- a/dali-toolkit/internal/text/decorator/text-decorator.cpp +++ b/dali-toolkit/internal/text/decorator/text-decorator.cpp @@ -345,7 +345,7 @@ struct Decorator::Impl : public ConnectionTracker #endif mActiveLayer.SetParentOrigin( ParentOrigin::CENTER ); - mActiveLayer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + mActiveLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mActiveLayer.SetPositionInheritanceMode( USE_PARENT_POSITION ); parent.Add( mActiveLayer ); @@ -379,7 +379,7 @@ struct Decorator::Impl : public ConnectionTracker #endif mGrabArea.SetParentOrigin( ParentOrigin::TOP_CENTER ); mGrabArea.SetAnchorPoint( AnchorPoint::TOP_CENTER ); - mGrabArea.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); + mGrabArea.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); mGrabArea.SetSizeModeFactor( DEFAULT_GRAB_HANDLE_RELATIVE_SIZE ); mGrabHandle.Add( mGrabArea ); @@ -413,7 +413,7 @@ struct Decorator::Impl : public ConnectionTracker #ifdef DECORATOR_DEBUG primary.grabArea.SetName("SelectionHandleOneGrabArea"); #endif - primary.grabArea.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); + primary.grabArea.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); primary.grabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE ); primary.grabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); @@ -446,7 +446,7 @@ struct Decorator::Impl : public ConnectionTracker #ifdef DECORATOR_DEBUG secondary.grabArea.SetName("SelectionHandleTwoGrabArea"); #endif - secondary.grabArea.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); + secondary.grabArea.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); secondary.grabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE ); secondary.grabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); diff --git a/dali-toolkit/public-api/controls/buttons/push-button.cpp b/dali-toolkit/public-api/controls/buttons/push-button.cpp index f128778..d9e395e 100644 --- a/dali-toolkit/public-api/controls/buttons/push-button.cpp +++ b/dali-toolkit/public-api/controls/buttons/push-button.cpp @@ -77,7 +77,7 @@ PushButton PushButton::DownCast( BaseHandle handle ) void PushButton::SetButtonImage( Image image ) { Actor imageActor = ImageActor::New( image ); - imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); + imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); Dali::Toolkit::GetImplementation( *this ).SetButtonImage( imageActor ); } @@ -94,7 +94,7 @@ Actor PushButton::GetButtonImage() const void PushButton::SetBackgroundImage( Image image ) { Actor imageActor = ImageActor::New( image ); - imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); + imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( imageActor ); } @@ -111,7 +111,7 @@ Actor PushButton::GetBackgroundImage() const void PushButton::SetSelectedImage( Image image ) { Actor imageActor = ImageActor::New( image ); - imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); + imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( imageActor ); } @@ -143,7 +143,7 @@ Actor PushButton::GetSelectedBackgroundImage() const void PushButton::SetDisabledBackgroundImage( Image image ) { Actor imageActor = ImageActor::New( image ); - imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); + imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( imageActor ); } @@ -160,7 +160,7 @@ Actor PushButton::GetDisabledBackgroundImage() const void PushButton::SetDisabledImage( Image image ) { Actor imageActor = ImageActor::New( image ); - imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); + imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( imageActor ); } diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 16b4e67..d65c16b 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -420,13 +420,13 @@ Vector3 Control::GetNaturalSize() return mImpl->mNaturalSize; } -float Control::CalculateChildSize( const Dali::Actor& child, Dimension dimension ) +float Control::CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension ) { // Could be overridden in derived classes. return CalculateChildSizeBase( child, dimension ); } -bool Control::RelayoutDependentOnChildren( Dimension dimension ) +bool Control::RelayoutDependentOnChildren( Dimension::Type dimension ) { return RelayoutDependentOnChildrenBase( dimension ); } @@ -900,11 +900,11 @@ void Control::OnControlSizeSet( const Vector3& size ) { } -void Control::OnCalculateRelayoutSize( Dimension dimension ) +void Control::OnCalculateRelayoutSize( Dimension::Type dimension ) { } -void Control::OnLayoutNegotiated( float size, Dimension dimension ) +void Control::OnLayoutNegotiated( float size, Dimension::Type dimension ) { } @@ -916,7 +916,7 @@ void Control::OnRelayout( const Vector2& size, RelayoutContainer& container ) } } -void Control::OnSetResizePolicy( ResizePolicy policy, Dimension dimension ) +void Control::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) { } diff --git a/dali-toolkit/public-api/controls/control-impl.h b/dali-toolkit/public-api/controls/control-impl.h index a816989..5c29c39 100644 --- a/dali-toolkit/public-api/controls/control-impl.h +++ b/dali-toolkit/public-api/controls/control-impl.h @@ -384,7 +384,7 @@ protected: /** * @copydoc Dali::CustomActorImpl::RelayoutDependentOnChildren() */ - virtual bool RelayoutDependentOnChildren( Dimension dimension = ALL_DIMENSIONS ); + virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ); private: @@ -550,12 +550,12 @@ private: /** * @copydoc Dali::CustomActorImpl::OnCalculateRelayoutSize() */ - virtual void OnCalculateRelayoutSize( Dimension dimension ); + virtual void OnCalculateRelayoutSize( Dimension::Type dimension ); /** * @copydoc Dali::CustomActorImpl::OnLayoutNegotiated() */ - virtual void OnLayoutNegotiated( float size, Dimension dimension ); + virtual void OnLayoutNegotiated( float size, Dimension::Type dimension ); /** * @copydoc Dali::CustomActorImpl::OnRelayout() @@ -565,12 +565,12 @@ private: /** * @copydoc Dali::CustomActorImpl::OnSetResizePolicy() */ - virtual void OnSetResizePolicy( ResizePolicy policy, Dimension dimension ); + virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ); /** * @copydoc Dali::CustomActorImpl::CalculateChildSize() */ - virtual float CalculateChildSize( const Dali::Actor& child, Dimension dimension ); + virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension ); // From CustomActorImpl, derived classes should NOT override these. diff --git a/docs/content/programming-guide/size-negotiation-controls.h b/docs/content/programming-guide/size-negotiation-controls.h index 1663e79..d0a8a93 100644 --- a/docs/content/programming-guide/size-negotiation-controls.h +++ b/docs/content/programming-guide/size-negotiation-controls.h @@ -27,7 +27,7 @@ Relayout requests are put in automatically when a property is changed on an acto In addition to the resize policies detailed in the Size Negotiation Programming Guide there is one additional policy available to control writers: -- USE_ASSIGNED_SIZE: Tells the actor to use the size that was passed into the size negotiation algorithm for it. This is used in the OnRelayout +- ResizePolicy::USE_ASSIGNED_SIZE: Tells the actor to use the size that was passed into the size negotiation algorithm for it. This is used in the OnRelayout method derived from Actor when passing back controls to be negotiated using the container argument to the method.

Creating a Control: Popups

@@ -47,42 +47,42 @@ and resized by the popup. The following screen shot shows an example popup. \image html size-negotiation/PopupExample.png The first step is to set the default resize policies. This is done in the OnInitialize method. In the following snippet the popup -is set to have a height resize policy of FIT_TO_CHILDREN. This assumes that the width of the popup will be specified by the user of +is set to have a height resize policy of ResizePolicy::FIT_TO_CHILDREN. This assumes that the width of the popup will be specified by the user of the popup and that the desired behaviour is to fit the height of the popup to the size of its content. @code void Popup::OnInitialize() ... Actor self = Self(); -self.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT ); +self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT ); @endcode The popup will use a layer to place its content in. The layer is created and specified to fill the whole screen by using the following command. @code -mLayer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); +mLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @endcode A half transparent backing image is added to the layer and told to fill the layer with the following. @code -mBacking.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); +mBacking.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @endcode The popup control is added to the layer and a background image is specified to fill the size of the popup and add a border by the following. @code -mBackgroundImage.SetResizePolicy( SIZE_FIXED_OFFSET_FROM_PARENT, ALL_DIMENSIONS ); +mBackgroundImage.SetResizePolicy( ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT, Dimension::ALL_DIMENSIONS ); Vector3 border( mPopupStyle->backgroundOuterBorder.x, mPopupStyle->backgroundOuterBorder.z, 0.0f ); mBackgroundImage.SetSizeModeFactor( border ); @endcode A table view is added to the popup to specify layout. It will fill to the width of the popup and expand/contract around its children cell heights. @code -mPopupLayout.SetResizePolicy( FILL_TO_PARENT, WIDTH ); -mPopupLayout.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT ); +mPopupLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); +mPopupLayout.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); @endcode Override the OnRelayout method to position and resize the buttons. The trick to this is that the buttons do not know they are part of a popup and are about to be resized so could already have had their sizes negotiated. The call to PropagateRelayoutFlags on the button will ensure that it and all its child dependents are ready for a new size negotiation pass. The container.Add call will add the button to the relayout queue to be processed this frame. The buttonSize parameter is the desired size for the button. The desired size will only be set if the size policy of the button has already been changed to -USE_ASSIGNED_SIZE, which is what happens when a button is added to the popup. +ResizePolicy::USE_ASSIGNED_SIZE, which is what happens when a button is added to the popup. @code void Popup::AddButton( Toolkit::Button button ) ... -button.SetResizePolicy( USE_ASSIGNED_SIZE, ALL_DIMENSIONS ); +button.SetResizePolicy( ResizePolicy::USE_ASSIGNED_SIZE, Dimension::ALL_DIMENSIONS ); ... void Popup::OnRelayout( const Vector2& size, RelayoutContainer& container ) @@ -96,22 +96,22 @@ container.Add( button, buttonSize ); Another aspect to the popup is that depending which resize policies are active on it then the inner table view requires different resize policies itself. OnSetResizePolicy can be overridden to receive notice that the resize policy has changed on the control and action can be taken. @code -void Popup::OnSetResizePolicy( ResizePolicy policy, Dimension dimension ) +void Popup::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) ... -if( policy == FIT_TO_CHILDREN ) +if( policy == ResizePolicy::FIT_TO_CHILDREN ) { // Make content fit to children - mPopupLayout.SetResizePolicy( USE_NATURAL_SIZE, dimension ); - if( dimension & HEIGHT ) + mPopupLayout.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, dimension ); + if( dimension & Dimension::HEIGHT ) { mPopupLayout.SetFitHeight( 1 ); } } else { - mPopupLayout.SetResizePolicy( FILL_TO_PARENT, dimension ); + mPopupLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, dimension ); // Make the content cell fill the whole of the available space - if( dimension & HEIGHT ) + if( dimension & Dimension::HEIGHT ) { mPopupLayout.SetRelativeHeight( 1, 1.0f ); } @@ -137,7 +137,7 @@ These overridable methods in control provide customization points for the size n

Responding to the Change of Size on a Control

OnRelayout is called during the relayout process at the end of the frame immediately after the new size has been set on the actor. If the actor has calculated -the size of child actors then add them to container with their desired size and set the USE_ASSIGNED_SIZE resize policy on them. +the size of child actors then add them to container with their desired size and set the ResizePolicy::USE_ASSIGNED_SIZE resize policy on them. At this point the size of the actor has been calculated so it is a good place to calculate positions of child actors etc. @code virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ) @endcode @@ -148,11 +148,11 @@ children of an actor that is not a control. The OnCalculateRelayoutSize is called right before the size is calculated for an actor's dimension during the size negotiation phase. At this point all other actors this actor is dependent on have been negotiated so calculations depending on these actors can be performed before the size for this actor is calculated. Useful for container size calculations. -@code virtual void OnCalculateRelayoutSize( Dimension dimension ) @endcode +@code virtual void OnCalculateRelayoutSize( Dimension::Type dimension ) @endcode OnLayoutNegotiated is called right after the size in a given dimension has been negotiated for an actor. This allows calculations to be performed in response to the change in a given dimension but before OnRelayout is called. -@code virtual void OnLayoutNegotiated( float size, Dimension dimension ) @endcode +@code virtual void OnLayoutNegotiated( float size, Dimension::Type dimension ) @endcode

Calculating Sizes

@@ -160,11 +160,11 @@ Calculate the natural size for this control. This will be called when a control' For example, TableView will calculated the size of the table given its various cell properties. @code virtual Vector3 GetNaturalSize() @endcode -Given an input width return the correct height for this control. This will be called when the resize policy is set to DIMENSION_DEPENDENCY and +Given an input width return the correct height for this control. This will be called when the resize policy is set to ResizePolicy::DIMENSION_DEPENDENCY and height has a dependency on width. @code virtual float GetHeightForWidth( float width ) @endcode -Given the input height return the correct width for this control. This will be called when the resize policy is set to DIMENSION_DEPENDENCY and +Given the input height return the correct width for this control. This will be called when the resize policy is set to ResizePolicy::DIMENSION_DEPENDENCY and width has a dependency on height. @code virtual float GetWidthForHeight( float height ) @endcode @@ -172,15 +172,15 @@ width has a dependency on height. Return true from this method if this control is dependent on any of its children to calculate its own size. All relayout containers that can be dependent on their children for their own size need to return true from this. -@code virtual bool RelayoutDependentOnChildren( Dimension dimension = ALL_DIMENSIONS ) @endcode +@code virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) @endcode -This will be called by children when they are using the FILL_TO_PARENT resize policy. It is the parent's responsibility to calculate the child's correct size. -@code virtual float CalculateChildSize( const Dali::Actor& child, Dimension dimension ) @endcode +This will be called by children when they are using the ResizePolicy::FILL_TO_PARENT resize policy. It is the parent's responsibility to calculate the child's correct size. +@code virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension ) @endcode

Events

OnSetResizePolicy is called when the resize policy is set on an actor. Allows deriving actors to respond to changes in resize policy. -@code virtual void OnSetResizePolicy( ResizePolicy policy, Dimension dimension ) @endcode +@code virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) @endcode

Creating a Control: TableView

@@ -197,19 +197,19 @@ We need to be able to calculate the fixed sizes of all actors placed into table this is called every actor the table view is dependent on has already had their sizes calculated. Calculations can be made that the main calculation for the actor can then use. @code -void TableView::OnCalculateRelayoutSize( Dimension dimension ) +void TableView::OnCalculateRelayoutSize( Dimension::Type dimension ) ... CalculateRowColumnData(); -if( dimension & WIDTH ) +if( dimension & Dimension::WIDTH ) { - CalculateFixedSizes( mColumnData, WIDTH ); + CalculateFixedSizes( mColumnData, Dimension::WIDTH ); mFixedTotals.width = CalculateTotalFixedSize( mColumnData ); } -if( dimension & HEIGHT ) +if( dimension & Dimension::HEIGHT ) { - CalculateFixedSizes( mRowData, HEIGHT ); + CalculateFixedSizes( mRowData, Dimension::HEIGHT ); mFixedTotals.height = CalculateTotalFixedSize( mRowData ); } ... @@ -225,7 +225,7 @@ return Vector3( mFixedTotals.width, mFixedTotals.height, 1.0f ); When the time comes to calculate the size of each child in the table cells the following method will be called. @code -float TableView::CalculateChildSize( const Actor& child, Dimension dimension ) +float TableView::CalculateChildSize( const Actor& child, Dimension::Type dimension ) ... // Use cell data to calculate child size @endcode @@ -233,7 +233,7 @@ float TableView::CalculateChildSize( const Actor& child, Dimension dimension ) The table view is dependent on its children if its size policy is set to USE_NATURAL_SIZE or a row or column is set to "fit" an actor. The following code shows calling the base class RelayoutDependentOnChildren to check the resize policy and then searches for fit row or columns. @code -bool TableView::RelayoutDependentOnChildren( Dimension dimension ) +bool TableView::RelayoutDependentOnChildren( Dimension::Type dimension ) { if ( Control::RelayoutDependentOnChildren( dimension ) ) { diff --git a/docs/content/programming-guide/size-negotiation.h b/docs/content/programming-guide/size-negotiation.h index c8bcb89..8259359 100644 --- a/docs/content/programming-guide/size-negotiation.h +++ b/docs/content/programming-guide/size-negotiation.h @@ -18,10 +18,10 @@ The topics covered are: The notion of width and height is generalised into the concept of a Dimension. Several methods take a Dimension parameter. The Dimension enum specifies the available dimensions as bitfields: -- WIDTH -- HEIGHT +- Dimension::WIDTH +- Dimension::HEIGHT -If a method can process width and height at the same time then the ALL_DIMENSIONS mask can be specified. +If a method can process width and height at the same time then the Dimension::ALL_DIMENSIONS mask can be specified.

Resize Policies

@@ -29,13 +29,13 @@ If a method can process width and height at the same time then the ALL_DIMENSION The ResizePolicy enum specifies a range of options for controlling the way actors resize. These are powerful rules that enable much automatic resizing behaviour. They are as following: -- FIXED: This is the option to use when you want the specific definite size as set by SetSize (This is the default for all actors) -- USE_NATURAL_SIZE: Use this option for objects such as images or text to get their natural size e.g. The dimensions of the image, or the size of the text without wrapping. Also use this on TableViews when the size of the table is dependent on its children. -- FILL_TO_PARENT: Size will fill up to the size of its parent's size, taking a size factor into account to allow proportionate filling -- SIZE_RELATIVE_TO_PARENT: Fill up the parent with a relative scale. Use SetSizeModeFactor to specify the ratio to fill up to the parent. -- SIZE_FIXED_OFFSET_FROM_PARENT: Fill up the parent and add a fixed offset using SetSizeModeFactor. -- FIT_TO_CHILDREN: Size will scale around the size of the actor's children. E.g. A popup's height may resize itself around it's contents. -- DIMENSION_DEPENDENCY: This covers rules such as width-for-height and height-for-width. You specify that one dimension depends on another. +- ResizePolicy::FIXED: This is the option to use when you want the specific definite size as set by SetSize (This is the default for all actors) +- ResizePolicy::USE_NATURAL_SIZE: Use this option for objects such as images or text to get their natural size e.g. The dimensions of the image, or the size of the text without wrapping. Also use this on TableViews when the size of the table is dependent on its children. +- ResizePolicy::FILL_TO_PARENT: Size will fill up to the size of its parent's size, taking a size factor into account to allow proportionate filling +- ResizePolicy::SIZE_RELATIVE_TO_PARENT: Fill up the parent with a relative scale. Use SetSizeModeFactor to specify the ratio to fill up to the parent. +- ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT: Fill up the parent and add a fixed offset using SetSizeModeFactor. +- ResizePolicy::FIT_TO_CHILDREN: Size will scale around the size of the actor's children. E.g. A popup's height may resize itself around it's contents. +- ResizePolicy::DIMENSION_DEPENDENCY: This covers rules such as width-for-height and height-for-width. You specify that one dimension depends on another. \image html size-negotiation/ResizePolicies.png @@ -58,11 +58,11 @@ placed on the stage it will use its natural size by default. However if the user size policy is overridden by the FIXED size policy and the actor will take on the size specified. The next step is to specify how an actor will be size negotiated. The resize policies for an actor may be specified by the following method: -@code void SetResizePolicy( ResizePolicy policy, Dimension dimension ) @endcode +@code void SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) @endcode It is common to specifiy different policies for the different dimensions of width and height to achive different layouts. Different actors have different resize policies specified by default. For example ImageActors are set to use USE_NATURAL_SIZE. -The following example code snippet shows rootActor having its width policy set to FILL_TO_PARENT and its height policy set to FIT_TO_CHILDREN. +The following example code snippet shows rootActor having its width policy set to ResizePolicy::FILL_TO_PARENT and its height policy set to ResizePolicy::FIT_TO_CHILDREN. It has an ImageActor added to it with an explicit call to USE_NATURAL_SIZE in both dimensions called on it. This will make an actor that will fill up the space of its parent in the width dimension and fit to its child in the height dimension. As the image actor child is using natural size the height of the root actor will fit to the height of the child image. @@ -70,10 +70,10 @@ 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( FILL_TO_PARENT, WIDTH ); -rootActor.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT ); +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 ) ); -image.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); +image.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); rootActor.Add( image ); @endcode @@ -87,15 +87,15 @@ After: This example shows an actor rootActor set to expand to its parent's width and contract/expand around its child's height. The child image actor is set to natural size which means it will display at the acutal size of the image. -To specify that a dimension has a dependency on another dimension use DIMENSION_DEPENDENCY. For example if dimension is HEIGHT and dependency is -WIDTH then there is a height-for-width dependency in effect. The classic use case for this +To specify that a dimension has a dependency on another dimension use ResizePolicy::DIMENSION_DEPENDENCY. For example if dimension is Dimension::HEIGHT and dependency is +Dimension::WIDTH then there is a height-for-width dependency in effect. The classic use case for this is a text view that wraps its text. The following example snippet shows a text view that expands its width to the size of its parent, wraps its contents and then determines its height based on the width. @code TextView text = TextView::New( "Example" ); text.SetMultilinePolicy( SplitByWord ); -text.SetResizePolicy( FILL_TO_PARENT, WIDTH ); -text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); +text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); +text.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); @endcode

Specifying Sizes and Size Limits

@@ -112,10 +112,10 @@ void SetMaximumSize( const Vector2& size )

Altering Negotiated Size

When an actor is required to maintain the aspect ratio of its natural size the following method can be used. This is useful for size negotiating images -to ensure they maintain their aspect ratio while still fitting within the bounds they have been allocated. This can be one of USE_SIZE_SET, FIT_WITH_ASPECT_RATIO -or FILL_WITH_ASPECT_RATIO. The first is the default. The second will fit the actor within the bounds it has been allocated while maintaining aspect ratio. The +to ensure they maintain their aspect ratio while still fitting within the bounds they have been allocated. This can be one of SizeScalePolicy::USE_SIZE_SET, SizeScalePolicy::FIT_WITH_ASPECT_RATIO +or SizeScalePolicy::FILL_WITH_ASPECT_RATIO. The first is the default. The second will fit the actor within the bounds it has been allocated while maintaining aspect ratio. The third will fill all available space, potentially overflowing its bounds, while maintaining apsect ratio. -@code void SetSizeScalePolicy( SizeScalePolicy policy ) @endcode +@code void SetSizeScalePolicy( SizeScalePolicy::Type policy ) @endcode

Using Actors in Containers

@@ -133,8 +133,8 @@ mPopup.SetTitle( "Warning" ); // Content Toolkit::TableView content = Toolkit::TableView::New( 2, 2 ); -content.SetResizePolicy( FILL_TO_PARENT, WIDTH ); -content.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT ); +content.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); +content.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); content.SetFitHeight( 0 ); content.SetFitHeight( 1 ); content.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 0.0f ) ); @@ -145,22 +145,22 @@ 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 ); +text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); +text.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); content.AddChild( text, Toolkit::TableView::CellPosition( 0, 0 ) ); // Image ImageActor image = ImageActor::New( ResourceImage::New( IMAGE1 ) ); -image.SetResizePolicy( FILL_TO_PARENT, WIDTH ); -image.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); +image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); +image.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) ); content.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) ); // Checkbox and text Toolkit::TableView root = Toolkit::TableView::New( 1, 2 ); -root.SetResizePolicy( FILL_TO_PARENT, WIDTH ); -root.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT ); +root.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); +root.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); root.SetFitHeight( 0 ); root.SetFitWidth( 0 ); root.SetPadding( Padding( 0.0f, 0.0f, 0.0f, 20.0f ) ); @@ -190,42 +190,42 @@ The resulting popup with additional buttons added is shown below. \image html size-negotiation/Popup.png The key things to pick out from this example are the use of the size negotiation API. -The content table view is set to FILL_TO_PARENT for its width and USE_NATURAL_SIZE for its height. This will result +The content table view is set to ResizePolicy::FILL_TO_PARENT for its width and USE_NATURAL_SIZE for its height. This will result in the table view expanding its width to fit the available space in the popup while also expanding/contracting its height based on the size of the contents in its cells. @code -content.SetResizePolicy( FILL_TO_PARENT, WIDTH ); -content.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT ); +content.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); +content.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); @endcode To add a little space around the left, right and bottom of the table view, some padding is added. @code content.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 0.0f ) ); @endcode -The first text view has its width set to FILL_TO_PARENT and its height has a dimension dependency on its width. This +The first text view has its width set to ResizePolicy::FILL_TO_PARENT and its height has a dimension dependency on its width. This will result in a text view that fills up its width to available space in the table cell and then then calculates its height based on its new width. The table view will then fit its height taking the height of the text view into account. @code -text.SetResizePolicy( FILL_TO_PARENT, WIDTH ); -text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); +text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); +text.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); @endcode The image view performs a similar relayout. It fits its width to the size of the cell and calculates its height based on the new width. Some padding is added to the left of it as well to center it more. @code -image.SetResizePolicy( FILL_TO_PARENT, WIDTH ); -image.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); +image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); +image.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) ); @endcode The sub table view is similar as well in that it expands its width to the size of its cell. When it is added to the table view it will span two columns. Its height is set to natural size so that it will grow or shrink based on its children cells. Note that for -a container like table view, USE_NATURAL_SIZE acts in a similar manner to FIT_TO_CHILDREN in that the size of the container could +a container like table view, USE_NATURAL_SIZE acts in a similar manner to ResizePolicy::FIT_TO_CHILDREN in that the size of the container could grow or shrink based on the sizes of the child actors. @code -root.SetResizePolicy( FILL_TO_PARENT, WIDTH ); -root.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT ); +root.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); +root.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); @endcode The checkbox is set to have a fixed size. @code -checkBox.SetResizePolicy( FIXED, ALL_DIMENSIONS ); +checkBox.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); @endcode The second text view has not specified a resize policy so will use its default of USE_NATURAL_SIZE. @@ -236,10 +236,10 @@ describe a pitfall to avoid when creating scenes and a way to print debug output

Infinite Dependency Loops

Despite the power of the resize rules there is one pitfall to be aware of: infinite dependency loops. The most simplest form of this is -shown by a parent actor with resize policy set to FIT_TO_CHILDREN with a child that has a resize policy of FILL_TO_PARENT. Who should -determine the size in this case? A more complex loop occurs when DIMENSION_DEPENDENCY comes into play. Say a parent has a width policy -of DIMENSION_DEPENDENCY with height and a height policy of FIT_TO_CHILDREN. The parent has a single child with a height policy DIMENSION_DEPENDENCY -with width. If the child's width policy is FILL_TO_PARENT then a loop will occur. These are two simple examples but the loops could occur +shown by a parent actor with resize policy set to ResizePolicy::FIT_TO_CHILDREN with a child that has a resize policy of ResizePolicy::FILL_TO_PARENT. Who should +determine the size in this case? A more complex loop occurs when ResizePolicy::DIMENSION_DEPENDENCY comes into play. Say a parent has a width policy +of ResizePolicy::DIMENSION_DEPENDENCY with height and a height policy of ResizePolicy::FIT_TO_CHILDREN. The parent has a single child with a height policy ResizePolicy::DIMENSION_DEPENDENCY +with width. If the child's width policy is ResizePolicy::FILL_TO_PARENT then a loop will occur. These are two simple examples but the loops could occur over larger spreads of parent child relationships. These loops are detected by the relayout algorithm with the result being that actors will receive zero sizes. These loops are not common but are still something to watch out for. @@ -256,7 +256,7 @@ PushButton, OKAY_BUTTON - Pos: [185, 0, 0.1] Size: [165, 76, 76], Dirty: (FALSE, The format is as follows: -[Actor type], [Actor name] – Pos:[X, Y, Z] Size[WIDTH, HEIGHT, DEPTH], Dirty:(WIDTH, HEIGHT), Negotiated: (WIDTH, HEIGHT), Enabled: BOOLEAN, (Object address) +[Actor type], [Actor name] – Pos:[X, Y, Z] Size[Dimension::WIDTH, Dimension::HEIGHT, DEPTH], Dirty:(Dimension::WIDTH, Dimension::HEIGHT), Negotiated: (Dimension::WIDTH, Dimension::HEIGHT), Enabled: BOOLEAN, (Object address) - Actor type: The type name of the actor E.g. PushButton - Actor name: The name set on the actor with SetName(). Useful for debugging. - Pos: The position of the actor