From: minsung Date: Fri, 7 Jun 2013 11:58:52 +0000 (+0530) Subject: modified focus ui in TableView X-Git-Tag: submit/tizen_2.2/20130714.153149~609^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2c0907d6bfb4dd74d87d28919949e67d4e831985;p=framework%2Fosp%2Fuifw.git modified focus ui in TableView Change-Id: I7912c4ec15642a6e9c871e6ecb08f8d75ca6095d Signed-off-by: minsung --- diff --git a/src/ui/controls/FUiCtrl_TableView.cpp b/src/ui/controls/FUiCtrl_TableView.cpp index bf30055..ab68dbd 100644 --- a/src/ui/controls/FUiCtrl_TableView.cpp +++ b/src/ui/controls/FUiCtrl_TableView.cpp @@ -1383,4 +1383,16 @@ _TableView::IsChildControlFocusManage(void) const { return true; } + +void +_TableView::OnDrawFocus(void) +{ + return __pTableViewPresenter->OnDrawFocus(); +} + +void +_TableView::OnFocusModeStateChanged(void) +{ + return __pTableViewPresenter->OnFocusModeStateChanged(); +} }}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TableViewItem.cpp b/src/ui/controls/FUiCtrl_TableViewItem.cpp index af8a32b..eaace57 100644 --- a/src/ui/controls/FUiCtrl_TableViewItem.cpp +++ b/src/ui/controls/FUiCtrl_TableViewItem.cpp @@ -3638,7 +3638,6 @@ _TableViewItem::SetSectionHeaderFooterContents(const Tizen::Base::String& text, positionY = GetBoundsF().height - contentsHeight; } __pHeaderFooterItemText->Construct(FloatRectangle(0.0f, positionY, GetBoundsF().width, contentsHeight), text); - __pHeaderFooterItemText->SetTextHorizontalAlignment(alignment); __pHeaderFooterItemText->SetTextColor(textColor); __pHeaderFooterItemText->SetBackgroundColor(Color(0, 0, 0, 0)); @@ -4590,28 +4589,171 @@ _TableViewItem::OnAccessibilityValueDecreased(const _AccessibilityContainer& con bool _TableViewItem::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo) { - _KeyCode keyCode = keyInfo.GetKeyCode(); - _Control* pFocusedControl = null; + _KeyCode keyCode = keyInfo.GetKeyCode(); + IListT<_Control*>* pFocusList = GetFocusListN(); + _Control* pChildControl = null; + _Control* pFocusedControl = null; _Window* pTop = source.GetRootWindow(); + if (pTop) { pFocusedControl = pTop->GetFocusControl(); } - _Control* pChildControl = null; - switch (keyCode) - { - case _KEY_LEFT: - if (pFocusedControl != null) - { - pChildControl = GetPreviousFocusChildControl(*pFocusedControl); - } - break; + int count = pFocusList->GetCount(); + + if (pFocusedControl == null) + { + return false; + } + + switch (keyCode) + { + case _KEY_LEFT: + if (pFocusList == null) + { + break; + } + + if (IsFocused() == false) + { + for(int i=0; iGetAt(i, pChildControl); + if (pChildControl == null) + { + continue; + } + + if (pChildControl->IsFocused()) + { + if (i == count -1) + { + pChildControl = null; + break; + } + + for (int j=i+1; jGetAt(j, pChildControl); + if (pChildControl == null) + { + continue; + } + + if (pChildControl->IsFocusable()) + { + break; + } + else + { + pChildControl = null; + } + } + break; + } + } + } + + if (pChildControl == null) + { + for (int i=0; iGetAt(i, pChildControl); + if (pChildControl == null) + { + continue; + } + + if (pChildControl->IsFocusable()) + { + break; + } + else + { + pChildControl = null; + } + } + } + + if (pChildControl) + { + pChildControl->SetFocused(true); + pChildControl->DrawFocus(); + } + break; case _KEY_RIGHT: - if (pFocusedControl != null) + if (pFocusList == null) + { + break; + } + + if (IsFocused() == false) + { + for(int i=count-1; i>=0; i--) + { + pFocusList->GetAt(i, pChildControl); + if (pChildControl == null) + { + continue; + } + + if (pChildControl->IsFocused()) + { + if (i == 0) + { + pChildControl = null; + break; + } + + for(int j=i-1; j>=0; j--) + { + pFocusList->GetAt(j, pChildControl); + if (pChildControl == null) + { + continue; + } + + if (pChildControl->IsFocusable()) + { + break; + } + else + { + pChildControl = null; + } + } + break; + } + } + } + + if (pChildControl == null) + { + for (int i=count-1; i>=0; i--) + { + pFocusList->GetAt(i, pChildControl); + if (pChildControl == null) + { + continue; + } + + if (pChildControl->IsFocusable()) + { + break; + } + else + { + pChildControl = null; + } + } + } + + if (pChildControl) { - pChildControl = GetNextFocusChildControl(*pFocusedControl); + pChildControl->SetFocused(true); + pChildControl->DrawFocus(); } break; @@ -4640,23 +4782,6 @@ _TableViewItem::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo) return false; } - if (keyCode == _KEY_LEFT || keyCode == _KEY_RIGHT) - { - if (pFocusedControl != null) - { - if (pChildControl) - { - pChildControl->SetFocused(true); - pChildControl->DrawFocus(); - } - else - { - _Control* pParentControl = pFocusedControl->GetParent(); - pParentControl->SetFocused(true); - pParentControl->DrawFocus(); - } - } - } return true; } diff --git a/src/ui/controls/FUiCtrl_TableViewPresenter.cpp b/src/ui/controls/FUiCtrl_TableViewPresenter.cpp index da1a8fb..d6a7db9 100644 --- a/src/ui/controls/FUiCtrl_TableViewPresenter.cpp +++ b/src/ui/controls/FUiCtrl_TableViewPresenter.cpp @@ -5267,17 +5267,6 @@ _TableViewPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInf pItem->GetItemIndex(itemPos.groupIndex, itemPos.itemIndex); if (GetPreviousItemPosition(itemPos, itemPos)) { - _Control* pChildControl = null; - int childControlCount = pItem->GetChildCount(); - for (int i=0; iGetChild(i); - if (pChildControl != null) - { - pChildControl->OnFocusLost(*pChildControl); - } - } - if (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SIMPLE) { TableViewItemTag firstItemPos = {-1, -1}; @@ -5360,17 +5349,6 @@ _TableViewPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInf pItem->GetItemIndex(itemPos.groupIndex, itemPos.itemIndex); if (GetNextItemPosition(itemPos, itemPos)) { - _Control* pChildControl = null; - int childControlCount = pItem->GetChildCount(); - for (int i=0; iGetChild(i); - if (pChildControl != null) - { - pChildControl->OnFocusLost(*pChildControl); - } - } - if (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SIMPLE && itemPos.itemIndex == -1) { itemPos.itemIndex = 0; @@ -5430,6 +5408,60 @@ _TableViewPresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyIn return false; } +void +_TableViewPresenter::OnDrawFocus(void) +{ + _Control* pFocusedControl = null; + _Window* pTop = __pTableView->GetRootWindow(); + if (pTop) + { + pFocusedControl = pTop->GetFocusControl(); + } + + _TableView* pTableView = null; + _TableViewItem* pItem = null; + TableViewItemTag itemPos = {-1, -1}; + + if (pFocusedControl != null) + { + pTableView = dynamic_cast<_TableView*>(pFocusedControl); + if (pTableView != null) + { + GetFirstItem(itemPos); + if (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SIMPLE) + { + itemPos.itemIndex = 0; + } + + ScrollToItem(itemPos.groupIndex, itemPos.itemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP); + pItem = FindItem(itemPos); + if (pItem != null) + { + pItem->SetFocused(true); + pItem->DrawFocus(); + } + } + } +} + +void +_TableViewPresenter::OnFocusModeStateChanged(void) +{ + _Control* pFocusedControl = null; + _Window* pTop = __pTableView->GetRootWindow(); + if (pTop) + { + pFocusedControl = pTop->GetFocusControl(); + } + + _TableViewItem* pItem = null; + pItem = dynamic_cast<_TableViewItem*>(pFocusedControl); + if (pItem != null) + { + pItem->SetFocused(false); + } +} + bool _TableViewPresenter::GetAccessibilityElementFocusedState(void) { diff --git a/src/ui/inc/FUiCtrl_TableView.h b/src/ui/inc/FUiCtrl_TableView.h index 608a33d..d8ab3f0 100644 --- a/src/ui/inc/FUiCtrl_TableView.h +++ b/src/ui/inc/FUiCtrl_TableView.h @@ -236,6 +236,8 @@ public: 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); protected: // Properties diff --git a/src/ui/inc/FUiCtrl_TableViewPresenter.h b/src/ui/inc/FUiCtrl_TableViewPresenter.h index 8360e0e..2054ed1 100644 --- a/src/ui/inc/FUiCtrl_TableViewPresenter.h +++ b/src/ui/inc/FUiCtrl_TableViewPresenter.h @@ -188,6 +188,8 @@ public: // Focus Ui virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo); virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo); + virtual void OnDrawFocus(void); + virtual void OnFocusModeStateChanged(void); void Dispose(void);