2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <Elementary.h>
20 #include <AppCommon.h>
23 #include <InputHandler.h>
28 #define MAX_CONTROL_BTNS 6
31 void (*func)(void *data, const char *ev);
38 Evas_Object *btn[MAX_CONTROL_BTNS];
43 void CVideoController::sm_CbEvent(void *dt, Evas_Object *obj,
44 const char *emission, const char *source)
48 struct SControlData *data;
50 data = (SControlData *)dt;
51 data->cb.func(data->cb.data, source);
54 void CVideoController::m_SetFocusDirection(Evas_Object **btn, int count)
59 for (i = 0; i < count; i++) {
65 elm_object_focus_next_object_set(btn[i], obj, ELM_FOCUS_RIGHT);
72 elm_object_focus_next_object_set(btn[i], obj, ELM_FOCUS_LEFT);
76 Evas_Object *CVideoController::m_AddButton(const char *style)
80 btn = elm_button_add(m->base);
84 elm_object_style_set(btn, style);
85 evas_object_show(btn);
90 int CVideoController::m_AddControls(const char **btns, int count)
95 for (i = 0; i < count; i++) {
96 snprintf(buf, sizeof(buf), "video_btn_%s", btns[i]);
97 m->btn[i] = m_AddButton(buf);
101 snprintf(buf, sizeof(buf), "part_btn%d", i);
102 elm_object_part_content_set(m->base,
105 Connect(m->btn[i], -1, TYPE_MOUSE_MOVE | TYPE_CLICKED);
107 elm_object_signal_callback_add(m->btn[i],
108 SIG_BTN_ANI_FIN, btns[i],
111 elm_object_focus_next_object_set(m->btn[i],
112 m->btn[i], ELM_FOCUS_DOWN);
120 bool CVideoController::Create(Evas_Object *base, const char **btns, int count)
129 m = new SControlData;
131 _ERR("allocation failed");
138 r = m_AddControls(btns, count);
142 m_SetFocusDirection(m->btn, m->btns);
147 void CVideoController::Destroy(void)
155 void CVideoController::AddHandler(void (*func)(void *, const char *),
167 void CVideoController::Focus(int id, Eina_Bool foc)
171 elm_object_focus_set(m->btn[id], foc);
174 void CVideoController::Signal(int id, const char *emission, const char *source)
178 elm_object_signal_emit(m->btn[id], emission, source);
181 void CVideoController::Hide(void)
187 for (i = 0; i < m->btns; i++) {
188 evas_object_freeze_events_set(m->btn[i], EINA_TRUE);
189 elm_object_focus_allow_set(m->btn[i], EINA_FALSE);
193 void CVideoController::Show(void)
199 for (i = 0; i < m->btns; i++) {
200 evas_object_freeze_events_set(m->btn[i], EINA_FALSE);
201 elm_object_focus_allow_set(m->btn[i], EINA_TRUE);
205 void CVideoController::OnMouseMove(int id, Evas *e, Evas_Object *obj,
206 Evas_Event_Mouse_Move *ev)
210 if (!elm_object_focus_get(obj))
211 elm_object_focus_set(obj, EINA_TRUE);
214 void CVideoController::OnMouseClicked(int id, Evas_Object *obj)
218 elm_object_signal_emit(obj, SIG_BTN_ANI_START, "");