SET(PACKAGE org.tizen.ui-viewmgr)
SET(SRCS
- src/efl/ui_controller.cpp
- src/efl/ui_view.cpp
- src/efl/ui_viewmgr.cpp
src/interface/ui_controller_base.cpp
src/interface/ui_view_base.cpp
src/interface/ui_viewmgr_base.cpp
+ src/efl/ui_controller.cpp
+ src/efl/ui_view.cpp
+ src/efl/ui_viewmgr.cpp
+ src/efl/ui_key_handler.cpp
src/efl/mobile/ui_basic_view.cpp
+ src/efl/mobile/mobile_key_handler.cpp
src/main.cpp
)
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "../efl_viewmgr.h"
+#include "mobile_key_handler.h"
+
+using namespace efl;
+
+static const char *KEY_BACK = "XF86Back";
+static const char *KEY_MENU = "XF86Menu";
+
+enum mobile_key_event_type
+{
+ UI_KEY_EVENT_BACK = 0,
+ UI_KEY_EVENT_MENU
+};
+
+mobile_key_handler::mobile_key_handler(ui_viewmgr *viewmgr)
+ : ui_key_handler(viewmgr)
+{
+}
+
+static void event_proc(mobile_key_handler *key_handler, Evas_Event_Key_Down *ev)
+{
+ mobile_key_event_type type;
+
+ if (!strcmp(ev->keyname, KEY_BACK))
+ type = UI_KEY_EVENT_BACK;
+ else if (!strcmp(ev->keyname, KEY_MENU))
+ type = UI_KEY_EVENT_MENU;
+ else return;
+
+ ui_viewmgr *viewmgr = key_handler->get_viewmgr();
+ if (!viewmgr->is_activated()) return;
+
+ //Get Top View
+ ui_view *view = reinterpret_cast<ui_view *>(viewmgr->get_last_view());
+ if (!view) return;
+
+ //call events
+ switch (type)
+ {
+ case UI_KEY_EVENT_BACK:
+ //view->back();
+ LOGE("BACK!");
+ break;
+ case UI_KEY_EVENT_MENU:
+ //view->menu();
+ LOGE("MENU!");
+ break;
+ }
+}
+
+bool mobile_key_handler::term()
+{
+ evas_object_del(this->key_grabber);
+ return true;
+}
+
+bool mobile_key_handler::init()
+{
+ if (!this->viewmgr)
+ {
+ LOGE("No view manager??");
+ return false;
+ }
+
+ Evas *e = evas_object_evas_get(this->viewmgr->get_window());
+ if (!e)
+ {
+ LOGE("Failed to get Evas from window");
+ return false;
+ }
+
+ Evas_Object *key_grab_rect = evas_object_rectangle_add(e);
+ if (!key_grab_rect)
+ {
+ LOGE("Failed to create a key grabber rectangle");
+ return false;
+ }
+
+ evas_object_event_callback_add(key_grab_rect, EVAS_CALLBACK_KEY_UP,
+ [](void *data, Evas *e, Evas_Object *obj, void *event_info) -> void
+ {
+ Evas_Event_Key_Down *ev = static_cast<Evas_Event_Key_Down *>(event_info);
+ mobile_key_handler *key_handler = static_cast<mobile_key_handler *>(data);
+ event_proc(key_handler, ev);
+ },
+ this);
+
+ if (!evas_object_key_grab(key_grab_rect, KEY_BACK, 0, 0, EINA_FALSE))
+ {
+ LOGE("Failed to grab BACK KEY(%s)\n", KEY_BACK);
+ evas_object_del(key_grab_rect);
+ return false;
+ }
+
+ if (!evas_object_key_grab(key_grab_rect, KEY_MENU, 0, 0, EINA_FALSE))
+ {
+ LOGE("Failed to grab MENU KEY(%s)\n", KEY_MENU);
+ evas_object_del(key_grab_rect);
+ return false;
+ }
+
+ this->key_grabber = key_grab_rect;
+
+ return true;
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 MOBILE_KEY_HANDLER
+#define MOBILE_KEY_HANDLER
+
+#include <Elementary.h>
+#include "../ui_key_handler.h"
+
+namespace efl
+{
+class ui_viewmgr;
+
+class mobile_key_handler : public ui_key_handler
+{
+public:
+ mobile_key_handler(ui_viewmgr *viewmgr);
+
+ bool init();
+ bool term();
+
+ ui_viewmgr *get_viewmgr() { return this->viewmgr; }
+};
+
+}
+
+#endif /* MOBILE_KEY_HANDLER */
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "ui_viewmgr.h"
+#include "ui_key_handler.h"
+
+using namespace efl;
+
+static const char *KEY_BACK = "XF86Back";
+
+enum ui_key_event_type
+{
+ UI_KEY_EVENT_BACK = 0,
+};
+
+ui_key_handler::ui_key_handler(ui_viewmgr *viewmgr)
+ : viewmgr(viewmgr), key_grabber(NULL)
+{
+
+}
+
+static void event_proc(ui_key_handler *key_handler, Evas_Event_Key_Down *ev)
+{
+ ui_key_event_type type;
+
+ if (!strcmp(ev->keyname, KEY_BACK))
+ type = UI_KEY_EVENT_BACK;
+ else return;
+
+ ui_viewmgr *viewmgr = key_handler->get_viewmgr();
+ if (!viewmgr->is_activated()) return;
+
+ //Get Top View
+ ui_view *view = reinterpret_cast<ui_view *>(viewmgr->get_last_view());
+ if (!view) return;
+
+ //call events
+ switch (type)
+ {
+ case UI_KEY_EVENT_BACK:
+ //view->back();
+ LOGE("BACK!");
+ break;
+ }
+}
+
+bool ui_key_handler::term()
+{
+ evas_object_del(this->key_grabber);
+ return true;
+}
+
+bool ui_key_handler::init()
+{
+ if (!this->viewmgr)
+ {
+ LOGE("No view manager??");
+ return false;
+ }
+
+ Evas *e = evas_object_evas_get(this->viewmgr->get_window());
+ if (!e)
+ {
+ LOGE("Failed to get Evas from window");
+ return false;
+ }
+
+ Evas_Object *key_grab_rect = evas_object_rectangle_add(e);
+ if (!key_grab_rect)
+ {
+ LOGE("Failed to create a key grabber rectangle");
+ return false;
+ }
+
+ evas_object_event_callback_add(key_grab_rect, EVAS_CALLBACK_KEY_UP,
+ [](void *data, Evas *e, Evas_Object *obj, void *event_info) -> void
+ {
+ Evas_Event_Key_Down *ev = static_cast<Evas_Event_Key_Down *>(event_info);
+ ui_key_handler *key_handler = static_cast<ui_key_handler *>(data);
+ event_proc(key_handler, ev);
+ },
+ this);
+
+ if (!evas_object_key_grab(key_grab_rect, KEY_BACK, 0, 0, EINA_FALSE))
+ {
+ LOGE("Failed to grab BACK KEY(%s)\n", KEY_BACK);
+ evas_object_del(key_grab_rect);
+ return false;
+ }
+
+ this->key_grabber = key_grab_rect;
+
+ return true;
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 UI_KEY_HANDLER
+#define UI_KEY_HANDLER
+
+#include <Elementary.h>
+#include "../interface/ui_viewmgr.h"
+
+namespace efl
+{
+class ui_viewmgr;
+
+class ui_key_handler
+{
+protected:
+ ui_viewmgr *viewmgr;
+ Evas_Object *key_grabber;
+
+public:
+ ui_key_handler(ui_viewmgr *viewmgr);
+ virtual ~ui_key_handler() {}
+
+ virtual bool init();
+ virtual bool term();
+
+ ui_viewmgr *get_viewmgr() { return this->viewmgr; }
+};
+
+}
+
+#endif /* UI_KEY_HANDLER */
}
ui_viewmgr::ui_viewmgr(const char *pkg)
- : ui_viewmgr_base()
+ : ui_viewmgr_base(), key_handler(NULL)
{
if (!pkg)
{
elm_win_indicator_opacity_set(this->win, ELM_WIN_INDICATOR_OPAQUE);
elm_win_autodel_set(this->win, EINA_TRUE);
+
+ this->set_key_handler();
}
ui_viewmgr::~ui_viewmgr()
{
+ this->key_handler->term();
+}
+
+void ui_viewmgr::set_key_handler()
+{
+ this->key_handler = new ui_key_handler(this);
+ this->key_handler->init();
}
bool ui_viewmgr::activate()
#include <Elementary.h>
#include "../interface/ui_viewmgr.h"
+#include "ui_key_handler.h"
namespace efl
{
Evas_Object *win;
Evas_Object *conform;
Evas_Object *layout;
+ ui_key_handler *key_handler; //HW Key Handler such as "BACK" key...
ui_view_indicator indicator;
bool create_conformant(Evas_Object *win);
bool create_base_layout(Evas_Object *conform);
bool set_indicator(ui_view_indicator indicator);
+ virtual void set_key_handler();
protected:
Evas_Object *get_base()
friend class ui_view_base;
private:
- list<ui_view_base*> view_list; //view list.
+ list<ui_view_base*> view_list; //view list.
bool event_block; //event block on view transition. This value should be configurable by system.
bool activated; //activated status of this viewmgr.
bool soft_back_key; //If system doesn't support HW back key, then this value is true.
return NULL;
}
- //FIXME: Doc.
- ui_view_base *get_last_view();
-
/**
* @brief Return a stack index number of the given view.
* You could use this function to query the given view stack order.
///Destructor. Delete all contained views.
virtual ~ui_viewmgr_base();
+ //FIXME: Doc.
+ ui_view_base *get_last_view();
+
/**
* @brief Return the number of views which this viewmgr has.
*