apply horizontal fittocontent for tizen_2.1
authorMyung Jin Kim <critical.kim@samsung.com>
Mon, 20 May 2013 11:53:35 +0000 (20:53 +0900)
committerMyung Jin Kim <critical.kim@samsung.com>
Mon, 20 May 2013 11:53:35 +0000 (20:53 +0900)
Change-Id: Id010b71b062f2cbedb48b6489968c47f76da76df

src/ui/controls/FUiCtrl_Button.cpp
src/ui/controls/FUiCtrl_Label.cpp

index 7117f57..942895d 100644 (file)
@@ -1360,7 +1360,6 @@ _Button::GetContentSizeInternalF(bool horizontalMode, bool verticalMode) const
        pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE);
        pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
        pTextObject->Compose();
-       dimension = pTextObject->GetTextExtentF();
 
        _ControlOrientation orientation = GetOrientation();
        if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
@@ -1372,24 +1371,34 @@ _Button::GetContentSizeInternalF(bool horizontalMode, bool verticalMode) const
                contentRect.width = _ControlManager::GetInstance()->GetScreenSizeF().height;
        }
 
-       if (dimension.width > contentRect.width - GetBoundsF().x - __leftMargin * 2)
+       if (horizontalMode == true)
        {
-               dimension.width = contentRect.width - GetBoundsF().x - __leftMargin * 2;
+               dimension = pTextObject->GetTextExtentF(0, pTextObject->GetTextLength());
 
-               pTextObject->SetBounds(FloatRectangle(previousRect.x, previousRect.y, dimension.width, previousRect.height));
-               pTextObject->Compose();
+               if (dimension.width > contentRect.width - GetBoundsF().x - __leftMargin * 2)
+               {
+                       dimension.width = contentRect.width - GetBoundsF().x - __leftMargin * 2;
+
+                       pTextObject->SetBounds(FloatRectangle(previousRect.x, previousRect.y, dimension.width, previousRect.height));
+                       pTextObject->Compose();
 
-               dimension.height = pTextObject->GetTotalHeightF();
+                       dimension.height = pTextObject->GetTotalHeightF();
+               }
        }
 
-       if (dimension.width > GetBoundsF().width - __leftMargin * 2)
+       if (verticalMode == true)
        {
-               dimension.width = GetBoundsF().width - __leftMargin * 2;
+               dimension = pTextObject->GetTextExtentF();
 
-               pTextObject->SetBounds(FloatRectangle(previousRect.x, previousRect.y, dimension.width, previousRect.height));
-               pTextObject->Compose();
+               if (dimension.width > GetBoundsF().width - __leftMargin * 2)
+               {
+                       dimension.width = GetBoundsF().width - __leftMargin * 2;
+
+                       pTextObject->SetBounds(FloatRectangle(previousRect.x, previousRect.y, dimension.width, previousRect.height));
+                       pTextObject->Compose();
 
-               dimension.height = pTextObject->GetTotalHeightF();
+                       dimension.height = pTextObject->GetTotalHeightF();
+               }
        }
 
        pTextObject->SetBounds(previousRect);
index dba7e38..cf292e9 100644 (file)
@@ -562,7 +562,6 @@ _Label::GetContentSizeInternalF(bool horizontalMode, bool verticalMode) const
        pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE);
        pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
        pTextObject->Compose();
-       dimension = pTextObject->GetTextExtentF();
 
        _ControlOrientation orientation = GetOrientation();
        if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
@@ -574,24 +573,34 @@ _Label::GetContentSizeInternalF(bool horizontalMode, bool verticalMode) const
                contentRect.width = _ControlManager::GetInstance()->GetScreenSizeF().height;
        }
 
-       if (dimension.width > contentRect.width - GetBoundsF().x - __leftMargin * 2)
+       if (horizontalMode == true)
        {
-               dimension.width = contentRect.width - GetBoundsF().x - __leftMargin * 2;
+               dimension = pTextObject->GetTextExtentF(0, pTextObject->GetTextLength());
 
-               pTextObject->SetBounds(FloatRectangle(previousRect.x, previousRect.y, dimension.width, previousRect.height));
-               pTextObject->Compose();
+               if (dimension.width > contentRect.width - GetBoundsF().x - __leftMargin * 2)
+               {
+                       dimension.width = contentRect.width - GetBoundsF().x - __leftMargin * 2;
+
+                       pTextObject->SetBounds(FloatRectangle(previousRect.x, previousRect.y, dimension.width, previousRect.height));
+                       pTextObject->Compose();
 
-               dimension.height = pTextObject->GetTotalHeightF();
+                       dimension.height = pTextObject->GetTotalHeightF();
+               }
        }
 
-       if (dimension.width > GetBoundsF().width - __leftMargin * 2)
+       if (verticalMode == true)
        {
-               dimension.width = GetBoundsF().width - __leftMargin * 2;
+               dimension = pTextObject->GetTextExtentF();
 
-               pTextObject->SetBounds(FloatRectangle(previousRect.x, previousRect.y, dimension.width, previousRect.height));
-               pTextObject->Compose();
+               if (dimension.width > GetBoundsF().width - __leftMargin * 2)
+               {
+                       dimension.width = GetBoundsF().width - __leftMargin * 2;
+
+                       pTextObject->SetBounds(FloatRectangle(previousRect.x, previousRect.y, dimension.width, previousRect.height));
+                       pTextObject->Compose();
 
-               dimension.height = pTextObject->GetTotalHeightF();
+                       dimension.height = pTextObject->GetTotalHeightF();
+               }
        }
 
        pTextObject->SetBounds(previousRect);