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
33 void (*func)(void *data, const char *ev);
40 Evas_Object *btn[MAX_CONTROL_BTNS];
45 void CVideoController::sm_CbEvent(void *dt, Evas_Object *obj,
46 const char *emission, const char *source)
48 struct SControlData *data;
53 data = (SControlData *)dt;
55 data->cb.func(data->cb.data, source);
58 void CVideoController::m_SetFocusDirection(Evas_Object **btn, int count)
63 for (i = 0; i < count; i++) {
69 elm_object_focus_next_object_set(btn[i], obj, ELM_FOCUS_RIGHT);
76 elm_object_focus_next_object_set(btn[i], obj, ELM_FOCUS_LEFT);
80 Evas_Object *CVideoController::m_AddButton(const char *style)
86 btn = elm_button_add(m->base);
90 elm_object_style_set(btn, style);
91 evas_object_show(btn);
96 int CVideoController::m_AddControls(const char **btns, int count)
103 for (i = 0; i < count; i++) {
104 snprintf(buf, sizeof(buf), "video_btn_%s", btns[i]);
105 m->btn[i] = m_AddButton(buf);
109 snprintf(buf, sizeof(buf), "part_btn%d", i);
110 elm_object_part_content_set(m->base,
113 Connect(m->btn[i], -1, TYPE_MOUSE_MOVE | TYPE_CLICKED);
115 elm_object_signal_callback_add(m->btn[i],
116 SIG_BTN_ANI_FIN, btns[i],
119 elm_object_focus_next_object_set(m->btn[i],
120 m->btn[i], ELM_FOCUS_DOWN);
128 bool CVideoController::Create(Evas_Object *base, const char **btns, int count)
137 m = new SControlData;
139 _ERR("failed to add slider");
146 r = m_AddControls(btns, count);
150 m_SetFocusDirection(m->btn, m->btns);
155 void CVideoController::Destroy(void)
163 void CVideoController::AddHandler(void (*func)(void *, const char *),
175 void CVideoController::Focus(int id, Eina_Bool foc)
179 elm_object_focus_set(m->btn[id], foc);
182 void CVideoController::Signal(int id, const char *emission, const char *source)
186 elm_object_signal_emit(m->btn[id], emission, source);
189 void CVideoController::Hide(void)
195 for (i = 0; i < m->btns; i++) {
196 evas_object_freeze_events_set(m->btn[i], EINA_TRUE);
197 elm_object_focus_allow_set(m->btn[i], EINA_FALSE);
201 void CVideoController::Show(void)
207 for (i = 0; i < m->btns; i++) {
208 evas_object_freeze_events_set(m->btn[i], EINA_FALSE);
209 elm_object_focus_allow_set(m->btn[i], EINA_TRUE);
213 void CVideoController::OnMouseMove(int id, Evas *e, Evas_Object *obj,
214 Evas_Event_Mouse_Move *ev)
219 if (!elm_object_focus_get(obj))
220 elm_object_focus_set(obj, EINA_TRUE);
223 void CVideoController::OnMouseClicked(int id, Evas_Object *obj)
225 elm_object_signal_emit(obj, SIG_BTN_ANI_START, "");