GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_sprite_create.c Lines: 12 12 100.0 %
Date: 2026-03-06 19:21:09 Branches: 2 2 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
/**   Sprite Management (Sprite)                                          */
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_sprite.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_sprite_create                                   PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function creates a sprite, which is a special type of          */
45
/*    widget.                                                             */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    sprite                                Pointer to sprite widget      */
50
/*                                            control block               */
51
/*    name                                  Logical name of sprite        */
52
/*    parent                                Pointer to parent widget      */
53
/*                                            of sprite                   */
54
/*    frame_list                            The frame_list to be assigned */
55
/*    frame_count                           Number of frames in the frame */
56
/*    style                                 Sprite stuyle                 */
57
/*    button_id                             Application-defined ID of     */
58
/*                                             the sprite                 */
59
/*    size                                  Size of the sprite            */
60
/*                                                                        */
61
/*  OUTPUT                                                                */
62
/*                                                                        */
63
/*    status                                Completion status             */
64
/*                                                                        */
65
/*  CALLS                                                                 */
66
/*                                                                        */
67
/*    _gx_widget_create                     Create the underlying widget  */
68
/*    _gx_widget_link                       Link the sprite to its parent */
69
/*                                                                        */
70
/*  CALLED BY                                                             */
71
/*                                                                        */
72
/*    Application Code                                                    */
73
/*                                                                        */
74
/**************************************************************************/
75
477
UINT  _gx_sprite_create(GX_SPRITE *sprite, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
76
                        GX_SPRITE_FRAME *frame_list, USHORT frame_count,
77
                        ULONG style, USHORT sprite_id, GX_CONST GX_RECTANGLE *size)
78
{
79
80
    /* Call the widget create function.  */
81
477
    _gx_widget_create((GX_WIDGET *)sprite, name, GX_NULL, style, sprite_id, size);
82
83
    /* Populate the rest of prompt control block - overriding as necessary.  */
84
477
    sprite -> gx_widget_type =                   GX_TYPE_SPRITE;
85
477
    sprite -> gx_widget_draw_function =          (VOID (*)(GX_WIDGET *))_gx_sprite_draw;
86
477
    sprite -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_sprite_event_process;
87
477
    sprite -> gx_sprite_current_frame = 0;
88
477
    sprite -> gx_sprite_run_state = GX_SPRITE_IDLE;
89
477
    sprite -> gx_sprite_frame_list = frame_list;
90
477
    sprite -> gx_sprite_frame_count = frame_count;
91
92
    /* Determine if a parent widget was provided.  */
93
477
    if (parent)
94
    {
95
476
        _gx_widget_link(parent, (GX_WIDGET *)sprite);
96
    }
97
98
    /* Return the status from prompt create.  */
99
477
    return(GX_SUCCESS);
100
}
101