+Vector3 Controller::GetNaturalSize()
+{
+ // Operations that can be done only once until the text changes.
+ const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
+ GET_SCRIPTS |
+ VALIDATE_FONTS |
+ GET_LINE_BREAKS |
+ GET_WORD_BREAKS |
+ SHAPE_TEXT |
+ GET_GLYPH_METRICS );
+
+ // Operations that need to be done if the size or the text changes.
+ const OperationsMask sizeOperations = static_cast<OperationsMask>( LAYOUT |
+ REORDER );
+
+ const float maxFloat = std::numeric_limits<float>::max();
+ DoRelayout( Vector2( maxFloat, maxFloat ),
+ static_cast<OperationsMask>( onlyOnceOperations |
+ sizeOperations ) );
+
+ // Do not do again the only once operations.
+ mImpl->mOperations = static_cast<OperationsMask>( mImpl->mOperations & ~onlyOnceOperations );
+
+ // Do the size related operations again.
+ mImpl->mOperations = static_cast<OperationsMask>( mImpl->mOperations | sizeOperations );
+
+ return Vector3( mImpl->mVisualModel->GetNaturalSize() );
+}
+
+float Controller::GetHeightForWidth( float width )
+{
+ // Operations that can be done only once until the text changes.
+ const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
+ GET_SCRIPTS |
+ VALIDATE_FONTS |
+ GET_LINE_BREAKS |
+ GET_WORD_BREAKS |
+ SHAPE_TEXT |
+ GET_GLYPH_METRICS );
+
+ // Operations that need to be done if the size or the text changes.
+ const OperationsMask sizeOperations = static_cast<OperationsMask>( LAYOUT |
+ REORDER );
+
+ DoRelayout( Size( width, 0.f ),
+ static_cast<OperationsMask>( onlyOnceOperations |
+ sizeOperations ) );
+
+ // Do not do again the only once operations.
+ mImpl->mOperations = static_cast<OperationsMask>( mImpl->mOperations & ~onlyOnceOperations );
+
+ // Do the size related operations again.
+ mImpl->mOperations = static_cast<OperationsMask>( mImpl->mOperations | sizeOperations );
+
+ return mImpl->mVisualModel->GetActualSize().height;
+}
+