From: Myung Jin Kim Date: Mon, 20 May 2013 07:31:37 +0000 (+0900) Subject: fix FitToContent for tizen_2.1 X-Git-Tag: accepted/tizen/20130924.144426~1^2~837 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=80fe55bf732ded52686b0255910af65e94c27792;p=platform%2Fframework%2Fnative%2Fuifw.git fix FitToContent for tizen_2.1 Change-Id: I647aca38956e96784c9d0dc100ca2e30b0f09c06 --- diff --git a/src/graphics/inc/FGrp_TextTextObject.h b/src/graphics/inc/FGrp_TextTextObject.h index d9f43f1..75395da 100644 --- a/src/graphics/inc/FGrp_TextTextObject.h +++ b/src/graphics/inc/FGrp_TextTextObject.h @@ -147,6 +147,10 @@ public: FloatDimension GetTextExtentF(int startTextIndex, int textLength) const; + Dimension GetTextExtent(void) const; + + FloatDimension GetTextExtentF(void) const; + result SetAction(TextObjectActionType action); TextObjectActionType GetAction(void) const; diff --git a/src/graphics/text/FGrp_TextTextObject.cpp b/src/graphics/text/FGrp_TextTextObject.cpp index 39ecbc0..cc9faa9 100644 --- a/src/graphics/text/FGrp_TextTextObject.cpp +++ b/src/graphics/text/FGrp_TextTextObject.cpp @@ -1124,6 +1124,42 @@ TextObject::GetTextExtentF(int startTextIndex, int textLength) const return textSize; } +Dimension +TextObject::GetTextExtent(void) const +{ + return _CoordinateSystemUtils::ConvertToInteger(GetTextExtentF()); +} + +FloatDimension +TextObject::GetTextExtentF(void) const +{ + IF_NOT_CONSTRUCTED(return FloatDimension(-1, -1)); + + TextLine* pTextLine = null; + FloatDimension textSize(0.0f, 0.0f); + FloatDimension lineSize(0.0f, 0.0f); + int lineCount = GetTotalLineCount(); + + for (int i = 0; i < lineCount; i++) + { + pTextLine = __pTextColumn->GetTextLine(i); + SysTryReturn(NID_GRP, pTextLine, FloatDimension(-1, -1), E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + pTextLine->GetRegion(0, pTextLine->GetTextLength(), lineSize.width, lineSize.height); + + if (textSize.width < lineSize.width) + { + textSize.width = lineSize.width; + } + } + + textSize.height = GetTotalHeightF(); + + SetLastResult(E_SUCCESS); + + return textSize; +} + result TextObject::AppendElement(TextElement& textElement) { diff --git a/src/ui/controls/FUiCtrl_Button.cpp b/src/ui/controls/FUiCtrl_Button.cpp index bc02ba5..2ba7afb 100644 --- a/src/ui/controls/FUiCtrl_Button.cpp +++ b/src/ui/controls/FUiCtrl_Button.cpp @@ -1360,12 +1360,21 @@ _Button::GetContentSizeInternalF(void) const TextObjectWrapType previousWrapType = pTextObject->GetWrap(); FloatRectangle previousRect = pTextObject->GetBoundsF(); + pTextObject->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width - __leftMargin * 2, GetBoundsF().height - __topMargin * 2)); pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE); pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); pTextObject->Compose(); - dimension = pTextObject->GetTextExtentF(0, pTextObject->GetTextLength()); + dimension = pTextObject->GetTextExtentF(); - contentRect.width = _ControlManager::GetInstance()->GetScreenSizeF().width; + _ControlOrientation orientation = GetOrientation(); + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + contentRect.width = _ControlManager::GetInstance()->GetScreenSizeF().width; + } + else + { + contentRect.width = _ControlManager::GetInstance()->GetScreenSizeF().height; + } if (dimension.width > contentRect.width - GetBoundsF().x - __leftMargin * 2) { @@ -1407,7 +1416,6 @@ _Button::GetContentSizeInternalF(void) const return dimension; } - int _Button::GetTextExtentSize(void) const { diff --git a/src/ui/controls/FUiCtrl_Label.cpp b/src/ui/controls/FUiCtrl_Label.cpp index afbdd2f..664267b 100644 --- a/src/ui/controls/FUiCtrl_Label.cpp +++ b/src/ui/controls/FUiCtrl_Label.cpp @@ -562,10 +562,11 @@ _Label::GetContentSizeInternalF(void) const TextObjectWrapType previousWrapType = pTextObject->GetWrap(); FloatRectangle previousRect = pTextObject->GetBoundsF(); + pTextObject->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width - __leftMargin * 2, GetBoundsF().height - __topMargin * 2)); pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE); pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); pTextObject->Compose(); - dimension = pTextObject->GetTextExtentF(0, pTextObject->GetTextLength()); + dimension = pTextObject->GetTextExtentF(); _ControlOrientation orientation = GetOrientation(); if (orientation == _CONTROL_ORIENTATION_PORTRAIT) diff --git a/src/ui/controls/FUiCtrl_LabelPresenter.cpp b/src/ui/controls/FUiCtrl_LabelPresenter.cpp index 4e3bb4c..b215241 100644 --- a/src/ui/controls/FUiCtrl_LabelPresenter.cpp +++ b/src/ui/controls/FUiCtrl_LabelPresenter.cpp @@ -155,6 +155,7 @@ _LabelPresenter::OnFontChanged(Font* pFont) { __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength()); } + return; }