From a247090ccb70e932774e1942f2ae9f6b3ebf649d Mon Sep 17 00:00:00 2001 From: Sudha Date: Wed, 29 May 2013 18:18:39 +0530 Subject: [PATCH] Apply EEA token accessibility changes Change-Id: Id3ed0d39440d210efb0dc97917f69f899ed7d977 Signed-off-by: Sudha --- src/ui/controls/FUiCtrl_Edit.cpp | 285 ++++++----- src/ui/controls/FUiCtrl_EditPresenter.cpp | 2 + src/ui/controls/FUiCtrl_TokenEdit.cpp | 265 ++++++++-- src/ui/controls/FUiCtrl_TokenEditPresenter.cpp | 667 +++++++++++++++++++------ src/ui/inc/FUiCtrl_Edit.h | 11 +- src/ui/inc/FUiCtrl_TokenEdit.h | 29 +- src/ui/inc/FUiCtrl_TokenEditPresenter.h | 33 +- 7 files changed, 955 insertions(+), 337 deletions(-) diff --git a/src/ui/controls/FUiCtrl_Edit.cpp b/src/ui/controls/FUiCtrl_Edit.cpp index 20e4801..05c2f54 100644 --- a/src/ui/controls/FUiCtrl_Edit.cpp +++ b/src/ui/controls/FUiCtrl_Edit.cpp @@ -107,7 +107,7 @@ private: _EditInternalTouchEventListener::_EditInternalTouchEventListener(const _Edit& edit) { - __pEdit = const_cast<_Edit*>(&edit); + __pEdit = const_cast< _Edit* >(&edit); } bool @@ -280,10 +280,10 @@ _Edit::~_Edit(void) } if (__pDefaultBackgroundBitmap[status]) - { + { delete __pDefaultBackgroundBitmap[status]; __pDefaultBackgroundBitmap[status] = null; - } + } } if (__pDefaultBackgroundEffectBitmap) @@ -330,7 +330,7 @@ _Edit::~_Edit(void) if (__pGestureFlick) { - _ITouchFlickGestureEventListener* pListener = dynamic_cast<_ITouchFlickGestureEventListener*>(this); + _ITouchFlickGestureEventListener* pListener = dynamic_cast< _ITouchFlickGestureEventListener* >(this); __pGestureFlick->RemoveGestureListener(*pListener); RemoveGestureDetector(*__pGestureFlick); delete __pGestureFlick; @@ -339,7 +339,7 @@ _Edit::~_Edit(void) if (__pGestureLongPress) { - _ITouchLongPressGestureEventListener* pListener = dynamic_cast<_ITouchLongPressGestureEventListener*>(this); + _ITouchLongPressGestureEventListener* pListener = dynamic_cast< _ITouchLongPressGestureEventListener* >(this); __pGestureLongPress->RemoveGestureListener(*pListener); RemoveGestureDetector(*__pGestureLongPress); delete __pGestureLongPress; @@ -348,7 +348,7 @@ _Edit::~_Edit(void) if (__pGestureTap) { - _ITouchTapGestureEventListener* pListener = dynamic_cast<_ITouchTapGestureEventListener*>(this); + _ITouchTapGestureEventListener* pListener = dynamic_cast< _ITouchTapGestureEventListener* >(this); __pGestureTap->RemoveGestureListener(*pListener); RemoveGestureDetector(*__pGestureTap); delete __pGestureTap; @@ -498,23 +498,15 @@ _Edit::Initialize(int editStyle, InputStyle inputStyle, int limitLength, GroupSt __isConstructed = true; _AccessibilityContainer* pEditAccessibilityContainer = GetAccessibilityContainer(); - if(pEditAccessibilityContainer) + if (pEditAccessibilityContainer) { pEditAccessibilityContainer->Activate(true); } if (pEditAccessibilityContainer) { __pTextAccessibilityElement = new _AccessibilityElement(true); - __pTextAccessibilityElement->SetBounds(FloatRectangle(0.0f,0.0f, GetBoundsF().width, GetBoundsF().height)); - if ((GetEditStyle() & EDIT_STYLE_TITLE_TOP) || (GetEditStyle() & EDIT_STYLE_TITLE_LEFT)) - { - __pTextAccessibilityElement->SetLabel(GetTitleText() + GetGuideText() + GetText()); - } - else - { - __pTextAccessibilityElement->SetLabel(GetGuideText() + GetText()); - } - + __pTextAccessibilityElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height)); + __pTextAccessibilityElement->SetLabel(GetTitleText() + GetGuideText() + GetText()); __pTextAccessibilityElement->SetTrait(L"Edit Field"); __pTextAccessibilityElement->SetName(L"EditText"); pEditAccessibilityContainer->AddElement(*__pTextAccessibilityElement); @@ -574,7 +566,7 @@ _Edit::SetPresenter(const _EditPresenter& pPresenter) { result r = E_SUCCESS; - _pEditPresenter = const_cast<_EditPresenter*>(&pPresenter); + _pEditPresenter = const_cast< _EditPresenter* >(&pPresenter); return r; } @@ -593,7 +585,7 @@ _Edit::GetContentSizeInternalF(bool horizontalMode, bool verticalMode) const return FloatDimension(GetBoundsF().width, GetBoundsF().height); } - FloatDimension dimension(0.0f,0.0f); + FloatDimension dimension(0.0f, 0.0f); float textLeftMargin = 0.0f; float textRightMargin = 0.0f; float textTopMargin = 0.0f; @@ -706,7 +698,7 @@ _Edit::GetContentSizeInternalF(bool horizontalMode, bool verticalMode) const dimension.height += textTopMargin + textBottomMargin; } - return dimension; + return dimension; } bool @@ -912,7 +904,7 @@ result _Edit::SetVerticalMargin(int margin, EditTextVerticalMargin marginType) { float floatMargin = _CoordinateSystemUtils::ConvertToFloat(margin); - return SetVerticalMargin( floatMargin, marginType); + return SetVerticalMargin(floatMargin, marginType); } result @@ -984,14 +976,14 @@ _Edit::GetKeypadAction(void) const { Variant var = GetProperty("keypadAction"); - return (CoreKeypadAction)var.ToInt(); + return (CoreKeypadAction) var.ToInt(); } result _Edit::SetKeypadAction(CoreKeypadAction keypadAction) { SysTryReturn(NID_UI_CTRL, (__inputStyle == INPUT_STYLE_OVERLAY), E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The current state unable to this operation."); - Variant var((int)keypadAction); + Variant var((int) keypadAction); return SetProperty("keypadAction", var); } @@ -1017,14 +1009,14 @@ _Edit::GetKeypadStyle(void) const { Variant var = GetProperty("keypadStyle"); - return (KeypadStyle)var.ToInt(); + return (KeypadStyle) var.ToInt(); } result _Edit::SetKeypadStyle(KeypadStyle keypadStyle) { SysTryReturn(NID_UI_CTRL, (KEYPAD_STYLE_PASSWORD != keypadStyle), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given."); - Variant var((int)keypadStyle); + Variant var((int) keypadStyle); return SetProperty("keypadStyle", var); } @@ -1086,30 +1078,32 @@ _Edit::UpdateAccessibilityElement(EditAccessibilityElementType type) } } - switch(type) + switch (type) { - case EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT: - if (__pTextAccessibilityElement) + case EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT: + if (__pTextAccessibilityElement) + { + __pTextAccessibilityElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height)); + if ((GetEditStyle() & EDIT_STYLE_TITLE_TOP) || (GetEditStyle() & EDIT_STYLE_TITLE_LEFT)) { - __pTextAccessibilityElement->SetBounds(FloatRectangle(0.0f,0.0f, GetBoundsF().width, GetBoundsF().height)); - if ((GetEditStyle() & EDIT_STYLE_TITLE_TOP) || (GetEditStyle() & EDIT_STYLE_TITLE_LEFT)) - { - __pTextAccessibilityElement->SetLabel(GetTitleText() + GetGuideText() + GetText()); - } - else - { - __pTextAccessibilityElement->SetLabel(GetGuideText() + GetText()); - } + __pTextAccessibilityElement->SetLabel(GetTitleText() + GetGuideText() + GetText()); } - break; - case EDIT_ACCESSIBILITY_ELEMENT_TYPE_CLEAR_ICON: - if (__pClearButtonTextAccessibilityElement) + else { - __pClearButtonTextAccessibilityElement->SetBounds(_pEditPresenter->GetClearIconBoundsF()); + __pTextAccessibilityElement->SetLabel(GetGuideText() + GetText()); } - break; - default: - break; + } + break; + + case EDIT_ACCESSIBILITY_ELEMENT_TYPE_CLEAR_ICON: + if (__pClearButtonTextAccessibilityElement) + { + __pClearButtonTextAccessibilityElement->SetBounds(_pEditPresenter->GetClearIconBoundsF()); + } + break; + + default: + break; } return; @@ -1201,17 +1195,17 @@ _Edit::GetTextColor(EditTextColor type) const { case EDIT_TEXT_COLOR_NORMAL: variantColor = GetProperty("normalTextColor"); - color = variantColor.ToColor(); + color = variantColor.ToColor(); break; case EDIT_TEXT_COLOR_DISABLED: variantColor = GetProperty("disabledTextColor"); - color = variantColor.ToColor(); + color = variantColor.ToColor(); break; case EDIT_TEXT_COLOR_HIGHLIGHTED: variantColor = GetProperty("highlightedTextColor"); - color = variantColor.ToColor(); + color = variantColor.ToColor(); break; case EDIT_TEXT_COLOR_LINK: @@ -1315,20 +1309,20 @@ _Edit::SetTextColor(EditTextColor type, const Color& color) switch (type) { case EDIT_TEXT_COLOR_NORMAL: - r = SetProperty("normalTextColor", Variant(color)); + r = SetProperty("normalTextColor", Variant(color)); SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] System error occurred.", GetErrorMessage(r)); break; case EDIT_TEXT_COLOR_DISABLED: - r = SetProperty("disabledTextColor", Variant(color)); + r = SetProperty("disabledTextColor", Variant(color)); SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] System error occurred.", GetErrorMessage(r)); break; case EDIT_TEXT_COLOR_HIGHLIGHTED: - r = SetProperty("highlightedTextColor", Variant(color)); + r = SetProperty("highlightedTextColor", Variant(color)); SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] System error occurred.", GetErrorMessage(r)); - r = SetProperty("pressedTextColor", Variant(color)); + r = SetProperty("pressedTextColor", Variant(color)); SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] System error occurred.", GetErrorMessage(r)); break; @@ -1475,7 +1469,7 @@ _Edit::AddScrollPanelEventListener(const _IScrollPanelEventListener& listener) { __pScrollPanelEvent = _ScrollPanelEvent::CreateScrollPanelEventN(*this); SysTryReturn(NID_UI_CTRL, __pScrollPanelEvent, - E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); } } @@ -2024,7 +2018,7 @@ _Edit::OnAttachedToMainTree(void) if (__pTextAccessibilityElement) { - __pTextAccessibilityElement->SetBounds(FloatRectangle(0.0f,0.0f, GetBoundsF().width, GetBoundsF().height)); + __pTextAccessibilityElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height)); } if (__pClearButtonTextAccessibilityElement) { @@ -2064,11 +2058,11 @@ _Edit::OnBoundsChanged(void) _pEditPresenter->Resize(); - if(__isAccessibilityCreated) + if (__isAccessibilityCreated) { if (__pTextAccessibilityElement) { - __pTextAccessibilityElement->SetBounds(FloatRectangle(0.0f,0.0f, GetBoundsF().width, GetBoundsF().height)); + __pTextAccessibilityElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height)); } if (__pClearButtonTextAccessibilityElement) @@ -2255,80 +2249,85 @@ _Edit::LoadDefaultBackgroundBitmap(GroupStyle groupStyle) { result r = E_SUCCESS; - switch(groupStyle) - { - case GROUP_STYLE_NONE: - r = GET_BITMAP_CONFIG_N(EDIT::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_DISABLED]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_HIGHLIGHTED]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_PRESSED]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - break; - case GROUP_STYLE_SINGLE: - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_SINGLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_SINGLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_DISABLED]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_SINGLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_HIGHLIGHTED]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_SINGLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_PRESSED]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_SINGLE_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - break; - case GROUP_STYLE_TOP: - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_TOP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_TOP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_DISABLED]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_TOP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_HIGHLIGHTED]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_TOP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_PRESSED]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_TOP_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - break; - case GROUP_STYLE_MIDDLE: - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_MIDDLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_MIDDLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_DISABLED]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_MIDDLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_HIGHLIGHTED]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_MIDDLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_PRESSED]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_MIDDLE_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - break; - case GROUP_STYLE_BOTTOM: - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_BOTTOM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_BOTTOM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_DISABLED]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_BOTTOM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_HIGHLIGHTED]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_BOTTOM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_PRESSED]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_BOTTOM_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - break; - default: - r = GET_BITMAP_CONFIG_N(EDIT::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_DISABLED]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_HIGHLIGHTED]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_PRESSED]); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - r = GET_BITMAP_CONFIG_N(EDIT::BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); - break; + switch (groupStyle) + { + case GROUP_STYLE_NONE: + r = GET_BITMAP_CONFIG_N(EDIT::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_DISABLED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_HIGHLIGHTED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_PRESSED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + break; + + case GROUP_STYLE_SINGLE: + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_SINGLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_SINGLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_DISABLED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_SINGLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_HIGHLIGHTED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_SINGLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_PRESSED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_SINGLE_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + break; + + case GROUP_STYLE_TOP: + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_TOP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_TOP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_DISABLED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_TOP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_HIGHLIGHTED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_TOP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_PRESSED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_TOP_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + break; + + case GROUP_STYLE_MIDDLE: + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_MIDDLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_MIDDLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_DISABLED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_MIDDLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_HIGHLIGHTED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_MIDDLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_PRESSED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_MIDDLE_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + break; + + case GROUP_STYLE_BOTTOM: + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_BOTTOM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_BOTTOM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_DISABLED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_BOTTOM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_HIGHLIGHTED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_BOTTOM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_PRESSED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::GROUPED_BOTTOM_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + break; + + default: + r = GET_BITMAP_CONFIG_N(EDIT::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_DISABLED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_HIGHLIGHTED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_PRESSED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + break; } return r; @@ -2431,15 +2430,19 @@ _Edit::IsCustomDefaultBackgroundBitmap(EditStatus status) const case EDIT_STATUS_NORMAL: isCustomBitmap = IS_CUSTOM_BITMAP(EDIT::BG_NORMAL); break; + case EDIT_STATUS_DISABLED: isCustomBitmap = IS_CUSTOM_BITMAP(EDIT::BG_DISABLED); break; + case EDIT_STATUS_HIGHLIGHTED: isCustomBitmap = IS_CUSTOM_BITMAP(EDIT::BG_HIGHLIGHTED); break; + case EDIT_STATUS_PRESSED: isCustomBitmap = IS_CUSTOM_BITMAP(EDIT::BG_PRESSED); break; + default: isCustomBitmap = false; break; @@ -2730,7 +2733,7 @@ _Edit::SendLanguageEvent(LanguageCode prevLanguageCode, LanguageCode currentLang result _Edit::AttachScrollPanelEvent(void) { - _ScrollPanel* pScrollPanelCore = dynamic_cast<_ScrollPanel*>(GetParent()); + _ScrollPanel* pScrollPanelCore = dynamic_cast< _ScrollPanel* >(GetParent()); if (pScrollPanelCore) { if (__pScrollPanelEvent) @@ -2746,7 +2749,7 @@ _Edit::AttachScrollPanelEvent(void) result _Edit::DetachScrollPanelEvent(void) { - _ScrollPanel* pScrollPanelCore = dynamic_cast<_ScrollPanel*>(GetParent()); + _ScrollPanel* pScrollPanelCore = dynamic_cast< _ScrollPanel* >(GetParent()); if (pScrollPanelCore) { if (__pScrollPanelEvent && (pScrollPanelCore->GetScrollPanelEvent() == __pScrollPanelEvent)) @@ -2929,7 +2932,7 @@ _Edit::SetPropertyKeypadAction(const Variant& action) result r = E_SUCCESS; - r = _pEditPresenter->SetKeypadAction((CoreKeypadAction)action.ToInt()); + r = _pEditPresenter->SetKeypadAction((CoreKeypadAction) action.ToInt()); return r; } @@ -2937,7 +2940,7 @@ _Edit::SetPropertyKeypadAction(const Variant& action) Variant _Edit::GetPropertyKeypadAction(void) const { - return Variant((int)_pEditPresenter->GetKeypadAction()); + return Variant((int) _pEditPresenter->GetKeypadAction()); } result @@ -3081,16 +3084,16 @@ _Edit::SetPropertyKeypadStyle(const Variant& style) { if (!(GetEditStyle() & EDIT_STYLE_SINGLE_LINE)) { - SysTryReturn(NID_UI_CTRL, (KEYPAD_STYLE_PASSWORD != (KeypadStyle)style.ToInt()), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given."); + SysTryReturn(NID_UI_CTRL, (KEYPAD_STYLE_PASSWORD != (KeypadStyle) style.ToInt()), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given."); } - return _pEditPresenter->SetKeypadStyle((KeypadStyle)style.ToInt()); + return _pEditPresenter->SetKeypadStyle((KeypadStyle) style.ToInt()); } Variant _Edit::GetPropertyKeypadStyle(void) const { - return Variant((int)_pEditPresenter->GetKeypadStyle()); + return Variant((int) _pEditPresenter->GetKeypadStyle()); } result @@ -3154,7 +3157,7 @@ _Edit::SetPropertyAutoLinkMask(const Variant& autoLinks) Variant _Edit::GetPropertyAutoLinkMask(void) const { - SysTryReturn(NID_UI_CTRL, (__inputStyle == INPUT_STYLE_OVERLAY), Variant((unsigned long)LINK_TYPE_NONE), E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The current state unable to this operation."); + SysTryReturn(NID_UI_CTRL, (__inputStyle == INPUT_STYLE_OVERLAY), Variant((unsigned long) LINK_TYPE_NONE), E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The current state unable to this operation."); return Variant(_pEditPresenter->GetAutoLinkMask()); } @@ -3328,7 +3331,7 @@ _Edit::SetEditTextFilter(IEditTextFilter* pFilter) } void -_Edit::SendOpaqueCommand (const String& command) +_Edit::SendOpaqueCommand(const String& command) { _pEditPresenter->SendOpaqueCommand(command); @@ -3345,4 +3348,10 @@ _Edit::OnSettingChanged(String& key) } } +_AccessibilityElement* +_Edit::GetTextAccessibilityElement(void) const +{ + return __pTextAccessibilityElement; +} + }}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_EditPresenter.cpp b/src/ui/controls/FUiCtrl_EditPresenter.cpp index 6ab659a..0cb12ae 100644 --- a/src/ui/controls/FUiCtrl_EditPresenter.cpp +++ b/src/ui/controls/FUiCtrl_EditPresenter.cpp @@ -7793,6 +7793,8 @@ _EditPresenter::SetGuideText(const String& guideText) __pGuideTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); } + __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT); + return r; } diff --git a/src/ui/controls/FUiCtrl_TokenEdit.cpp b/src/ui/controls/FUiCtrl_TokenEdit.cpp index c7c60a5..a56de92 100644 --- a/src/ui/controls/FUiCtrl_TokenEdit.cpp +++ b/src/ui/controls/FUiCtrl_TokenEdit.cpp @@ -40,9 +40,8 @@ _TokenEdit::_TokenEdit(void) , __pTokenEditPresenter(null) , __isSelectedTokenTextColorSet(false) , __pTokenFilter(null) - , __pDescriptionTextAccessibilityElement(null) - , __pHiddenTokenCountAccessibilityElement(null) - , __pExpandableButtonAccessibilityElement(null) + , __pTitleTextAccessibilityElement(null) + , __pCursorAccessibilityElement(null) { GET_COLOR_CONFIG(TOKENEDIT::BG_NORMAL, __tokenColor[EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL]); GET_COLOR_CONFIG(TOKENEDIT::BG_SELECTED, __tokenColor[EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED]); @@ -111,7 +110,7 @@ _TokenEdit::SetTokenFilter(const _ITokenFilter* pFilter) { result r = E_SUCCESS; - __pTokenFilter = const_cast <_ITokenFilter*>(pFilter); + __pTokenFilter = const_cast< _ITokenFilter* >(pFilter); return r; } @@ -215,15 +214,15 @@ _TokenEdit::GetTokenColor(ExpandableEditAreaTokenStatus status) const switch (status) { - case EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL : + case EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL: var = GetProperty("normalTokenColor"); break; - case EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED : + case EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED: var = GetProperty("selectedTokenColor"); break; - default : + default: break; } @@ -246,15 +245,15 @@ _TokenEdit::SetTokenColor(ExpandableEditAreaTokenStatus status, const Color& col switch (status) { - case EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL : + case EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL: r = SetProperty("normalTokenColor", var); break; - case EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED : + case EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED: r = SetProperty("selectedTokenColor", var); break; - default : + default: break; } @@ -294,13 +293,13 @@ _TokenEdit::SetTitleText(const String& title) __pTokenEditPresenter->SetDescriptionText(title); r = __pTokenEditPresenter->CalculateDescriptionTextRect(title); - SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); r = __pTokenEditPresenter->CalculateTokenPositionFromIndex(0); - SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); r = __pTokenEditPresenter->SetInitialBounds(); - SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); Invalidate(true); return r; @@ -426,8 +425,10 @@ _TokenEdit::SetPropertyTokenTextColor(const Variant& color) ClearLastResult(); __tokenTextColor[EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL] = color.ToColor(); - if(!__isSelectedTokenTextColorSet) + if (!__isSelectedTokenTextColorSet) + { __tokenTextColor[EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED] = color.ToColor(); + } return E_SUCCESS; } @@ -460,7 +461,6 @@ _TokenEdit::GetPropertySelectedTokenTextColor(void) const return Variant(__tokenTextColor[EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED]); } - result _TokenEdit::SetPropertyTokenEditModeEnabled(const Variant& enable) { @@ -490,51 +490,234 @@ _TokenEdit::OnAttachedToMainTree(void) pContainer = GetAccessibilityContainer(); if (pContainer) { - if (__pDescriptionTextAccessibilityElement) + if (__pTitleTextAccessibilityElement) { return E_SUCCESS; } + pContainer->AddListener(*this); + UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT); + } - if (GetEditStyle() & EDIT_STYLE_TITLE_LEFT) - { - __pDescriptionTextAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); - if (__pDescriptionTextAccessibilityElement) - { - __pDescriptionTextAccessibilityElement->SetTrait(L"Edit field"); - pContainer->AddElement(*__pDescriptionTextAccessibilityElement); - } - } + return E_SUCCESS; +} + +void +_TokenEdit::OnBoundsChanged(void) +{ + SysAssertf(__pTokenEditPresenter != null, "_TokenEditPresenter instance is null"); + + __pTokenEditPresenter->OnBoundsChanged(); + + return; +} + +bool +_TokenEdit::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_TokenEdit::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_TokenEdit::OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_TokenEdit::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_TokenEdit::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return __pTokenEditPresenter->OnAccessibilityFocusIn(control, element); +} + +bool +_TokenEdit::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return __pTokenEditPresenter->OnAccessibilityFocusOut(control, element); +} + +bool +_TokenEdit::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_TokenEdit::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_TokenEdit::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} - if (IsAutoShrinkModeEnabled()) +void +_TokenEdit::UpdateAccessibilityElement(EditAccessibilityElementType type) +{ + _AccessibilityElement* pTextAccessibilityElement = _Edit::GetTextAccessibilityElement(); + String spaceString(L" "); + switch (type) + { + case EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT: + if (pTextAccessibilityElement) { - __pHiddenTokenCountAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); - if (__pHiddenTokenCountAccessibilityElement) + pTextAccessibilityElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height)); + if (GetTokenCount()) { - __pHiddenTokenCountAccessibilityElement->SetTrait(L"Edit field"); - pContainer->AddElement(*__pHiddenTokenCountAccessibilityElement); + pTextAccessibilityElement->SetLabel(GetTitleText() + spaceString + __pTokenEditPresenter->GetTextAccessibilityElementText()); } - - __pExpandableButtonAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); - if (__pExpandableButtonAccessibilityElement) + else { - __pExpandableButtonAccessibilityElement->SetTrait(L"EXPAND BUTTON"); - pContainer->AddElement(*__pExpandableButtonAccessibilityElement); + pTextAccessibilityElement->SetLabel(GetTitleText() + spaceString + GetGuideText() + GetText()); } + pTextAccessibilityElement->SetHint(L"double tap to edit"); } + break; + + default: + break; } + return; +} + +_AccessibilityElement* +_TokenEdit::GetTitleTextAccessibilityElement(void) const +{ + return __pTitleTextAccessibilityElement; +} + +_AccessibilityElement* +_TokenEdit::GetCursorAccessibilityElement(void) const +{ + return __pCursorAccessibilityElement; +} + +result +_TokenEdit::AddTitleAccessibilityElement(void) +{ + result r = E_SUCCESS; + + if (!(GetEditStyle() & EDIT_STYLE_TITLE_LEFT)) + { + return r; + } + + if (__pTitleTextAccessibilityElement) + { + return r; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + + if (pContainer) + { + _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + String labelText = GetTitleText(); + pAccessibilityElement->SetBounds(__pTokenEditPresenter->GetDescriptionTextRect()); + pAccessibilityElement->SetLabel(labelText); + pContainer->AddElement(*pAccessibilityElement); + __pTitleTextAccessibilityElement = pAccessibilityElement; + } + + return r; +} + +result +_TokenEdit::AddCursorAccessibilityElement(void) +{ + result r = E_SUCCESS; + + if (__pCursorAccessibilityElement) + { + return r; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + + if (pContainer) + { + _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + if (GetTextLength()) + { + pAccessibilityElement->SetLabel(GetText()); + } + else + { + pAccessibilityElement->SetTrait(L"Edit field"); + } + + pContainer->AddElement(*pAccessibilityElement); + + __pCursorAccessibilityElement = pAccessibilityElement; + + SetCursorAccessibilityBounds(__pTokenEditPresenter->GetTextBoundsF()); + } + + return r; +} + +result +_TokenEdit::SetCursorAccessibilityBounds(const FloatRectangle& cursorBounds) +{ + if (!__pCursorAccessibilityElement) + { + return E_SUCCESS; + } + + if (IsInternalFocused()) // Set cursor as global focus accessibility element only in focused mode. + { + _AccessibilityManager::GetInstance()->SetGlobalFocusedElement(*__pCursorAccessibilityElement); + } + __pCursorAccessibilityElement->SetBounds(cursorBounds); + return E_SUCCESS; } void -_TokenEdit::OnBoundsChanged(void) +_TokenEdit::RemoveTitleAccessibilityElement(void) { - SysAssertf(__pTokenEditPresenter != null, "_TokenEditPresenter instance is null"); - - __pTokenEditPresenter->OnBoundsChanged(); + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer) + { + if (__pTitleTextAccessibilityElement) + { + pContainer->RemoveElement(*__pTitleTextAccessibilityElement); + __pTitleTextAccessibilityElement = null; + } + } +} - return; +void +_TokenEdit::RemoveCursorAccessibilityElement(void) +{ + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer) + { + if (__pCursorAccessibilityElement) + { + pContainer->RemoveElement(*__pCursorAccessibilityElement); + __pCursorAccessibilityElement = null; + } + } } }}} //Tizen::Ui::Controls - diff --git a/src/ui/controls/FUiCtrl_TokenEditPresenter.cpp b/src/ui/controls/FUiCtrl_TokenEditPresenter.cpp index 8cdfe6c..c019407 100644 --- a/src/ui/controls/FUiCtrl_TokenEditPresenter.cpp +++ b/src/ui/controls/FUiCtrl_TokenEditPresenter.cpp @@ -29,6 +29,8 @@ #include "FUiCtrl_Scroll.h" #include "FUi_Math.h" #include "FUi_CoordinateSystemUtils.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" using namespace Tizen::Base; using namespace Tizen::Base::Runtime; @@ -45,8 +47,8 @@ SineTimingFunction::CalculateProgress(float timeProgress) const { const float segments[3][3] = {{0.0f, 0.01f, 0.37f}, {0.37f, 0.72f, 0.888f}, {0.888f, 0.9999f, 1.0f}}; float timeProgressValue = timeProgress; - int segmentsLength = 3; //Length of the segments array - int index = (int)floor(segmentsLength * timeProgressValue); + int segmentsLength = 3; //Length of the segments array + int index = (int) floor(segmentsLength * timeProgressValue); if (index >= segmentsLength) { index = segmentsLength - 1; @@ -54,7 +56,7 @@ SineTimingFunction::CalculateProgress(float timeProgress) const float progressValue = (timeProgressValue - index * (1.0 / segmentsLength)) * segmentsLength; float segmentAtIndex[3]; - for(int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { segmentAtIndex[i] = segments[index][i]; } @@ -90,7 +92,7 @@ private: float __textPixelWidth; float __textPixelHeight; _VisualElement* __pVisualElement; -}; // _Token +}; // _Token _Token::_Token(void) : pTextObject(null) @@ -181,7 +183,7 @@ _Token::ResetToken(const String& text) } int length = text.GetLength(); - wchar_t* pTempString = const_cast (text.GetPointer()); + wchar_t* pTempString = const_cast< wchar_t* >(text.GetPointer()); SysTryReturnResult(NID_UI_CTRL, pTempString != null, E_SYSTEM, "A system error has occurred. Token text string is null."); __pTextBuffer = new (std::nothrow) wchar_t[(length + 1) * (sizeof(wchar_t))]; @@ -195,7 +197,7 @@ _Token::ResetToken(const String& text) pTextObject->RemoveAll(true); - TextSimple* pSimpleText = new (std::nothrow)TextSimple(__pTextBuffer, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, pFont); + TextSimple* pSimpleText = new (std::nothrow) TextSimple(__pTextBuffer, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, pFont); SysTryCatch(NID_UI_CTRL, pSimpleText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); r = pTextObject->AppendElement(*pSimpleText); @@ -277,7 +279,7 @@ _TokenEditPresenter::_TokenEditPresenter(void) , __pTokenBgPressedEffectBitmap(null) , __pressedTokenIndex(-1) , __isEditingToken(false) - , __edittingTokenIndex(-1) + , __editingTokenIndex(-1) , __clientRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f)) , __initTextRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f)) , __isEditModeEnabled(true) @@ -311,6 +313,8 @@ _TokenEditPresenter::_TokenEditPresenter(void) , __editContentFontSize(0.0f) , __trackTokenIndex(-1) , __isAnimationInProgress(false) + , __focusOutIndex(-1) + , __accessibilityElements() { } @@ -319,7 +323,7 @@ _TokenEditPresenter::InitializeDescriptionText(void) { result r = E_SUCCESS; float descriptionTextSize = 0.0f; - Font *pFont = null; + Font* pFont = null; float editFontSize = 0.0f; __pDescriptionTextTextObject = new (std::nothrow) TextObject(); @@ -413,6 +417,8 @@ _TokenEditPresenter::DisposeTokenEditPresenter(void) __pTimingFunction = null; } + RemoveChildAccessibilityElements(); + return E_SUCCESS; } @@ -445,7 +451,7 @@ _TokenEditPresenter::Initialize(const _Control& control) pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE); } - __pTokenEdit = dynamic_cast <_TokenEdit*>(GetEditView()); + __pTokenEdit = dynamic_cast< _TokenEdit* >(GetEditView()); SysTryReturnResult(NID_UI_CTRL, __pTokenEdit != null, E_SYSTEM, "A system error has occurred. The _Token instance is null."); _TokenEditModel* pTokenEditModel = new (std::nothrow) _TokenEditModel(); @@ -525,9 +531,9 @@ _TokenEditPresenter::DrawText(void) { bool isCustomBitmap = IS_CUSTOM_BITMAP(TOKENEDIT::BG_NORMAL); //Checking IsBlocked() is additional check for handler movement in token edit mode - if ((__isEditingToken) && (__edittingTokenIndex >= 0)) + if ((__isEditingToken) && (__editingTokenIndex >= 0)) { - _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + _Token* pToken = static_cast< _Token* >(__pTokenList->GetAt(__editingTokenIndex)); if (pToken) { _VisualElement* pTokenVisualElement = pToken->GetVisualElement(); @@ -637,7 +643,7 @@ _TokenEditPresenter::Draw(Canvas& canvas) _VisualElement* pCursorVisualElement = GetCursorVisualElement(); SysTryReturnResult(NID_UI_CTRL, pCursorVisualElement != null, E_SYSTEM, "A system error has occurred. Failed to get cursor visual element."); - _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + _Token* pToken = static_cast< _Token* >(__pTokenList->GetAt(__editingTokenIndex)); if (pToken) { @@ -650,6 +656,7 @@ _TokenEditPresenter::Draw(Canvas& canvas) SysTryReturnResult(NID_UI_CTRL, pTokenCanvas != null, E_SYSTEM, "A system error has occurred. Failed to get canvas of the token."); _EditPresenter::DrawText(*pTokenCanvas); + InitializeCursor(); delete pTokenCanvas; @@ -672,7 +679,7 @@ _TokenEditPresenter::Draw(Canvas& canvas) if (__isTokenEditingFinished) { __isEditingToken = false; - __edittingTokenIndex = -1; + __editingTokenIndex = -1; _EditPresenter::SetTextSize(__editContentFontSize); __isTokenEditingFinished = false; @@ -715,7 +722,7 @@ _TokenEditPresenter::DrawToken(int count) { Bitmap* pReplacementColorBackgroundBitmap = null; - _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + _Token* pToken = static_cast< _Token* >(__pTokenList->GetAt(i)); if (pToken == null || pToken->pTextObject == null) { SysLog(NID_UI_CTRL, "[E_SYSTEM] The _Token instance is null"); @@ -928,7 +935,7 @@ _TokenEditPresenter::MakeToken(const String& tokenString) r = pToken->Construct(inputTokenString, GetFont()); SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct token.", GetErrorMessage(r)); - r = __pTokenList->Add(static_cast (*pToken)); + r = __pTokenList->Add(static_cast< Object& >(*pToken)); SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); tokenCount = __pTokenList->GetCount(); @@ -955,6 +962,9 @@ _TokenEditPresenter::MakeToken(const String& tokenString) r = CheckTokenScrolling(); SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to process scroll.", GetErrorMessage(r)); + AppendTokenAccessibilityElement(); + UpdateTokenAccessibilityBounds(); + return r; CATCH: @@ -985,9 +995,9 @@ _TokenEditPresenter::AppendToken(const Tizen::Base::String& token) r = MakeToken(token); SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - if (__edittingTokenIndex >= 0) + if (__editingTokenIndex >= 0) { - SetEditingTokenTextBounds(__edittingTokenIndex); + SetEditingTokenTextBounds(__editingTokenIndex); _EditPresenter::SetCursorPosition(__previousCursorPosition); } @@ -1033,24 +1043,26 @@ _TokenEditPresenter::InsertTokenAt(int index, const String& token, bool isUser) for (int i = 0; i < GetTokenCount(); i++) { - pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); - SysTryCatch(NID_UI_CTRL, pToken != null, ,r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null"); + pToken = static_cast< _Token* >(__pTokenList->GetAt(i)); + SysTryCatch(NID_UI_CTRL, pToken != null, , r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null"); r = pToken->SetBounds(pToken->displayRect); SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds", GetErrorMessage(r)); } + InsertTokenAccessibilityElementAt(index); + if (isUser) { - if (__edittingTokenIndex >= 0) + if (__editingTokenIndex >= 0) { - if (index <= __edittingTokenIndex) + if (index <= __editingTokenIndex) { - __edittingTokenIndex++; + __editingTokenIndex++; } - __pressedTokenIndex = __edittingTokenIndex; + __pressedTokenIndex = __editingTokenIndex; - SetEditingTokenTextBounds(__edittingTokenIndex); + SetEditingTokenTextBounds(__editingTokenIndex); _EditPresenter::SetCursorPosition(__previousCursorPosition); } else if (__pressedTokenIndex >= index) @@ -1077,7 +1089,7 @@ _TokenEditPresenter::GetTokenAt(int index) const SysTryReturn(NID_UI_CTRL, index >= 0 && index < __pTokenList->GetCount(), tempString, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] index (%d) is out of range.", index); _Token* pToken = null; - pToken = static_cast <_Token*>(__pTokenList->GetAt(index)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(index)); if (pToken) { tempString = pToken->GetText(); @@ -1095,9 +1107,9 @@ _TokenEditPresenter::GetTokenCount(bool isInvokedByApp) const } else { - if(__isAnimationInProgress) + if (__isAnimationInProgress) { - return __pTokenList->GetCount() -1; + return __pTokenList->GetCount() - 1; } else { @@ -1124,7 +1136,7 @@ _TokenEditPresenter::RemoveTokenAt(int index, bool isClearText) result r = E_SUCCESS; SysTryReturnResult(NID_UI_CTRL, index >= 0 && index < __pTokenList->GetCount(), E_OUT_OF_RANGE, "index (%d) is out of range.", index); - if (index == __edittingTokenIndex && isClearText) + if (index == __editingTokenIndex && isClearText) { _VisualElement* pEditVisualElement = __pTokenEdit->GetVisualElement(); SysTryReturnResult(NID_UI_CTRL, pEditVisualElement, E_SYSTEM, "A system error has occurred. Failed to get root visual element."); @@ -1138,7 +1150,7 @@ _TokenEditPresenter::RemoveTokenAt(int index, bool isClearText) r = pEditVisualElement->AttachChild(*pCursorVisualElement); SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); - __edittingTokenIndex = -1; + __editingTokenIndex = -1; __isEditingToken = false; __pressedTokenIndex = -1; __isTokenEditingFinished = true; @@ -1162,7 +1174,7 @@ _TokenEditPresenter::RemoveTokenAt(int index, bool isClearText) for (int i = 0; i < GetTokenCount(); i++) { - pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(i)); SysTryReturnResult(NID_UI_CTRL, pToken != null, E_SYSTEM, "A system error has occurred. The _Token instance is null"); r = pToken->SetBounds(pToken->displayRect); @@ -1175,21 +1187,24 @@ _TokenEditPresenter::RemoveTokenAt(int index, bool isClearText) r = CheckTokenScrolling(); SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to process scroll."); + RemoveTokenAccessibilityElementAt(index); + UpdateTokenAccessibilityBounds(); + if (isClearText) { - if (index > __edittingTokenIndex) + if (index > __editingTokenIndex) { - SetEditingTokenTextBounds(__edittingTokenIndex); + SetEditingTokenTextBounds(__editingTokenIndex); _EditPresenter::SetCursorPosition(__previousCursorPosition); } - if (index < __edittingTokenIndex) + if (index < __editingTokenIndex) { - if (__edittingTokenIndex > 0) + if (__editingTokenIndex > 0) { - __edittingTokenIndex--; - __pressedTokenIndex = __edittingTokenIndex; + __editingTokenIndex--; + __pressedTokenIndex = __editingTokenIndex; - SetEditingTokenTextBounds(__edittingTokenIndex); + SetEditingTokenTextBounds(__editingTokenIndex); _EditPresenter::SetCursorPosition(__previousCursorPosition); } } @@ -1285,7 +1300,7 @@ _TokenEditPresenter::CalculateTokenPositionFromIndex(int startIndex, bool leftWa FloatRectangle tokenEditBounds = __pTokenEdit->GetBoundsF(); String titleText = __pTokenEdit->GetTitleText(); - if(!_FloatCompare(GetDescriptionTextRect().width, __previousTitleWidth)) + if (!_FloatCompare(GetDescriptionTextRect().width, __previousTitleWidth)) { __descriptionTextRectForScroll = GetDescriptionTextRect(); __previousTitleWidth = GetDescriptionTextRect().width; @@ -1294,7 +1309,7 @@ _TokenEditPresenter::CalculateTokenPositionFromIndex(int startIndex, bool leftWa bool findPrevTokenLoopFlag = true; for (; index < tokenCount; index++) { - pToken = static_cast <_Token*>(__pTokenList->GetAt(index)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(index)); SysTryReturn(NID_UI_CTRL, pToken, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); if (index == 0) @@ -1305,7 +1320,7 @@ _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 = leftMargin + __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN); pToken->displayRect.y = tokenTopMargin + __scrollValue + __pTokenEdit->GetVerticalMarginF(EDIT_TEXT_TOP_MARGIN) + __lineSpacing; @@ -1318,12 +1333,12 @@ _TokenEditPresenter::CalculateTokenPositionFromIndex(int startIndex, bool leftWa { if (findPrevTokenLoopFlag) { - pPreviousToken = static_cast <_Token*>(__pTokenList->GetAt(index - 1)); + pPreviousToken = static_cast< _Token* >(__pTokenList->GetAt(index - 1)); findPrevTokenLoopFlag = false; } float tempTextWidth = tokenEditBounds.width - pPreviousToken->displayRect.x - pPreviousToken->displayRect.width - tokenHorizontalSpacing - rightMargin - __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN); - if (tokenTextLeftMargin + pToken->GetTextPixelWidth() + tokenTextRightMargin > tempTextWidth) // Line change + if (tokenTextLeftMargin + pToken->GetTextPixelWidth() + tokenTextRightMargin > tempTextWidth) // Line change { pToken->displayRect.x = leftMargin + __pTokenEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN); pToken->displayRect.y = pPreviousToken->displayRect.y + tokenHeight + tokenVerticalSpacing + __lineSpacing; @@ -1332,7 +1347,7 @@ _TokenEditPresenter::CalculateTokenPositionFromIndex(int startIndex, bool leftWa else { pToken->displayRect.x = pPreviousToken->displayRect.x + pPreviousToken->displayRect.width + - tokenHorizontalSpacing; + tokenHorizontalSpacing; pToken->displayRect.y = pPreviousToken->displayRect.y; } @@ -1358,7 +1373,7 @@ _TokenEditPresenter::InitializeTokenVisibilityAt(int ndex) result r = E_SUCCESS; _Token* pToken = null; - pToken = static_cast <_Token*>(__pTokenList->GetAt(ndex)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(ndex)); SysTryReturn(NID_UI_CTRL, pToken, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); r = pToken->SetBounds(pToken->displayRect); @@ -1381,7 +1396,7 @@ _TokenEditPresenter::InitializeTokenVisibilityAt(int ndex) float _TokenEditPresenter::GetMaxTextHeight(void) { - Font *pFont = null; + Font* pFont = null; float maxHeight = __editContentFontSize; pFont = GetFont(); @@ -1459,12 +1474,14 @@ _TokenEditPresenter::SetInitialBounds(void) tokenTextRect.height = textObjectMaxHeight; SetTextBounds(tokenTextRect); + //set cursor bounds with tokenTextRect + __pTokenEdit->SetCursorAccessibilityBounds(tokenTextRect); return r; } _Token* pToken = null; // SetTextBounds from last token - pToken = static_cast <_Token*>(__pTokenList->GetAt(tokenCount - 1)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(tokenCount - 1)); 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; @@ -1484,6 +1501,11 @@ _TokenEditPresenter::SetInitialBounds(void) tokenTextRect.height = textObjectMaxHeight; SetTextBounds(tokenTextRect); + if (__pressedTokenIndex < 0) // Set cursor as global focused element if no token is selected + { + __pTokenEdit->SetCursorAccessibilityBounds(tokenTextRect); + } + } else { @@ -1514,7 +1536,7 @@ _TokenEditPresenter::GetTextBounds(void) const { if ((__isPopupVisible == true || __isLongPressed == true) && __pressedTokenIndex >= 0) { - _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(__pressedTokenIndex)); + _Token* pToken = static_cast< _Token* >(__pTokenList->GetAt(__pressedTokenIndex)); SysTryReturn(NID_UI_CTRL, pToken, Rectangle(), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Unable to get valid token."); _ControlOrientation orientation = __pTokenEdit->GetOrientation(); @@ -1523,7 +1545,7 @@ _TokenEditPresenter::GetTextBounds(void) const GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_LEFT_MARGIN, orientation, tokenTextLeftMargin); GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_VERTICAL_SPACING, orientation, tokenTextVerticalMargin); - FloatRectangle textBoundsF(pToken->displayRect.x + tokenTextLeftMargin, pToken->displayRect.y + (tokenTextVerticalMargin /2.0f), pToken->displayRect.width - (tokenTextLeftMargin * 2.0f), pToken->displayRect.height - tokenTextVerticalMargin); + FloatRectangle textBoundsF(pToken->displayRect.x + tokenTextLeftMargin, pToken->displayRect.y + (tokenTextVerticalMargin / 2.0f), pToken->displayRect.width - (tokenTextLeftMargin * 2.0f), pToken->displayRect.height - tokenTextVerticalMargin); Rectangle textBounds = _CoordinateSystemUtils::ConvertToInteger(textBoundsF); return textBounds; @@ -1539,7 +1561,7 @@ _TokenEditPresenter::GetTextBoundsF(void) const { if ((__isPopupVisible == true || __isLongPressed == true) && __pressedTokenIndex >= 0) { - _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(__pressedTokenIndex)); + _Token* pToken = static_cast< _Token* >(__pTokenList->GetAt(__pressedTokenIndex)); SysTryReturn(NID_UI_CTRL, pToken, FloatRectangle(), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Unable to get valid token."); _ControlOrientation orientation = __pTokenEdit->GetOrientation(); @@ -1548,7 +1570,7 @@ _TokenEditPresenter::GetTextBoundsF(void) const GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_LEFT_MARGIN, orientation, tokenTextLeftMargin); GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_VERTICAL_SPACING, orientation, tokenTextVerticalMargin); - FloatRectangle textBounds(pToken->displayRect.x + tokenTextLeftMargin, pToken->displayRect.y + (tokenTextVerticalMargin /2.0f), pToken->displayRect.width - (tokenTextLeftMargin * 2.0f), pToken->displayRect.height - tokenTextVerticalMargin); + FloatRectangle textBounds(pToken->displayRect.x + tokenTextLeftMargin, pToken->displayRect.y + (tokenTextVerticalMargin / 2.0f), pToken->displayRect.width - (tokenTextLeftMargin * 2.0f), pToken->displayRect.height - tokenTextVerticalMargin); return textBounds; } @@ -1563,7 +1585,7 @@ _TokenEditPresenter::CutText(void) { if (__isEditingToken) { - _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + _Token* pToken = static_cast< _Token* >(__pTokenList->GetAt(__editingTokenIndex)); SysTryReturnResult(NID_UI_CTRL, pToken != null, E_SYSTEM, "A system error has occurred. The _Token instance is null"); pToken->isTextCut = true; @@ -1695,12 +1717,12 @@ _TokenEditPresenter::CalculateDescriptionTextRect(const String& descriptionText) int length = descriptionText.GetLength(); FloatDimension textSize; - wchar_t* pTempString = const_cast (descriptionText.GetPointer()); + wchar_t* pTempString = const_cast< wchar_t* >(descriptionText.GetPointer()); SysAssertf(__pDescriptionTextTextObject != null, "The TextObject instance is null."); __pDescriptionTextTextObject->RemoveAll(true); - pSimpleText = new (std::nothrow)TextSimple(pTempString, length, TEXT_ELEMENT_SOURCE_TYPE_INTERNAL); + pSimpleText = new (std::nothrow) TextSimple(pTempString, length, TEXT_ELEMENT_SOURCE_TYPE_INTERNAL); __pDescriptionTextTextObject->AppendElement(*pSimpleText); textSize = __pDescriptionTextTextObject->GetTextExtentF(0, length); @@ -1751,6 +1773,7 @@ _TokenEditPresenter::DrawDescriptionText(void) { result r = E_SUCCESS; FloatRectangle tempDescriptionTextRect; + FloatRectangle descriptionTextRect(__descriptionTextRect); Canvas* pDescriptionTextCanvas = null; Font* pDescriptionFont = null; @@ -1791,7 +1814,9 @@ _TokenEditPresenter::DrawDescriptionText(void) SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); } - __pDescriptionTextVisualElement->SetBounds(FloatRectangle(__descriptionTextRect.x, (__descriptionTextRectForScroll.y + __scrollValue), __descriptionTextRect.width, __descriptionTextRect.height)); + descriptionTextRect.y = __descriptionTextRectForScroll.y + __scrollValue; + __pDescriptionTextVisualElement->SetBounds(descriptionTextRect); + UpdateTitleAccessibilityBounds(descriptionTextRect); // Update title accessibility bounds to same as DescriptionTextVisualElement bounds pDescriptionTextCanvas = __pDescriptionTextVisualElement->GetCanvasN(); if (pDescriptionTextCanvas == null) @@ -1879,7 +1904,7 @@ _TokenEditPresenter::TrimTokenAndAdjustEllipsisAt(int index) GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_MIN_WIDTH, orientation, tokenMinimumSize); _Token* pToken = null; - pToken = static_cast <_Token*>(__pTokenList->GetAt(index)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(index)); SysTryReturn(NID_UI_CTRL, pToken, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null"); FloatRectangle tokenEditBounds = __pTokenEdit->GetBoundsF(); @@ -1920,7 +1945,7 @@ _TokenEditPresenter::GetTokenIndexFromCoordinate(const Point point) const int tokenCount = __pTokenList->GetCount(); for (int i = 0; i < tokenCount; i++) { - _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + _Token* pToken = static_cast< _Token* >(__pTokenList->GetAt(i)); if (pToken) { FloatRectangle tokenRect = pToken->displayRect; @@ -1950,7 +1975,7 @@ _TokenEditPresenter::SetEditingTokenTextBounds(int index, bool isSetText) GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_LEFT_MARGIN, orientation, tokenTextLeftMargin); GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_SIZE, orientation, tokenFontSize); - _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(index)); + _Token* pToken = static_cast< _Token* >(__pTokenList->GetAt(index)); SysTryReturnResult(NID_UI_CTRL, pToken != null, E_SYSTEM, "A system error has occurred. The _Token instance is null"); FloatRectangle tempTextDspRect; @@ -1988,7 +2013,7 @@ _TokenEditPresenter::RecalculateTokenBounds(float position) for (int i = 0; i < tokenCount; i++) { _Token* pToken = null; - pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(i)); if (pToken) { @@ -2017,13 +2042,13 @@ _TokenEditPresenter::SetTokenBoundsByTouchInfo(const _TouchInfo& touchinfo) result r = E_SUCCESS; int currentYPosition = _CoordinateSystemUtils::ConvertToInteger(touchinfo.GetCurrentPosition()).y; - if(_FloatCompare(__prevScrollValue, 0.0f)) + if (_FloatCompare(__prevScrollValue, 0.0f)) { __prevScrollValue = currentYPosition; } - else // Adjust moved y position to all tokens. + else // Adjust moved y position to all tokens. { - if (__isNeedToScroll) // Need to scroll + if (__isNeedToScroll) // Need to scroll { float tempDefference = __prevScrollValue - currentYPosition; @@ -2049,7 +2074,7 @@ _TokenEditPresenter::SetTokenBoundsByTouchInfo(const _TouchInfo& touchinfo) for (int i = 0; i < tokenCount; i++) { _Token* pToken = null; - pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(i)); if (pToken) { @@ -2091,7 +2116,7 @@ _TokenEditPresenter::ProcessTokeningByTouchEvent(const _Control& source, const _ } int prevPressedTokenIndex = __pressedTokenIndex; - int prevEditedTokenIndex = __edittingTokenIndex; + int prevEditedTokenIndex = __editingTokenIndex; result r = E_SUCCESS; if (IsFocused()) @@ -2099,12 +2124,12 @@ _TokenEditPresenter::ProcessTokeningByTouchEvent(const _Control& source, const _ if (__isEditModeEnabled && __pressedTokenIndex != -1 && __pressedTokenIndex == tokenIndex) { //Comment below to Block Copy & Paste functionality in Token Edit mode - __edittingTokenIndex = __pressedTokenIndex; + __editingTokenIndex = __pressedTokenIndex; __isEditingToken = true; __isTokenEditingFinished = false; - if (prevEditedTokenIndex != __edittingTokenIndex) + if (prevEditedTokenIndex != __editingTokenIndex) { - SetEditingTokenTextBounds(__edittingTokenIndex); + SetEditingTokenTextBounds(__editingTokenIndex); } SetCursorDisabled(false); } @@ -2126,7 +2151,7 @@ _TokenEditPresenter::ProcessTokeningByTouchEvent(const _Control& source, const _ _Token* pToken = null; _VisualElement* pTokenVisualElement = null; - pToken = static_cast <_Token*>(__pTokenList->GetAt(prevPressedTokenIndex)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(prevPressedTokenIndex)); bool isParentChanged = false; if (pToken) @@ -2166,7 +2191,7 @@ _TokenEditPresenter::ProcessTokeningByTouchEvent(const _Control& source, const _ r = InsertTokenAt(prevPressedTokenIndex, inputTokenString); SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); - pToken = static_cast <_Token*>(__pTokenList->GetAt(prevPressedTokenIndex)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(prevPressedTokenIndex)); if (pToken) { pToken->currTokenLength = inputTokenString.GetLength(); @@ -2176,7 +2201,7 @@ _TokenEditPresenter::ProcessTokeningByTouchEvent(const _Control& source, const _ ClearText(); //Flex height adjusted since token can move to another line AdjustFlexibleHeight(); - __edittingTokenIndex = -1; + __editingTokenIndex = -1; __isTokenEditingFinished = true; __isEditingToken = false; _EditPresenter::SetTextSize(__editContentFontSize); @@ -2203,7 +2228,7 @@ _TokenEditPresenter::ProcessTokeningByTouchEvent(const _Control& source, const _ _Token* pToken = null; _VisualElement* pTokenVisualElement = null; - pToken = static_cast <_Token*>(__pTokenList->GetAt(__pressedTokenIndex)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(__pressedTokenIndex)); bool isParentChanged = false; if (pToken) @@ -2246,7 +2271,7 @@ _TokenEditPresenter::ProcessTokeningByTouchEvent(const _Control& source, const _ _Token* pToken = null; _VisualElement* pTokenVisualElement = null; - pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(__editingTokenIndex)); bool isParentChanged = false; if (pToken) @@ -2277,11 +2302,11 @@ _TokenEditPresenter::ProcessTokeningByTouchEvent(const _Control& source, const _ } __pressedTokenIndex = tokenIndex; - RemoveTokenAt(__edittingTokenIndex); + RemoveTokenAt(__editingTokenIndex); if (inputTokenString.GetLength() > 0) { - InsertTokenAt(__edittingTokenIndex, inputTokenString); + InsertTokenAt(__editingTokenIndex, inputTokenString); if (isParentChanged) { @@ -2290,7 +2315,7 @@ _TokenEditPresenter::ProcessTokeningByTouchEvent(const _Control& source, const _ } __isEditingToken = false; - __edittingTokenIndex = -1; + __editingTokenIndex = -1; _EditPresenter::SetTextSize(__editContentFontSize); __isTokenEditingFinished = false; @@ -2342,7 +2367,7 @@ _TokenEditPresenter::CheckTokenScrolling(bool scrollToCursorPosition) GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_VERTICAL_SPACING, orientation, tokenVerticalSpacing); int tokenCount = GetTokenCount(); - if (tokenCount == 0) // There is no token to scroll + if (tokenCount == 0) // There is no token to scroll { __isNeedToScroll = false; __maxScrollValue = 0.0f; @@ -2351,7 +2376,7 @@ _TokenEditPresenter::CheckTokenScrolling(bool scrollToCursorPosition) return E_SUCCESS; } - _Token* pToken = static_cast<_Token*>(__pTokenList->GetAt(tokenCount - 1)); + _Token* pToken = static_cast< _Token* >(__pTokenList->GetAt(tokenCount - 1)); SysTryReturn(NID_UI_CTRL, pToken, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); float newScrollValue = 0.0f; @@ -2359,7 +2384,7 @@ _TokenEditPresenter::CheckTokenScrolling(bool scrollToCursorPosition) if (scrollToCursorPosition) { FloatRectangle cursorBounds; - GetCursorBounds(false, cursorBounds); + GetCursorBounds(false, cursorBounds); newScrollValue = cursorBounds.y + cursorBounds.height - __scrollValue + tokenBottomMargin - __pTokenEdit->GetBoundsF().height; __isScrollValueModified = true; } @@ -2382,10 +2407,10 @@ _TokenEditPresenter::CheckTokenScrolling(bool scrollToCursorPosition) } else { - if(!_FloatCompare(__scrollValue, 0.0f)) + if (!_FloatCompare(__scrollValue, 0.0f)) { __scrollValue = 0.0f; - __maxScrollValue = 0.0f; // To prevent unnecessary token scrolling. + __maxScrollValue = 0.0f; // To prevent unnecessary token scrolling. RecalculateTokenBounds(__scrollValue); __isTokenScrolling = false; } @@ -2397,7 +2422,7 @@ _TokenEditPresenter::CheckTokenScrolling(bool scrollToCursorPosition) result _TokenEditPresenter::SetTokenVisualElementBounds(int index, const FloatRectangle& bounds) { - _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(index)); + _Token* pToken = static_cast< _Token* >(__pTokenList->GetAt(index)); SysTryReturnResult(NID_UI_CTRL, pToken != null, E_SYSTEM, "A system error has occurred. The _Token instance is null."); return pToken->SetBounds(pToken->displayRect); @@ -2487,7 +2512,7 @@ _TokenEditPresenter::DrawScrollBar(void) } } - _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(GetTokenCount() - 1)); + _Token* pToken = static_cast< _Token* >(__pTokenList->GetAt(GetTokenCount() - 1)); if (pToken == null) { return E_SUCCESS; @@ -2573,7 +2598,7 @@ _TokenEditPresenter::CalculateVisibleTokenCount(void) for (int i = 0; i < tokenCount; i++) { tempInitialBounds = intialBounds; - _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + _Token* 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 displayBounds = pToken->displayRect; @@ -2601,7 +2626,7 @@ _TokenEditPresenter::OnFocusGained(void) for (int i = 0; i < tokenCount; i++) { - pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(i)); if (pToken) { @@ -2615,7 +2640,7 @@ _TokenEditPresenter::OnFocusGained(void) SetFlexBounds(tempRect); - SetEditingTokenTextBounds(__edittingTokenIndex, false); + SetEditingTokenTextBounds(__editingTokenIndex, false); if (!__isFocus) { @@ -2649,6 +2674,8 @@ _TokenEditPresenter::OnFocusGained(void) StartCursorTimer(); } + RefreshAccessibilityElements(); + return _EditPresenter::OnFocusGained(); } @@ -2665,10 +2692,10 @@ _TokenEditPresenter::OnFocusLost(void) _EditPresenter::StopTitleSlidingTimer(); __isTitleSliding = false; - if (__edittingTokenIndex >= 0) + if (__editingTokenIndex >= 0) { _Token* pToken = null; - pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(__editingTokenIndex)); if (pToken) { if (GetText().GetLength() > 0) @@ -2677,7 +2704,7 @@ _TokenEditPresenter::OnFocusLost(void) } else { - RemoveTokenAt(__edittingTokenIndex, true); + RemoveTokenAt(__editingTokenIndex, true); } } } @@ -2702,7 +2729,7 @@ _TokenEditPresenter::OnFocusLost(void) _Token* pToken = null; for (int i = 0; i < tokenCount; i++) { - pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(i)); if (pToken) { pToken->SetBounds(pToken->displayRect); @@ -2712,6 +2739,8 @@ _TokenEditPresenter::OnFocusLost(void) r = SetInitialBounds(); SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating", GetErrorMessage(r)); + UpdateTokenAccessibilityBounds(); + __scrollValue = 0.0f; r = CalculateTokenPositionFromIndex(0); SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); @@ -2720,7 +2749,7 @@ _TokenEditPresenter::OnFocusLost(void) for (int i = visibleTokenCount; i < tokenCount; i++) { - pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(i)); if (pToken) { _VisualElement* pTokenVisualElement = pToken->GetVisualElement(); @@ -2748,7 +2777,7 @@ _TokenEditPresenter::OnFocusLost(void) FloatRectangle intialWindowBounds = GetInitialBoundsF(); SetFlexBounds(intialWindowBounds); - SetEditingTokenTextBounds(__edittingTokenIndex, false); + SetEditingTokenTextBounds(__editingTokenIndex, false); __descriptionTextRect.y = __descriptionTextRectForScroll.y + __scrollValue; } @@ -2760,6 +2789,9 @@ _TokenEditPresenter::OnFocusLost(void) pTextObject->Compose(); } + RemoveChildAccessibilityElements(); + __pTokenEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT); + return _EditPresenter::OnFocusLost(); } @@ -2817,13 +2849,13 @@ _TokenEditPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& to _TouchInfo TouchInfo(touchinfo); if (tokenIndex != -1) { - if (tokenIndex == __edittingTokenIndex) + if (tokenIndex == __editingTokenIndex) { __touchPressInfo.x = touchinfo.GetCurrentPosition().x; __touchPressInfo.y = touchinfo.GetCurrentPosition().y; _Token* pToken = null; - pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(__editingTokenIndex)); if (pToken) { float tokenX = pToken->displayRect.x; @@ -2846,7 +2878,7 @@ _TokenEditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& t if (GetTokenCount()) { //Set token bounds appropriately On Fast flick of scroll bar - if (!(__isEditingToken || __edittingTokenIndex >= 0)) + if (!(__isEditingToken || __editingTokenIndex >= 0)) { SetTokenBoundsByTouchInfo(touchinfo); } @@ -2866,9 +2898,9 @@ _TokenEditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& t _TouchInfo TouchInfo(touchinfo); _Token* pToken = null; - if (__edittingTokenIndex >= 0) + if (__editingTokenIndex >= 0) { - pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(__editingTokenIndex)); if (pToken) { int tokenX = _CoordinateSystemUtils::ConvertToInteger(pToken->displayRect.x); @@ -2908,7 +2940,7 @@ _TokenEditPresenter::OnTextCommitted(const String& commitText) CoreKeypadAction keypadaction = GetKeypadAction(); __pTokenEdit->SendKeypadEvent(keypadaction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION); - if (__edittingTokenIndex != -1) + if (__editingTokenIndex != -1) { _VisualElement* pEditVisualElement = __pTokenEdit->GetVisualElement(); SysTryReturnVoidResult(NID_UI_CTRL, pEditVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get root visual element."); @@ -2919,7 +2951,7 @@ _TokenEditPresenter::OnTextCommitted(const String& commitText) _Token* pToken = null; _VisualElement* pTokenVisualElement = null; - pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(__editingTokenIndex)); if (pToken) { @@ -2946,16 +2978,16 @@ _TokenEditPresenter::OnTextCommitted(const String& commitText) inputTokenString = replacementString; } - r = RemoveTokenAt(__edittingTokenIndex); + r = RemoveTokenAt(__editingTokenIndex); _EditPresenter::SetTextSize(__editContentFontSize); SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); if (inputTokenString.GetLength() > 0) { - r = InsertTokenAt(__edittingTokenIndex, inputTokenString); + r = InsertTokenAt(__editingTokenIndex, inputTokenString); SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(__editingTokenIndex)); SysTryReturnVoidResult(NID_UI_CTRL, pToken != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); pToken->currTokenLength = inputTokenString.GetLength(); @@ -2966,7 +2998,7 @@ _TokenEditPresenter::OnTextCommitted(const String& commitText) for (int i = 0; i < lastTokenIndex + 1; i++) { _Token* pToken = null; - pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(i)); if (pToken) { @@ -2977,7 +3009,7 @@ _TokenEditPresenter::OnTextCommitted(const String& commitText) AdjustFlexibleHeight(); __pressedTokenIndex = -1; __isTokenEditingFinished = true; - __edittingTokenIndex = -1; + __editingTokenIndex = -1; __isEditingToken = false; CheckTokenScrolling(); @@ -3016,13 +3048,13 @@ _TokenEditPresenter::OnTextCommitted(const String& commitText) __previousCursorPosition = GetCursorPosition(); _Token* pToken = null; - if (__edittingTokenIndex >= 0) + if (__editingTokenIndex >= 0) { - pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(__editingTokenIndex)); SysTryReturnVoidResult(NID_UI_CTRL, pToken, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null"); pToken->ResetToken(GetText()); - TrimTokenAndAdjustEllipsisAt(__edittingTokenIndex); + TrimTokenAndAdjustEllipsisAt(__editingTokenIndex); float tokenHeight = 0.0f; float tokenVerticalSpacing = 0.0f; @@ -3067,7 +3099,7 @@ _TokenEditPresenter::OnTextCommitted(const String& commitText) SetTextBounds(textBounds); } - if (__edittingTokenIndex < 0) + if (__editingTokenIndex < 0) { CheckTokenScrolling(); } @@ -3105,7 +3137,7 @@ _TokenEditPresenter::OnSurroundingTextDeleted(int offset, int charCount) _Token* pToken = null; _VisualElement* pTokenVisualElement = null; - pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(__editingTokenIndex)); if (pToken) { @@ -3123,13 +3155,13 @@ _TokenEditPresenter::OnSurroundingTextDeleted(int offset, int charCount) } } - RemoveTokenAt(__edittingTokenIndex); + RemoveTokenAt(__editingTokenIndex); - CalculateTokenPositionFromIndex(__edittingTokenIndex); - for (int i = __edittingTokenIndex; i < __lastTokenIndex + 1; i++) + CalculateTokenPositionFromIndex(__editingTokenIndex); + for (int i = __editingTokenIndex; i < __lastTokenIndex + 1; i++) { _Token* pToken = null; - pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(i)); if (pToken) { pToken->SetBounds(pToken->displayRect); @@ -3137,7 +3169,7 @@ _TokenEditPresenter::OnSurroundingTextDeleted(int offset, int charCount) } __pressedTokenIndex = -1; - __edittingTokenIndex = -1; + __editingTokenIndex = -1; __isEditingToken = false; _EditPresenter::SetTextSize(__editContentFontSize); __isTokenEditingFinished = false; @@ -3156,7 +3188,7 @@ _TokenEditPresenter::OnSurroundingTextDeleted(int offset, int charCount) _Token* pToken = null; _VisualElement* pTokenVisualElement = null; - pToken = static_cast <_Token*>(__pTokenList->GetAt(__pressedTokenIndex)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(__pressedTokenIndex)); if (pToken) { @@ -3180,13 +3212,14 @@ _TokenEditPresenter::OnSurroundingTextDeleted(int offset, int charCount) for (int i = __pressedTokenIndex; i < __lastTokenIndex + 1; i++) { _Token* pToken = null; - pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(i)); if (pToken) { pToken->SetBounds(pToken->displayRect); } } + } else { @@ -3200,7 +3233,7 @@ _TokenEditPresenter::OnSurroundingTextDeleted(int offset, int charCount) _VisualElement* pTokenVisualElement = null; if (__animatingIndex == (GetTokenCount() - 1)) { - pToken = static_cast <_Token*>(__pTokenList->GetAt(GetTokenCount() - 1)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(GetTokenCount() - 1)); if (pToken) { pTokenVisualElement = pToken->GetVisualElement(); @@ -3208,7 +3241,7 @@ _TokenEditPresenter::OnSurroundingTextDeleted(int offset, int charCount) pTokenVisualElement->RemoveAnimation(L"TokenAnimation"); } } - pToken = static_cast <_Token*>(__pTokenList->GetAt(GetTokenCount() - 1)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(GetTokenCount() - 1)); if (pToken) { pTokenVisualElement = pToken->GetVisualElement(); @@ -3236,13 +3269,15 @@ _TokenEditPresenter::OnSurroundingTextDeleted(int offset, int charCount) } } + __pTokenEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT); + DrawText(); __pTokenEdit->Invalidate(); return; } } - if (__pressedTokenIndex >= 0 && __edittingTokenIndex < 0 && !__isEditingToken) + if (__pressedTokenIndex >= 0 && __editingTokenIndex < 0 && !__isEditingToken) { RemoveTokenAt(__pressedTokenIndex); __pTokenEdit->Invalidate(); @@ -3311,9 +3346,9 @@ _TokenEditPresenter::OnSurroundingTextDeleted(int offset, int charCount) _Token* pToken = null; - if (__edittingTokenIndex >= 0 && __isEditingToken) + if (__editingTokenIndex >= 0 && __isEditingToken) { - pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(__editingTokenIndex)); if (pToken) { @@ -3338,7 +3373,7 @@ _TokenEditPresenter::OnSurroundingTextDeleted(int offset, int charCount) _EditPresenter::SetCursorPosition(start); pToken->ResetToken(GetText()); - TrimTokenAndAdjustEllipsisAt(__edittingTokenIndex); + TrimTokenAndAdjustEllipsisAt(__editingTokenIndex); } } @@ -3348,7 +3383,7 @@ _TokenEditPresenter::OnSurroundingTextDeleted(int offset, int charCount) bool _TokenEditPresenter::OnTapGestureDetected(void) { - if (__edittingTokenIndex >= 0) + if (__editingTokenIndex >= 0) { __isPopupVisible = true; } @@ -3364,18 +3399,18 @@ _TokenEditPresenter::OnTapGestureDetected(void) bool _TokenEditPresenter::CheckCopyPastePopupShowStatus(void) { - if (__edittingTokenIndex < 0) - { - float controlHeight = __pTokenEdit->GetBoundsF().height; - FloatRectangle cursorBounds; - GetCursorBounds(false, cursorBounds); - if (cursorBounds.y > controlHeight) - { - return true; - } - } + if (__editingTokenIndex < 0) + { + float controlHeight = __pTokenEdit->GetBoundsF().height; + FloatRectangle cursorBounds; + GetCursorBounds(false, cursorBounds); + if (cursorBounds.y > controlHeight) + { + return true; + } + } - return false; + return false; } bool @@ -3406,7 +3441,7 @@ _TokenEditPresenter::OnLongPressGestureDetected(void) void _TokenEditPresenter::OnCursorTimerExpired(void) { - if (__edittingTokenIndex != -1) + if (__editingTokenIndex != -1) { if (!IsFocused()) { @@ -3416,7 +3451,7 @@ _TokenEditPresenter::OnCursorTimerExpired(void) FloatRectangle cursorRect; - _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + _Token* pToken = static_cast< _Token* >(__pTokenList->GetAt(__editingTokenIndex)); SysTryReturnVoidResult(NID_UI_CTRL, pToken != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null"); //Set Editing token bounds for text scroll and cursor position calculation (SetTextBounds should have been done prior to this) @@ -3463,7 +3498,7 @@ _TokenEditPresenter::OnCursorTimerExpired(void) bool _TokenEditPresenter::IsTextBlockedInTokenEdit(void) const { - if ((IsBlocked() == true) && (__isEditingToken) && (__edittingTokenIndex >= 0)) + if ((IsBlocked() == true) && (__isEditingToken) && (__editingTokenIndex >= 0)) { return true; } @@ -3486,11 +3521,11 @@ _TokenEditPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touc //Allow touch move only in horizontal direction when editing token _TouchInfo TouchInfo(touchinfo); _Token* pToken = null; - if (__edittingTokenIndex >= 0) + if (__editingTokenIndex >= 0) { if (__touchPressInfo.y > 0.0f) { - pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(__editingTokenIndex)); if (pToken) { float tokenX = pToken->displayRect.x; @@ -3544,7 +3579,7 @@ _TokenEditPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touc } void -_TokenEditPresenter::OnVisualElementAnimationFinished (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target, bool completedNormally) +_TokenEditPresenter::OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally) { __isAnimationInProgress = false; RemoveTokenAt(GetTokenCount() - 1); @@ -3553,13 +3588,14 @@ _TokenEditPresenter::OnVisualElementAnimationFinished (const Tizen::Ui::Animatio for (int i = GetTokenCount() - 1; i < GetTokenCount() - 1 + 1; i++) { _Token* pToken = null; - pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + pToken = static_cast< _Token* >(__pTokenList->GetAt(i)); if (pToken) { pToken->SetBounds(pToken->displayRect); } } + if (__lastTokenIndex == __pressedTokenIndex) { __pressedTokenIndex--; @@ -3574,6 +3610,8 @@ _TokenEditPresenter::OnVisualElementAnimationFinished (const Tizen::Ui::Animatio DrawToken(); + __pTokenEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT); + return; } @@ -3639,7 +3677,7 @@ _TokenEditPresenter::ChangeInternalLayout(_ControlOrientation orientation) if (__isEditingToken) { - if (__edittingTokenIndex >= 0 && __edittingTokenIndex < GetTokenCount()) + if (__editingTokenIndex >= 0 && __editingTokenIndex < GetTokenCount()) { String inputTokenString = GetText(); String replacementString = inputTokenString; @@ -3653,8 +3691,8 @@ _TokenEditPresenter::ChangeInternalLayout(_ControlOrientation orientation) if (inputTokenString.GetLength() > 0) { - int index = __edittingTokenIndex; - RemoveTokenAt(__edittingTokenIndex, true); + int index = __editingTokenIndex; + RemoveTokenAt(__editingTokenIndex, true); InsertTokenAt(index, inputTokenString); } } @@ -3747,4 +3785,349 @@ _TokenEditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInf return _EditPresenter::OnKeyPressed(source, keyInfo); } + +String +_TokenEditPresenter::GetTextAccessibilityElementText(void) const +{ + String tokenText; + String spaceText = " "; + _Token* pToken = null; + int tokenCount = GetTokenCount(); + static const int readTokenCount = 2; + if (tokenCount > 0) + { + for (int index = 0; index < readTokenCount; index++) + { + pToken = static_cast< _Token* >(__pTokenList->GetAt(index)); + SysTryReturn(NID_UI_CTRL, pToken, tokenText, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + if (index < (readTokenCount - 1)) + { + tokenText += pToken->GetText() + spaceText; + } + else + { + String moreTokenText; + int moreTokenCount = tokenCount - readTokenCount; + if (moreTokenCount > 0) + { + moreTokenText.Format(15, L"and %d more", moreTokenCount); + } + tokenText += pToken->GetText() + spaceText + moreTokenText; + } + } + } + return tokenText; +} + +void +_TokenEditPresenter::RefreshAccessibilityElements(void) +{ + RemoveChildAccessibilityElements(); + AddChildAccessibilityElements(); + + return; +} + +result +_TokenEditPresenter::AddChildAccessibilityElements(void) +{ + //Accessibility Elements added to the container upon focus gained + //1.Title + //2.Token(s) + //3. __accessibilityElements 0 - title 1 - token 0 + + result r = E_SUCCESS; + _AccessibilityContainer* pContainer = __pTokenEdit->GetAccessibilityContainer(); + + __pTokenEdit->AddTitleAccessibilityElement(); + int tokenCount = GetTokenCount(); + + for (int index = 0; index < tokenCount; index++) + { + _Token* pToken = static_cast< _Token* >(__pTokenList->GetAt(index)); + SysTryReturn(NID_UI_CTRL, pToken != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + if (pContainer) + { + _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + String labelText = pToken->GetText(); + pAccessibilityElement->SetBounds(pToken->displayRect); + pAccessibilityElement->SetLabel(labelText); + pContainer->AddElement(*pAccessibilityElement); + __accessibilityElements.Add(pAccessibilityElement); + } + } + + __pTokenEdit->AddCursorAccessibilityElement(); + + return r; +} + +void +_TokenEditPresenter::RemoveChildAccessibilityElements(void) +{ + _AccessibilityContainer* pContainer = __pTokenEdit->GetAccessibilityContainer(); + _AccessibilityElement* pAccessibilityElement = null; + + __pTokenEdit->RemoveTitleAccessibilityElement(); + + while (__accessibilityElements.GetCount() > 0) + { + if ((__accessibilityElements.GetAt(0, pAccessibilityElement)) == E_SUCCESS) + { + __accessibilityElements.RemoveAt(0); + pContainer->RemoveElement(*pAccessibilityElement); + } + } + + __pTokenEdit->RemoveCursorAccessibilityElement(); + + return; +} + +result +_TokenEditPresenter::AppendTokenAccessibilityElement(void) +{ + result r = E_SUCCESS; + int tokenCount = GetTokenCount(); + + _AccessibilityContainer* pContainer = __pTokenEdit->GetAccessibilityContainer(); + + _Token* pToken = static_cast< _Token* >(__pTokenList->GetAt(tokenCount - 1)); + SysTryReturn(NID_UI_CTRL, pToken != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + if (pContainer) + { + _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + String labelText = pToken->GetText(); + pAccessibilityElement->SetBounds(pToken->displayRect); + pAccessibilityElement->SetLabel(labelText); + pAccessibilityElement->SetHint(L"double tap to edit"); + pContainer->AddElement(*pAccessibilityElement); + __accessibilityElements.Add(pAccessibilityElement); + } + + return r; +} + +result +_TokenEditPresenter::InsertTokenAccessibilityElementAt(int index) +{ + result r = E_SUCCESS; + + _AccessibilityContainer* pContainer = __pTokenEdit->GetAccessibilityContainer(); + _Token* pToken = static_cast< _Token* >(__pTokenList->GetAt(index)); + SysTryReturn(NID_UI_CTRL, pToken != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + if (pContainer) + { + _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + String labelText = pToken->GetText(); + pAccessibilityElement->SetBounds(pToken->displayRect); + pAccessibilityElement->SetLabel(labelText); + pContainer->AddElement(*pAccessibilityElement); + __accessibilityElements.InsertAt(pAccessibilityElement, index); + } + + return r; +} + +void +_TokenEditPresenter::RemoveTokenAccessibilityElementAt(int index) +{ + _AccessibilityContainer* pContainer = __pTokenEdit->GetAccessibilityContainer(); + _AccessibilityElement* pAccessibilityElement = null; + + if (pContainer) + { + if (__accessibilityElements.GetCount() > 0) + { + if ((__accessibilityElements.GetAt(index, pAccessibilityElement)) == E_SUCCESS) + { + __accessibilityElements.RemoveAt(index); + pContainer->RemoveElement(*pAccessibilityElement); + } + } + } + return; +} + +result +_TokenEditPresenter::UpdateTokenAccessibilityBounds(void) +{ + result r = E_SUCCESS; + int tokenCount = GetTokenCount(); + _AccessibilityElement* pAccessibilityElement = null; + + for (int index = 0; index < tokenCount; index++) + { + _Token* pToken = static_cast< _Token* >(__pTokenList->GetAt(index)); + SysTryReturn(NID_UI_CTRL, pToken != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + if ((__accessibilityElements.GetAt(index, pAccessibilityElement)) == E_SUCCESS) + { + pAccessibilityElement->SetBounds(pToken->displayRect); + } + } + return r; +} + +result +_TokenEditPresenter::UpdateTitleAccessibilityBounds(const FloatRectangle& titleBounds) +{ + _AccessibilityElement* pTitleAccessibilityElement = __pTokenEdit->GetTitleTextAccessibilityElement(); + + if (!pTitleAccessibilityElement) + { + return E_SUCCESS; + } + + pTitleAccessibilityElement->SetBounds(titleBounds); + + return E_SUCCESS; +} + +result +_TokenEditPresenter::ScrollToFocusedTokenAccessibilityElement(const _AccessibilityElement& element) +{ + result r = E_SUCCESS; + int focusedTokenIndex = -1; + int tokenCount = GetTokenCount(); + FloatRectangle focusedTokenRectangle; + float newScrollValue = 0.0f; + float tokenTopMargin = 0.0f; + float tokenBottomMargin = 0.0f; + _ControlOrientation orientation = __pTokenEdit->GetOrientation(); + _AccessibilityElement* pAccessibilityElement = null; + + GET_SHAPE_CONFIG(TOKENEDIT::TOP_MARGIN, orientation, tokenTopMargin); + GET_SHAPE_CONFIG(TOKENEDIT::BOTTOM_MARGIN, orientation, tokenBottomMargin); + + FloatRectangle tokenEditRect = __pTokenEdit->GetBoundsF(); + + pAccessibilityElement = const_cast< _AccessibilityElement* >(&element); + r = __accessibilityElements.IndexOf(pAccessibilityElement, focusedTokenIndex); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + if ((focusedTokenIndex > -1) && (focusedTokenIndex < tokenCount)) + { + _Token* pToken = null; + pToken = static_cast< _Token* >(__pTokenList->GetAt(focusedTokenIndex)); + + focusedTokenRectangle = pToken->displayRect; + + float focusedTokenPosition = focusedTokenRectangle.y + focusedTokenRectangle.height; + + if ((focusedTokenRectangle.y > 0) && (focusedTokenPosition < tokenEditRect.height)) + { + DrawToken(); + } + else + { + if (focusedTokenRectangle.y < 0) + { + newScrollValue = focusedTokenRectangle.y - tokenTopMargin - __scrollValue; + } + else + { + newScrollValue = focusedTokenPosition - tokenEditRect.height + tokenBottomMargin - __scrollValue; + } + + r = RecalculateTokenBounds(newScrollValue); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + + __accessibilityElements.GetAt(focusedTokenIndex, pAccessibilityElement); + _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance(); + pAccessibilityManager->SetGlobalFocusedElement(*pAccessibilityElement); + pAccessibilityManager->RequestToDrawFocusUi(); + } + + return r; +} + +bool +_TokenEditPresenter::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + if (__focusOutIndex < 0) // Not a token accessibility element + { + return false; + } + + _Token* pToken = null; + _AccessibilityElement* pCurrentElement = const_cast< _AccessibilityElement* >(&element); + _AccessibilityElement* pPreviousAccessibilityElement = null; + _AccessibilityElement* pNextAccessibilityElement = null; + __accessibilityElements.GetAt(__focusOutIndex, pPreviousAccessibilityElement); + + if (pPreviousAccessibilityElement && pPreviousAccessibilityElement->GetAbsoluteBounds().y > element.GetAbsoluteBounds().y) //Left flick + { + pToken = static_cast< _Token* >(__pTokenList->GetAt(__focusOutIndex - 1)); + if (pToken) + { + if (pToken->displayRect.y < 0.0f && __focusOutIndex > 0) + { + __accessibilityElements.GetAt(__focusOutIndex - 1, pNextAccessibilityElement); + ScrollToFocusedTokenAccessibilityElement(*pNextAccessibilityElement); + } + } + } + + if (pPreviousAccessibilityElement && pPreviousAccessibilityElement->GetAbsoluteBounds().y < element.GetAbsoluteBounds().y) //Right flick + { + pToken = static_cast< _Token* >(__pTokenList->GetAt(__focusOutIndex + 1)); + if (pToken) + { + if (pToken->displayRect.y + pToken->displayRect.height > __pTokenEdit->GetBoundsF().height) + { + __accessibilityElements.GetAt(__focusOutIndex + 1, pNextAccessibilityElement); + ScrollToFocusedTokenAccessibilityElement(*pNextAccessibilityElement); + } + } + } + + if (pToken == null) //Draw Cursor Accessibility Element + { + _AccessibilityElement* pCursorAccessibilityElement = __pTokenEdit->GetCursorAccessibilityElement(); + if (pCursorAccessibilityElement && pPreviousAccessibilityElement && pCursorAccessibilityElement != pPreviousAccessibilityElement) + { + if (GetTextBoundsF().y - pPreviousAccessibilityElement->GetBounds().y > pPreviousAccessibilityElement->GetBounds().height) //check for different lines + { + float height = GetTextBoundsF().height + pPreviousAccessibilityElement->GetBounds().y + pPreviousAccessibilityElement->GetBounds().height; + if (pCurrentElement == pCursorAccessibilityElement && height > __pTokenEdit->GetBoundsF().height) + { + float tokenBottomMargin = 0.0f; + GET_SHAPE_CONFIG(TOKENEDIT::BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, tokenBottomMargin); + float newScrollValue = GetTextBoundsF().height + tokenBottomMargin - __scrollValue; + RecalculateTokenBounds(newScrollValue); + _AccessibilityManager::GetInstance()->SetGlobalFocusedElement(*(__pTokenEdit->GetCursorAccessibilityElement())); + _AccessibilityManager::GetInstance()->RequestToDrawFocusUi(); + } + } + } + } + + __focusOutIndex = -1; + UpdateTokenAccessibilityBounds(); + + return false; +} + +bool +_TokenEditPresenter::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + _AccessibilityElement* pAccessibilityElement = null; + pAccessibilityElement = const_cast< _AccessibilityElement* >(&element); + __accessibilityElements.IndexOf(pAccessibilityElement, __focusOutIndex); + + return false; +} + }}} //Tizen::Ui::Controls diff --git a/src/ui/inc/FUiCtrl_Edit.h b/src/ui/inc/FUiCtrl_Edit.h index c754a42..9b2729b 100644 --- a/src/ui/inc/FUiCtrl_Edit.h +++ b/src/ui/inc/FUiCtrl_Edit.h @@ -312,7 +312,7 @@ public: result SetTextPredictionEnabled(bool enable); result SetLimitLength(int limitLength); result SetLineSpacing(int linePixelGap); - result SetLineSpacing(float linePixelGap); + result SetLineSpacing(float linePixelGap); void SetLowerCaseModeEnabled(bool enable); void SetMaxLineCount(int maxLineCount); result SetKeypadCommandButton(CommandButtonPosition position, const Tizen::Base::String& text, int actionId); @@ -395,8 +395,8 @@ public: result AppendCharacter(const Tizen::Base::Character& character); result AppendText(const Tizen::Base::String& text); result BeginTextBlock(void); - bool CalculateAbsoluteCursorBounds(int index ,Tizen::Graphics::Rectangle& absCursorRect); - bool CalculateAbsoluteCursorBounds(int index ,Tizen::Graphics::FloatRectangle& absCursorRect); + bool CalculateAbsoluteCursorBounds(int index, Tizen::Graphics::Rectangle& absCursorRect); + bool CalculateAbsoluteCursorBounds(int index, Tizen::Graphics::FloatRectangle& absCursorRect); result ClearText(void); result CopyText(void); result CutText(void); @@ -420,7 +420,7 @@ public: bool IsViewModeEnabled(void) const; bool IsKeypadEnabled(void) const; bool IsTextPredictionEnabled(void) const; - void UpdateAccessibilityElement(EditAccessibilityElementType type); + virtual void UpdateAccessibilityElement(EditAccessibilityElementType type); void SetFullScreenKeypadEdit(bool enabled); bool IsFullScreenKeypadEdit(void); bool IsBorderRoundStyleEnabled(void) const; @@ -500,7 +500,8 @@ public: bool IsInternalFocused(void) const; bool ValidatePastedText(const Tizen::Base::String& pastedText, Tizen::Base::String& replacedText); void SetEditTextFilter(IEditTextFilter* pFilter); - void SendOpaqueCommand (const Tizen::Base::String& command); + void SendOpaqueCommand(const Tizen::Base::String& command); + _AccessibilityElement* GetTextAccessibilityElement(void) const; protected: result SetPresenter(const _EditPresenter& pPresenter); diff --git a/src/ui/inc/FUiCtrl_TokenEdit.h b/src/ui/inc/FUiCtrl_TokenEdit.h index 0a2b61d..aaeaae3 100644 --- a/src/ui/inc/FUiCtrl_TokenEdit.h +++ b/src/ui/inc/FUiCtrl_TokenEdit.h @@ -26,6 +26,7 @@ #include #include "FUiCtrl_Edit.h" #include "FUiCtrl_ITokenFilter.h" +#include "FUi_IAccessibilityListener.h" namespace Tizen { namespace Ui { @@ -44,6 +45,7 @@ class _TokenEdit , virtual public Tizen::Ui::_IUiEventPreviewer , virtual public Tizen::Ui::_ITouchGestureEventListener , public Tizen::Ui::Controls::_Edit + , public Tizen::Ui::_IAccessibilityListener { public: @@ -104,6 +106,26 @@ public: virtual result OnAttachedToMainTree(void); + virtual void UpdateAccessibilityElement(EditAccessibilityElementType type); + _AccessibilityElement* GetTitleTextAccessibilityElement(void) const; + _AccessibilityElement* GetCursorAccessibilityElement(void) const; + result AddTitleAccessibilityElement(void); + result AddCursorAccessibilityElement(void); + result SetCursorAccessibilityBounds(const FloatRectangle& cursorBounds); + void RemoveTitleAccessibilityElement(void); + void RemoveCursorAccessibilityElement(void); + + //_IAccessibilityListener callbacks + virtual bool OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element); + private: _TokenEdit(const _TokenEdit& rhs); _TokenEdit& operator =(const _TokenEdit& rhs); @@ -121,10 +143,9 @@ private: _ITokenFilter* __pTokenFilter; - Tizen::Ui::_AccessibilityElement* __pDescriptionTextAccessibilityElement; - Tizen::Ui::_AccessibilityElement* __pHiddenTokenCountAccessibilityElement; - Tizen::Ui::_AccessibilityElement* __pExpandableButtonAccessibilityElement; -}; // _TokenEdit + Tizen::Ui::_AccessibilityElement* __pTitleTextAccessibilityElement; + Tizen::Ui::_AccessibilityElement* __pCursorAccessibilityElement; +}; // _TokenEdit }}} // Tizen::Ui::Controls diff --git a/src/ui/inc/FUiCtrl_TokenEditPresenter.h b/src/ui/inc/FUiCtrl_TokenEditPresenter.h index 6c7a815..a9656b7 100644 --- a/src/ui/inc/FUiCtrl_TokenEditPresenter.h +++ b/src/ui/inc/FUiCtrl_TokenEditPresenter.h @@ -85,7 +85,7 @@ public: virtual result SetInitialBounds(void); - result CalculateDescriptionTextRect(const Tizen::Base::String& descriptionText); + result CalculateDescriptionTextRect(const Tizen::Base::String& titleText); virtual void OnCursorTimerExpired(void); @@ -143,15 +143,32 @@ public: virtual bool OnTapGestureDetected(void); virtual bool OnLongPressGestureDetected(void); - virtual void OnVisualElementAnimationFinished (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target, bool completedNormally); - virtual void OnVisualElementAnimationRepeated (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target, long currentRepeatCount){} - virtual void OnVisualElementAnimationStarted (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target){} + virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally); + virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount){} + virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target){} void OnBoundsChanged(void); virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); virtual result ChangeLayout(_ControlOrientation orientation); virtual void ResetTextBounds(void); virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo); + result AttachCursorToPressedToken(void); + + Tizen::Graphics::FloatRectangle GetDescriptionTextRect(void) const; + String GetTextAccessibilityElementText(void) const; + void RefreshAccessibilityElements(void); + result AddChildAccessibilityElements(void); + void RemoveChildAccessibilityElements(void); + result AppendTokenAccessibilityElement(void); + result InsertTokenAccessibilityElementAt(int index); + void RemoveTokenAccessibilityElementAt(int index); + result UpdateTokenAccessibilityBounds(void); + result UpdateTitleAccessibilityBounds(const FloatRectangle& titleBounds); + result ScrollToFocusedTokenAccessibilityElement(const _AccessibilityElement& element); + + //Accessibility callbacks + bool OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element); + bool OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element); private: bool DrawToken(int count = -1); @@ -160,7 +177,6 @@ private: result InitializeTokenVisibilityAt(int index); bool DrawDescriptionText(void); result SetDescriptionTextRect(const Tizen::Graphics::FloatRectangle& rect); - Tizen::Graphics::FloatRectangle GetDescriptionTextRect(void) const; result TrimTokenAndAdjustEllipsisAt(int index); int GetTokenIndexFromCoordinate(const Tizen::Graphics::Point point) const; result SetEditingTokenTextBounds(int index, bool isSetText = true); @@ -190,7 +206,7 @@ private: bool __isEditingToken; - int __edittingTokenIndex; + int __editingTokenIndex; Tizen::Graphics::FloatRectangle __clientRect; Tizen::Graphics::FloatRectangle __initTextRect; @@ -263,8 +279,11 @@ private: static const int ANIMATION_DURATION_OPACITY = 83; + int __focusOutIndex; + + Tizen::Base::Collection::LinkedListT< _AccessibilityElement* > __accessibilityElements; -}; // _TokenEditPresenter +}; // _TokenEditPresenter }}} // Tizen::Ui::Controls -- 2.7.4