, __pTimingFunction(null)
, __descriptionTextRectForScroll(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
, __previousTitleWidth(-1.0f)
- , __previousEditBounds(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
, __isTokenEditPresenterInitialized(false)
, __isFocus(false)
, __previousCursorPosition(0)
r = GET_BITMAP_CONFIG_N(TOKENEDIT::BG_PRESSED_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pTokenBgPressedEffectBitmap);
SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
- __previousEditBounds = __pTokenEdit->GetBoundsF();
-
__isTokenEditPresenterInitialized = true;
__previousCursorPosition = GetCursorPosition();
findPrevTokenLoopFlag = false;
}
- float tempTextWidth = tokenEditBounds.width - pPreviousToken->displayRect.x - pPreviousToken->displayRect.width - tokenHorizontalSpacing - __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
+ float tempTextWidth = tokenEditBounds.width - pPreviousToken->displayRect.x - pPreviousToken->displayRect.width - tokenHorizontalSpacing - tokenTextRightMargin - __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
if (tokenTextLeftMargin + pToken->GetTextPixelWidth() + tokenTextRightMargin > tempTextWidth) // Line change
{
pToken->displayRect.x = tokenTextLeftMargin + __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
__descriptionTextRect.y = __descriptionTextRectForScroll.y + __scrollValue;
}
- __pTokenEdit->Draw();
- __pTokenEdit->Show();
+ __pTokenEdit->Invalidate();
r = SetInitialBounds();
SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds.");
__descriptionTextRect.y = __descriptionTextRectForScroll.y + __scrollValue;
}
- __pTokenEdit->Draw();
- __pTokenEdit->Show();
+ __pTokenEdit->Invalidate();
}
else
{
FloatRectangle displayScrollBounds = GetDisplayScrollBoundsF();
float calcHeight = CalculateFlexibleHeightF();
- if(!_FloatCompare(editRect.height, calcHeight))
+ if (!_FloatCompare(editRect.height, calcHeight))
{
displayScrollBounds.height = calcHeight;
SetScrollBarBounds(displayScrollBounds);
{
CheckTokenScrolling();
}
- __pTokenEdit->Draw();
+ __pTokenEdit->Invalidate();
return;
}
return;
}
-float
-_TokenEditPresenter::ResizeTokenAndAdjustEllipsis(int index, float value, bool isTokenShrink)
-{
- if (isTokenShrink)
- {
- float trimValue = value;
- float extraTrimValue = 0.0f;
-
- _Token* pToken = null;
- pToken = static_cast <_Token*>(__pTokenList->GetAt(index));
- SysTryReturn(NID_UI_CTRL, pToken != null, -1.0f, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null.");
-
- float tokenMinimumSize = 0.0f;
-
- _ControlOrientation orientation = __pTokenEdit->GetOrientation();
-
- GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_MIN_WIDTH, orientation, tokenMinimumSize);
-
- if ((pToken->displayRect.width - trimValue) >= tokenMinimumSize)
- {
- pToken->displayRect.width -= trimValue;
- }
- else
- {
- extraTrimValue = (tokenMinimumSize - (pToken->displayRect.width - trimValue));
- pToken->displayRect.width = tokenMinimumSize;
- }
-
- InitializeTokenVisibilityAt(index);
-
- pToken->pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
- pToken->pTextObject->SetTextObjectEllipsisType(TEXT_OBJECT_ELLIPSIS_TYPE_TAIL);
-
- return extraTrimValue;
- }
- else
- {
- float expandValue = value;
- float extraExpandValue = 0.0f;
-
- _Token* pToken = null;
- pToken = static_cast <_Token*>(__pTokenList->GetAt(index));
- SysTryReturn(NID_UI_CTRL, pToken != null, -1.0f, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null.");
-
- float tokenTextLeftMargin = 0.0f;
- float tokenTextRightMargin = 0.0f;
-
- _ControlOrientation orientation = __pTokenEdit->GetOrientation();
-
- GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_LEFT_MARGIN, orientation, tokenTextLeftMargin);
- GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_RIGHT_MARGIN, orientation, tokenTextRightMargin);
-
- float tokenTextWidth = pToken->GetTextPixelWidth();
-
- float tokenDisplayRectWidth = _CoordinateSystemUtils::ConvertToFloat(tokenTextLeftMargin + tokenTextWidth + tokenTextRightMargin);
- if ((pToken->displayRect.width + expandValue) <= tokenDisplayRectWidth)
- {
- pToken->displayRect.width += expandValue;
- }
- else
- {
- extraExpandValue = ((pToken->displayRect.width + expandValue) - tokenDisplayRectWidth);
- pToken->displayRect.width = tokenDisplayRectWidth;
- }
-
- InitializeTokenVisibilityAt(index);
-
- pToken->pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
- pToken->pTextObject->SetTextObjectEllipsisType(TEXT_OBJECT_ELLIPSIS_TYPE_TAIL);
-
- return extraExpandValue;
- }
-
- return -1;
-}
-
-int
-_TokenEditPresenter::PickToken(int index, FloatRectangle tokenDispRect, bool isTokenShrink)
-{
- int tokenCount = __pTokenList->GetCount();
-
- float tokenMinimumSize = 0.0f;
- float tokenTextLeftMargin = 0.0f;
- float tokenTextRightMargin = 0.0f;
-
- _ControlOrientation orientation = __pTokenEdit->GetOrientation();
-
- GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_MIN_WIDTH, orientation, tokenMinimumSize);
- GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_LEFT_MARGIN, orientation, tokenTextLeftMargin);
- GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_RIGHT_MARGIN, orientation, tokenTextRightMargin);
-
- if (isTokenShrink)
- {
- if (index < tokenCount)
- {
- for (int i = index; i >= 0; i--)
- {
- _Token* pToken = null;
- pToken = static_cast <_Token*>(__pTokenList->GetAt(i));
- SysTryReturn(NID_UI_CTRL, pToken != null, -1, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null.");
-
- FloatRectangle tokenRect = pToken->displayRect;
- if (_FloatCompare(tokenDispRect.y, tokenRect.y))
- {
- float tokenMinSize = _CoordinateSystemUtils::ConvertToFloat(tokenMinimumSize);
- if (tokenRect.width > tokenMinSize)
- {
- return i;
- }
- }
- }
- }
- }
- else
- {
- for (int i = index; i < tokenCount; i++)
- {
- _Token* pToken = null;
- pToken = static_cast <_Token*>(__pTokenList->GetAt(i));
- SysTryReturn(NID_UI_CTRL, pToken != null, -1, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null.");
-
- FloatRectangle tokenRect = pToken->displayRect;
- if (_FloatCompare(tokenDispRect.y, tokenRect.y))
- {
- float tokenTextWidth = pToken->GetTextPixelWidth();
- float currentTokenWidth = _CoordinateSystemUtils::ConvertToFloat(tokenTextLeftMargin + tokenTextWidth + tokenTextRightMargin);
-
- if (tokenRect.width < currentTokenWidth)
- {
- return i;
- }
- }
- }
- }
-
- return -1;
-}
-
-void
-_TokenEditPresenter::RepositionToken(int currentTokenIndex, float moveDistance, bool isTokenShrink)
-{
- int tokenCount = __pTokenList->GetCount();
-
- _Token* pCurrentToken = null;
- pCurrentToken = static_cast <_Token*>(__pTokenList->GetAt(currentTokenIndex));
- SysTryReturnVoidResult(NID_UI_CTRL, pCurrentToken != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null.");
-
- FloatRectangle currentTokenRect = pCurrentToken->displayRect;
-
- if (currentTokenIndex < (tokenCount - 1))
- {
- for (int i = currentTokenIndex + 1; i < tokenCount; i++)
- {
- _Token* pToken = null;
- pToken = static_cast <_Token*>(__pTokenList->GetAt(i));
- SysTryReturnVoidResult(NID_UI_CTRL, pToken != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null.");
-
- if (pToken)
- {
- FloatRectangle tokenRect = pToken->displayRect;
- if (_FloatCompare(currentTokenRect.y, tokenRect.y))
- {
- if (isTokenShrink)
- {
- pToken->displayRect.x -= moveDistance;
- }
- else
- {
- pToken->displayRect.x += moveDistance;
- }
-
- InitializeTokenVisibilityAt(i);
- }
- else
- {
- break;
- }
- }
- }
- }
-
- return;
-}
-
-void
-_TokenEditPresenter::ShrinkTokens()
-{
- float tokenTextRightMargin = 0.0f;
-
- _ControlOrientation orientation = __pTokenEdit->GetOrientation();
- GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_RIGHT_MARGIN, orientation, tokenTextRightMargin);
-
- int tokenCount = __pTokenList->GetCount();
- FloatRectangle currentEditBounds = __pTokenEdit->GetBoundsF();
-
- for (int i = 0; i < tokenCount; i++)
- {
- bool isTokenPicked = false;
- _Token* pToken = null;
- _Token* pNextToken = null;
-
- pToken = static_cast <_Token*>(__pTokenList->GetAt(i));
- SysTryReturnVoidResult(NID_UI_CTRL, pToken != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null.");
-
- FloatRectangle tokenRect = pToken->displayRect;
-
- FloatRectangle nextTokenRect;
- if (i < tokenCount - 1)
- {
- pNextToken = static_cast <_Token*>(__pTokenList->GetAt(i + 1));
- SysTryReturnVoidResult(NID_UI_CTRL, pNextToken != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null.");
-
- nextTokenRect = pNextToken->displayRect;
- }
-
- if (pNextToken)
- {
- if (nextTokenRect.y > tokenRect.y)
- {
- isTokenPicked = true;
- }
- }
- else
- {
- isTokenPicked = true;
- }
-
- //"pToken" (isTokenPicked = true) is the last token in a row
- if (isTokenPicked == false)
- {
- continue;
- }
-
- float tokenEndPoint = tokenRect.x + tokenRect.width + tokenTextRightMargin + __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
- if (tokenEndPoint <= currentEditBounds.width)
- {
- continue;
- }
-
- //Trimming Token required
- float trimValue = tokenEndPoint - currentEditBounds.width;
-
- while (trimValue > 0.0f)
- {
- int tokenIndex = PickToken(i, tokenRect, true);
- if (tokenIndex >= 0)
- {
- float extraTrimValue = ResizeTokenAndAdjustEllipsis(tokenIndex, trimValue, true);
- if (extraTrimValue < 0.0f)
- {
- SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null.");
- break;
- }
-
- if ((trimValue - extraTrimValue) > 0.0f)
- {
- RepositionToken(tokenIndex, (trimValue - extraTrimValue), true);
- }
-
- trimValue = extraTrimValue;
- }
- else
- {
- break;
- }
- }
- }
-
- return;
-}
-
-float
-_TokenEditPresenter::GetPickedTokenEndPoint(int index, Tizen::Graphics::FloatRectangle tokenDispRect)
-{
- float tokenTextRightMargin = 0.0f;
- float endValue = 0.0f;
-
- _ControlOrientation orientation = __pTokenEdit->GetOrientation();
- GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_RIGHT_MARGIN, orientation, tokenTextRightMargin);
-
- float marginValue = tokenTextRightMargin + __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);;
-
- FloatRectangle lastTokenRect(0.0f, 0.0f, 0.0f, 0.0f);
-
- int tokenCount = __pTokenList->GetCount();
- for (int i = index; i < tokenCount; i++)
- {
- _Token* pToken = null;
- pToken = static_cast <_Token*>(__pTokenList->GetAt(i));
- SysTryReturn(NID_UI_CTRL, pToken != null, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null.");
-
- FloatRectangle tokenRect = pToken->displayRect;
- if (_FloatCompare(tokenDispRect.y, tokenRect.y))
- {
- lastTokenRect = tokenRect;
- }
- else
- {
- break;
- }
- }
-
- endValue = marginValue + lastTokenRect.x + lastTokenRect.width;
-
- return endValue;
-}
-
-void
-_TokenEditPresenter::ExpandTokens()
-{
- int tokenCount = __pTokenList->GetCount();
- FloatRectangle currentEditBounds = __pTokenEdit->GetBoundsF();
-
- for (int i = tokenCount - 1; i >= 0; i--)
- {
- bool isTokenPicked = false;
- _Token* pToken = null;
- _Token* pPrevToken = null;
-
- pToken = static_cast <_Token*>(__pTokenList->GetAt(i));
- SysTryReturnVoidResult(NID_UI_CTRL, pToken != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null.");
-
- FloatRectangle tokenRect = pToken->displayRect;
-
- FloatRectangle prevTokenRect;
- if (i > 0)
- {
- pPrevToken = static_cast <_Token*>(__pTokenList->GetAt(i - 1));
- SysTryReturnVoidResult(NID_UI_CTRL, pPrevToken != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null.");
-
- prevTokenRect = pPrevToken->displayRect;
- }
-
- if (pPrevToken)
- {
- if (prevTokenRect.y < tokenRect.y)
- {
- isTokenPicked = true;
- }
- }
- else
- {
- isTokenPicked = true;
- }
-
- //"pToken" (isTokenPicked = true) is the first token in a row
- if (isTokenPicked == false)
- {
- continue;
- }
-
- float tokenEndPoint = GetPickedTokenEndPoint(i, tokenRect);;
-
- if ((_FloatCompare(tokenEndPoint, 0.0f)) || (tokenEndPoint >= currentEditBounds.width))
- {
- continue;
- }
-
- //Expanding Token required
- float expandValue = currentEditBounds.width - tokenEndPoint;
-
- while (expandValue > 0.0f)
- {
- int tokenIndex = PickToken(i, tokenRect, false);
- if (tokenIndex >= 0)
- {
- float extraExpandValue = ResizeTokenAndAdjustEllipsis(tokenIndex, expandValue, false);
- if (extraExpandValue < 0.0f)
- {
- SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null.");
- break;
- }
-
- if ((expandValue - extraExpandValue) > 0.0f)
- {
- RepositionToken(tokenIndex, (expandValue - extraExpandValue), false);
- }
-
- expandValue = extraExpandValue;
- }
- else
- {
- break;
- }
- }
- }
-
- return;
-}
-
-void
-_TokenEditPresenter::OnBoundsChanged(void)
-{
- if (!__isTokenEditPresenterInitialized)
- {
- return;
- }
-
- int tokenCount = __pTokenList->GetCount();
- SysTryReturnVoidResult(NID_UI_CTRL, tokenCount > 0, E_SUCCESS, "No Tokens available.");
-
- FloatRectangle tokenEditBounds = __pTokenEdit->GetBoundsF();
-
- if (tokenEditBounds.width < __previousEditBounds.width)
- {
- ShrinkTokens();
- }
- else if (tokenEditBounds.width > __previousEditBounds.width)
- {
- ExpandTokens();
- }
-
- __previousEditBounds = tokenEditBounds;
-
- return;
-}
-
void
_TokenEditPresenter::OnTimerExpired(Timer& timer)
{
return r;
}
+void
+_TokenEditPresenter::OnBoundsChanged(void)
+{
+ if (!__isTokenEditPresenterInitialized)
+ {
+ return;
+ }
+
+ _ControlOrientation orientation = __pTokenEdit->GetOrientation();
+ FloatRectangle tokenEditBounds = __pTokenEdit->GetBoundsF();
+
+ if (IsUpdateInitialBounds())
+ {
+ SetControlInitialBounds(tokenEditBounds);
+ }
+ ChangeInternalLayout(orientation);
+
+ return;
+}
+
}}} //Tizen::Ui::Controls