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.
20 #include "draglock-util.h"
21 #include "draglock-bg.h"
22 #include "draglock-time.h"
23 #include "draglock-slide.h"
25 static void _draglock_ui_down_cb(void *data, Evas *evas, Evas_Object *obj,
27 Evas_Event_Mouse_Down *ev = event_info;
28 struct appdata *ad = (struct appdata *) data;
31 DRAGLOCK_ERR("appdata is NULL");
36 DRAGLOCK_ERR("event_info is NULL");
40 if (ad->slide_rel1.x <= ev->canvas.x && ad->slide_rel1.y <= ev->canvas.y
41 && (ad->slide_rel1.x + ad->slide_rel1.w) >= ev->canvas.x
42 && (ad->slide_rel1.y + ad->slide_rel1.h) >= ev->canvas.y) {
43 ad->slide_status = TRUE;
45 edje_object_signal_emit(_EDJ(ad->slide_layout), "press",
47 edje_object_signal_emit(_EDJ(ad->slide_layout), "press02",
50 DRAGLOCK_DBG("sliding is canceled");
51 ad->slide_status = FALSE;
55 static void _draglock_ui_move_cb(void *data, Evas *evas, Evas_Object *obj,
57 Evas_Event_Mouse_Move *ev = event_info;
58 struct appdata *ad = (struct appdata *) data;
64 DRAGLOCK_ERR("appdata is NULL");
69 DRAGLOCK_ERR("event_info is NULL");
73 if (ad->slide_status == FALSE)
78 if (ad->slide_rel1.x <= ev->cur.canvas.x
79 && ad->slide_rel1.y <= ev->cur.canvas.y
80 && (ad->slide_rel2.x + ad->slide_rel2.w) >= ev->cur.canvas.x
81 && (ad->slide_rel2.y + ad->slide_rel2.h) >= ev->cur.canvas.y) {
82 ad->slide_status = TRUE;
84 step_width = (ad->slide_rel2.x + ad->slide_rel2.w - ad->slide_rel1.x)
86 step_number = (ev->cur.canvas.x - ad->slide_rel1.x) / step_width;
88 alpha = 255 - (2.55 * step_number * 3);
90 if (step_number < 1) {
91 edje_object_signal_emit(_EDJ(ad->slide_layout), "press02",
93 } else if (step_number < 2) {
94 edje_object_signal_emit(_EDJ(ad->slide_layout), "press03",
96 } else if (step_number < 3) {
97 edje_object_signal_emit(_EDJ(ad->slide_layout), "press04",
99 } else if (step_number < 4) {
100 edje_object_signal_emit(_EDJ(ad->slide_layout), "press05",
102 } else if (step_number < 5) {
103 edje_object_signal_emit(_EDJ(ad->slide_layout), "press06",
105 } else if (step_number < 6) {
106 edje_object_signal_emit(_EDJ(ad->slide_layout), "press07",
108 } else if (step_number < 7) {
109 edje_object_signal_emit(_EDJ(ad->slide_layout), "press08",
111 } else if (step_number < 8) {
112 edje_object_signal_emit(_EDJ(ad->slide_layout), "press09",
114 } else if (step_number < 9) {
115 edje_object_signal_emit(_EDJ(ad->slide_layout), "press10",
117 } else if (step_number < 10) {
118 edje_object_signal_emit(_EDJ(ad->slide_layout), "press11",
120 } else if (step_number < 11) {
121 edje_object_signal_emit(_EDJ(ad->slide_layout), "press12",
123 } else if (step_number < 12) {
124 edje_object_signal_emit(_EDJ(ad->slide_layout), "press13",
126 } else if (step_number < 13) {
127 edje_object_signal_emit(_EDJ(ad->slide_layout), "press14",
130 edje_object_signal_emit(_EDJ(ad->slide_layout), "press15",
133 evas_object_color_set(ad->ui_layout, alpha, alpha, alpha, alpha);
135 DRAGLOCK_DBG("sliding is canceled");
136 ad->slide_status = FALSE;
138 evas_object_color_set(ad->ui_layout, 255, 255, 255, 255);
140 edje_object_signal_emit(_EDJ(ad->slide_layout), "release",
142 edje_object_signal_emit(_EDJ(ad->slide_layout), "release",
147 static void _draglock_ui_up_cb(void *data, Evas *evas, Evas_Object *obj,
149 Evas_Event_Mouse_Up *ev = event_info;
150 struct appdata *ad = (struct appdata *) data;
153 DRAGLOCK_ERR("appdata is NULL");
158 DRAGLOCK_ERR("event_info is NULL");
162 if (ad->slide_status == TRUE && ad->slide_rel2.x <= ev->canvas.x
163 && ad->slide_rel2.y <= ev->canvas.y
164 && (ad->slide_rel2.x + ad->slide_rel2.w) >= ev->canvas.x
165 && (ad->slide_rel2.y + ad->slide_rel2.h) >= ev->canvas.y) {
166 ad->slide_status = TRUE;
168 DRAGLOCK_DBG("sliding is canceled");
169 ad->slide_status = FALSE;
172 edje_object_signal_emit(_EDJ(ad->slide_layout), "release", "lock.image.l");
173 edje_object_signal_emit(_EDJ(ad->slide_layout), "release", "lock.image.r");
175 if (ad->slide_status == TRUE) {
176 DRAGLOCK_DBG("unlock the lock-screen");
180 evas_object_color_set(ad->ui_layout, 255, 255, 255, 255);
182 ad->slide_status = FALSE;
185 int draglock_ui_create(void *data) {
186 struct appdata *ad = (struct appdata *) data;
187 Evas_Object *layout = NULL;
188 Evas_Object *image = NULL;
189 Evas_Object *time = NULL;
190 Evas_Object *slide = NULL;
196 layout = draglock_util_add_layout(ad->win, EDJEFILE, "draglock-ui");
197 evas_object_resize(layout, ad->win_w, ad->win_h);
199 if (layout == NULL) {
202 ad->ui_layout = layout;
204 image = draglock_bg_get_image(layout);
205 elm_object_part_content_set(layout, "sw.bg", image);
207 time = draglock_time_get_time(ad);
208 elm_object_part_content_set(layout, "sw.time", time);
210 slide = draglock_slide_get_slider(layout);
211 evas_object_resize(slide, ad->win_w, SLIDE_RATIO_H * ad->win_h);
212 evas_object_move(slide, 0, SLIDE_RATIO_Y * ad->win_h);
214 ad->slide_layout = slide;
216 evas_object_geometry_get(
217 edje_object_part_object_get(_EDJ(slide), "lock.wrapper.image.l"),
218 &ad->slide_rel1.x, &ad->slide_rel1.y, &ad->slide_rel1.w,
221 evas_object_geometry_get(
222 edje_object_part_object_get(_EDJ(slide), "lock.wrapper.image.r"),
223 &ad->slide_rel2.x, &ad->slide_rel2.y, &ad->slide_rel2.w,
226 evas_object_event_callback_add(slide, EVAS_CALLBACK_MOUSE_MOVE,
227 _draglock_ui_move_cb, ad);
228 evas_object_event_callback_add(slide, EVAS_CALLBACK_MOUSE_DOWN,
229 _draglock_ui_down_cb, ad);
230 evas_object_event_callback_add(slide, EVAS_CALLBACK_MOUSE_UP,
231 _draglock_ui_up_cb, ad);
233 evas_object_show(layout);
238 int draglock_ui_destroy(void *data) {
239 struct appdata *ad = (struct appdata *) data;
245 if (ad->clock_timer != NULL) {
246 ecore_timer_del(ad->clock_timer);
247 ad->clock_timer = NULL;