--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "FocusManager.h"
+#include "BrowserLogger.h"
+
+FocusManager::FocusManager()
+ : _rowTracker(0)
+ , _prevRowTracker(0)
+{
+ BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+}
+
+FocusManager::~FocusManager()
+{
+ BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__);
+}
+
+void FocusManager::startFocusManager(Evas_Object* gengrid)
+{
+ BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+ handlerDown = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _key_down_cb, this);
+ if (gengrid)
+ evas_object_smart_callback_add(gengrid, "item,focused", _row_tracker, this);
+}
+
+void FocusManager::stopFocusManager()
+{
+ BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+ verticalFocusVector.clear();
+ ecore_event_handler_del(handlerDown);
+}
+Eina_Bool FocusManager::_key_down_cb(void* data, int type, void* event)
+{
+ BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+ FocusManager* fm = static_cast<FocusManager*>(data);
+ Ecore_Event_Key* ev = static_cast<Ecore_Event_Key*>(event);
+ const std::string keyName = ev->keyname;
+
+ if (!keyName.compare("Up")) {
+ BROWSER_LOGD("[%s:%d] Keyname: %s", __PRETTY_FUNCTION__, __LINE__, ev->keyname);
+ if (fm->_prevRowTracker) {
+ fm->_prevRowTracker = 0;
+ return EINA_FALSE;
+ }
+ if (fm->focusListIterator == fm->verticalFocusVector.begin()) {
+ elm_object_focus_set(*(fm->focusListIterator), EINA_TRUE);
+ return EINA_FALSE;
+ }
+ --(fm->focusListIterator);
+ if (elm_object_disabled_get(*(fm->focusListIterator)) == EINA_TRUE)
+ --(fm->focusListIterator);
+ elm_object_focus_set(*(fm->focusListIterator), EINA_TRUE);
+ return EINA_TRUE;
+ }
+ else if (!keyName.compare("Down")) {
+ BROWSER_LOGD("[%s:%d] Keyname: %s", __PRETTY_FUNCTION__, __LINE__, ev->keyname);
+ if (fm->focusListIterator == fm->verticalFocusVector.end()-1) {
+ elm_object_focus_set(*(fm->focusListIterator), EINA_TRUE);
+ return EINA_FALSE;
+ }
+ ++(fm->focusListIterator);
+ if (elm_object_disabled_get(*(fm->focusListIterator)) == EINA_TRUE)
+ ++(fm->focusListIterator);
+ elm_object_focus_set(*(fm->focusListIterator), EINA_TRUE);
+ return EINA_TRUE;
+ }
+ return EINA_FALSE;
+}
+
+void FocusManager::_row_tracker(void* data, Evas_Object*, void* event)
+{
+ BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+ FocusManager* fm = static_cast<FocusManager*>(data);
+ Elm_Object_Item* it = static_cast<Elm_Object_Item*>(event);
+ unsigned int x, y;
+ elm_gengrid_item_pos_get(it, &x, &y);
+ fm->_prevRowTracker = fm->_rowTracker;
+ fm->_rowTracker = y;
+ BROWSER_LOGD("[%s:%d] prev Y:%d, Actual Y:%d", __PRETTY_FUNCTION__, __LINE__, fm->_prevRowTracker, fm->_rowTracker);
+}
+
+void FocusManager::addItem(Evas_Object* it)
+{
+ BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+ verticalFocusVector.push_back(it);
+}
+
+void FocusManager::setIterator()
+{
+ BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+ focusListIterator = verticalFocusVector.begin();
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FOCUSMANAGER_H
+#define FOCUSMANAGER_H
+
+#include <Evas.h>
+#include <Ecore.h>
+#include <Elementary.h>
+#include <vector>
+
+class FocusManager
+{
+public:
+ FocusManager();
+ ~FocusManager();
+
+ /**
+ * This function runs FocusManager. Set the gengrid as the parameter of this function to run _raw_tracker. If the view does not have gengrid, set nullptr.
+ * Before you call this function, add Evas_Object elements to verticalFocusVector using addItem(Evas_Object*) function and set focusListIterator using setIterator() function.
+ */
+ void startFocusManager(Evas_Object*);
+
+ /**
+ * This function stops FocusManager.
+ */
+ void stopFocusManager();
+
+ /**
+ * Use this function to add Evas_Object to FocusManager. The order matters.
+ */
+ void addItem(Evas_Object*);
+
+ /**
+ * Use this function set focusListIterator. Call it after adding items. This function sets iterator at the beginnig of the verticalFocusVector.
+ */
+ void setIterator();
+private:
+ static Eina_Bool _key_down_cb(void *data, int type, void *event);
+ static void _row_tracker(void *data, Evas_Object *obj, void *event);
+
+ std::vector<Evas_Object*> verticalFocusVector;
+ std::vector<Evas_Object*>::iterator focusListIterator;
+ unsigned int _rowTracker, _prevRowTracker;
+ Ecore_Event_Handler* handlerDown;
+ Evas_Object* _gen;
+};
+
+#endif // FOCUSMANAGER_H
+
addItems();
evas_object_show(m_mm_layout);
evas_object_show(elm_object_part_content_get(m_mm_layout,"current_tab_bar"));
+ m_focusManager.startFocusManager(m_gengrid);
evas_object_show(m_gengrid);
setFocus(EINA_TRUE);
}
evas_object_hide(elm_object_part_content_get(m_mm_layout,"current_tab_bar"));
clearItems();
evas_object_del(m_gengrid);
+ m_focusManager.stopFocusManager();
}
evas_object_size_hint_weight_set(m_gengrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(m_gengrid, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_gengrid_item_size_set(m_gengrid, 364 * efl_scale, 320 * efl_scale);
+ evas_object_show(m_gengrid);
}
void MoreMenuUI::showCurrentTab()
m_bookmarkButton = elm_button_add(m_mm_layout);
elm_object_style_set(m_bookmarkButton, "hidden_button");
+ evas_object_show(m_bookmarkButton);
evas_object_smart_callback_add(m_bookmarkButton, "clicked", _star_clicked, this);
m_bookmarkIcon = elm_icon_add(m_mm_layout);
elm_object_part_content_set(m_current_tab_bar, "bookmark_ico", m_bookmarkIcon);
elm_object_part_content_set(m_current_tab_bar, "star_click", m_bookmarkButton);
+ createFocusVector();
}
void MoreMenuUI::setFavIcon(std::shared_ptr<tizen_browser::tools::BrowserImage> favicon)
elm_object_focus_set(elm_object_part_content_get(m_current_tab_bar, "close_click"), focusable);
}
+void MoreMenuUI::createFocusVector()
+{
+ BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__);
+ m_focusManager.addItem(elm_object_part_content_get(m_current_tab_bar, "close_click"));
+ m_focusManager.addItem(m_bookmarkButton);
+ m_focusManager.addItem(m_gengrid);
+ m_focusManager.setIterator();
+}
+
}
}