3 * Copyright 2012 Samsung Electronics Co., Ltd
5 * Licensed under the Flora License, Version 1.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://floralicense.org/license/
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
21 #include "edit-view.h"
22 #include "detail-view.h"
23 #include "view-day-list.h"
25 #include "day-expandable-list.h"
27 static const char *_name = "main/day/time";
31 cal_base_time_s base_time;
35 Evas_Coord mouse_down_distance;
37 Ecore_Idler *idler_for_time_block;
38 Ecore_Idler *idler_for_change;
40 Ecore_Timer *mouse_clicked_timer;
46 Eina_Bool is_quit_editmode;
51 static cal_base_time_h __cal_day_time_new(void *data);
52 static void __cal_day_time_state_actions(cal_base_time_h base_time);
53 static void __cal_day_time_state_transition(cal_base_time_h base_time, enum cal_base_time_input_signal_type input);
54 static void __cal_day_time_update(cal_base_time_h base_time);
55 static void __cal_day_time_delete(cal_base_time_h base_time);
57 cal_base_time_operations day_time_operations = {
59 __cal_day_time_delete,
61 __cal_day_time_state_transition,
62 __cal_day_time_state_actions,
63 __cal_day_time_update,
66 extern void cal_day_update_genlist(Evas_Object *ly);
68 static void __cal_day_time_delete(cal_base_time_h base_time)
72 cal_day_time_s *p = base_time;
74 if (p->idler_for_time_block)
75 ecore_idler_del(p->idler_for_time_block);
77 if (p->idler_for_change)
78 ecore_idler_del(p->idler_for_change);
82 static cal_base_time_h __cal_day_time_new(void *data)
84 c_retv_if(!data, NULL);
86 cal_day_time_s *p = NULL;
88 CAL_CALLOC(p, 1, cal_day_time_s);
90 ((cal_base_time_s *)p)->name = _name;
94 p->threshold = elm_config_finger_size_get();
100 static void __cal_day_time_scroll_zoom(cal_base_time_h base_time, Evas *e, Evas_Object *obj, void *ei)
102 c_ret_if(!base_time);
104 cal_base_time_s *p = base_time;
106 Evas_Coord_Point sc_xy;
108 Evas_Coord_Point base_xy;
110 Evas_Coord_Rectangle r;
113 evas_object_geometry_get(p->scroller, &sc_xy.x, &sc_xy.y, NULL, &sc_h);
114 evas_object_geometry_get(p->base, &base_xy.x, &base_xy.y, NULL, &base_h);
116 cal_base_time_block_get_geometry(p->base_time_block, &r);
118 if (r.y > p->base_y) {
119 cal_base_time_block_move(p->base_time_block, base_xy.x, p->base_y);
121 if ((r.y+r.h) < (sc_xy.y+sc_h)) {
123 t_y = sc_xy.y + sc_h - r.h;
124 cal_base_time_block_move(p->base_time_block, base_xy.x, t_y);
126 cal_base_time_block_move(p->base_time_block, base_xy.x, p->base_y);
132 static inline void __cal_day_time_double_clicked_callback(cal_base_time_h base_time)
134 c_ret_if(!base_time);
136 cal_day_time_s *p = base_time;
138 c_ret_if(p->is_quit_editmode);
140 if (p->ad->is_magnifying)
143 p->ad->is_contracted = !p->ad->is_contracted;
145 cal_base_time_freeze_scroller(p);
147 if (!p->ad->is_contracted) {
148 cal_day_time_block_resize(((cal_base_time_s *)p)->base_time_block, 0, cal_day_time_block_get_max(((cal_base_time_s *)p)->base_time_block), p->ad->is_contracted);
149 cal_day_time_block_resize(((cal_base_time_s *)p)->left_base_time_block, 0, cal_day_time_block_get_max(((cal_base_time_s *)p)->base_time_block), p->ad->is_contracted);
150 cal_day_time_block_resize(((cal_base_time_s *)p)->right_base_time_block, 0, cal_day_time_block_get_max(((cal_base_time_s *)p)->base_time_block), p->ad->is_contracted);
152 cal_day_time_block_resize(((cal_base_time_s *)p)->base_time_block, 0, 0, p->ad->is_contracted);
153 cal_day_time_block_resize(((cal_base_time_s *)p)->left_base_time_block, 0, 0, p->ad->is_contracted);
154 cal_day_time_block_resize(((cal_base_time_s *)p)->right_base_time_block, 0, 0, p->ad->is_contracted);
157 cal_base_time_thaw_scroller(p);
159 __cal_day_time_scroll_zoom(p, NULL, NULL, NULL);
162 static Eina_Bool __cal_day_time_ug_callback(void *data)
164 c_retv_if(!data, EINA_FALSE);
166 cal_day_time_s *p = (cal_base_time_s *)data;
167 c_retv_if(!p->ad, EINA_FALSE);
168 c_retv_if(!p->ad->main, EINA_FALSE);
172 Evas_Object *content = elm_object_part_content_get(p->ad->main, "cont");
173 c_retv_if(!content, EINA_FALSE);
175 p->ad->base_tm.tm_hour = p->ad->base_hour;
177 cal_day_update_genlist(content);
179 cal_base_time_block_update(((cal_base_time_s *)p)->base_time_block);
181 cal_base_time_block_move_event_blocks(((cal_base_time_s *)p)->base_time_block);
183 cal_day_change_content_display_status(content);
185 cal_main_add_db_changed_callback(p->ad);
190 static Eina_Bool __cal_day_time_mouse_hold_timer_callback(void *data)
192 c_retv_if(!data, ECORE_CALLBACK_CANCEL);
194 cal_base_time_s *p = (cal_base_time_s *)data;
195 c_retv_if(!p->base_time_block, ECORE_CALLBACK_CANCEL);
197 switch (p->state_action_type)
199 case STATE_DOWN_FIRST:
200 case STATE_DOWN_SECOND:
201 cal_day_time_block_hint_longpress(p->base_time_block, &p->single_mouse_down);
207 return ECORE_CALLBACK_CANCEL;
210 static void __cal_day_time_time_block_clicked_callback(cal_base_time_h base_time, int hour)
212 c_ret_if(!base_time);
214 cal_day_time_s *p = base_time;
217 c_ret_if(p->is_quit_editmode);
219 p->ad->base_hour = hour;
222 calendar_record_h record = NULL;
223 calendar_error_e error = CALENDAR_ERROR_NONE;
225 error = calendar_record_create(_calendar_event._uri, &record);
226 c_retm_if(error != CALENDAR_ERROR_NONE, "calendar_record_create() is failed(%x)", error);
228 p->ad->base_hour = p->ad->base_tm.tm_hour;
229 p->ad->base_tm.tm_hour = hour;
231 cal_main_remove_db_changed_callback(p->ad);
233 cal_edit_create_view(p->ad, record, __cal_day_time_ug_callback, p);
236 static void __cal_day_time_event_block_clicked_callback(cal_base_time_h base_time, calendar_record_h record)
238 c_ret_if(!base_time);
240 cal_day_time_s *p = base_time;
244 c_ret_if(p->is_quit_editmode);
246 p->ad->cid = _calendar_get_record_index(record);
247 p->ad->base_hour = p->ad->base_tm.tm_hour;
249 cal_main_remove_db_changed_callback(p->ad);
251 cal_detail_create_view(p->ad, record, __cal_day_time_ug_callback, p);
254 static void __cal_day_time_more_event_block_clicked_callback(cal_base_time_h base_time)
256 c_ret_if(!base_time);
258 cal_day_time_s *p = base_time;
261 c_ret_if(p->is_quit_editmode);
263 Evas_Object* ly = cal_day_list_create(p->ad, p->ad->main);
264 cal_day_list_update_list(ly);
267 static void __cal_day_time_mouse_event_callback(void *data, int event_type, void *ei)
271 cal_base_time_s *p = (cal_base_time_s *)data;
273 switch (event_type) {
274 case EVEN_BLOCK_EVENT_CLICEKD:
275 p->state_action_type = STATE_START;
276 __cal_day_time_event_block_clicked_callback(p, (calendar_record_h)ei);
278 case EVEN_BLOCK_MORE_EVENT_CLICEKD:
279 p->state_action_type = STATE_START;
280 __cal_day_time_more_event_block_clicked_callback(p);
282 case TIME_BLOCK_SLICE_CLICEKD:
283 p->state_action_type = STATE_START;
284 __cal_day_time_time_block_clicked_callback(p, (int)ei);
286 case DAY_TIME_DOUBLE_CLICEKD:
287 p->state_action_type = STATE_START;
288 __cal_day_time_double_clicked_callback(p);
296 cal_base_time_h cal_day_time_create(void *data)
298 return cal_base_time_create(&day_time_operations, data);
301 static Eina_Bool __cal_day_time_move_time_block_to_time_line(void *data)
303 c_retv_if(!data, ECORE_CALLBACK_CANCEL);
305 cal_day_time_s *p = (cal_day_time_s *)data;
307 if (p->idler_for_time_block) {
308 ecore_idler_del(p->idler_for_time_block);
309 p->idler_for_time_block = NULL;
312 cal_base_time_block_move_to_time_line(((cal_base_time_s *)p)->base_time_block);
314 return ECORE_CALLBACK_CANCEL;
317 static void __cal_day_time_update(cal_base_time_h base_time)
321 c_ret_if(!base_time);
323 cal_base_time_s *p = (cal_base_time_s *)base_time;
324 c_ret_if(!p->base_time_block);
326 cal_day_time_block_set_callback(p->base_time_block, __cal_day_time_mouse_event_callback, p);
328 cal_base_time_block_update(p->base_time_block);
330 if (((cal_day_time_s *)p)->ad->is_magnifying) {
331 cal_day_time_block_resize(p->base_time_block, 0, cal_day_time_block_get_current(p->base_time_block), EINA_FALSE);
333 if (((cal_day_time_s *)p)->ad->is_contracted) {
334 cal_day_time_block_resize(p->base_time_block, 0, cal_day_time_block_get_max(p->base_time_block), EINA_FALSE);
335 cal_day_time_block_resize(p->base_time_block, 0, 0, EINA_TRUE);
339 cal_base_time_attach_scroller(p);
342 if (!((cal_day_time_s *)p)->idler_for_time_block)
343 ((cal_day_time_s *)p)->idler_for_time_block = ecore_idler_add(__cal_day_time_move_time_block_to_time_line, p);
348 static Eina_Bool __cal_day_time_mouse_clicked_timer_callback(void *data)
350 c_retv_if(!data, EINA_FALSE);
352 cal_base_time_s *p = data;
354 switch (p->state_action_type)
357 cal_day_time_block_hint_clicked(p->base_time_block, &p->single_mouse_down);
358 cal_day_change_content_display_status(p->parent);
359 p->state_action_type = STATE_START;
361 case STATE_UP_SECOND:
362 __cal_day_time_mouse_event_callback(p, DAY_TIME_DOUBLE_CLICEKD, NULL);
363 p->state_action_type = STATE_START;
369 if (((cal_day_time_s *)p)->mouse_clicked_timer) {
370 ecore_timer_del(((cal_day_time_s *)p)->mouse_clicked_timer);
371 ((cal_day_time_s *)p)->mouse_clicked_timer = NULL;
374 return ECORE_CALLBACK_CANCEL;
377 static void __cal_day_time_state_down_action(cal_base_time_h base_time)
379 c_ret_if(!base_time);
381 cal_day_time_s *p = base_time;
384 static void __cal_day_time_state_up_action(cal_base_time_h base_time)
386 c_ret_if(!base_time);
388 cal_day_time_s *p = base_time;
391 if (!p->mouse_clicked_timer) {
392 p->mouse_clicked_timer = ecore_timer_add(DAY_TIME_DOUBLE_CLICK_TIME, __cal_day_time_mouse_clicked_timer_callback, p);
397 static Evas_Object* __cal_day_time_create_time_d(cal_base_time_h base_time, int d)
399 c_retv_if(!base_time, NULL);
401 cal_base_time_s *p = (cal_base_time_s *)base_time;
403 struct appdata *ad = ((cal_day_time_s *)p)->ad;
404 c_retv_if(!ad, NULL);
406 cal_base_time_block_h time_block = NULL;
407 time_t r = cal_util_update_tm_day(&ad->base_tm, d);
408 c_retv_if(r < 0, NULL);
411 if (!p->left_base_time_block) {
412 p->left_base_time_block = cal_base_time_block_new(p->base_type, p->scroller, p->clip, NULL, ((cal_day_time_s *)p)->ad->base_tm.tm_hour, ((cal_day_time_s *)p)->ad);
413 time_block = p->left_base_time_block;
416 if (!p->right_base_time_block) {
417 p->right_base_time_block = cal_base_time_block_new(p->base_type, p->scroller, p->clip, NULL, ((cal_day_time_s *)p)->ad->base_tm.tm_hour, ((cal_day_time_s *)p)->ad);
418 time_block = p->right_base_time_block;
421 r = cal_util_update_tm_day(&ad->base_tm, -d);
422 c_retv_if(r < 0, NULL);
424 if (((cal_day_time_s *)p)->ad->is_magnifying) {
425 cal_day_time_block_resize(time_block, 0, cal_day_time_block_get_current(p->base_time_block), EINA_FALSE);
427 if (((cal_day_time_s *)p)->ad->is_contracted) {
428 cal_day_time_block_resize(time_block, 0, 0, EINA_TRUE);
430 cal_day_time_block_resize(time_block, 0, cal_day_time_block_get_max(p->base_time_block), EINA_FALSE);
437 static void __cal_day_time_state_enable_flick_action(cal_base_time_h base_time)
439 c_ret_if(!base_time);
441 cal_day_time_s *p = base_time;
443 cal_base_time_freeze_scroller(p);
446 static void __cal_day_time_state_flicking_action(cal_base_time_h base_time)
448 c_ret_if(!base_time);
450 cal_base_time_s *p = (cal_base_time_s *)base_time;
452 Evas_Coord_Rectangle r;
454 __cal_day_time_create_time_d(p, ((cal_day_time_s *)p)->flick_direction);
456 Evas_Coord d = p->single_mouse_move.x - p->single_mouse_down.x;
458 cal_base_time_block_get_geometry(p->base_time_block, &r);
460 cal_base_time_block_move(p->base_time_block, p->scroller_coord.x + d, r.y);
462 if (p->left_base_time_block) {
463 cal_base_time_block_move(p->left_base_time_block, p->scroller_coord.x + d - r.w, r.y);
466 if (p->right_base_time_block) {
467 cal_base_time_block_move(p->right_base_time_block, p->scroller_coord.x + d + r.w, r.y);
471 static void __cal_day_time_update_time_block(cal_base_time_h base_time)
474 c_ret_if(!base_time);
476 cal_base_time_s *p = (cal_base_time_s *)base_time;
478 Evas_Coord_Rectangle rect = {0};
480 cal_base_time_block_get_geometry(p->base_time_block, &rect);
482 int r = cal_util_update_tm_day(&((cal_day_time_s *)p)->ad->base_tm, ((cal_day_time_s *)p)->flick_direction);
483 c_retm_if(r < 0, "cal_util_update_tm_day() is returned %d", r);
485 cal_day_time_block_unset_callback(p->base_time_block);
487 if (0 < ((cal_day_time_s *)p)->flick_direction) {
488 if (p->left_base_time_block){
489 cal_base_time_block_delete(p->left_base_time_block);
490 p->left_base_time_block = NULL;
493 p->left_base_time_block = p->base_time_block;
494 p->base_time_block = p->right_base_time_block;
495 p->right_base_time_block = __cal_day_time_create_time_d(p, 1);
496 } else if (((cal_day_time_s *)p)->flick_direction < 0) {
497 if (p->right_base_time_block) {
498 cal_base_time_block_delete(p->right_base_time_block);
499 p->right_base_time_block = NULL;
502 p->right_base_time_block = p->base_time_block;
503 p->base_time_block = p->left_base_time_block;
504 p->left_base_time_block = __cal_day_time_create_time_d(p, -1);
507 cal_day_time_block_set_callback(p->base_time_block, __cal_day_time_mouse_event_callback, p);
509 cal_base_time_block_move(p->left_base_time_block, p->scroller_coord.x - rect.w, rect.y);
510 cal_base_time_block_move(p->base_time_block, p->scroller_coord.x, rect.y);
511 cal_base_time_block_move(p->right_base_time_block, p->scroller_coord.x + rect.w, rect.y);
513 cal_main_update_title_text(((cal_day_time_s *)p)->ad);
515 cal_day_update_genlist(p->parent);
518 static void __cal_day_time_state_disable_flick_action(cal_base_time_h base_time)
521 c_ret_if(!base_time);
523 cal_base_time_s *p = (cal_base_time_s *)base_time;
525 Evas_Coord_Rectangle r;
527 Evas_Coord_Rectangle rect = {0};
529 d = p->single_mouse_move.x - p->single_mouse_down.x;
531 cal_util_get_geometry(&rect, p->scroller);
533 if ( (rect.w/2) < abs(d)) {
534 __cal_day_time_update_time_block(p);
536 cal_base_time_block_get_geometry(p->base_time_block, &r);
537 cal_base_time_block_move(p->base_time_block, p->scroller_coord.x, r.y);
538 if (p->left_base_time_block) {
539 cal_base_time_block_move(p->left_base_time_block, p->scroller_coord.x - r.w, r.y);
541 if (p->right_base_time_block) {
542 cal_base_time_block_move(p->right_base_time_block, p->scroller_coord.x + r.w, r.y);
546 cal_base_time_thaw_scroller(p);
549 static void __cal_day_time_state_enable_scroll_action(cal_base_time_h base_time)
551 c_ret_if(!base_time);
553 cal_day_time_s *p = (cal_day_time_s *)base_time;
557 static void __cal_day_time_state_scrolling_action(cal_base_time_h base_time)
559 c_ret_if(!base_time);
563 static void __cal_day_time_state_disable_scroll_action(cal_base_time_h base_time)
565 c_ret_if(!base_time);
567 cal_base_time_s *p = (cal_base_time_s *)base_time;
569 p->single_mouse_down.x = -1;
570 p->single_mouse_down.y = -1;
572 p->single_mouse_move.x = -1;
573 p->single_mouse_move.y = -1;
576 static void __cal_day_time_state_enable_moving_event_action(cal_base_time_h base_time)
578 c_ret_if(!base_time);
580 cal_base_time_freeze_scroller(base_time);
583 static void __cal_day_time_state_event_moving_action(cal_base_time_h base_time)
585 c_ret_if(!base_time);
587 cal_base_time_s *p = (cal_base_time_s *)base_time;
589 c_ret_if(-1 == p->single_mouse_down.x);
590 c_ret_if(-1 == p->single_mouse_down.y);
591 c_ret_if(-1 == p->single_mouse_move.x);
592 c_ret_if(-1 == p->single_mouse_move.y);
594 cal_day_time_block_moving_moveable_event(p->base_time_block, &p->single_mouse_move, &p->single_mouse_down);
598 static void __cal_day_time_state_disable_moving_event_action(cal_base_time_h base_time)
600 c_ret_if(!base_time);
602 cal_base_time_s *p = (cal_base_time_s *)base_time;
604 cal_base_time_thaw_scroller(p);
606 cal_day_time_block_disable_moving_moveable_event(p->base_time_block, &p->single_mouse_move, &p->single_mouse_down);
608 ((cal_day_time_s *)p)->is_quit_editmode = EINA_TRUE;
610 cal_base_time_state_transition(p, SINGLE_MOUSE_DOWN);
611 cal_base_time_state_actions(p);
615 static void __cal_day_time_state_enable_zoom_event_action(cal_base_time_h base_time)
617 c_ret_if(!base_time);
619 cal_base_time_s *p = (cal_base_time_s *)base_time;
621 cal_base_time_freeze_scroller(p);
623 ((cal_day_time_s *)p)->mouse_down_distance = cal_util_get_distance(&p->single_mouse_down, &p->multi_mouse_down);
626 static void __cal_day_time_zoom_callback(cal_base_time_h base_time)
628 c_ret_if(!base_time);
630 cal_day_time_s *p = (cal_day_time_s *)base_time;
635 if (p->ad->is_contracted)
638 Evas_Coord d = cal_util_get_distance(&((cal_base_time_s *)p)->single_mouse_move, &((cal_base_time_s *)p)->multi_mouse_move);
639 rate = (double)d/p->mouse_down_distance;
641 if (p->ad->is_magnifying) {
642 h = cal_day_time_block_get_current(((cal_base_time_s *)p)->base_time_block);
644 h = cal_day_time_block_get_max(((cal_base_time_s *)p)->base_time_block);
647 if (rate < 1 && !p->ad->is_magnifying)
650 if (p->ad->is_magnifying) {
651 cal_day_time_block_resize(((cal_base_time_s *)p)->base_time_block, (((cal_base_time_s *)p)->single_mouse_down.y + ((cal_base_time_s *)p)->multi_mouse_down.y) >> 1, h + cal_day_time_block_get_min() * (rate-1), EINA_FALSE);
653 cal_day_time_block_resize(((cal_base_time_s *)p)->base_time_block, (((cal_base_time_s *)p)->single_mouse_down.y + ((cal_base_time_s *)p)->multi_mouse_down.y) >> 1, h * rate, EINA_FALSE);
657 static void __cal_day_time_state_zooming_event_action(cal_base_time_h base_time)
659 c_ret_if(!base_time);
661 __cal_day_time_zoom_callback(base_time);
665 static Eina_Bool __cal_day_time_change(void *data)
667 c_retv_if(!data, ECORE_CALLBACK_CANCEL);
669 cal_day_time_s *p = (cal_day_time_s *)data;
671 if (p->idler_for_time_block) {
672 ecore_idler_del(p->idler_for_time_block);
673 p->idler_for_time_block = NULL;
676 cal_main_change_view(p->ad->main, CV_WEEK);
678 return ECORE_CALLBACK_CANCEL;
682 static void __cal_day_time_signal_disable_zoom_callback(cal_base_time_h base_time)
684 c_ret_if(!base_time);
686 cal_day_time_s *p = (cal_day_time_s *)base_time;
689 c_ret_if(!p->ad->main);
690 c_ret_if(!((cal_base_time_s *)p)->base_time_block);
692 Eina_Bool is_magnifying = p->ad->is_magnifying;
693 int h_cur = cal_day_time_block_get_current(((cal_base_time_s *)p)->base_time_block);
694 int h_normal = cal_day_time_block_get_max(((cal_base_time_s *)p)->base_time_block);
696 if (!is_magnifying && (h_normal < h_cur)) {
697 p->ad->is_magnifying = EINA_TRUE;
699 cal_day_time_block_resize(((cal_base_time_s *)p)->left_base_time_block, 0, cal_day_time_block_get_current(((cal_base_time_s *)p)->base_time_block), EINA_FALSE);
700 cal_day_time_block_resize(((cal_base_time_s *)p)->right_base_time_block, 0, cal_day_time_block_get_current(((cal_base_time_s *)p)->base_time_block), EINA_FALSE);
702 ((cal_base_time_s *)p)->state_action_type = STATE_START;
704 cal_base_time_thaw_scroller(p);
705 __cal_day_time_scroll_zoom(p, NULL, NULL, NULL);
706 } else if (is_magnifying) {
707 if (h_cur <= h_normal)
708 p->ad->is_magnifying = EINA_FALSE;
710 cal_day_time_block_resize(((cal_base_time_s *)p)->left_base_time_block, 0, cal_day_time_block_get_current(((cal_base_time_s *)p)->base_time_block), EINA_FALSE);
711 cal_day_time_block_resize(((cal_base_time_s *)p)->right_base_time_block, 0, cal_day_time_block_get_current(((cal_base_time_s *)p)->base_time_block), EINA_FALSE);
713 ((cal_base_time_s *)p)->state_action_type = STATE_START;
715 cal_base_time_thaw_scroller(p);
716 __cal_day_time_scroll_zoom(p, NULL, NULL, NULL);
719 Evas_Coord th = elm_config_finger_size_get();
721 d = cal_util_get_distance(&((cal_base_time_s *)p)->single_mouse_move, &((cal_base_time_s *)p)->multi_mouse_move);
723 if (th < abs(d-p->mouse_down_distance)) {
724 if (p->idler_for_change)
725 ecore_idler_del(p->idler_for_change);
727 p->idler_for_change = ecore_idler_add(__cal_day_time_change, p);
732 static void __cal_day_time_state_disable_zoom_event_action(cal_base_time_h base_time)
734 c_ret_if(!base_time);
738 static void __cal_day_time_state_actions(cal_base_time_h base_time)
740 c_ret_if(!base_time);
742 cal_base_time_s *p = (cal_base_time_s *)base_time;
744 switch (p->state_action_type)
746 case STATE_DOWN_FIRST:
747 case STATE_DOWN_SECOND:
748 __cal_day_time_state_down_action(p);
751 __cal_day_time_state_up_action(p);
753 case STATE_ENABLE_FLICK:
754 __cal_day_time_state_enable_flick_action(p);
757 __cal_day_time_state_flicking_action(p);
759 case STATE_DISABLE_FLICK:
760 __cal_day_time_state_disable_flick_action(p);
762 case STATE_ENABLE_SCROLL:
763 __cal_day_time_state_enable_scroll_action(p);
765 case STATE_SCROLLING:
766 __cal_day_time_state_scrolling_action(p);
768 case STATE_DISABLE_SCROLL:
769 __cal_day_time_state_disable_scroll_action(p);
771 case STATE_ENABLE_MOVEING_EVENT:
772 __cal_day_time_state_enable_moving_event_action(p);
774 case STATE_MOVING_EVENT:
775 __cal_day_time_state_event_moving_action(p);
777 case STATE_DISABLE_MOVEING_EVENT:
778 __cal_day_time_state_disable_moving_event_action(p);
780 case STATE_ENABLE_ZOOM:
781 __cal_day_time_state_enable_zoom_event_action(p);
784 __cal_day_time_state_zooming_event_action(p);
786 case STATE_DISABLE_ZOOM:
787 __cal_day_time_state_disable_zoom_event_action(p);
794 static void __cal_day_time_state_transition(cal_base_time_h base_time, enum cal_base_time_input_signal_type input)
796 c_ret_if(!base_time);
798 cal_base_time_s *p = (cal_base_time_s *)base_time;
800 switch (p->state_action_type)
803 if (SINGLE_MOUSE_DOWN == input) {
804 ((cal_day_time_s *)p)->is_quit_editmode = EINA_FALSE;
805 p->state_action_type = STATE_DOWN_FIRST;
808 case STATE_DOWN_FIRST:
809 if (SINGLE_MOUSE_UP == input) {
810 p->state_action_type = STATE_UP_FIRST;
811 } else if (SCROLLER_DRAG_START == input) {
812 int width_d = p->single_mouse_move.x - p->single_mouse_down.x;
813 int heigt_d = p->single_mouse_move.y - p->single_mouse_down.y;
814 if (abs(width_d) < abs(heigt_d)) {
815 p->state_action_type = STATE_ENABLE_SCROLL;
817 ((cal_day_time_s *)p)->flick_direction = ((0 < width_d) ? -1 : 1);
818 p->state_action_type = STATE_ENABLE_FLICK;
820 } else if (MULTI_MOUSE_DOWN == input) {
821 p->state_action_type = STATE_ENABLE_ZOOM;
825 if (SINGLE_MOUSE_DOWN == input) {
826 p->state_action_type = STATE_DOWN_SECOND;
829 case STATE_DOWN_SECOND:
830 if (SINGLE_MOUSE_UP == input) {
831 p->state_action_type = STATE_UP_SECOND;
832 } else if (SCROLLER_DRAG_START == input) {
833 int width_d = p->single_mouse_move.x - p->single_mouse_down.x;
834 int heigt_d = p->single_mouse_move.y - p->single_mouse_down.y;
835 if (abs(width_d) < abs(heigt_d)) {
836 p->state_action_type = STATE_ENABLE_SCROLL;
838 ((cal_day_time_s *)p)->flick_direction = ((0 < width_d) ? -1 : 1);
839 p->state_action_type = STATE_ENABLE_FLICK;
841 } else if (MULTI_MOUSE_DOWN == input) {
842 p->state_action_type = STATE_ENABLE_ZOOM;
845 case STATE_ENABLE_FLICK:
847 ((cal_day_time_s *)p)->flick_direction = ((0 < (p->single_mouse_move.x - p->single_mouse_down.x) ) ? -1 : 1);
848 if (SINGLE_MOUSE_UP == input) {
849 p->state_action_type = STATE_DISABLE_FLICK;
850 } else if (SINGLE_MOUSE_MOVE == input) {
851 p->state_action_type = STATE_FLICKING;
854 case STATE_ENABLE_SCROLL:
855 case STATE_SCROLLING:
856 if (SINGLE_MOUSE_UP == input) {
857 p->state_action_type = STATE_DISABLE_SCROLL;
858 } else if (SINGLE_MOUSE_MOVE == input) {
859 p->state_action_type = STATE_SCROLLING;
862 case STATE_ENABLE_MOVEING_EVENT:
863 if (SINGLE_MOUSE_DOWN == input) {
864 Eina_Bool is_quit = cal_day_time_block_hint_quit_event_moveable_state(p->base_time_block, &p->single_mouse_down);
866 p->state_action_type = STATE_DISABLE_MOVEING_EVENT;
869 if (SINGLE_MOUSE_MOVE == input) {
870 p->state_action_type = STATE_MOVING_EVENT;
873 if (SINGLE_MOUSE_UP == input) {
874 p->single_mouse_down.x = -1;
875 p->single_mouse_down.y = -1;
877 p->single_mouse_move.x = -1;
878 p->single_mouse_move.y = -1;
882 case STATE_MOVING_EVENT:
883 if (SINGLE_MOUSE_DOWN == input) {
884 Eina_Bool is_quit = cal_day_time_block_hint_quit_event_moveable_state(p->base_time_block, &p->single_mouse_down);
886 p->state_action_type = STATE_DISABLE_MOVEING_EVENT;
889 if (SINGLE_MOUSE_UP == input) {
890 p->single_mouse_down.x = -1;
891 p->single_mouse_down.y = -1;
893 p->single_mouse_move.x = -1;
894 p->single_mouse_move.y = -1;
898 case STATE_DISABLE_MOVEING_EVENT:
899 p->state_action_type = STATE_START;
900 if (SINGLE_MOUSE_DOWN == input) {
901 p->state_action_type = STATE_DOWN_FIRST;
904 case STATE_ENABLE_ZOOM:
905 if (input == SINGLE_MOUSE_UP || input == MULTI_MOUSE_UP) {
906 p->state_action_type = STATE_DISABLE_ZOOM;
908 p->state_action_type = STATE_ZOOMING;
912 if (input == SINGLE_MOUSE_UP || input == MULTI_MOUSE_UP) {
913 p->state_action_type = STATE_DISABLE_ZOOM;
916 case STATE_DISABLE_ZOOM:
917 if (input == SINGLE_MOUSE_UP || input == MULTI_MOUSE_UP) {
918 __cal_day_time_signal_disable_zoom_callback(p);
921 case STATE_DISABLE_FLICK:
922 case STATE_DISABLE_SCROLL:
923 case STATE_UP_SECOND:
924 p->state_action_type = STATE_START;
925 if (SINGLE_MOUSE_DOWN == input) {
926 ((cal_day_time_s *)p)->is_quit_editmode = EINA_FALSE;
927 p->state_action_type = STATE_DOWN_FIRST;