Content Text bounds Set
authorKunal Sinha <kunal.sinha@samsung.com>
Fri, 10 May 2013 13:48:10 +0000 (19:18 +0530)
committerKunal Sinha <kunal.sinha@samsung.com>
Tue, 21 May 2013 14:04:47 +0000 (19:34 +0530)
Change-Id: I98a9f61cb5e5fdfd9b696a0e9eb6f63c6cd58895
Signed-off-by: Kunal Sinha <kunal.sinha@samsung.com>
src/ui/controls/FUiCtrl_TokenEditPresenter.cpp

index ed603de..09dadf1 100644 (file)
@@ -1334,7 +1334,7 @@ _TokenEditPresenter::CalculateTokenPositionFromIndex(int startIndex, bool leftWa
        int tokenCount = __pTokenList->GetCount();
 
        float tokenLeftMargin = 0.0f;
-       float tokenRighttMargin = 0.0f;
+       float tokenRightMargin = 0.0f;
        float tokenTopMargin = 0.0f;
        float tokenBottomMargin = 0.0f;
        float tokenHeight = 0.0f;
@@ -1346,7 +1346,7 @@ _TokenEditPresenter::CalculateTokenPositionFromIndex(int startIndex, bool leftWa
        _ControlOrientation orientation = __pTokenEdit->GetOrientation();
 
        GET_SHAPE_CONFIG(TOKENEDIT::LEFT_MARGIN, orientation, tokenLeftMargin);
-       GET_SHAPE_CONFIG(TOKENEDIT::RIGHT_MARGIN, orientation, tokenRighttMargin);
+       GET_SHAPE_CONFIG(TOKENEDIT::RIGHT_MARGIN, orientation, tokenRightMargin);
        GET_SHAPE_CONFIG(TOKENEDIT::TOP_MARGIN, orientation, tokenTopMargin);
        GET_SHAPE_CONFIG(TOKENEDIT::BOTTOM_MARGIN, orientation, tokenBottomMargin);
        GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_HEIGHT, orientation, tokenHeight);
@@ -1386,9 +1386,9 @@ _TokenEditPresenter::CalculateTokenPositionFromIndex(int startIndex, bool leftWa
                                pToken->displayRect.x = __descriptionTextRectForScroll.x + __descriptionTextRectForScroll.width + descriptionTextRightMargin;
                                pToken->displayRect.y = __descriptionTextRectForScroll.y + __scrollValue;
                        }
-                       else        // Set description text.
+                       else    // Set description text.
                        {
-                               pToken->displayRect.x = tokenTextLeftMargin + __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
+                               pToken->displayRect.x = tokenLeftMargin + __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
                                pToken->displayRect.y = tokenTopMargin + __scrollValue + __pTokenEdit->GetVerticalMarginF(EDIT_TEXT_TOP_MARGIN) + __lineSpacing;
 
                        }
@@ -1403,10 +1403,10 @@ _TokenEditPresenter::CalculateTokenPositionFromIndex(int startIndex, bool leftWa
                                findPrevTokenLoopFlag = false;
                        }
 
-                       float tempTextWidth = tokenEditBounds.width - pPreviousToken->displayRect.x - pPreviousToken->displayRect.width - tokenHorizontalSpacing - tokenTextRightMargin - __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
+                       float tempTextWidth = tokenEditBounds.width - pPreviousToken->displayRect.x - pPreviousToken->displayRect.width - tokenHorizontalSpacing - tokenRightMargin - __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
                        if (tokenTextLeftMargin + pToken->GetTextPixelWidth() + tokenTextRightMargin > tempTextWidth)           // Line change
                        {
-                               pToken->displayRect.x = tokenTextLeftMargin + __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
+                               pToken->displayRect.x = tokenLeftMargin + __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
                                pToken->displayRect.y = pPreviousToken->displayRect.y + tokenHeight + tokenVerticalSpacing + __lineSpacing;
                                __lineAdded++;
                        }
@@ -1489,6 +1489,8 @@ _TokenEditPresenter::SetInitialBounds(void)
 {
        result r = E_SUCCESS;
 
+       float tokenLeftMargin = 0.0f;
+       float tokenRightMargin = 0.0f;
        float tokenTopMargin = 0.0f;
        float tokenHeight = 0.0f;
        float tokenMinWidth = 0.0f;
@@ -1500,6 +1502,8 @@ _TokenEditPresenter::SetInitialBounds(void)
        float descriptionTextRightMargin = 0.0f;
        _ControlOrientation orientation = GetEditView()->GetOrientation();
 
+       GET_SHAPE_CONFIG(TOKENEDIT::LEFT_MARGIN, orientation, tokenLeftMargin);
+       GET_SHAPE_CONFIG(TOKENEDIT::RIGHT_MARGIN, orientation, tokenRightMargin);
        GET_SHAPE_CONFIG(TOKENEDIT::TOP_MARGIN, orientation, tokenTopMargin);
        GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_HEIGHT, orientation, tokenHeight);
        GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_MIN_WIDTH, orientation, tokenMinWidth);
