#include <dali/public-api/object/type-registry.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
+#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
namespace Dali
{
Actor& buttonImage = GetButtonImage();
buttonImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+
+ buttonImage.RelayoutRequestTree();
+
+ RelayoutRequest();
}
void PushButton::OnSelectedImageSet()
Actor& selectedImage = GetSelectedImage();
selectedImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+
+ selectedImage.RelayoutRequestTree();
+
+ RelayoutRequest();
}
void PushButton::OnBackgroundImageSet()
Actor& backgroundImage = GetBackgroundImage();
backgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+
+ backgroundImage.RelayoutRequestTree();
+
+ RelayoutRequest();
}
void PushButton::OnSelectedBackgroundImageSet()
Actor& disabledImage = GetDisabledImage();
disabledImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+
+ disabledImage.RelayoutRequestTree();
+
+ RelayoutRequest();
}
void PushButton::OnDisabledBackgroundImageSet()
Actor& disabledBackgroundImage = GetDisabledBackgroundImage();
disabledBackgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+
+ disabledBackgroundImage.RelayoutRequestTree();
+
+ RelayoutRequest();
}
bool PushButton::OnSelected()
Vector3 PushButton::GetNaturalSize()
{
- Vector3 size = Control::GetNaturalSize();
+ Vector3 size;
- const bool widthIsZero = EqualsZero( size.width );
- const bool heightIsZero = EqualsZero( size.height );
-
- if( widthIsZero || heightIsZero )
+ // If background and background not scale9 try get size from that
+ ImageActor imageActor = FindImageActor( GetButtonImage() );
+ if( imageActor && imageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
{
- // If background and background not scale9 try get size from that
- ImageActor imageActor = FindImageActor( GetButtonImage() );
- if( imageActor && imageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
- {
- Vector3 imageSize = imageActor.GetNaturalSize();
-
- if( widthIsZero )
- {
- size.width = imageSize.width;
- }
-
- if( heightIsZero )
- {
- size.height = imageSize.height;
- }
- }
-
- ImageActor backgroundImageActor = FindImageActor( GetBackgroundImage() );
- if( backgroundImageActor && backgroundImageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
- {
- Vector3 imageSize = backgroundImageActor.GetNaturalSize();
-
- if( widthIsZero )
- {
- size.width = std::max( size.width, imageSize.width );
- }
-
- if( heightIsZero )
- {
- size.height = std::max( size.height, imageSize.height );
- }
- }
+ size.width = imageActor.GetRelayoutSize( WIDTH );
+ size.height = imageActor.GetRelayoutSize( HEIGHT );
+ }
- // If label, test against it's size
- Toolkit::TextView textView = Toolkit::TextView::DownCast( GetLabel() );
- if( textView )
- {
- Vector3 textViewSize = textView.GetNaturalSize();
+ ImageActor backgroundImageActor = FindImageActor( GetBackgroundImage() );
+ if( backgroundImageActor && backgroundImageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
+ {
+ size.width = std::max( size.width, backgroundImageActor.GetRelayoutSize( WIDTH ) );
+ size.height = std::max( size.height, backgroundImageActor.GetRelayoutSize( HEIGHT ) );
+ }
- if( widthIsZero )
- {
- size.width = std::max( size.width, textViewSize.width + TEXT_PADDING * 2.0f );
- }
+ // If label, test against it's size
+ Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( GetLabel() );
+ if( label )
+ {
+ Vector3 labelSize = label.GetNaturalSize();
- if( heightIsZero )
- {
- size.height = std::max( size.height, textViewSize.height + TEXT_PADDING * 2.0f );
- }
- }
+ 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;