GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_vertical_list_slide_back_check.c Lines: 21 21 100.0 %
Date: 2024-12-05 08:52:37 Branches: 16 18 88.9 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 *
4
 * This program and the accompanying materials are made available under the
5
 * terms of the MIT License which is available at
6
 * https://opensource.org/licenses/MIT.
7
 *
8
 * SPDX-License-Identifier: MIT
9
 **************************************************************************/
10
11
12
/**************************************************************************/
13
/**************************************************************************/
14
/**                                                                       */
15
/** GUIX Component                                                        */
16
/**                                                                       */
17
/**   List Management (List)                                              */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_widget.h"
28
#include "gx_window.h"
29
#include "gx_system.h"
30
#include "gx_scrollbar.h"
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_vertical_list_slide_back_check                  PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function checks the sliding back of the scrollbar.             */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    vertical_list                         Vertical list widget control  */
49
/*                                            block                       */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    None                                                                */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    _gx_first_client_child_get            Get the first child widget    */
58
/*    _gx_system_timer_start                Allocate a free timer and     */
59
/*                                            activate it                 */
60
/*    _gx_last_client_child_get             Get the last client child     */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    Application Code                                                    */
65
/*                                                                        */
66
/*  RELEASE HISTORY                                                       */
67
/*                                                                        */
68
/*    DATE              NAME                      DESCRIPTION             */
69
/*                                                                        */
70
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
71
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
72
/*                                            resulting in version 6.1    */
73
/*                                                                        */
74
/**************************************************************************/
75
143
VOID _gx_vertical_list_slide_back_check(GX_VERTICAL_LIST *list)
76
{
77
GX_WIDGET *child;
78
INT        page_index;
79
80
143
    if (list -> gx_vertical_list_child_count <= 0)
81
    {
82
1
        return;
83
    }
84
85
    /* Calculate page index. */
86
142
    page_index = list -> gx_vertical_list_top_index;
87
88
142
    child = _gx_widget_first_client_child_get((GX_WIDGET *)list);
89
90

495
    while (child && (child -> gx_widget_size.gx_rectangle_top <= list -> gx_widget_size.gx_rectangle_top))
91
    {
92
353
        page_index++;
93
353
        child = _gx_widget_next_client_child_get(child);
94
    }
95
96
142
    list -> gx_vertical_list_snap_back_distance = 0;
97
98
142
    if (page_index == 0)
99
    {
100
19
        child = _gx_widget_first_client_child_get((GX_WIDGET *)list);
101

19
        if (child && (child -> gx_widget_size.gx_rectangle_top > list -> gx_window_client.gx_rectangle_top))
102
        {
103
13
            list -> gx_vertical_list_snap_back_distance = (GX_VALUE)(list -> gx_window_client.gx_rectangle_top -
104
13
                                                                     child -> gx_widget_size.gx_rectangle_top);
105
13
            _gx_system_timer_start((GX_WIDGET *)list, GX_SNAP_TIMER, 1, 1);
106
        }
107
    }
108
    else
109
    {
110
123
        if (list -> gx_vertical_list_top_index + list -> gx_vertical_list_child_count >= list -> gx_vertical_list_total_rows - 1)
111
        {
112
53
            child = _gx_widget_last_client_child_get((GX_WIDGET *)list);
113

53
            if (child && (child -> gx_widget_size.gx_rectangle_bottom < list -> gx_window_client.gx_rectangle_bottom))
114
            {
115
8
                list -> gx_vertical_list_snap_back_distance = (GX_VALUE)(list -> gx_window_client.gx_rectangle_bottom -
116
8
                                                                         child -> gx_widget_size.gx_rectangle_bottom);
117
8
                _gx_system_timer_start((GX_WIDGET *)list, GX_SNAP_TIMER, 1, 1);
118
            }
119
        }
120
    }
121
}
122