From c99d36a5a70d669a68ea4a6a960d8aef6e5cb738 Mon Sep 17 00:00:00 2001 From: Victor Cebollada Date: Fri, 6 Mar 2015 16:44:12 +0000 Subject: [PATCH] Fix for text-label.example and text-label-multilanguage.example * In both demos: set the size of the text-label control, otherwise the size negotiation sets the natural size. * In the multilanguage demo: change the parent origin and anchor point of the labels. --- examples/text-label-multi-language/text-label-multi-language-example.cpp | 3 ++- examples/text-label-multi-language/vertical-layout-impl.cpp | 8 ++++++-- examples/text-label/center-layout-impl.cpp | 5 ++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/text-label-multi-language/text-label-multi-language-example.cpp b/examples/text-label-multi-language/text-label-multi-language-example.cpp index 91bc74a..27c5422 100644 --- a/examples/text-label-multi-language/text-label-multi-language-example.cpp +++ b/examples/text-label-multi-language/text-label-multi-language-example.cpp @@ -72,7 +72,8 @@ public: const Language& language = LANGUAGES[index]; TextLabel label = TextLabel::New(); - label.SetParentOrigin( ParentOrigin::CENTER ); + label.SetParentOrigin( ParentOrigin::TOP_CENTER ); + label.SetAnchorPoint( AnchorPoint::TOP_CENTER ); label.SetProperty( TextLabel::Property::MULTI_LINE, true ); diff --git a/examples/text-label-multi-language/vertical-layout-impl.cpp b/examples/text-label-multi-language/vertical-layout-impl.cpp index e3b326a..b3ebbf2 100644 --- a/examples/text-label-multi-language/vertical-layout-impl.cpp +++ b/examples/text-label-multi-language/vertical-layout-impl.cpp @@ -113,16 +113,20 @@ void VerticalLayout::OnRelayout( const Vector2& size, ActorSizeContainer& contai Vector3 position; for( unsigned int index = 0u, count = self.GetChildCount(); index < count; ++index ) { + Size childSize = size; Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( self.GetChildAt( index ) ); if( label ) { label.SetPosition( position ); - position.height += label.GetHeightForWidth( size.width ); + childSize.height = label.GetHeightForWidth( size.width ); + position.height += childSize.height; + + label.SetSize( childSize ); } - container.push_back( ActorSizePair( label, size ) ); + container.push_back( ActorSizePair( label, childSize ) ); } } diff --git a/examples/text-label/center-layout-impl.cpp b/examples/text-label/center-layout-impl.cpp index 04b0720..dc5cb53 100644 --- a/examples/text-label/center-layout-impl.cpp +++ b/examples/text-label/center-layout-impl.cpp @@ -106,7 +106,10 @@ void CenterLayout::OnRelayout( const Vector2& size, ActorSizeContainer& containe float height = child.GetHeightForWidth( size.width ); - container.push_back( ActorSizePair( child, Vector2( size.width, std::min(height, size.height) ) ) ); + const Size childSize( size.width, std::min( height, size.height ) ); + child.SetSize( childSize ); + + container.push_back( ActorSizePair( child, childSize ) ); } } } -- libgit2 0.21.4