Size negotiation patch 3: Scope size negotiation enums
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-controls / text-selection-popup-impl.cpp
index e117e22..01ede36 100644 (file)
@@ -260,7 +260,7 @@ void TextSelectionPopup::OnInitialize()
   CreatePopup();
 }
 
-void TextSelectionPopup::OnRelayout( const Vector2& size, ActorSizeContainer& container )
+void TextSelectionPopup::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
 
 }
@@ -429,8 +429,8 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part )
      mNinePatchMargins.w = ninePatchImageSize.height - ( childRect.y + childRect.height ) - 1u;
    }
 
-   SetBackground ( mBackgroundImage );
-   SetBackgroundColor ( mBackgroundColor );
+   SetBackgroundImage( mBackgroundImage );
+   SetBackgroundColor( mBackgroundColor );
  }
 
  void TextSelectionPopup::AddOption( Actor& parent, const std::string& name, const std::string& caption, const Image iconImage, bool finalOption, bool showIcons )
@@ -438,23 +438,22 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part )
    // 1. Create the backgrounds for the popup option both normal and pressed.
    // Both containers will be added to a button.
    Actor optionContainer = Actor::New();
+   optionContainer.SetRelayoutEnabled( true );
    optionContainer.SetDrawMode( DrawMode::OVERLAY );
-   //optionContainer.SetParentOrigin( ParentOrigin::CENTER );
    optionContainer.SetAnchorPoint( AnchorPoint::TOP_LEFT );
 
    ImageActor optionPressedContainer = Toolkit::CreateSolidColorActor( mBackgroundPressedColor );
    optionPressedContainer.SetDrawMode( DrawMode::OVERLAY );
-   //optionPressedContainer.SetParentOrigin( ParentOrigin::CENTER );
    optionPressedContainer.SetAnchorPoint( AnchorPoint::TOP_LEFT );
 
    // 2. Add text.
    Toolkit::TextLabel captionTextLabel = Toolkit::TextLabel::New();
    captionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
-   optionContainer.Add( captionTextLabel );
+   // optionContainer.Add( captionTextLabel ); Temporary removed.
 
    Toolkit::TextLabel pressedCaptionTextLabel = Toolkit::TextLabel::New();
    pressedCaptionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
-   optionPressedContainer.Add( pressedCaptionTextLabel );
+   // optionPressedContainer.Add( pressedCaptionTextLabel ); Temporary removed.
 
    // Calculates the icon/text position.
    float iconTextOffsetY = 0.0f;
@@ -500,8 +499,8 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part )
    textSize.width = std::min( textSize.width, OPTION_MAX_WIDTH - 2.f * OPTION_MARGIN_WIDTH );
 
    // Set the size to the text. Text will be ellipsized if exceeds the max width.
-   captionTextLabel.SetSize( textSize );
-   pressedCaptionTextLabel.SetSize( textSize );
+   captionTextLabel.SetSize( textSize.GetVectorXY() );
+   pressedCaptionTextLabel.SetSize( textSize.GetVectorXY() );
 
    // 4. Calculate the size of option.
 
@@ -515,7 +514,6 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part )
 
    // 5. Create a option.
    Toolkit::PushButton option = Toolkit::PushButton::New();
-   option.SetSizePolicy( Toolkit::Control::Fixed, Toolkit::Control::Fixed );
    option.SetSize( optionSize );
    option.SetAnchorPoint( AnchorPoint::TOP_LEFT );
    option.SetX( mContentSize.width );
@@ -541,7 +539,7 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part )
      const Size size( POPUP_DIVIDER_WIDTH, mContentSize.height );
 
      ImageActor divider =  Toolkit::CreateSolidColorActor( Color::WHITE );
-     divider.SetSize (size);
+     divider.SetSize( size );
      divider.SetParentOrigin( ParentOrigin::TOP_LEFT );
      divider.SetAnchorPoint( AnchorPoint::TOP_LEFT );
      divider.SetPosition( mContentSize.width - POPUP_DIVIDER_WIDTH, 0.0f );
@@ -559,14 +557,15 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part )
    stencil.SetDrawMode( DrawMode::STENCIL );
    stencil.SetVisible( true );
    Actor scrollview = Actor::New(); //todo make a scrollview
+   stencil.SetRelayoutEnabled( true );
 
-   //todo Use Size negotiation
-   //self.SetSize( size ); // control matches stencil size
    self.SetSize( mRequiredPopUpSize ); // control matches stencil size
+
    mStencilLayer.SetSize( size ); // matches stencil size
-   stencil.SetSize( size );
-   scrollview.SetSize( size );
-   mButtons.SetSize( size );
+
+   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);
@@ -587,6 +586,7 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part )
    mContentSize = Vector2::ZERO;
 
    mButtons = Actor::New();
+   mButtons.SetRelayoutEnabled( true );
 
    // Add the options into the buttons container.