#include <FBaseColIEnumeratorT.h>
#include "FUi_ControlImplManager.h"
#include "FUi_ResourceManager.h"
+#include "FUi_KeyEventManager.h"
#include "FUiAnim_VisualElement.h"
#include "FUiAnim_AnimationManager.h"
#include "FUi_AccessibilityContainer.h"
namespace Tizen { namespace Ui { namespace Controls
{
+class _ContextMenu::_ContextMenuHwKeyEventListener
+ : public _IKeyEventListener
+ , virtual public _IUiEventListener
+ , virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ _ContextMenuHwKeyEventListener(_ContextMenu* pContextMenu)
+ {
+ __pContextMenu = pContextMenu;
+ }
+
+ virtual ~_ContextMenuHwKeyEventListener(void)
+ {
+ }
+
+ virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
+ {
+ _KeyCode keyCode = keyInfo.GetKeyCode();
+
+ switch (keyCode) {
+ case _KEY_MENU:
+ // fall through
+ case _KEY_CONTEXT_MENU:
+ // fall through
+ case _KEY_ESC:
+ // fall through
+ case _KEY_BACK:
+ return __pContextMenu->__pContextMenuPresenter->OnKeyPressed(source, keyInfo);
+ default:
+ return false;
+ }
+ }
+
+ virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
+ {
+ _KeyCode keyCode = keyInfo.GetKeyCode();
+
+ switch (keyCode) {
+ case _KEY_MENU:
+ // fall through
+ case _KEY_CONTEXT_MENU:
+ // fall through
+ case _KEY_ESC:
+ // fall through
+ case _KEY_BACK:
+ return __pContextMenu->__pContextMenuPresenter->OnKeyReleased(source, keyInfo);
+ default:
+ return false;
+ }
+ }
+
+private:
+ _ContextMenuHwKeyEventListener(const _ContextMenu& rhs);
+ _ContextMenuHwKeyEventListener& operator =(const _ContextMenu& rhs);
+
+private:
+ _ContextMenu* __pContextMenu;
+}; // _ContextMenuHwKeyEventListener
+
IMPLEMENT_PROPERTY(_ContextMenu);
_ContextMenu::_ContextMenu(const FloatPoint& point, enum ContextMenuCoreStyle style, enum ContextMenuCoreAlign contextMenuAlign)
, __layout(_CONTROL_ORIENTATION_PORTRAIT)
, __rotation(_CONTROL_ROTATION_0)
, __pScrollPanel(null)
+ , __pHwKeyEventListener(null)
{
__backgroundColor = Color(255, 255, 255, 255);
GetOwner()->UnlockInputEvent();
}
+ if (__pHwKeyEventListener != null)
+ {
+ _KeyEventManager::GetInstance()->RemoveKeyEventListener(*__pHwKeyEventListener);
+ delete __pHwKeyEventListener;
+ __pHwKeyEventListener = null;
+ }
+
if (__pScrollPanel) {
__pScrollPanel->DetachAllChildren();
DetachChild(*__pScrollPanel);
r = __pContextMenuPresenter->CalculateWindowRect();
SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ if (__pScrollPanel != null)
+ {
+ __pScrollPanel->SetScrollPosition(0.0f, false);
+ }
+
r = Open();
SetVisibleState(true);
+ if (!this->IsFocusable())
+ {
+ if (__pHwKeyEventListener == null)
+ {
+ __pHwKeyEventListener = new (std::nothrow) _ContextMenuHwKeyEventListener(this);
+ }
+
+ if (__pHwKeyEventListener != null)
+ {
+ _KeyEventManager::GetInstance()->AddKeyEventListener(*__pHwKeyEventListener);
+ }
+ }
+
if (__style == CONTEXT_MENU_CORE_STYLE_LIST)
{
SetTouchCapture(false, false);
{
result r = E_SUCCESS;
+ if (__pHwKeyEventListener != null)
+ {
+ _KeyEventManager::GetInstance()->RemoveKeyEventListener(*__pHwKeyEventListener);
+ }
+
ReleaseTouchCapture();
_Control* pOwner = GetOwner();
, __bgPressedMargin(0.0f)
, __anchorPopupOverlap(0.0f)
, __enterKeyPressed(false)
+ , __backKeyPressed(false)
, __focusedIndex(-1)
{
{
FloatRectangle pressedDrawRect = pItem->GetPressedDrawRect();
+ Color contentHighlightedColor;
+ GET_COLOR_CONFIG(FOCUSUI::CONTENT_BG_HIGHLIGHTED, contentHighlightedColor);
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.");
-
+ Bitmap* pTempBitmap = null;
+ result r = GET_BITMAP_CONFIG_N(FOCUSUI::FOCUS, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
+ SysTryReturn(NID_UI_CTRL, pTempBitmap != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
if (r == E_SUCCESS)
{
- DrawBitmap(*pCanvas, pressedDrawRect, *pBitmap);
+ pBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentHighlightedColor);
+ if (pBitmap != null)
+ {
+ DrawBitmap(*pCanvas, pressedDrawRect, *pBitmap);
+ }
}
+ delete pTempBitmap;
+ pTempBitmap = null;
+
delete pBitmap;
pBitmap = null;
}
{
__selectedIndex = -1;
__pressedIndex = -1;
+ __focusedIndex = -1;
__pContextMenu->SetFocused(false);
__pContextMenu->SetVisibleState(false);
return true;
__selectedIndex = -1;
__pressedIndex = -1;
+ __focusedIndex = -1;
int actionId = pItem->GetActionId();
// fall through
case _KEY_UP:
{
+ if (__focusedIndex == -1)
+ {
+ break;
+ }
+
if (__enterKeyPressed)
{
__enterKeyPressed = false;
__selectedIndex = -1;
}
- if (__focusedIndex <= 0)
+ _ContextMenuItem* pItem = __pModel->GetItem(--__focusedIndex);
+ if (pItem == null)
{
+ __focusedIndex++;
break;
}
-
- --__focusedIndex;
- _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
pItem->SetFocused(true);
Draw();
// fall through
case _KEY_DOWN:
{
+ if (__focusedIndex == -1)
+ {
+ break;
+ }
+
if (__enterKeyPressed)
{
__enterKeyPressed = false;
__selectedIndex = -1;
}
- if (__focusedIndex >= __pModel->GetItemCount() - 1)
+ _ContextMenuItem* pItem = __pModel->GetItem(++__focusedIndex);
+ if (pItem == null)
{
+ __focusedIndex--;
break;
}
-
- ++__focusedIndex;
- _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
pItem->SetFocused(true);
Draw();
}
case _KEY_ENTER:
{
+ __enterKeyPressed = true;
+
if (__focusedIndex == -1)
{
- return true;
+ break;
}
- __enterKeyPressed = true;
__selectedIndex = __focusedIndex;
-
_ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
pItem->SetFocused(true);
Draw();
}
case _KEY_BACKSPACE:
{
- if (__focusedIndex == -1)
- {
- return true;
- }
-
_ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
if (pItem != null)
{
pItem->SetFocused(false);
}
+
__enterKeyPressed = false;
+ __backKeyPressed = false;
+ __pressedIndex = -1;
__selectedIndex = -1;
__focusedIndex = -1;
__pContextMenu->SetFocused(false);
__pContextMenu->SetVisibleState(false);
+
break;
}
+ case _KEY_ESC:
+ // fall through
+ case _KEY_MENU:
+ // fall through
+ case _KEY_CONTEXT_MENU:
+ // fall through
+ case _KEY_BACK:
+ __backKeyPressed = true;
+ break;
default:
return false;
}
case _KEY_DOWN:
// fall through
case _KEY_BACKSPACE:
- return true;
+ break;
case _KEY_ENTER:
{
if (!__enterKeyPressed)
}
__enterKeyPressed = false;
-
- _ActionEvent* pActionEvent = __pContextMenu->GetActionEvent();
-
- if (pActionEvent == null)
- {
- __pContextMenu->SetFocused(false);
- __pContextMenu->SetVisibleState(false);
- return true;
- }
+ __backKeyPressed = false;
_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;
+
+ break;
+ }
+
+ int actionId = pItem->GetActionId();
+
+ _ActionEvent* pActionEvent = __pContextMenu->GetActionEvent();
+ if (pActionEvent == null)
+ {
+ break;
+ }
+
+ IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId);
+ if (pEventArg == null)
+ {
+ break;
}
+ pActionEvent->Fire(*pEventArg);
+
__selectedIndex = -1;
__pressedIndex = -1;
__focusedIndex = -1;
+ pItem->SetFocused(false);
+ __pContextMenu->SetFocused(false);
+ __pContextMenu->SetVisibleState(false);
- int actionId = pItem->GetActionId();
-
- IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId);
+ break;
+ }
+ case _KEY_ESC:
+ // fall through
+ case _KEY_MENU:
+ // fall through
+ case _KEY_CONTEXT_MENU:
+ // fall through
+ case _KEY_BACK:
+ {
+ if (!__backKeyPressed)
+ {
+ return true;
+ }
- if (pEventArg == null)
+ _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
+ if (pItem != null)
{
pItem->SetFocused(false);
- __pContextMenu->SetFocused(false);
- __pContextMenu->SetVisibleState(false);
- return true;
}
- pItem->SetFocused(false);
+ __enterKeyPressed = false;
+ __backKeyPressed = false;
+ __selectedIndex = -1;
+ __pressedIndex = -1;
+ __focusedIndex = -1;
__pContextMenu->SetFocused(false);
__pContextMenu->SetVisibleState(false);
- pActionEvent->Fire(*pEventArg);
break;
}
default:
- return false;
+ return false;
}
return true;
void
_ContextMenuGridPresenter::OnDrawFocus(void)
{
- __focusedIndex = 0;
+ if (__focusedIndex == -1)
+ {
+ __focusedIndex = 0;
+ }
__selectedIndex = -1;
+
Draw();
}
__pLowerDividerLineLabel = null;
}
+ delete __pTextLabel;
+ __pTextLabel = null;
+
+ delete __pBitmapLabel;
+ __pBitmapLabel = null;
+
_AccessibilityContainer* pContainer = GetAccessibilityContainer();
if (pContainer)
{
, __dividerHeight(0.0f)
, __anchorPopupOverlap(0.0f)
, __enterKeyPressed(false)
+ , __backKeyPressed(false)
+ , __focusedIndex(-1)
{
}
if (!itemRect.Contains(touchPosition))
{
__selectedIndex = -1;
+ __focusedIndex = -1;
__pContextMenu->SetFocused(false);
__pContextMenu->SetVisibleState(false);
pItem = __pModel->GetItem(__selectedIndex);
__selectedIndex = -1;
+ __focusedIndex = -1;
__pContextMenu->SetFocused(false);
__pContextMenu->SetVisibleState(false);
_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)
+ if (__focusedIndex == -1)
{
- return true;
+ break;
}
if (__enterKeyPressed)
{
__enterKeyPressed = false;
- _ContextMenuItem* pItem = __pModel->GetItem(focusedIndex);
- pItem->SetAndInvalidate(false);
+ _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
+ if (pItem != null)
+ {
+ pItem->SetAndInvalidate(false);
+ }
}
- if (focusedIndex <= 0)
+ _ContextMenuItem* pItem = __pModel->GetItem(--__focusedIndex);
+ if(pItem == null)
{
+ __focusedIndex++;
break;
}
- _ContextMenuItem* pItem = __pModel->GetItem(--focusedIndex);
- if(pItem != null)
- {
- pItem->SetFocused(true);
- pItem->DrawFocus();
- }
+ pItem->SetFocused(true);
+ pItem->DrawFocus();
+ __pContextMenu->GetScrollPanel()->OnChildControlFocusMoved(*pItem);
+
break;
}
case _KEY_DOWN:
{
- if (focusedIndex == -1)
+ if (__focusedIndex == -1)
{
- return true;
+ break;
}
if (__enterKeyPressed)
{
__enterKeyPressed = false;
- _ContextMenuItem* pItem = __pModel->GetItem(focusedIndex);
- pItem->SetAndInvalidate(false);
+ _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
+ if(pItem != null)
+ {
+ pItem->SetAndInvalidate(false);
+ }
}
- if (focusedIndex >= __pModel->GetItemCount() - 1)
+ _ContextMenuItem* pItem = __pModel->GetItem(++__focusedIndex);
+ if(pItem == null)
{
+ __focusedIndex--;
break;
}
- _ContextMenuItem* pItem = __pModel->GetItem(++focusedIndex);
- if(pItem != null)
- {
- pItem->SetFocused(true);
- pItem->DrawFocus();
- }
+ pItem->SetFocused(true);
+ pItem->DrawFocus();
+ __pContextMenu->GetScrollPanel()->OnChildControlFocusMoved(*pItem);
+
break;
}
case _KEY_ENTER:
{
- if (focusedIndex == -1)
+ __enterKeyPressed = true;
+
+ _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
+ if(pItem != null)
{
- return true;
+ pItem->SetAndInvalidate(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);
+ _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
if (pItem != null)
{
- pItem->SetAndInvalidate(false);
pItem->SetFocused(false);
- pItem->DrawFocus();
pItem->SetAndInvalidate(false);
}
__enterKeyPressed = false;
+ __backKeyPressed = false;
__selectedIndex = -1;
+ __focusedIndex = -1;
__pContextMenu->SetFocused(false);
__pContextMenu->SetVisibleState(false);
+
break;
}
+ case _KEY_ESC:
+ // fall through
+ case _KEY_MENU:
+ // fall through
+ case _KEY_CONTEXT_MENU:
+ // fall through
+ case _KEY_BACK:
+ __backKeyPressed = true;
+ break;
default:
- return false;
+ return false;
}
return true;
case _KEY_DOWN:
// fall through
case _KEY_BACKSPACE:
- return true;
+ break;
case _KEY_ENTER:
{
if (!__enterKeyPressed)
}
__enterKeyPressed = false;
+ __backKeyPressed = false;
+
+ _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
- _Control* pFocusedControl = null;
- _Window* pTop = source.GetRootWindow();
- if (pTop)
+ if (pItem == null)
{
- pFocusedControl = pTop->GetCurrentFocusControl();
+ __selectedIndex = -1;
+ __focusedIndex = -1;
+ __pContextMenu->SetFocused(false);
+ __pContextMenu->SetVisibleState(false);
+
+ break;
}
- _ContextMenuItem* pItem = null;
+ int actionId = pItem->GetActionId();
- for (int i = 0; i < __pModel->GetItemCount(); i++)
+ _ActionEvent* pActionEvent = __pContextMenu->GetActionEvent();
+ if (pActionEvent == null)
{
- pItem = __pModel->GetItem(i);
- if (pFocusedControl == pItem)
- {
- break;
- }
+ break;
}
- if (pItem == null)
+ IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId);
+ if (pEventArg == null)
{
- return false;
+ break;
}
+ pActionEvent->Fire(*pEventArg);
+
pItem->SetFocused(false);
- pItem->DrawFocus();
pItem->SetAndInvalidate(false);
__selectedIndex = -1;
+ __focusedIndex = -1;
__pContextMenu->SetFocused(false);
__pContextMenu->SetVisibleState(false);
- int actionId = pItem->GetActionId();
-
- _ActionEvent* pActionEvent = __pContextMenu->GetActionEvent();
- if (pActionEvent == null)
+ break;
+ }
+ case _KEY_ESC:
+ // fall through
+ case _KEY_MENU:
+ // fall through
+ case _KEY_CONTEXT_MENU:
+ // fall through
+ case _KEY_BACK:
+ {
+ if (!__backKeyPressed)
{
return true;
}
- IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId);
- if (pEventArg == null)
+ _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
+ if (pItem != null)
{
- return true;
+ pItem->SetFocused(false);
+ pItem->SetAndInvalidate(false);
}
- pActionEvent->Fire(*pEventArg);
+ __enterKeyPressed = false;
+ __backKeyPressed = false;
+ __selectedIndex = -1;
+ __focusedIndex = -1;
+ __pContextMenu->SetFocused(false);
+ __pContextMenu->SetVisibleState(false);
break;
}
default:
- return false;
+ return false;
}
return true;
_ContextMenuListPresenter::IsChildControlFocusManage(void) const
{
return true;
+
}
void
_ContextMenuListPresenter::OnDrawFocus(void)
{
- _ContextMenuItem* pItem = __pModel->GetItem(0);
+ _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
+ if (pItem == null)
+ {
+ __focusedIndex = 0;
+ pItem = __pModel->GetItem(__focusedIndex);
+ }
+
if (pItem != null)
{
pItem->SetFocused(true);
pItem->DrawFocus();
+ __pContextMenu->GetScrollPanel()->OnChildControlFocusMoved(*pItem);
}
}
_ScrollPanel* __pScrollPanel;
+ class _ContextMenuHwKeyEventListener;
+ _ContextMenuHwKeyEventListener* __pHwKeyEventListener;
}; // _ContextMenu
}}} // Tizen::Ui: Control
float __anchorPopupOverlap;
bool __enterKeyPressed;
+ bool __backKeyPressed;
int __focusedIndex;
}; // _ContextMenuGridPresenter
float __anchorPopupOverlap;
bool __enterKeyPressed;
+ bool __backKeyPressed;
+ int __focusedIndex;
}; // _ContextMenuListPresenter
}}} // Tizen::Ui: Control