2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
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.
19 #include "draglock-util.h"
20 #include "draglock-bg.h"
21 #include "draglock-time.h"
22 #include "draglock-slide.h"
24 static void _draglock_ui_down_cb(void *data, Evas *evas, Evas_Object *obj,
26 Evas_Event_Mouse_Down *ev = event_info;
27 struct appdata *ad = (struct appdata *) data;
30 DRAGLOCK_ERR("appdata is NULL");
35 DRAGLOCK_ERR("event_info is NULL");
39 if (ad->slide_rel1.x <= ev->canvas.x && ad->slide_rel1.y <= ev->canvas.y
40 && (ad->slide_rel1.x + ad->slide_rel1.w) >= ev->canvas.x
41 && (ad->slide_rel1.y + ad->slide_rel1.h) >= ev->canvas.y) {
42 ad->slide_status = TRUE;
44 edje_object_signal_emit(_EDJ(ad->slide_layout), "press",
46 edje_object_signal_emit(_EDJ(ad->slide_layout), "press02",
49 DRAGLOCK_DBG("sliding is canceled");
50 ad->slide_status = FALSE;
54 static void _draglock_ui_move_cb(void *data, Evas *evas, Evas_Object *obj,
56 Evas_Event_Mouse_Move *ev = event_info;
57 struct appdata *ad = (struct appdata *) data;
63 DRAGLOCK_ERR("appdata is NULL");
68 DRAGLOCK_ERR("event_info is NULL");
72 if (ad->slide_status == FALSE)
77 if (ad->slide_rel1.x <= ev->cur.canvas.x
78 && ad->slide_rel1.y <= ev->cur.canvas.y
79 && (ad->slide_rel2.x + ad->slide_rel2.w) >= ev->cur.canvas.x
80 && (ad->slide_rel2.y + ad->slide_rel2.h) >= ev->cur.canvas.y) {
81 ad->slide_status = TRUE;
83 step_width = (ad->slide_rel2.x + ad->slide_rel2.w - ad->slide_rel1.x)
85 step_number = (ev->cur.canvas.x - ad->slide_rel1.x) / step_width;
87 alpha = 255 - (2.55 * step_number * 3);
89 if (step_number < 1) {
90 edje_object_signal_emit(_EDJ(ad->slide_layout), "press02",
92 } else if (step_number < 2) {
93 edje_object_signal_emit(_EDJ(ad->slide_layout), "press03",
95 } else if (step_number < 3) {
96 edje_object_signal_emit(_EDJ(ad->slide_layout), "press04",
98 } else if (step_number < 4) {
99 edje_object_signal_emit(_EDJ(ad->slide_layout), "press05",
101 } else if (step_number < 5) {
102 edje_object_signal_emit(_EDJ(ad->slide_layout), "press06",
104 } else if (step_number < 6) {
105 edje_object_signal_emit(_EDJ(ad->slide_layout), "press07",
107 } else if (step_number < 7) {
108 edje_object_signal_emit(_EDJ(ad->slide_layout), "press08",
110 } else if (step_number < 8) {
111 edje_object_signal_emit(_EDJ(ad->slide_layout), "press09",
113 } else if (step_number < 9) {
114 edje_object_signal_emit(_EDJ(ad->slide_layout), "press10",
116 } else if (step_number < 10) {
117 edje_object_signal_emit(_EDJ(ad->slide_layout), "press11",
119 } else if (step_number < 11) {
120 edje_object_signal_emit(_EDJ(ad->slide_layout), "press12",
122 } else if (step_number < 12) {
123 edje_object_signal_emit(_EDJ(ad->slide_layout), "press13",
125 } else if (step_number < 13) {
126 edje_object_signal_emit(_EDJ(ad->slide_layout), "press14",
129 edje_object_signal_emit(_EDJ(ad->slide_layout), "press15",
132 evas_object_color_set(ad->ui_layout, alpha, alpha, alpha, alpha);
134 DRAGLOCK_DBG("sliding is canceled");
135 ad->slide_status = FALSE;
137 evas_object_color_set(ad->ui_layout, 255, 255, 255, 255);
139 edje_object_signal_emit(_EDJ(ad->slide_layout), "release",
141 edje_object_signal_emit(_EDJ(ad->slide_layout), "release",
146 static void _draglock_ui_up_cb(void *data, Evas *evas, Evas_Object *obj,
148 Evas_Event_Mouse_Up *ev = event_info;
149 struct appdata *ad = (struct appdata *) data;
152 DRAGLOCK_ERR("appdata is NULL");
157 DRAGLOCK_ERR("event_info is NULL");
161 if (ad->slide_status == TRUE && ad->slide_rel2.x <= ev->canvas.x
162 && ad->slide_rel2.y <= ev->canvas.y
163 && (ad->slide_rel2.x + ad->slide_rel2.w) >= ev->canvas.x
164 && (ad->slide_rel2.y + ad->slide_rel2.h) >= ev->canvas.y) {
165 ad->slide_status = TRUE;
167 DRAGLOCK_DBG("sliding is canceled");
168 ad->slide_status = FALSE;
171 edje_object_signal_emit(_EDJ(ad->slide_layout), "release", "lock.image.l");
172 edje_object_signal_emit(_EDJ(ad->slide_layout), "release", "lock.image.r");
174 if (ad->slide_status == TRUE) {
175 DRAGLOCK_DBG("unlock the lock-screen");
179 evas_object_color_set(ad->ui_layout, 255, 255, 255, 255);
181 ad->slide_status = FALSE;
184 int draglock_ui_create(void *data) {
185 struct appdata *ad = (struct appdata *) data;
186 Evas_Object *layout = NULL;
187 Evas_Object *image = NULL;
188 Evas_Object *time = NULL;
189 Evas_Object *slide = NULL;
195 layout = draglock_util_add_layout(ad->win, EDJEFILE, "draglock-ui");
196 evas_object_resize(layout, ad->win_w, ad->win_h);
198 if (layout == NULL) {
201 ad->ui_layout = layout;
203 image = draglock_bg_get_image(layout);
204 elm_object_part_content_set(layout, "sw.bg", image);
206 time = draglock_time_get_time(ad);
207 elm_object_part_content_set(layout, "sw.time", time);
209 slide = draglock_slide_get_slider(layout);
210 evas_object_resize(slide, ad->win_w, SLIDE_RATIO_H * ad->win_h);
211 evas_object_move(slide, 0, SLIDE_RATIO_Y * ad->win_h);
213 ad->slide_layout = slide;
215 evas_object_geometry_get(
216 edje_object_part_object_get(_EDJ(slide), "lock.wrapper.image.l"),
217 &ad->slide_rel1.x, &ad->slide_rel1.y, &ad->slide_rel1.w,
220 evas_object_geometry_get(
221 edje_object_part_object_get(_EDJ(slide), "lock.wrapper.image.r"),
222 &ad->slide_rel2.x, &ad->slide_rel2.y, &ad->slide_rel2.w,
225 evas_object_event_callback_add(slide, EVAS_CALLBACK_MOUSE_MOVE,
226 _draglock_ui_move_cb, ad);
227 evas_object_event_callback_add(slide, EVAS_CALLBACK_MOUSE_DOWN,
228 _draglock_ui_down_cb, ad);
229 evas_object_event_callback_add(slide, EVAS_CALLBACK_MOUSE_UP,
230 _draglock_ui_up_cb, ad);
232 evas_object_show(layout);
237 int draglock_ui_destroy(void *data) {
238 struct appdata *ad = (struct appdata *) data;
244 if (ad->clock_timer != NULL) {
245 ecore_timer_del(ad->clock_timer);
246 ad->clock_timer = NULL;