GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_horizontal_list_selected_visible.c Lines: 13 13 100.0 %
Date: 2026-03-06 19:21:09 Branches: 8 8 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
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
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_horizontal_list_selected_visible                PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This service sets the list entry at the current list index.         */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    horizontal_list                       Horizontal list widget        */
50
/*                                            control block               */
51
/*    list_entry                            Pointer to new list entry     */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    status                                Completion status             */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    _gx_widget_event_generate             Creates a new GX_EVENT        */
60
/*    _gx_system_dirty_mark                 Mark the widget dirty         */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    _gx_horizontal_list_event_process                                   */
65
/*                                                                        */
66
/**************************************************************************/
67
52
VOID _gx_horizontal_list_selected_visible(GX_HORIZONTAL_LIST *list, GX_WIDGET *child)
68
{
69
GX_SCROLLBAR *pScroll;
70
52
GX_BOOL       update_scroll = GX_FALSE;
71
72
52
    if (child -> gx_widget_size.gx_rectangle_left < list -> gx_window_client.gx_rectangle_left)
73
    {
74
        /* need to scroll children down */
75
2
        _gx_horizontal_list_scroll(list, list -> gx_window_client.gx_rectangle_left - child -> gx_widget_size.gx_rectangle_left);
76
2
        update_scroll = GX_TRUE;
77
    }
78
    else
79
    {
80
50
        if (child -> gx_widget_size.gx_rectangle_right > list -> gx_window_client.gx_rectangle_right)
81
        {
82
            /* need to scroll children up */
83
14
            _gx_horizontal_list_scroll(list, list -> gx_window_client.gx_rectangle_right - child -> gx_widget_size.gx_rectangle_right);
84
14
            update_scroll = GX_TRUE;
85
        }
86
    }
87
88
52
    if (update_scroll)
89
    {
90
16
        _gx_window_scrollbar_find((GX_WINDOW *)list, GX_TYPE_HORIZONTAL_SCROLL, &pScroll);
91
92
16
        if (pScroll)
93
        {
94
8
            _gx_scrollbar_reset(pScroll, GX_NULL);
95
        }
96
    }
97
52
}
98