GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_horizontal_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
/**   Horizontal List (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
#define GX_SNAP_TIMER  1000
33
#define GX_FLICK_TIMER 1001
34
35
/**************************************************************************/
36
/*                                                                        */
37
/*  FUNCTION                                               RELEASE        */
38
/*                                                                        */
39
/*    _gx_horizontal_list_slide_back_check                PORTABLE C      */
40
/*                                                           6.1          */
41
/*  AUTHOR                                                                */
42
/*                                                                        */
43
/*    Kenneth Maxwell, Microsoft Corporation                              */
44
/*                                                                        */
45
/*  DESCRIPTION                                                           */
46
/*                                                                        */
47
/*    This function checks the sliding back of the scrollbar.             */
48
/*                                                                        */
49
/*  INPUT                                                                 */
50
/*                                                                        */
51
/*    list                                  Horizontal list widget        */
52
/*                                            control block               */
53
/*                                                                        */
54
/*  OUTPUT                                                                */
55
/*                                                                        */
56
/*    None                                                                */
57
/*                                                                        */
58
/*  CALLS                                                                 */
59
/*                                                                        */
60
/*    _gx_first_client_child_get            Get the first client child    */
61
/*    _gx_system_timer_start                Allocate a free timer and     */
62
/*                                            activates it                */
63
/*    _gx_last_client_child_get             Get the last client child     */
64
/*                                                                        */
65
/*  CALLED BY                                                             */
66
/*                                                                        */
67
/*    _gx_horizontal_list_event_process                                   */
68
/*    sw_horizontal_list_event_process                                    */
69
/*                                                                        */
70
/*  RELEASE HISTORY                                                       */
71
/*                                                                        */
72
/*    DATE              NAME                      DESCRIPTION             */
73
/*                                                                        */
74
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
75
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
76
/*                                            resulting in version 6.1    */
77
/*                                                                        */
78
/**************************************************************************/
79
147
VOID _gx_horizontal_list_slide_back_check(GX_HORIZONTAL_LIST *list)
80
{
81
GX_WIDGET *child;
82
INT        page_index;
83
84
147
    if (list -> gx_horizontal_list_child_count <= 0)
85
    {
86
1
        return;
87
    }
88
89
    /* Calculate page index. */
90
146
    page_index = list -> gx_horizontal_list_top_index;
91
92
146
    child = _gx_widget_first_client_child_get((GX_WIDGET *)list);
93
94

493
    while (child && (child -> gx_widget_size.gx_rectangle_left <= list -> gx_widget_size.gx_rectangle_left))
95
    {
96
347
        page_index++;
97
347
        child = _gx_widget_next_client_child_get(child);
98
    }
99
100
146
    list -> gx_horizontal_list_snap_back_distance = 0;
101
102
146
    if (page_index == 0)
103
    {
104
22
        child = _gx_widget_first_client_child_get((GX_WIDGET *)list);
105

22
        if (child && (child -> gx_widget_size.gx_rectangle_left > list -> gx_window_client.gx_rectangle_left))
106
        {
107
11
            list -> gx_horizontal_list_snap_back_distance = (GX_VALUE)(list -> gx_window_client.gx_rectangle_left -
108
11
                                                                       child -> gx_widget_size.gx_rectangle_left);
109
11
            _gx_system_timer_start((GX_WIDGET *)list, GX_SNAP_TIMER, 1, 1);
110
        }
111
    }
112
    else
113
    {
114
124
        if (list -> gx_horizontal_list_top_index + list -> gx_horizontal_list_child_count >= list -> gx_horizontal_list_total_columns - 1)
115
        {
116
54
            child = _gx_widget_last_client_child_get((GX_WIDGET *)list);
117

54
            if (child && (child -> gx_widget_size.gx_rectangle_right < list -> gx_window_client.gx_rectangle_right))
118
            {
119
8
                list -> gx_horizontal_list_snap_back_distance = (GX_VALUE)(list -> gx_window_client.gx_rectangle_right -
120
8
                                                                           child -> gx_widget_size.gx_rectangle_right);
121
8
                _gx_system_timer_start((GX_WIDGET *)list, GX_SNAP_TIMER, 1, 1);
122
            }
123
        }
124
    }
125
}
126