@@ -1524,21 +1528,18 @@ _TokenEditPresenter::SetInitialBounds(void)
                        if (__pTokenEdit->GetTitleText().GetLength())
                        {
                                FloatRectangle descriptionTextRect = GetDescriptionTextRect();
-
                                tokenTextRect.x = descriptionTextRect.x + descriptionTextRect.width + descriptionTextRightMargin;
-                               tokenTextRect.width -= (tokenTextLeftMargin + tokenTextRightMargin + descriptionTextRect.width + descriptionTextRightMargin + 2.0f * __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN));
                        }
                        else
                        {
-                               tokenTextRect.x = tokenTextLeftMargin + __pTokenEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN);
-                               tokenTextRect.width -= (tokenTextLeftMargin + tokenTextRightMargin + 2 * __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN));
+                               tokenTextRect.x = tokenLeftMargin + __pTokenEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN);
                        }
 
                        tokenTextRect.y = tokenTopMargin + __pTokenEdit->GetVerticalMarginF(EDIT_TEXT_TOP_MARGIN) + textBoundsAlignValue;
+                       tokenTextRect.width -= tokenTextRect.x + tokenRightMargin + __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
                        tokenTextRect.height = textObjectMaxHeight;
 
                        SetTextBounds(tokenTextRect);
-
                        return r;
                }
 
@@ -1548,21 +1549,19 @@ _TokenEditPresenter::SetInitialBounds(void)
                SysTryReturn(NID_UI_CTRL, pToken, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null");
 
                float tempTextRectWidth = 0.0f;
-               tempTextRectWidth = tokenEditBounds.width - pToken->displayRect.x - pToken->displayRect.width - tokenHorizontalSpacing - __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
+               tempTextRectWidth = tokenEditBounds.width - pToken->displayRect.x - pToken->displayRect.width - tokenHorizontalSpacing - tokenRightMargin - __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
                if (tokenMinWidth > tempTextRectWidth)        // Line change
                {
-                       tokenTextRect.x = tokenTextLeftMargin + __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
+                       tokenTextRect.x = tokenLeftMargin + __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
                        tokenTextRect.y = pToken->displayRect.y + tokenHeight + tokenVerticalSpacing + __lineSpacing + textBoundsAlignValue;
-                       tokenTextRect.width = tokenEditBounds.width - tokenTextLeftMargin - tokenTextRightMargin - 2 * __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
                }
                else
                {
                        tokenTextRect.x = pToken->displayRect.x + pToken->displayRect.width + tokenHorizontalSpacing;
                        tokenTextRect.y = pToken->displayRect.y + textBoundsAlignValue;
-                       tokenTextRect.width = tokenEditBounds.width - pToken->displayRect.x - pToken->displayRect.width -
-                                       tokenTextRightMargin - __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN) - tokenTextLeftMargin;
                }
 
+               tokenTextRect.width -= tokenTextRect.x + tokenRightMargin + __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
                tokenTextRect.height = textObjectMaxHeight;
 
                SetTextBounds(tokenTextRect);
@@ -1757,6 +1756,7 @@ _TokenEditPresenter::CalculateDescriptionTextRect(const String& descriptionText)
        result r = E_SUCCESS;
 
        TextSimple* pSimpleText = null;
+       float leftMargin = 0.0f;
        float tokenTopMargin = 0.0f;
        float tokenHeight = 0.0f;
        float tokenVerticalSpacing = 0.0f;
@@ -1766,6 +1766,7 @@ _TokenEditPresenter::CalculateDescriptionTextRect(const String& descriptionText)
        _ControlOrientation orientation = __pTokenEdit->GetOrientation();
 
        GET_SHAPE_CONFIG(TOKENEDIT::TOP_MARGIN, orientation, tokenTopMargin);
+       GET_SHAPE_CONFIG(TOKENEDIT::LEFT_MARGIN, orientation, leftMargin);
        GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_HEIGHT, orientation, tokenHeight);
        GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_VERTICAL_SPACING, orientation, tokenVerticalSpacing);
        GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_LEFT_MARGIN, orientation, tokenTextLeftMargin);
@@ -1787,7 +1788,7 @@ _TokenEditPresenter::CalculateDescriptionTextRect(const String& descriptionText)
        r = __pDescriptionTextTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
        r = __pDescriptionTextTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
 
-       __descriptionTextRect.x = tokenTextLeftMargin + __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
+       __descriptionTextRect.x = leftMargin + __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
        __descriptionTextRect.y = tokenTopMargin + __pTokenEdit->GetVerticalMarginF(EDIT_TEXT_TOP_MARGIN);
        if (textSize.width > tokenTitleWidth)
        {
@@ -1951,11 +1952,11 @@ _TokenEditPresenter::TrimTokenAndAdjustEllipsisAt(int index)
 {
        result r = E_SUCCESS;
 
-       float tokenTextRightMargin = 0.0f;
+       float tokenRightMargin = 0.0f;
        float tokenMinimumSize = 0.0f;
 
        _ControlOrientation orientation = __pTokenEdit->GetOrientation();
-       GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_RIGHT_MARGIN, orientation, tokenTextRightMargin);
+       GET_SHAPE_CONFIG(TOKENEDIT::RIGHT_MARGIN, orientation, tokenRightMargin);
        GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_MIN_WIDTH, orientation, tokenMinimumSize);
 
        _Token* pToken = null;
@@ -1965,7 +1966,8 @@ _TokenEditPresenter::TrimTokenAndAdjustEllipsisAt(int index)
        FloatRectangle tokenEditBounds = __pTokenEdit->GetBoundsF();
        FloatRectangle tokenRect = pToken->displayRect;
 
-       float remainWidth = tokenEditBounds.width - tokenTextRightMargin - __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);;
+       float remainWidth = tokenEditBounds.width - tokenRightMargin - __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
+
        float dspTokenWidth = tokenRect.x + tokenRect.width;
        float dspTokenGap = dspTokenWidth - remainWidth;