GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_radial_slider_needle_rectangle_calculate.c Lines: 19 19 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
/**   Radial Slider Management (Slider)                                   */
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_utility.h"
30
#include "gx_radial_slider.h"
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_radial_slider_needle_rectangle_calculate        PORTABLE C      */
37
/*                                                           6.1.10       */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This service calculates the bounding rectangle of the radial slider */
45
/*    needle.                                                             */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    slider                                Radial slider control block   */
50
/*    rectangle                             Rectangle to be retrieved     */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    status                                Completion status             */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    _gx_widget_pixelmap_get               Retrieve pixelmap with        */
59
/*                                           specified resource id        */
60
/*    _gx_utility_rectangle_define          Define a rectangle            */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    GUIX Internal Code                                                  */
65
/*                                                                        */
66
/**************************************************************************/
67
189
UINT _gx_radial_slider_needle_rectangle_calculate(GX_RADIAL_SLIDER *slider, GX_RECTANGLE *rectangle)
68
{
69
GX_PIXELMAP           *map;
70
189
GX_RADIAL_SLIDER_INFO *info = &slider -> gx_radial_slider_info;
71
INT                    xpos;
72
INT                    ypos;
73
74
189
    _gx_widget_pixelmap_get((GX_WIDGET *)slider, info -> gx_radial_slider_info_needle_pixelmap, &map);
75
76
189
    if (map)
77
    {
78
188
        xpos = _gx_utility_math_cos(GX_FIXED_VAL_MAKE(info -> gx_radial_slider_info_current_angle));
79
188
        ypos = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(info -> gx_radial_slider_info_current_angle));
80
81
        /* calculate sin and cos value of current angle value. */
82
188
        xpos = GX_FIXED_VAL_RND((info -> gx_radial_slider_info_radius + info -> gx_radial_slider_info_needle_offset) * xpos);
83
188
        ypos = GX_FIXED_VAL_RND((info -> gx_radial_slider_info_radius + info -> gx_radial_slider_info_needle_offset) * ypos);
84
85
        /* calculate needle position. */
86
188
        xpos += info -> gx_radial_slider_info_xcenter;
87
188
        ypos = info -> gx_radial_slider_info_ycenter - ypos;
88
89
188
        xpos -= map -> gx_pixelmap_width >> 1;
90
188
        ypos -= map -> gx_pixelmap_height >> 1;
91
92
188
        xpos += slider -> gx_widget_size.gx_rectangle_left;
93
188
        ypos += slider -> gx_widget_size.gx_rectangle_top;
94
95
        /* define needle rectangle. */
96
188
        _gx_utility_rectangle_define(rectangle, (GX_VALUE)xpos, (GX_VALUE)ypos,
97
188
                                    (GX_VALUE)(xpos + map -> gx_pixelmap_width),
98
188
                                    (GX_VALUE)(ypos + map -> gx_pixelmap_height));
99
    }
100
    else
101
    {
102
1
        _gx_utility_rectangle_define(rectangle, 0, 0, 0, 0);
103
    }
104
105
189
    return GX_SUCCESS;
106
}
107