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 /** List Management (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 /**************************************************************************/ 34 /* */ 35 /* FUNCTION RELEASE */ 36 /* */ 37 /* _gx_vertical_list_slide_back_check PORTABLE C */ 38 /* 6.1 */ 39 /* AUTHOR */ 40 /* */ 41 /* Kenneth Maxwell, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This function checks the sliding back of the scrollbar. */ 46 /* */ 47 /* INPUT */ 48 /* */ 49 /* vertical_list Vertical list widget control */ 50 /* block */ 51 /* */ 52 /* OUTPUT */ 53 /* */ 54 /* None */ 55 /* */ 56 /* CALLS */ 57 /* */ 58 /* _gx_first_client_child_get Get the first child widget */ 59 /* _gx_system_timer_start Allocate a free timer and */ 60 /* activate it */ 61 /* _gx_last_client_child_get Get the last client child */ 62 /* */ 63 /* CALLED BY */ 64 /* */ 65 /* Application Code */ 66 /* */ 67 /* RELEASE HISTORY */ 68 /* */ 69 /* DATE NAME DESCRIPTION */ 70 /* */ 71 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 72 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 73 /* resulting in version 6.1 */ 74 /* */ 75 /**************************************************************************/ _gx_vertical_list_slide_back_check(GX_VERTICAL_LIST * list)76VOID _gx_vertical_list_slide_back_check(GX_VERTICAL_LIST *list) 77 { 78 GX_WIDGET *child; 79 INT page_index; 80 81 if (list -> gx_vertical_list_child_count <= 0) 82 { 83 return; 84 } 85 86 /* Calculate page index. */ 87 page_index = list -> gx_vertical_list_top_index; 88 89 child = _gx_widget_first_client_child_get((GX_WIDGET *)list); 90 91 while (child && (child -> gx_widget_size.gx_rectangle_top <= list -> gx_widget_size.gx_rectangle_top)) 92 { 93 page_index++; 94 child = _gx_widget_next_client_child_get(child); 95 } 96 97 list -> gx_vertical_list_snap_back_distance = 0; 98 99 if (page_index == 0) 100 { 101 child = _gx_widget_first_client_child_get((GX_WIDGET *)list); 102 if (child && (child -> gx_widget_size.gx_rectangle_top > list -> gx_window_client.gx_rectangle_top)) 103 { 104 list -> gx_vertical_list_snap_back_distance = (GX_VALUE)(list -> gx_window_client.gx_rectangle_top - 105 child -> gx_widget_size.gx_rectangle_top); 106 _gx_system_timer_start((GX_WIDGET *)list, GX_SNAP_TIMER, 1, 1); 107 } 108 } 109 else 110 { 111 if (list -> gx_vertical_list_top_index + list -> gx_vertical_list_child_count >= list -> gx_vertical_list_total_rows - 1) 112 { 113 child = _gx_widget_last_client_child_get((GX_WIDGET *)list); 114 if (child && (child -> gx_widget_size.gx_rectangle_bottom < list -> gx_window_client.gx_rectangle_bottom)) 115 { 116 list -> gx_vertical_list_snap_back_distance = (GX_VALUE)(list -> gx_window_client.gx_rectangle_bottom - 117 child -> gx_widget_size.gx_rectangle_bottom); 118 _gx_system_timer_start((GX_WIDGET *)list, GX_SNAP_TIMER, 1, 1); 119 } 120 } 121 } 122 } 123 124