1 
2 #include "demo_guix_home_automation.h"
3 
4 extern GX_ANIMATION slide_animation;
5 
6 /* Define screen information structure. */
7 typedef struct SCREEN_INFO_STRUCT{
8     SCREEN_BASE_CONTROL_BLOCK *widget; /* Poniter to screen widget. */
9     GX_WIDGET **window_list; /* Page list for screen slide animation. */
10     GX_WIDGET **pagination_list; /* Pagination list to indicate current page. */
11 }SCREEN_INFO;
12 
13 /* Define footer menu information structure. */
14 typedef struct FOOTER_MENU_INFO_STRUCT{
15     INT            footer_menu_id; /* Footer menu widget id. */
16     GX_RESOURCE_ID footer_normal_icon; /* Normal pixelmap id. */
17     GX_RESOURCE_ID footer_selected_icon; /* Selected pixelmap id. */
18 }FOOTER_MENU_INFO;
19 
20 /* Page list for light screen. */
21 static GX_WIDGET *lights_win_list[] = {
22     (GX_WIDGET *)&lights_page_1,
23     (GX_WIDGET *)&lights_page_2,
24     (GX_WIDGET *)&lights_page_3,
25     (GX_WIDGET *)&lights_page_4,
26     GX_NULL
27 };
28 
29 /* Page list for thermostat screen. */
30 static GX_WIDGET *thermostat_win_list[] = {
31     (GX_WIDGET *)&thermostat_page_1,
32     (GX_WIDGET *)&thermostat_page_2,
33     (GX_WIDGET *)&thermostat_page_3,
34     (GX_WIDGET *)&thermostat_page_4,
35     GX_NULL
36 };
37 
38 /* Page list for lock screen. */
39 static GX_WIDGET *locks_win_list[] = {
40     (GX_WIDGET *)&locks_page_1,
41     (GX_WIDGET *)&locks_page_2,
42     (GX_WIDGET *)&locks_page_3,
43     GX_NULL
44 };
45 
46 /* Page list for weather screen. */
47 static GX_WIDGET *weather_win_list[] = {
48     (GX_WIDGET *)&win_San_Diego,
49     (GX_WIDGET *)&win_New_York,
50     (GX_WIDGET *)&win_Las_Vegas,
51     GX_NULL
52 };
53 
54 /* Pagination list for light screen. */
55 static GX_WIDGET *lights_pagination_list[] = {
56     (GX_WIDGET *)&lights_screen.lights_screen_pagination_1,
57     (GX_WIDGET *)&lights_screen.lights_screen_pagination_2,
58     (GX_WIDGET *)&lights_screen.lights_screen_pagination_3,
59     (GX_WIDGET *)&lights_screen.lights_screen_pagination_4,
60     GX_NULL
61 };
62 
63 /* Pagination list for lock screen. */
64 static GX_WIDGET *locks_pagination_list[] = {
65     (GX_WIDGET *)&locks_screen.locks_screen_pagination_1,
66     (GX_WIDGET *)&locks_screen.locks_screen_pagination_2,
67     (GX_WIDGET *)&locks_screen.locks_screen_pagination_3,
68     GX_NULL
69 };
70 
71 /* Pagination list for weather screen. */
72 static GX_WIDGET *weather_pagination_list[] = {
73     (GX_WIDGET *)&weather_screen.weather_screen_pagination_1,
74     (GX_WIDGET *)&weather_screen.weather_screen_pagination_2,
75     (GX_WIDGET *)&weather_screen.weather_screen_pagination_3,
76     GX_NULL
77 };
78 
79 /* Pagination list for thermostat screen. */
80 static GX_WIDGET *thermostat_pagination_list[] = {
81     (GX_WIDGET *)&thermostat_screen.thermostat_screen_pagination_1,
82     (GX_WIDGET *)&thermostat_screen.thermostat_screen_pagination_2,
83     (GX_WIDGET *)&thermostat_screen.thermostat_screen_pagination_3,
84     (GX_WIDGET *)&thermostat_screen.thermostat_screen_pagination_4,
85     GX_NULL
86 };
87 
88 /* This is a list of screens and page/pagination lists that applied to those screens. */
89 static SCREEN_INFO screen_info_list[] = {
90     { &lights_screen.base, lights_win_list, lights_pagination_list},
91     { &thermostat_screen.base, thermostat_win_list, thermostat_pagination_list},
92     { &locks_screen.base, locks_win_list, locks_pagination_list},
93     { &weather_screen.base, weather_win_list, weather_pagination_list},
94     {GX_NULL, GX_NULL, GX_NULL}
95 };
96 
97 /* This is a list of footer menu ids, normal and selected pixelmaps that maps to one menu. */
98 static FOOTER_MENU_INFO footer_menu_info_list[] = {
99     { ID_FOOTER_LIGHTS, GX_PIXELMAP_ID_FOOTER_MENU_ICON_LIGHT, GX_PIXELMAP_ID_FOOTER_MENU_ICON_LIGHT_ACTIVE },
100     { ID_FOOTER_THERMOSTAT, GX_PIXELMAP_ID_FOOTER_MENU_ICON_THERMOSTAT, GX_PIXELMAP_ID_FOOTER_MENU_ICON_THERMOSTAT_ACTIVE },
101     { ID_FOOTER_LOCKS, GX_PIXELMAP_ID_FOOTER_MENU_ICON_LOCK, GX_PIXELMAP_ID_FOOTER_MENU_ICON_LOCK_ACTIVE },
102     { ID_FOOTER_WEATHER, GX_PIXELMAP_ID_FOOTER_MENU_ICON_WEATHER, GX_PIXELMAP_ID_FOOTER_MENU_ICON_WEATHER_ACTIVE },
103     { 0, 0, 0}
104 };
105 
106 /* This variable is used to count the number of in process slide animations. */
107 int page_slide_animation_count = 0;
108 
109 /* This variable is used to count the number of in process child animations in current screen. */
110 int screen_animation_count = 0;
111 
112 /******************************************************************************************/
113 /* Test if there is animation in process.                                                 */
114 /******************************************************************************************/
is_animation_active()115 static GX_BOOL is_animation_active()
116 {
117     if (page_slide_animation_count ||
118         slide_animation.gx_animation_status != GX_ANIMATION_IDLE)
119     {
120         return GX_TRUE;
121     }
122 
123     return GX_FALSE;
124 }
125 
126 /******************************************************************************************/
127 /* Reterieve window list for screen slide animation.                                      */
128 /******************************************************************************************/
screen_info_get(GX_WIDGET * screen)129 static SCREEN_INFO *screen_info_get(GX_WIDGET *screen)
130 {
131     SCREEN_INFO *info = screen_info_list;
132 
133     while (info->widget)
134     {
135         if ((GX_WIDGET *)info->widget == screen)
136         {
137             return info;
138         }
139         info++;
140     }
141 
142     return GX_NULL;
143 }
144 
145 /******************************************************************************************/
146 /* Start animations for footer icons.                                                     */
147 /******************************************************************************************/
footer_icons_animation_start(SCREEN_BASE_CONTROL_BLOCK * base)148 static VOID footer_icons_animation_start(SCREEN_BASE_CONTROL_BLOCK *base)
149 {
150     GX_ANIMATION *animation;
151     GX_ANIMATION_INFO info;
152     GX_WIDGET *target;
153 
154     memset(&info, 0, sizeof(GX_ANIMATION_INFO));
155     info.gx_animation_style = GX_ANIMATION_ELASTIC_EASE_OUT;
156     info.gx_animation_parent = (GX_WIDGET *)base;
157     info.gx_animation_start_alpha = 255;
158     info.gx_animation_end_alpha = 255;
159     info.gx_animation_steps = 400 / GX_SYSTEM_TIMER_MS;
160     info.gx_animation_frame_interval = 2;
161 
162     if (gx_system_animation_get(&animation) == GX_SUCCESS)
163     {
164         /* start home icon animation. */
165         target = (GX_WIDGET *)&base->screen_base_home;;
166 
167         info.gx_animation_id = ANIMATION_ID_FOOTER_HOME;
168         info.gx_animation_target = target;
169         info.gx_animation_start_position.gx_point_x = target->gx_widget_size.gx_rectangle_left;
170         info.gx_animation_start_position.gx_point_y = 0;
171         info.gx_animation_end_position.gx_point_x = target->gx_widget_size.gx_rectangle_left;
172         info.gx_animation_end_position.gx_point_y = DISPLAY_1_Y_RESOLUTION - 45;
173 
174         gx_widget_style_remove(target, GX_STYLE_ENABLED);
175         gx_animation_start(animation, &info);
176     }
177 
178     if (gx_system_animation_get(&animation) == GX_SUCCESS)
179     {
180         /* start setting icon animation. */
181         target = (GX_WIDGET *)&base->screen_base_setting;;
182         info.gx_animation_id = ANIMATION_ID_FOOTER_SETTING;
183         info.gx_animation_target = target;
184         info.gx_animation_start_position.gx_point_x = target->gx_widget_size.gx_rectangle_left;
185         info.gx_animation_start_position.gx_point_y = DISPLAY_1_Y_RESOLUTION + 55;
186         info.gx_animation_end_position.gx_point_x = target->gx_widget_size.gx_rectangle_left;
187         info.gx_animation_end_position.gx_point_y = DISPLAY_1_Y_RESOLUTION - 45;
188 
189         gx_widget_style_remove(target, GX_STYLE_ENABLED);
190         gx_animation_start(animation, &info);
191     }
192 
193     if (gx_system_animation_get(&animation) == GX_SUCCESS)
194     {
195         /* start add window animation. */
196         target = (GX_WIDGET *)&base->screen_base_add;
197 
198         info.gx_animation_id = ANIMATION_ID_FOOTER_ADD;
199         info.gx_animation_target = target;
200         info.gx_animation_start_position.gx_point_x = DISPLAY_1_X_RESOLUTION;
201         info.gx_animation_start_position.gx_point_y = target->gx_widget_size.gx_rectangle_top;
202         info.gx_animation_end_position.gx_point_x = DISPLAY_1_X_RESOLUTION - 115;
203         info.gx_animation_end_position.gx_point_y = target->gx_widget_size.gx_rectangle_top;
204 
205         gx_widget_style_remove(target, GX_STYLE_ENABLED);
206         gx_animation_start(animation, &info);
207     }
208 }
209 
210 /******************************************************************************************/
211 /* Start title animation for widgets that based on "controler_base".                      */
212 /******************************************************************************************/
title_animation_start(CONTROLLER_BASE_CONTROL_BLOCK * base)213 VOID title_animation_start(CONTROLLER_BASE_CONTROL_BLOCK *base)
214 {
215     GX_ANIMATION *animation;
216     GX_ANIMATION_INFO info;
217     GX_WIDGET *target;
218 
219     if (gx_system_animation_get(&animation) == GX_SUCCESS)
220     {
221         memset(&info, 0, sizeof(GX_ANIMATION_INFO));
222 
223         target = (GX_WIDGET *)&base->controller_base_title;
224         info.gx_animation_style = 0;
225         info.gx_animation_id = ANIMATION_ID_SCREEN_CHILDREN;
226         info.gx_animation_parent = (GX_WIDGET *)base;
227         info.gx_animation_target = target;
228         info.gx_animation_start_alpha = 255;
229         info.gx_animation_end_alpha = 255;
230         info.gx_animation_steps = 100 / GX_SYSTEM_TIMER_MS;
231         info.gx_animation_frame_interval = 2;
232         info.gx_animation_start_position.gx_point_x = base->gx_widget_size.gx_rectangle_left + 22;
233         info.gx_animation_start_position.gx_point_y = base->gx_widget_size.gx_rectangle_top - 18;
234         info.gx_animation_end_position.gx_point_x = base->gx_widget_size.gx_rectangle_left + 22;
235         info.gx_animation_end_position.gx_point_y = base->gx_widget_size.gx_rectangle_top + 14;
236 
237         gx_animation_start(animation, &info);
238 
239         screen_animation_count++;
240     }
241 }
242 
243 /******************************************************************************************/
244 /* Start screen slide animation for specified window.                                     */
245 /******************************************************************************************/
slide_animation_start(GX_WINDOW * window)246 static VOID slide_animation_start(GX_WINDOW *window)
247 {
248     GX_ANIMATION_INFO slide_animation_info;
249     SCREEN_INFO *info = screen_info_get(window->gx_widget_parent);
250 
251     if (info)
252     {
253         if (!window->gx_widget_first_child)
254         {
255             gx_widget_attach((GX_WIDGET *)window, info->window_list[0]);
256         }
257 
258         memset(&slide_animation_info, 0, sizeof(GX_ANIMATION_INFO));
259         slide_animation_info.gx_animation_parent = (GX_WIDGET *)window;
260         slide_animation_info.gx_animation_style = GX_ANIMATION_SCREEN_DRAG | GX_ANIMATION_HORIZONTAL | GX_ANIMATION_WRAP | GX_ANIMATION_SINE_EASE_OUT;
261         slide_animation_info.gx_animation_id = ANIMATION_ID_DRAG_SLIDE;
262         slide_animation_info.gx_animation_frame_interval = 1;
263         slide_animation_info.gx_animation_steps = 400 / GX_SYSTEM_TIMER_MS;
264         slide_animation_info.gx_animation_slide_screen_list = info->window_list;
265 
266         gx_animation_drag_enable(&slide_animation, (GX_WIDGET *)window, &slide_animation_info);
267     }
268 }
269 
270 /******************************************************************************************/
271 /* Retrieve page index with the specified page id.                                        */
272 /******************************************************************************************/
get_page_index(INT page_id)273 static INT get_page_index(INT page_id)
274 {
275     INT page_index = 0;
276 
277     switch (page_id)
278     {
279     case ID_PAGINATION_1:
280         page_index = 0;
281         break;
282 
283     case ID_PAGINATION_2:
284         page_index = 1;
285         break;
286 
287     case ID_PAGINATION_3:
288         page_index = 2;
289         break;
290 
291     case ID_PAGINATION_4:
292         page_index = 3;
293         break;
294     }
295 
296     return page_index;
297 }
298 
299 /******************************************************************************************/
300 /* Enable/Disable pagination buttons.                                                     */
301 /******************************************************************************************/
pagination_button_enable_disable(GX_WINDOW * window,GX_BOOL enabled)302 VOID pagination_button_enable_disable(GX_WINDOW *window, GX_BOOL enabled)
303 {
304     SCREEN_INFO *info = screen_info_get((GX_WIDGET *)window);
305     GX_WIDGET *pagination;
306     INT index = 0;
307 
308     if (!info)
309     {
310         return;
311     }
312 
313     while (1)
314     {
315         pagination = info->pagination_list[index];
316 
317         if (pagination)
318         {
319             if (enabled)
320             {
321                 gx_widget_style_add(pagination, GX_STYLE_ENABLED);
322             }
323             else
324             {
325                 gx_widget_style_remove(pagination, GX_STYLE_ENABLED);
326             }
327 
328             index++;
329         }
330         else
331         {
332             break;
333         }
334     };
335 }
336 
337 /******************************************************************************************/
338 /* Update status of pagination buttons.                                                   */
339 /******************************************************************************************/
pagination_button_update(GX_WINDOW * window)340 static VOID pagination_button_update(GX_WINDOW *window)
341 {
342     INT         index;
343     GX_WIDGET  *screen;
344     GX_WIDGET  *pagination;
345     SCREEN_INFO *info = screen_info_get((GX_WIDGET *)window);
346 
347     /* Search current visible menu index. */
348     index = 0;
349 
350     if (!info)
351     {
352         return;
353     }
354 
355     switch (info->widget->gx_widget_id)
356     {
357     case ID_LIGHTS_SCREEN:
358         lights_screen_animation_start();
359         break;
360 
361     case ID_THERMOSTAT_SCREEN:
362         thermostat_screen_animation_start();
363         break;
364 
365     case ID_LOCKS_SCREEN:
366         locks_screen_animation_start();
367         break;
368 
369     case ID_WEATHER_SCREEN:
370         /* Start weather children animations. */
371         weather_screen_animation_start();
372         break;
373     }
374 
375     while (1)
376     {
377         screen = info->window_list[index];
378         pagination = info->pagination_list[index];
379 
380         if (screen && pagination)
381         {
382             if (screen->gx_widget_status & GX_STATUS_VISIBLE)
383             {
384                 gx_widget_style_add(pagination, GX_STYLE_BUTTON_PUSHED);
385             }
386             else
387             {
388                 gx_widget_style_remove(pagination, GX_STYLE_BUTTON_PUSHED);
389             }
390 
391             index++;
392         }
393         else
394         {
395             break;
396         }
397     }
398 }
399 
400 /******************************************************************************************/
401 /* Start animation to slide from current page to the specified page.                      */
402 /******************************************************************************************/
screen_list_slide(GX_WINDOW * window,INT page_id)403 static VOID screen_list_slide(GX_WINDOW *window, INT page_id)
404 {
405     GX_WIDGET        *target;
406     INT               current_index = -1;
407     INT               index;
408     INT               screen_width;
409     INT               animation_dis;
410     GX_ANIMATION     *animation;
411     GX_ANIMATION_INFO animation_info;
412     GX_WIDGET        *parent = GX_NULL;
413     SCREEN_INFO      *info = screen_info_get((GX_WIDGET *)window);
414     INT               page_index = get_page_index(page_id);
415 
416     if (!info)
417     {
418         return;
419     }
420 
421     index = 0;
422 
423     /* Search for visible page. */
424     while (1)
425     {
426         target = info->window_list[index];
427 
428         if (target)
429         {
430             if (target->gx_widget_status & GX_STATUS_VISIBLE)
431             {
432                 current_index = index;
433                 parent = target->gx_widget_parent;
434                 break;
435             }
436 
437             index++;
438         }
439         else
440         {
441             break;
442         }
443     }
444 
445     if (!parent)
446     {
447         return;
448     }
449 
450     screen_width = (target->gx_widget_size.gx_rectangle_right - target->gx_widget_size.gx_rectangle_left + 1);
451     animation_dis = screen_width * (current_index - page_index);
452 
453     memset(&animation_info, 0, sizeof(GX_ANIMATION_INFO));
454     animation_info.gx_animation_frame_interval = 1;
455     animation_info.gx_animation_id = ANIMATION_ID_PAGE_SLIDE;
456     animation_info.gx_animation_steps = 600 / GX_SYSTEM_TIMER_MS;
457     animation_info.gx_animation_start_alpha = 255;
458     animation_info.gx_animation_end_alpha = 255;
459     animation_info.gx_animation_parent = parent;
460     animation_info.gx_animation_start_position.gx_point_x = info->window_list[current_index]->gx_widget_size.gx_rectangle_left;
461     animation_info.gx_animation_start_position.gx_point_y = info->window_list[current_index]->gx_widget_size.gx_rectangle_top;
462     animation_info.gx_animation_end_position.gx_point_x = info->window_list[current_index]->gx_widget_size.gx_rectangle_left + animation_dis;
463     animation_info.gx_animation_end_position.gx_point_y = info->window_list[current_index]->gx_widget_size.gx_rectangle_top;
464     animation_info.gx_animation_target = info->window_list[current_index];
465     animation_info.gx_animation_style = GX_ANIMATION_TRANSLATE | GX_ANIMATION_DETACH;
466 
467     if (gx_system_animation_get(&animation) == GX_SUCCESS)
468     {
469         /* start animation to slide current page to target position. */
470         gx_animation_start(animation, &animation_info);
471         page_slide_animation_count++;
472     }
473 
474     while (current_index != page_index)
475     {
476         if (current_index < page_index)
477         {
478             animation_info.gx_animation_start_position.gx_point_x += screen_width;
479             current_index++;
480         }
481         else
482         {
483             animation_info.gx_animation_start_position.gx_point_x -= screen_width;
484             current_index--;
485         }
486 
487         if (current_index == page_index)
488         {
489             animation_info.gx_animation_style = GX_ANIMATION_TRANSLATE;
490         }
491 
492         animation_info.gx_animation_end_position.gx_point_x = animation_info.gx_animation_start_position.gx_point_x + animation_dis;
493 
494         animation_info.gx_animation_target = info->window_list[current_index];
495 
496         if (gx_system_animation_get(&animation) == GX_SUCCESS)
497         {
498             /* Start animation to slide following pages to target position until
499                the target page is on animation. */
500             gx_animation_start(animation, &animation_info);
501             page_slide_animation_count++;
502         }
503     }
504 }
505 
506 /******************************************************************************************/
507 /* Event handler for GX_EVENT_ANIMATION_COMPLETE.                                         */
508 /******************************************************************************************/
on_animation_complete(GX_WINDOW * window,GX_EVENT * event_ptr)509 static VOID on_animation_complete(GX_WINDOW *window, GX_EVENT *event_ptr)
510 {
511     SCREEN_BASE_CONTROL_BLOCK *base = (SCREEN_BASE_CONTROL_BLOCK*)window;
512 
513     switch (event_ptr->gx_event_sender)
514     {
515     case ANIMATION_ID_DRAG_SLIDE:
516         /* Update pagination status. */
517         pagination_button_update(window);
518         break;
519 
520     case ANIMATION_ID_PAGE_SLIDE:
521         page_slide_animation_count--;
522 
523         if (page_slide_animation_count == 0)
524         {
525             /* Update pagination status. */
526             pagination_button_update(window);
527         }
528         break;
529 
530     case ANIMATION_ID_FOOTER_HOME:
531         gx_widget_style_add(&base->screen_base_home, GX_STYLE_ENABLED);
532         break;
533 
534     case ANIMATION_ID_FOOTER_ADD:
535         gx_widget_style_add(&base->screen_base_add, GX_STYLE_ENABLED);
536         break;
537 
538     case ANIMATION_ID_FOOTER_SETTING:
539         gx_widget_style_add(&base->screen_base_setting, GX_STYLE_ENABLED);
540         break;
541 
542     case ANIMATION_ID_SCREEN_CHILDREN:
543         screen_animation_count--;
544 
545         if (screen_animation_count == 0)
546         {
547             /* Enable drag slide animation. */
548             slide_animation_start(&base->screen_base_slide_win);
549             pagination_button_enable_disable(window, GX_TRUE);
550         }
551         break;
552     }
553 }
554 
555 /******************************************************************************************/
556 /* Event handler for footer menu button click.                                            */
557 /******************************************************************************************/
on_footer_menu_clicked(INT button_id)558 VOID on_footer_menu_clicked(INT button_id)
559 {
560     SCREEN_BASE_CONTROL_BLOCK *base;
561     FOOTER_MENU_INFO *info = footer_menu_info_list;
562     GX_PIXELMAP_BUTTON *button;
563     GX_WIDGET *child;
564     INT map_id;
565 
566     switch (button_id)
567     {
568     case ID_FOOTER_LIGHTS:
569         base = &lights_screen.base;
570         break;
571 
572     case ID_FOOTER_THERMOSTAT:
573         base = &thermostat_screen.base;
574         break;
575 
576     case ID_FOOTER_LOCKS:
577         base = &locks_screen.base;
578         break;
579 
580     case ID_FOOTER_WEATHER:
581         base = &weather_screen.base;
582         break;
583 
584     default:
585         return;
586     }
587 
588     while (info->footer_menu_id)
589     {
590         gx_widget_find(base, info->footer_menu_id, GX_SEARCH_DEPTH_INFINITE, &button);
591 
592         if (info->footer_menu_id == button_id)
593         {
594             map_id = info->footer_selected_icon;
595         }
596         else
597         {
598             map_id = info->footer_normal_icon;
599         }
600 
601         child = button->gx_widget_first_child;
602 
603         while (child)
604         {
605             switch (child->gx_widget_type)
606             {
607             case GX_TYPE_PIXELMAP_BUTTON:
608                 gx_pixelmap_button_pixelmap_set((GX_PIXELMAP_BUTTON *)child, map_id, map_id, map_id);
609                 break;
610 
611             case GX_TYPE_PROMPT:
612                 if (info->footer_menu_id == button_id)
613                 {
614                     gx_widget_hide(child);
615                 }
616                 else
617                 {
618                     gx_widget_show(child);
619                 }
620 
621                 break;
622             }
623 
624             child = child->gx_widget_next;
625         }
626 
627         info++;
628     }
629 
630     toggle_screen((GX_WIDGET *)base);
631 }
632 
633 /******************************************************************************************/
634 /* Override the default event processing of "slide_win" to handle signals from my child   */
635 /* widgets.                                                                               */
636 /******************************************************************************************/
slide_win_event_process(GX_WINDOW * window,GX_EVENT * event_ptr)637 UINT slide_win_event_process(GX_WINDOW *window, GX_EVENT *event_ptr)
638 {
639     switch (event_ptr->gx_event_type)
640     {
641     case GX_EVENT_SHOW:
642         slide_animation_start(window);
643         return gx_widget_event_process(window, event_ptr);
644 
645     case GX_EVENT_HIDE:
646         gx_animation_drag_disable(&slide_animation, (GX_WIDGET *)window);
647         return gx_widget_event_process(window, event_ptr);
648 
649     default:
650         return gx_window_event_process(window, event_ptr);
651     }
652 
653     return 0;
654 }
655 
656 /******************************************************************************************/
657 /* Override the default event processing of templates based on "screen_base" to handle    */
658 /* signals from my child widgets.                                                         */
659 /******************************************************************************************/
screen_base_event_process(GX_WINDOW * window,GX_EVENT * event_ptr)660 UINT screen_base_event_process(GX_WINDOW *window, GX_EVENT *event_ptr)
661 {
662     switch (event_ptr->gx_event_type)
663     {
664     case GX_EVENT_SHOW:
665         /* Start animation of footer icons. */
666         footer_icons_animation_start((SCREEN_BASE_CONTROL_BLOCK *)window);
667         gx_window_event_process(window, event_ptr);
668         break;
669 
670     case GX_EVENT_HIDE:
671         switch (window->gx_widget_id)
672         {
673         case ID_LIGHTS_SCREEN:
674             lights_screen_animation_stop();
675             break;
676 
677         case ID_THERMOSTAT_SCREEN:
678             thermostat_screen_animation_stop();
679             break;
680 
681         case ID_LOCKS_SCREEN:
682             locks_screen_animation_stop();
683             break;
684 
685         case ID_WEATHER_SCREEN:
686             weather_screen_animation_stop();
687             break;
688         }
689 
690         /* Delete footer animations.  */
691         gx_animation_delete(GX_NULL, (GX_WIDGET *)window);
692 
693         /* Disable drag slide animation. */
694         gx_animation_drag_disable(&slide_animation, (GX_WIDGET*)&((SCREEN_BASE_CONTROL_BLOCK*)window)->screen_base_slide_win);
695 
696         gx_window_event_process(window, event_ptr);
697         break;
698 
699     case GX_SIGNAL(ID_HOME, GX_EVENT_CLICKED):
700         if (!is_animation_active())
701         {
702             /* Toggle to home screen. */
703             toggle_screen((GX_WIDGET *)&main_screen.main_screen_home_window);
704         }
705         break;
706 
707     case GX_SIGNAL(ID_ADD, GX_EVENT_CLICKED):
708         if (!is_animation_active())
709         {
710             /* Toggle to passcode screen. */
711             toggle_screen((GX_WIDGET *)&passcode_screen);
712         }
713         break;
714 
715     case GX_SIGNAL(ID_FOOTER_LIGHTS, GX_EVENT_CLICKED):
716     case GX_SIGNAL(ID_FOOTER_THERMOSTAT, GX_EVENT_CLICKED):
717     case GX_SIGNAL(ID_FOOTER_LOCKS, GX_EVENT_CLICKED):
718     case GX_SIGNAL(ID_FOOTER_WEATHER, GX_EVENT_CLICKED):
719         if (!is_animation_active())
720         {
721             on_footer_menu_clicked(event_ptr->gx_event_type >> 8);
722         }
723         break;
724 
725     case GX_SIGNAL(ID_PAGINATION_1, GX_EVENT_RADIO_SELECT):
726     case GX_SIGNAL(ID_PAGINATION_2, GX_EVENT_RADIO_SELECT):
727     case GX_SIGNAL(ID_PAGINATION_3, GX_EVENT_RADIO_SELECT):
728     case GX_SIGNAL(ID_PAGINATION_4, GX_EVENT_RADIO_SELECT):
729         if (!is_animation_active())
730         {
731             /* Disable drag slide animation. */
732             gx_animation_drag_disable(&slide_animation, (GX_WIDGET *)&((SCREEN_BASE_CONTROL_BLOCK *)window)->screen_base_slide_win);
733             pagination_button_enable_disable(window, GX_FALSE);
734 
735             screen_list_slide(window, event_ptr->gx_event_type >> 8);
736         }
737         break;
738 
739     case GX_EVENT_ANIMATION_COMPLETE:
740         if (window -> gx_widget_status & GX_STATUS_VISIBLE)
741         {
742             on_animation_complete(window, event_ptr);
743         }
744         break;
745 
746     default:
747         return gx_window_event_process(window, event_ptr);
748     }
749 
750     return 0;
751 }
752