X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fpopup%2Fpopup-impl.cpp;h=42fac718e38bd27a9956bef36f3bfbb62c71380d;hp=b67bdcc41a732a98707d13324bf6333dda7d49d7;hb=4b347781c8761d2909b235ded2e98d272fa9ac16;hpb=cc82bd9b187cda8fe2c8336b73fd1fa9376cfebd diff --git a/dali-toolkit/internal/controls/popup/popup-impl.cpp b/dali-toolkit/internal/controls/popup/popup-impl.cpp index b67bdcc..42fac71 100755 --- a/dali-toolkit/internal/controls/popup/popup-impl.cpp +++ b/dali-toolkit/internal/controls/popup/popup-impl.cpp @@ -19,6 +19,7 @@ #include // EXTERNAL INCLUDES +#include // for strcmp #include #include #include @@ -223,11 +224,10 @@ 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( FILL_TO_PARENT, ALL_DIMENSIONS ); + mBackgroundImage.SetResizePolicy( SIZE_FIXED_OFFSET_FROM_PARENT, ALL_DIMENSIONS ); mBackgroundImage.SetAnchorPoint( AnchorPoint::CENTER ); mBackgroundImage.SetParentOrigin( ParentOrigin::CENTER ); - mBackgroundImage.SetSizeMode( SIZE_FIXED_OFFSET_FROM_PARENT ); Vector3 border( mPopupStyle->backgroundOuterBorder.x, mPopupStyle->backgroundOuterBorder.z, 0.0f ); mBackgroundImage.SetSizeModeFactor( border ); @@ -263,13 +263,36 @@ void Popup::SetButtonAreaImage( Actor image ) void Popup::SetTitle( const std::string& text ) { -// TODO + // Replaces the current title actor. + if( mPopupLayout ) + { + mPopupLayout.RemoveChildAt( Toolkit::TableView::CellPosition( 0, 0 ) ); + } + + mTitle = Toolkit::TextLabel::New( text ); + mTitle.SetName( "POPUP_TITLE" ); + mTitle.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true ); + mTitle.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); + + if( mPopupLayout ) + { + mTitle.SetPadding( Padding( 0.0f, 0.0f, mPopupStyle->margin, mPopupStyle->margin ) ); + mTitle.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + mTitle.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); + mPopupLayout.AddChild( mTitle, Toolkit::TableView::CellPosition( 0, 0 ) ); + } + + RelayoutRequest(); } -const std::string& Popup::GetTitle() const +std::string Popup::GetTitle() const { - static std::string temp(""); - return temp; + if( mTitle ) + { + return mTitle.GetProperty( Toolkit::TextLabel::Property::TEXT ); + } + + return std::string(); } void Popup::CreateFooter() @@ -712,6 +735,29 @@ Vector3 Popup::GetNaturalSize() Vector3 naturalSize( 0.0f, 0.0f, 0.0f ); + if ( mTitle ) + { + Vector3 titleNaturalSize = mTitle.GetImplementation().GetNaturalSize(); + // Buffer to avoid errors. The width of the popup could potentially be the width of the title text. + // It was observed in this case that text wrapping was then inconsistent when seen on device + const float titleBuffer = 0.5f; + titleNaturalSize.width += titleBuffer; + + // As TextLabel GetNaturalSize does not take wrapping into account, limit the width + // to that of the stage + if( titleNaturalSize.width >= maxWidth) + { + naturalSize.width = maxWidth; + naturalSize.height = mTitle.GetImplementation().GetHeightForWidth( naturalSize.width ); + } + else + { + naturalSize += titleNaturalSize; + } + + naturalSize.height += mPopupStyle->margin; + } + if( mContent ) { Vector3 contentSize = mContent.GetNaturalSize(); @@ -742,6 +788,12 @@ float Popup::GetHeightForWidth( float width ) float height( 0.0f ); float popupWidth( width - 2.f * ( POPUP_OUT_MARGIN_WIDTH + mPopupStyle->margin ) ); + if ( mTitle ) + { + height += mTitle.GetImplementation().GetHeightForWidth( popupWidth ); + height += mPopupStyle->margin; + } + if( mContent ) { height += mContent.GetHeightForWidth( popupWidth ) + mPopupStyle->margin;