GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_vertical_list_selected_visible.c Lines: 13 13 100.0 %
Date: 2024-12-05 08:52:37 Branches: 8 8 100.0 %

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
/**   Vertical 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
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_vertical_list_selected_visible                  PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This service make the selected list item visible.                   */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    vertical_list                         Vertical list widget control  */
49
/*                                          block                         */
50
/*    list_entry                            Pointer to new list entry     */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    NONE                                                                */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    _gx_vertical_list_scroll                                            */
59
/*    _gx_window_scrollbar_find                                           */
60
/*    _gx_scrollbar_reset                                                 */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    _gx_vertical_list_selected_set                                      */
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
46
VOID _gx_vertical_list_selected_visible(GX_VERTICAL_LIST *list, GX_WIDGET *child)
76
{
77
GX_SCROLLBAR *pScroll;
78
46
GX_BOOL       update_scroll = GX_FALSE;
79
80
46
    if (child -> gx_widget_size.gx_rectangle_top < list -> gx_window_client.gx_rectangle_top)
81
    {
82
        /* need to scroll children down */
83
4
        _gx_vertical_list_scroll(list, list -> gx_window_client.gx_rectangle_top - child -> gx_widget_size.gx_rectangle_top);
84
4
        update_scroll = GX_TRUE;
85
    }
86
    else
87
    {
88
42
        if (child -> gx_widget_size.gx_rectangle_bottom > list -> gx_window_client.gx_rectangle_bottom)
89
        {
90
            /* need to scroll children up */
91
12
            _gx_vertical_list_scroll(list, list -> gx_window_client.gx_rectangle_bottom - child -> gx_widget_size.gx_rectangle_bottom);
92
12
            update_scroll = GX_TRUE;
93
        }
94
    }
95
96
46
    if (update_scroll)
97
    {
98
16
        _gx_window_scrollbar_find((GX_WINDOW *)list, GX_TYPE_VERTICAL_SCROLL, &pScroll);
99
100
16
        if (pScroll)
101
        {
102
10
            _gx_scrollbar_reset(pScroll, GX_NULL);
103
        }
104
    }
105
46
}
106