1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** GUIX Component */ 17 /** */ 18 /** Horizontal List (List) */ 19 /** */ 20 /**************************************************************************/ 21 22 #define GX_SOURCE_CODE 23 24 25 /* Include necessary system files. */ 26 27 #include "gx_api.h" 28 #include "gx_widget.h" 29 #include "gx_window.h" 30 #include "gx_system.h" 31 #include "gx_scrollbar.h" 32 33 #define GX_SNAP_TIMER 1000 34 #define GX_FLICK_TIMER 1001 35 36 /**************************************************************************/ 37 /* */ 38 /* FUNCTION RELEASE */ 39 /* */ 40 /* _gx_horizontal_list_slide_back_check PORTABLE C */ 41 /* 6.1 */ 42 /* AUTHOR */ 43 /* */ 44 /* Kenneth Maxwell, Microsoft Corporation */ 45 /* */ 46 /* DESCRIPTION */ 47 /* */ 48 /* This function checks the sliding back of the scrollbar. */ 49 /* */ 50 /* INPUT */ 51 /* */ 52 /* list Horizontal list widget */ 53 /* control block */ 54 /* */ 55 /* OUTPUT */ 56 /* */ 57 /* None */ 58 /* */ 59 /* CALLS */ 60 /* */ 61 /* _gx_first_client_child_get Get the first client child */ 62 /* _gx_system_timer_start Allocate a free timer and */ 63 /* activates it */ 64 /* _gx_last_client_child_get Get the last client child */ 65 /* */ 66 /* CALLED BY */ 67 /* */ 68 /* _gx_horizontal_list_event_process */ 69 /* sw_horizontal_list_event_process */ 70 /* */ 71 /* RELEASE HISTORY */ 72 /* */ 73 /* DATE NAME DESCRIPTION */ 74 /* */ 75 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 76 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 77 /* resulting in version 6.1 */ 78 /* */ 79 /**************************************************************************/ _gx_horizontal_list_slide_back_check(GX_HORIZONTAL_LIST * list)80VOID _gx_horizontal_list_slide_back_check(GX_HORIZONTAL_LIST *list) 81 { 82 GX_WIDGET *child; 83 INT page_index; 84 85 if (list -> gx_horizontal_list_child_count <= 0) 86 { 87 return; 88 } 89 90 /* Calculate page index. */ 91 page_index = list -> gx_horizontal_list_top_index; 92 93 child = _gx_widget_first_client_child_get((GX_WIDGET *)list); 94 95 while (child && (child -> gx_widget_size.gx_rectangle_left <= list -> gx_widget_size.gx_rectangle_left)) 96 { 97 page_index++; 98 child = _gx_widget_next_client_child_get(child); 99 } 100 101 list -> gx_horizontal_list_snap_back_distance = 0; 102 103 if (page_index == 0) 104 { 105 child = _gx_widget_first_client_child_get((GX_WIDGET *)list); 106 if (child && (child -> gx_widget_size.gx_rectangle_left > list -> gx_window_client.gx_rectangle_left)) 107 { 108 list -> gx_horizontal_list_snap_back_distance = (GX_VALUE)(list -> gx_window_client.gx_rectangle_left - 109 child -> gx_widget_size.gx_rectangle_left); 110 _gx_system_timer_start((GX_WIDGET *)list, GX_SNAP_TIMER, 1, 1); 111 } 112 } 113 else 114 { 115 if (list -> gx_horizontal_list_top_index + list -> gx_horizontal_list_child_count >= list -> gx_horizontal_list_total_columns - 1) 116 { 117 child = _gx_widget_last_client_child_get((GX_WIDGET *)list); 118 if (child && (child -> gx_widget_size.gx_rectangle_right < list -> gx_window_client.gx_rectangle_right)) 119 { 120 list -> gx_horizontal_list_snap_back_distance = (GX_VALUE)(list -> gx_window_client.gx_rectangle_right - 121 child -> gx_widget_size.gx_rectangle_right); 122 _gx_system_timer_start((GX_WIDGET *)list, GX_SNAP_TIMER, 1, 1); 123 } 124 } 125 } 126 } 127 128