GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, minHeight);
pContextMenu->__pScrollPanel = _ScrollPanel::CreateScrollPanelN(FloatRectangle(0.0f, 0.0f, minWidth, minHeight), SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL, false, false);
pContextMenu->__pScrollPanel->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
- pContextMenu->__pScrollPanel->SetFocusable(false);
_Scroll* pScroll = pContextMenu->__pScrollPanel->GetScrollBar();
SysTryCatch(NID_UI_CTRL, pScroll, , E_INVALID_STATE, "[E_INVALID_STATE] _Scroll isn't constructed");
}
}
-bool
-_ContextMenu::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
-{
- return __pContextMenuPresenter->OnKeyPressed(source, keyInfo);
-}
-
-bool
-_ContextMenu::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
-{
- return __pContextMenuPresenter->OnKeyReleased(source, keyInfo);
-}
-
-bool
-_ContextMenu::IsChildControlFocusManage(void) const
-{
- return __pContextMenuPresenter->IsChildControlFocusManage();
-}
-
-void
-_ContextMenu::OnDrawFocus(void)
-{
- __pContextMenuPresenter->OnDrawFocus();
-}
-
-void
-_ContextMenu::OnFocusModeStateChanged(void)
-{
- __pContextMenuPresenter->OnFocusModeStateChanged();
-}
-
_AccessibilityElement*
_ContextMenu::GetAccessibilityElement(const int mainIndex) const
{
, __dividerHeight(0.0f)
, __bgPressedMargin(0.0f)
, __anchorPopupOverlap(0.0f)
- , __enterKeyPressed(false)
- , __focusedIndex(-1)
{
}
}
ContextMenuItemDrawingType itemType = pItem->GetType();
-
if (itemType == CONTEXT_MENU_ITEM_DRAWING_TYPE_TEXT)
{
FloatRectangle drawRect = rect;
DrawBitmap(*pCanvas, drawRect, *pBitmap);
}
}
-
- if (__focusedIndex == i)
- {
- FloatRectangle pressedDrawRect = pItem->GetPressedDrawRect();
-
- Bitmap* pBitmap = null;
- result r = GET_BITMAP_CONFIG_N(FOCUSUI::FOCUS, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap);
- SysTryReturn(NID_UI_CTRL, pBitmap, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
-
- if (r == E_SUCCESS)
- {
- DrawBitmap(*pCanvas, pressedDrawRect, *pBitmap);
- }
-
- delete pBitmap;
- pBitmap = null;
- }
-
}
return r;
if (__touchOutRect == true)
{
- __pContextMenu->SetFocused(false);
__pContextMenu->SetVisibleState(false);
}
if (pActionEvent == null)
{
- __pContextMenu->SetFocused(false);
__pContextMenu->SetVisibleState(false);
return true;
}
{
__selectedIndex = -1;
__pressedIndex = -1;
- __pContextMenu->SetFocused(false);
__pContextMenu->SetVisibleState(false);
return true;
}
if (pEventArg == null)
{
- __pContextMenu->SetFocused(false);
__pContextMenu->SetVisibleState(false);
return true;
}
PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, __pContextMenu);
- __pContextMenu->SetFocused(false);
__pContextMenu->SetVisibleState(false);
pActionEvent->Fire(*pEventArg);
}
return true;
}
-bool
-_ContextMenuGridPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
-{
- _KeyCode keyCode = keyInfo.GetKeyCode();
-
- switch (keyCode)
- {
- case _KEY_LEFT:
- // fall through
- case _KEY_UP:
- {
- if (__enterKeyPressed)
- {
- __enterKeyPressed = false;
- __selectedIndex = -1;
- }
-
- if (__focusedIndex <= 0)
- {
- break;
- }
-
- --__focusedIndex;
- _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
- pItem->SetFocused(true);
- Draw();
-
- break;
- }
- case _KEY_RIGHT:
- // fall through
- case _KEY_DOWN:
- {
- if (__enterKeyPressed)
- {
- __enterKeyPressed = false;
- __selectedIndex = -1;
- }
-
- if (__focusedIndex >= __pModel->GetItemCount() - 1)
- {
- break;
- }
-
- ++__focusedIndex;
- _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
- pItem->SetFocused(true);
- Draw();
-
- break;
- }
- case _KEY_ENTER:
- {
- if (__focusedIndex == -1)
- {
- return true;
- }
-
- __enterKeyPressed = true;
- __selectedIndex = __focusedIndex;
-
- _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
- pItem->SetFocused(true);
- Draw();
-
- break;
- }
- case _KEY_BACKSPACE:
- {
- if (__focusedIndex == -1)
- {
- return true;
- }
-
- _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
- if (pItem != null)
- {
- pItem->SetFocused(false);
- }
- __enterKeyPressed = false;
- __selectedIndex = -1;
- __focusedIndex = -1;
-
- __pContextMenu->SetFocused(false);
- __pContextMenu->SetVisibleState(false);
- break;
- }
- default:
- return false;
- }
-
- return true;
-}
-
-bool
-_ContextMenuGridPresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
-{
- _KeyCode keyCode = keyInfo.GetKeyCode();
-
- switch (keyCode)
- {
- case _KEY_LEFT:
- // fall through
- case _KEY_UP:
- // fall through
- case _KEY_RIGHT:
- // fall through
- case _KEY_DOWN:
- // fall through
- case _KEY_BACKSPACE:
- return true;
- case _KEY_ENTER:
- {
- if (!__enterKeyPressed)
- {
- return true;
- }
-
- __enterKeyPressed = false;
-
- _ActionEvent* pActionEvent = __pContextMenu->GetActionEvent();
-
- if (pActionEvent == null)
- {
- __pContextMenu->SetFocused(false);
- __pContextMenu->SetVisibleState(false);
- return true;
- }
-
- _ContextMenuItem* pItem = __pModel->GetItem(__selectedIndex);
- if (pItem == null)
- {
- __selectedIndex = -1;
- __pressedIndex = -1;
- __focusedIndex = -1;
- pItem->SetFocused(false);
- __pContextMenu->SetFocused(false);
- __pContextMenu->SetVisibleState(false);
- return true;
- }
-
- __selectedIndex = -1;
- __pressedIndex = -1;
- __focusedIndex = -1;
-
- int actionId = pItem->GetActionId();
-
- IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId);
-
- if (pEventArg == null)
- {
- pItem->SetFocused(false);
- __pContextMenu->SetFocused(false);
- __pContextMenu->SetVisibleState(false);
- return true;
- }
-
- pItem->SetFocused(false);
- __pContextMenu->SetFocused(false);
- __pContextMenu->SetVisibleState(false);
- pActionEvent->Fire(*pEventArg);
-
- break;
- }
- default:
- return false;
- }
-
- return true;
-}
-
-bool
-_ContextMenuGridPresenter::IsChildControlFocusManage(void) const
-{
- return true;
-}
-
-void
-_ContextMenuGridPresenter::OnDrawFocus(void)
-{
- __focusedIndex = 0;
- __selectedIndex = -1;
- Draw();
-}
-
-void
-_ContextMenuGridPresenter::OnFocusModeStateChanged(void)
-{
- __focusedIndex = -1;
- Draw();
-}
-
void
_ContextMenuGridPresenter::OnFontChanged(Font* pFont)
{
, __itemFontSize(0.0f)
, __dividerHeight(0.0f)
, __anchorPopupOverlap(0.0f)
- , __enterKeyPressed(false)
{
}
if (!itemRect.Contains(touchPosition))
{
__selectedIndex = -1;
- __pContextMenu->SetFocused(false);
__pContextMenu->SetVisibleState(false);
return true;
pItem = __pModel->GetItem(__selectedIndex);
__selectedIndex = -1;
- __pContextMenu->SetFocused(false);
__pContextMenu->SetVisibleState(false);
int actionId = pItem->GetActionId();
return true;
}
-bool
-_ContextMenuListPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
-{
- _KeyCode keyCode = keyInfo.GetKeyCode();
- _Control* pFocusedControl = null;
- _Window* pTop = source.GetRootWindow();
- if (pTop)
- {
- pFocusedControl = pTop->GetCurrentFocusControl();
- }
-
- int focusedIndex = -1;
-
- for (int i = 0; i < __pModel->GetItemCount(); i++)
- {
- _ContextMenuItem* pItem = __pModel->GetItem(i);
- if (pFocusedControl == pItem)
- {
- focusedIndex = i;
- break;
- }
- }
-
- switch (keyCode)
- {
- case _KEY_UP:
- {
- if (focusedIndex == -1)
- {
- return true;
- }
-
- if (__enterKeyPressed)
- {
- __enterKeyPressed = false;
- _ContextMenuItem* pItem = __pModel->GetItem(focusedIndex);
- pItem->SetAndInvalidate(false);
- }
-
- if (focusedIndex <= 0)
- {
- break;
- }
-
- _ContextMenuItem* pItem = __pModel->GetItem(--focusedIndex);
- if(pItem != null)
- {
- pItem->SetFocused(true);
- pItem->DrawFocus();
- }
- break;
- }
- case _KEY_DOWN:
- {
- if (focusedIndex == -1)
- {
- return true;
- }
-
- if (__enterKeyPressed)
- {
- __enterKeyPressed = false;
- _ContextMenuItem* pItem = __pModel->GetItem(focusedIndex);
- pItem->SetAndInvalidate(false);
- }
-
- if (focusedIndex >= __pModel->GetItemCount() - 1)
- {
- break;
- }
-
- _ContextMenuItem* pItem = __pModel->GetItem(++focusedIndex);
- if(pItem != null)
- {
- pItem->SetFocused(true);
- pItem->DrawFocus();
- }
- break;
- }
- case _KEY_ENTER:
- {
- if (focusedIndex == -1)
- {
- return true;
- }
-
- __enterKeyPressed = true;
- _ContextMenuItem* pItem = __pModel->GetItem(focusedIndex);
- pItem->SetAndInvalidate(true);
-
- break;
- }
- case _KEY_BACKSPACE:
- {
- if (focusedIndex == -1)
- {
- return true;
- }
-
- _ContextMenuItem* pItem = __pModel->GetItem(focusedIndex);
- if (pItem != null)
- {
- pItem->SetAndInvalidate(false);
- pItem->SetFocused(false);
- pItem->DrawFocus();
- pItem->SetAndInvalidate(false);
- }
-
- __enterKeyPressed = false;
- __selectedIndex = -1;
- __pContextMenu->SetFocused(false);
- __pContextMenu->SetVisibleState(false);
- break;
- }
- default:
- return false;
- }
-
- return true;
-}
-
-bool
-_ContextMenuListPresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
-{
- _KeyCode keyCode = keyInfo.GetKeyCode();
-
- switch (keyCode)
- {
- case _KEY_UP:
- // fall through
- case _KEY_DOWN:
- // fall through
- case _KEY_BACKSPACE:
- return true;
- case _KEY_ENTER:
- {
- if (!__enterKeyPressed)
- {
- return true;
- }
-
- __enterKeyPressed = false;
-
- _Control* pFocusedControl = null;
- _Window* pTop = source.GetRootWindow();
- if (pTop)
- {
- pFocusedControl = pTop->GetCurrentFocusControl();
- }
-
- _ContextMenuItem* pItem = null;
-
- for (int i = 0; i < __pModel->GetItemCount(); i++)
- {
- pItem = __pModel->GetItem(i);
- if (pFocusedControl == pItem)
- {
- break;
- }
- }
-
- if (pItem == null)
- {
- return false;
- }
-
- pItem->SetFocused(false);
- pItem->DrawFocus();
- pItem->SetAndInvalidate(false);
-
- __selectedIndex = -1;
- __pContextMenu->SetFocused(false);
- __pContextMenu->SetVisibleState(false);
-
- int actionId = pItem->GetActionId();
-
- _ActionEvent* pActionEvent = __pContextMenu->GetActionEvent();
- if (pActionEvent == null)
- {
- return true;
- }
-
- IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId);
- if (pEventArg == null)
- {
- return true;
- }
-
- pActionEvent->Fire(*pEventArg);
-
- break;
- }
- default:
- return false;
- }
-
- return true;
-}
-
-bool
-_ContextMenuListPresenter::IsChildControlFocusManage(void) const
-{
- return true;
-}
-
-void
-_ContextMenuListPresenter::OnDrawFocus(void)
-{
- _ContextMenuItem* pItem = __pModel->GetItem(0);
- if (pItem != null)
- {
- pItem->SetFocused(true);
- pItem->DrawFocus();
- }
-}
-
-void
-_ContextMenuListPresenter::OnFocusModeStateChanged(void)
-{
- _Control* pFocusedControl = null;
- _Window* pTop = __pContextMenu->GetRootWindow();
- if (pTop)
- {
- pFocusedControl = pTop->GetCurrentFocusControl();
- }
-
- if (pFocusedControl != null)
- {
- pFocusedControl->SetFocused(false);
- }
-}
-
void
_ContextMenuListPresenter::OnFontChanged(Tizen::Graphics::Font* pFont)
{
virtual void OnChangeLayout(_ControlOrientation orientation);
virtual void OnOwnerChanged(_Control* pOldOwner);
- // Focus Ui
- virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
- virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo);
- virtual bool IsChildControlFocusManage(void) const;
- virtual void OnDrawFocus(void);
- virtual void OnFocusModeStateChanged(void);
-
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 OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo);
- // Focus Ui
- virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
- virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo);
- virtual bool IsChildControlFocusManage(void) const;
- virtual void OnDrawFocus(void);
- virtual void OnFocusModeStateChanged(void);
-
virtual void OnFontChanged(Tizen::Graphics::Font* pFont);
virtual void OnFontInfoRequested(unsigned long& style, float& size);
float __dividerHeight;
float __bgPressedMargin;
float __anchorPopupOverlap;
-
- bool __enterKeyPressed;
- int __focusedIndex;
}; // _ContextMenuGridPresenter
}}} // Tizen::Ui: Control
virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo);
- // Focus Ui
- virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
- virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo);
- virtual bool IsChildControlFocusManage(void) const;
- virtual void OnDrawFocus(void);
- virtual void OnFocusModeStateChanged(void);
-
virtual void OnFontChanged(Tizen::Graphics::Font* pFont);
virtual void OnFontInfoRequested(unsigned long& style, float& size);
float __itemFontSize;
float __dividerHeight;
float __anchorPopupOverlap;
-
- bool __enterKeyPressed;
}; // _ContextMenuListPresenter
}}} // Tizen::Ui: Control
virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) = 0;
virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) = 0;
- // Focus Ui
- virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo) { return false; };
- virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo) { return false; };
- virtual bool IsChildControlFocusManage(void) const { return false; };
- virtual void OnDrawFocus(void) {};
- virtual void OnFocusModeStateChanged(void) {};
-
virtual void OnFontChanged(Tizen::Graphics::Font* pFont) = 0;
virtual void OnFontInfoRequested(unsigned long& style, float& size) = 0;