+++ /dev/null
-/*
- * Copyright (c) 2014 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 __NEARBY_LAYOUT_H__
-#define __NEARBY_LAYOUT_H__
-
-class CNearbyLayout : public CBaseLayout, CListenerMgr,
- IKeyDownListener, IMouseMoveListener, IFocusedListener {
-
-private:
- struct SNearbyLayout *m;
-
-protected:
- virtual void t_OnShow(void);
- virtual void t_OnHide(void);
-
-private:
- static Eina_Bool sm_CbTimerDelItem(void *data);
- void m_TimerDelItem(void);
-
- void m_LaunchSettingApp(void);
- void m_AddSetNetworkButton(void);
- void m_AddNoSrcUtility(void);
- void m_DelNoSrcUtility(void);
- void m_DrawNoSrcUtility(void);
-
- void m_DrawNoContentArea(void);
- void m_DrawContentArea(void);
-
- Evas_Object *m_DrawGengrid(Evas_Object *layout);
-
-public:
- CNearbyLayout(const char *pLayoutId) : CBaseLayout(pLayoutId),
- IKeyDownListener(this), IMouseMoveListener(this),
- IFocusedListener(this), m(0) {}
-
- ~CNearbyLayout() {}
-
- bool Create(CLayoutMgr *mgr, void *data);
- virtual void Destroy(void);
-
- void Update(void *data, enum update_ui type);
-
-public:
- void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev);
- void OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev);
- void OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item);
-};
-
-#endif /* __NEARBY_LAYOUT_H__ */
#include "dbg.h"
#include "allsource_view.h"
#include "plugged_layout.h"
-#include "nearby_layout.h"
#define TEXT_PLUGGED "PLUGGED"
-#define TEXT_NEARBY "NEARBY"
-
#define LAYOUT_PLUGGED "LAYOUT_PLUGGED"
-#define LAYOUT_NEARBY "LAYOUT_NEARBY"
enum EObjectType {
ALL_PLUG_BTN = 0,
- ALL_NEAR_BTN
};
struct SAllSourceView {
Evas_Object *base;
Evas_Object *plug_btn;
- Evas_Object *near_btn;
Evas_Object *focus_btn;
Evas_Object *plug_layout;
- Evas_Object *near_layout;
CViewMgr *vmgr;
enum launch_mode mode;
CLayoutMgr *pLayoutMgr;
CPluggedLayout *pPluggedLayout;
- CNearbyLayout *pNearbyLayout;
SSigCallbackPair *sigCb;
Connect(m->plug_btn, ALL_PLUG_BTN, TYPE_KEY_DOWN | TYPE_MOUSE_MOVE | TYPE_FOCUSED);
- m->near_btn = m_AddBtn(BTN_STYLE_NEAR, _(TEXT_NEARBY));
- if (!m->near_btn) {
- _ERR("Add nearby button failed");
- evas_object_del(m->plug_btn);
- return false;
- }
-
- elm_object_part_content_set(m->base, PART_MENU_NEARBY, m->near_btn);
-
- Connect(m->near_btn, ALL_NEAR_BTN, TYPE_KEY_DOWN | TYPE_MOUSE_MOVE | TYPE_FOCUSED);
-
- elm_object_focus_next_object_set(m->plug_btn, m->near_btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(m->near_btn, m->plug_btn, ELM_FOCUS_DOWN);
-
return true;
}
|| type == SRC_PLUG_DEL_ONE
|| type == SRC_UPDATE_ALL)
m->pPluggedLayout->Update(data, type);
-
- if (type == SRC_NEAR_ADD_ONE
- || type == SRC_NEAR_DEL_ONE
- || type == SRC_UPDATE_ALL)
- m->pNearbyLayout->Update(data, type);
}
Evas_Object *CAllSourceView::Base(void)
_CHECK(m->pLayoutMgr = new CLayoutMgr);
_CHECK(m->pLayoutMgr->Create(m->base, NULL));
_CHECK(m->pPluggedLayout = new CPluggedLayout(LAYOUT_PLUGGED));
- _CHECK(m->pNearbyLayout = new CNearbyLayout(LAYOUT_NEARBY));
_CHECK(m->pPluggedLayout->Create(m->pLayoutMgr, m->sigCb));
- _CHECK(m->pNearbyLayout->Create(m->pLayoutMgr, m->sigCb));
_CHECK(m->pLayoutMgr->AddLayout(m->pPluggedLayout));
- _CHECK(m->pLayoutMgr->AddLayout(m->pNearbyLayout));
_CHECK(m_AddMenuArea());
_WHEN_SUCCESS{
m->vmgr = vmgr;
CBaseView::Create(NULL);
}
_CHECK_FAIL{}
- _CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pNearbyLayout); }
_CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pPluggedLayout); }
- _CHECK_FAIL{ m->pNearbyLayout->Destroy(); }
_CHECK_FAIL{ m->pPluggedLayout->Destroy(); }
- _CHECK_FAIL{ delete m->pNearbyLayout; }
_CHECK_FAIL{ delete m->pPluggedLayout; }
_CHECK_FAIL{ m->pLayoutMgr->Destroy(); }
_CHECK_FAIL{ delete m->pLayoutMgr; }
m->pPluggedLayout->Destroy();
delete m->pPluggedLayout;
- m->pLayoutMgr->RemoveLayout(m->pNearbyLayout);
- m->pNearbyLayout->Destroy();
- delete m->pNearbyLayout;
-
m->pLayoutMgr->Destroy();
delete m->pLayoutMgr;
Evas_Object *btn;
btn = m->plug_btn;
- if (m->mode == SRC_PLUGGED)
- btn = m->plug_btn;
- else if (m->mode == SRC_NEARBY)
- btn = m->near_btn;
elm_object_focus_set(btn, EINA_TRUE);
}
{
switch (id) {
case ALL_PLUG_BTN:
- case ALL_NEAR_BTN:
if (!strcmp(ev->keyname, KEY_BACK)
|| !strcmp(ev->keyname, KEY_BACK_REMOTE))
app_efl_exit();
{
switch (id) {
case ALL_PLUG_BTN:
- case ALL_NEAR_BTN:
if (!elm_object_focus_get(obj))
elm_object_focus_set(obj, EINA_TRUE);
break;
m->focus_btn = obj;
m->pLayoutMgr->Show(LAYOUT_PLUGGED);
break;
- case ALL_NEAR_BTN:
- m->focus_btn = obj;
- m->pLayoutMgr->Show(LAYOUT_NEARBY);
- break;
default:
break;
}
+++ /dev/null
-/*
- * Copyright (c) 2014 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 <Elementary.h>
-#include <app.h>
-#include "aul.h"
-#include "def.h"
-#include "dbg.h"
-
-#include "AppCommon.h"
-#include "BaseView.h"
-#include "ViewMgr.h"
-#include "BaseLayout.h"
-#include "LayoutMgr.h"
-#include "InputHandler.h"
-#include "source_mgr.h"
-#include "menu_view.h"
-#include "util.h"
-#include "allsource_view.h"
-#include "nearby_layout.h"
-
-#define PRIV "priv"
-#define NEARBY_DATA "nearby_data"
-
-#define SET_UP_NETWORK "Set up network"
-#define NET_WORK_SET "Network Setting"
-
-#define NO_SRC_TEXT_LINE1 "No nearby source"
-#define NO_SRC_TEXT_LINE2 "Add any nearby sources, set up network configuration"
-#define NO_SRC_TEXT_LINE3 "Wi-Fi ON | Wi-Fi Direct ON"
-
-#define PADDING_13 13
-#define PADDING_30 30
-#define SETTING_APP "org.tizen.settings-tv-ref"
-#define SETTING_ITEM "settings-item"
-#define SETTING_NETWORK "network-settings"
-
-enum EObjectType {
- NEARBY_GRID = 0,
- NEARBY_BTN_TOP,
- NEARBY_BTN_LAYOUT
-};
-
-struct SNearbyLayout {
- Evas_Object *base;
- Evas_Object *grid;
- Evas_Object *utility_pb;
- Evas_Object *utility_btn;
- Elm_Object_Item *focus_it;
- Elm_Object_Item *del_it;
- CSourceMgr *srcmgr;
- CViewMgr *vmgr;
- int list_count;
-
- SSigCallbackPair *SigCb;
-
- SNearbyLayout() {
- memset(this, 0, sizeof(SNearbyLayout));
- }
-};
-
-void CNearbyLayout::m_LaunchSettingApp(void)
-{
- bundle *b;
- int err;
-
- b = bundle_create();
- if (!b) {
- _ERR("create bundle failed.");
- return;
- }
-
- err = bundle_add(b, SETTING_ITEM, SETTING_NETWORK);
- if (err) {
- _ERR("add bundle failed.");
- bundle_free(b);
- return;
- }
-
- err = aul_launch_app(SETTING_APP, b);
- if (err) {
- _ERR("launch settings failed.");
- bundle_free(b);
- return;
- }
-
- bundle_free(b);
-}
-
-void CNearbyLayout::m_AddSetNetworkButton(void)
-{
- Evas_Object *btn;
-
- btn = util_add_btn(Layout(), BTN_STYLE_SET_UP_NETWORK);
- if (!btn) {
- _ERR("Add network button failed");
- return;
- }
-
- elm_object_text_set(btn, _(SET_UP_NETWORK));
- elm_object_part_content_set(Layout(), PART_BUTTON, btn);
-
- Connect(btn, NEARBY_BTN_LAYOUT, TYPE_KEY_DOWN | TYPE_MOUSE_MOVE | TYPE_FOCUSED);
-}
-
-void CNearbyLayout::m_AddNoSrcUtility(void)
-{
- Evas_Object *pb, *btn;
-
- if (m->utility_btn)
- return;
-
- pb = elm_progressbar_add(m->base);
- if (!pb)
- return;
-
- elm_object_style_set(pb, PB_STYLE_SRC_LOAD);
- elm_object_part_content_set(m->base, PART_UTILITY_LOADING, pb);
- elm_progressbar_pulse(m->utility_pb, EINA_TRUE);
- evas_object_show(m->utility_pb);
-
- /*TODO:to add utility button*/
- btn = util_add_btn(m->base, BTN_STYLE_NETWORK_SET);
- if (!btn) {
- evas_object_del(pb);
- return;
- }
- elm_object_text_set(btn, _(NET_WORK_SET));
- elm_object_part_content_set(m->base, PART_UTILITY_BUTTON, btn);
-
- Connect(btn, NEARBY_BTN_TOP, TYPE_KEY_DOWN | TYPE_MOUSE_MOVE | TYPE_FOCUSED);
-
- m->utility_pb = pb;
- m->utility_btn = btn;
-}
-
-void CNearbyLayout::m_DelNoSrcUtility(void)
-{
- if (m->utility_btn) {
- evas_object_del(m->utility_btn);
- m->utility_btn = NULL;
- }
-
- if (m->utility_pb) {
- evas_object_del(m->utility_pb);
- m->utility_pb = NULL;
- }
-}
-
-void CNearbyLayout::m_DrawNoSrcUtility(void)
-{
- if (m->list_count > 0)
- m_DelNoSrcUtility();
- else
- m_AddNoSrcUtility();
-}
-
-void CNearbyLayout::m_DrawNoContentArea(void)
-{
- elm_object_part_text_set(Layout(), PART_NO_SRC_TEXT_LINE1,
- _(NO_SRC_TEXT_LINE1));
- elm_object_part_text_set(Layout(), PART_NO_SRC_TEXT_LINE2,
- _(NO_SRC_TEXT_LINE2));
- elm_object_part_text_set(Layout(), PART_NO_SRC_TEXT_LINE3,
- _(NO_SRC_TEXT_LINE3));
-
- elm_object_part_content_unset(Layout(), PART_CONTENT_CONTENT);
- evas_object_hide(m->grid);
-
- m_AddSetNetworkButton();
-
- m->SigCb->cb(m->SigCb->cookie, E_RETURN);
-}
-
-void CNearbyLayout::m_DrawContentArea(void)
-{
- elm_object_part_text_set(Layout(), PART_NO_SRC_TEXT_LINE1, "");
- elm_object_part_text_set(Layout(), PART_NO_SRC_TEXT_LINE2, "");
- elm_object_part_text_set(Layout(), PART_NO_SRC_TEXT_LINE3, "");
- elm_object_part_content_unset(Layout(), PART_BUTTON);
-
- elm_object_part_content_set(Layout(), PART_CONTENT_CONTENT, m->grid);
- evas_object_show(m->grid);
-}
-
-Evas_Object *CNearbyLayout::m_DrawGengrid(Evas_Object *layout)
-{
- Evas_Object *grid;
-
- grid = util_add_grid(layout, ITEM_W, ITEM_H);
- if (!grid)
- return NULL;
-
- Connect(grid, NEARBY_GRID, TYPE_KEY_DOWN | TYPE_MOUSE_MOVE | TYPE_FOCUSED);
-
- return grid;
-}
-
-bool CNearbyLayout::Create(CLayoutMgr *lmgr, void *data)
-{
- ASSERT(!m);
-
- Evas_Object *layout;
- CViewMgr *vmgr;
- CSourceMgr *srcmgr;
-
- if (!lmgr)
- return false;
-
- m = new SNearbyLayout;
- if (!m)
- return false;
-
- m->base = lmgr->Base();
- if (!m->base) {
- delete m;
- m = NULL;
- return false;
- }
-
- layout = util_add_layout(m->base, GRP_NEARBY_CONTENT);
- if (!layout) {
- _ERR("Add layout failed");
- delete m;
- m = NULL;
- return false;
- }
-
- m->grid = m_DrawGengrid(layout);
- if (!m->grid) {
- _ERR("Add gengrid failed");
- delete m;
- m = NULL;
- evas_object_del(layout);
- return false;
- }
-
- vmgr = CViewMgr::GetInstance();
- srcmgr = CSourceMgr::GetInstance();
-
- m->srcmgr = srcmgr;
- m->vmgr = vmgr;
- m->SigCb = (SSigCallbackPair *)data;
-
- evas_object_data_set(m->base, NEARBY_DATA, m);
-
- elm_object_part_content_set(layout, PART_CONTENT_CONTENT, m->grid);
-
- CBaseLayout::Create(layout);
-
- return true;
-}
-
-void CNearbyLayout::t_OnShow(void)
-{
- ASSERT(m);
-
- CBaseLayout::t_OnShow();
-
- elm_object_part_content_set(m->base, PART_CONTENT, Layout());
-
- m_DrawNoSrcUtility();
-}
-
-void CNearbyLayout::t_OnHide(void)
-{
- ASSERT(m);
-
- CBaseLayout::t_OnHide();
-
- elm_object_part_content_unset(m->base, PART_CONTENT);
-
- m_DelNoSrcUtility();
-}
-
-void CNearbyLayout::Destroy(void)
-{
- ASSERT(m);
-
- evas_object_del(Layout());
-
- CBaseLayout::Destroy();
-
- delete m;
- m = NULL;
-}
-
-Eina_Bool CNearbyLayout::sm_CbTimerDelItem(void *data)
-{
- CNearbyLayout *root = (CNearbyLayout *)data;
- if (!root)
- return EINA_FALSE;
-
- root->m_TimerDelItem();
-
- return EINA_FALSE;
-}
-
-void CNearbyLayout::m_TimerDelItem(void)
-{
- Elm_Object_Item *prev;
- Elm_Object_Item *next;
-
- if (!m->del_it)
- return;
-
- prev = elm_gengrid_item_prev_get(m->del_it);
- next = elm_gengrid_item_prev_get(m->del_it);
-
- elm_object_item_data_set(m->del_it, NULL);
- elm_object_item_del(m->del_it);
-
- if (!prev && !next)
- m_DrawNoContentArea();
- else if (m->del_it == m->focus_it) {
- if (prev)
- m->focus_it = prev;
- else
- m->focus_it = next;
-
- elm_object_item_focus_set(m->focus_it, EINA_TRUE);
- }
-
- m->del_it = NULL;
-}
-
-void CNearbyLayout::Update(void *data, enum update_ui type)
-{
- ASSERT(m);
-
- Eina_List *list, *l;
- Ecore_Timer *timer;
- CSourceMgr *srcmgr;
- CSourceInfo *si;
- CSourceInfo *si_data;
- void *obj;
-
- srcmgr = m->srcmgr;
-
- /*TODO:there is only nearby connected source list*/
- list = srcmgr->NearbyConnList();
- m->list_count = eina_list_count(list);
-
- if (type == SRC_PLUG_ADD_ONE) {
- si_data = (CSourceInfo *)data;
- util_add_item(m->grid, si_data);
-
- if (m->list_count >= 1)
- m_DrawContentArea();
- } else if (type == SRC_PLUG_DEL_ONE) {
- si_data = (CSourceInfo *)data;
- m->del_it = (Elm_Object_Item*)si_data->Data();
- si_data->SetData(NULL);
-
- timer = ecore_timer_add(DEL_IT_TIME, sm_CbTimerDelItem, m);
- elm_object_item_data_set(m->del_it, timer);
- util_dim_item(m->del_it);
- } else if (type == SRC_UPDATE_ALL) {
- if (m->list_count == 0) {
- m_DrawNoContentArea();
- return;
- } else
- m_DrawContentArea();
-
- elm_gengrid_clear(m->grid);
-
- EINA_LIST_FOREACH(list, l, obj) {
- si = (CSourceInfo *)obj;
- util_add_item(m->grid, si);
- }
- }
-}
-
-void CNearbyLayout::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
-{
- switch (id) {
- case NEARBY_GRID:
- CSourceInfo *si;
-
- si = m->srcmgr->SourceInfoByData(m->focus_it);
- if (!si)
- return;
-
- if (!strcmp(ev->keyname, KEY_MENU)
- || !strcmp(ev->keyname, KEY_MENU_REMOTE))
- m->vmgr->PushView(MENU_VIEW, si);
-
- break;
- case NEARBY_BTN_TOP:
- case NEARBY_BTN_LAYOUT:
- if (!strcmp(ev->keyname, KEY_ENTER)
- || !strcmp(ev->keyname, KEY_ENTER_REMOTE))
- m_LaunchSettingApp();
- else if (!strcmp(ev->keyname, KEY_BACK)
- || !strcmp(ev->keyname, KEY_BACK_REMOTE))
- m->SigCb->cb(m->SigCb->cookie, E_RETURN);
- break;
- default:
- break;
- }
-}
-
-void CNearbyLayout::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev)
-{
- switch (id) {
- case NEARBY_GRID:
- Elm_Object_Item *it;
-
- it = elm_gengrid_at_xy_item_get(obj, ev->cur.canvas.x,
- ev->cur.canvas.y, NULL, NULL);
- if (!it)
- return;
-
- if (elm_object_item_focus_get(it))
- return;
-
- elm_object_item_focus_set(it, EINA_TRUE);
-
- m->SigCb->cb(m->SigCb->cookie, E_HIGHLIGHT);
-
- break;
- case NEARBY_BTN_TOP:
- case NEARBY_BTN_LAYOUT:
- if (elm_object_focus_get(obj))
- return;
-
- elm_object_focus_set(obj, EINA_TRUE);
-
- break;
- default:
- break;
- }
-}
-
-void CNearbyLayout::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item)
-{
- switch (id) {
- case NEARBY_GRID:
- m->focus_it = (Elm_Object_Item*)item;
-
- m->SigCb->cb(m->SigCb->cookie, E_HIGHLIGHT);
-
- break;
- case NEARBY_BTN_TOP:
- case NEARBY_BTN_LAYOUT:
- m->SigCb->cb(m->SigCb->cookie, E_HIGHLIGHT);
- break;
- default:
- break;
- }
-}