GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_radial_progress_bar_event_process.c Lines: 42 42 100.0 %
Date: 2024-12-05 08:52:37 Branches: 21 21 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
/**   Progress Bar Management (Radial Progress Bar)                       */
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_radial_progress_bar.h"
29
#include "gx_utility.h"
30
#include "gx_system.h"
31
#include "gx_canvas.h"
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_radial_progress_bar_event_process               PORTABLE C      */
38
/*                                                           6.1.8        */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This service processes a radial progress bar event.                 */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    radial_progress_bar                   Radial Progress Bar control   */
50
/*                                            block                       */
51
/*    event_ptr                             Pointer to event process      */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    status                                Completion status             */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    _gx_widget_event_process              Default widget event process  */
60
/*    _gx_radial_progress_bar_resize        Resize the progress bar       */
61
/*    _gx_radial_progress_bar_value_calculate                             */
62
/*                                          Calculate the value of the    */
63
/*                                            progress bar                */
64
/*                                                                        */
65
/*  CALLED BY                                                             */
66
/*                                                                        */
67
/*    Application Code                                                    */
68
/*    GUIX Internal Code                                                  */
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
/*  08-02-2021     Ting Zhu                 Modified comment(s),          */
78
/*                                            removed size update logic   */
79
/*                                            from GX_EVENT_SHOW entry,   */
80
/*                                            resulting in version 6.1.8  */
81
/*                                                                        */
82
/**************************************************************************/
83
963
UINT  _gx_radial_progress_bar_event_process(GX_RADIAL_PROGRESS_BAR *progress_bar, GX_EVENT *event_ptr)
84
{
85
UINT                         status;
86
INT                          x_dist;
87
INT                          y_dist;
88
INT                          dist;
89
GX_POINT                    *click;
90
GX_RADIAL_PROGRESS_BAR_INFO *info;
91
92
93
    /* Default status to success.  */
94
963
    status =  GX_SUCCESS;
95
96
    /* Process relative to the type of event.  */
97

963
    switch (event_ptr -> gx_event_type)
98
    {
99
158
    case GX_EVENT_SHOW:
100
158
        _gx_widget_event_process((GX_WIDGET *)progress_bar, event_ptr);
101
158
        break;
102
103
#if defined(GX_BRUSH_ALPHA_SUPPORT)
104
120
    case GX_EVENT_HIDE:
105
120
        _gx_widget_event_process((GX_WIDGET *)progress_bar, event_ptr);
106

120
        if ((progress_bar -> gx_radial_progress_bar_canvas.gx_canvas_memory) &&
107
            _gx_system_memory_free)
108
        {
109
4
            _gx_system_memory_free((VOID *)progress_bar -> gx_radial_progress_bar_canvas.gx_canvas_memory);
110
4
            _gx_canvas_delete(&progress_bar -> gx_radial_progress_bar_canvas);
111
        }
112
120
        break;
113
#endif
114
115
585
    case GX_EVENT_RESIZED:
116
585
        _gx_radial_progress_bar_resize(progress_bar);
117
585
        break;
118
119
27
    case GX_EVENT_PEN_DOWN:
120
27
        if (progress_bar -> gx_widget_style & GX_STYLE_ENABLED)
121
        {
122
26
            _gx_system_input_capture((GX_WIDGET *)progress_bar);
123
124
26
            info = &progress_bar -> gx_radial_progress_bar_info;
125
26
            click = &event_ptr -> gx_event_payload.gx_event_pointdata;
126
127
26
            x_dist = (INT)(click -> gx_point_x - info -> gx_radial_progress_bar_info_xcenter);
128
26
            y_dist = (INT)(click -> gx_point_y - info -> gx_radial_progress_bar_info_ycenter);
129
130
26
            dist = (x_dist * x_dist) + (y_dist * y_dist);
131
26
            dist = (INT)_gx_utility_math_sqrt((UINT)dist);
132
133
26
            if ((dist <= (INT)(info -> gx_radial_progress_bar_info_radius + (info -> gx_radial_progress_bar_info_selected_brush_width >> 1))) &&
134
25
                (dist >= (INT)(info -> gx_radial_progress_bar_info_radius - (info -> gx_radial_progress_bar_info_selected_brush_width >> 1))))
135
            {
136
                /* Calculate radial progress bar value.  */
137
17
                _gx_radial_progress_bar_value_calculate(progress_bar, event_ptr -> gx_event_payload.gx_event_pointdata);
138
            }
139
        }
140
        else
141
        {
142
1
            _gx_widget_event_to_parent((GX_WIDGET *)progress_bar, event_ptr);
143
        }
144
27
        break;
145
146
26
    case GX_EVENT_PEN_UP:
147
26
        if (progress_bar -> gx_widget_status & GX_STATUS_OWNS_INPUT)
148
        {
149
25
            _gx_system_input_release((GX_WIDGET *)progress_bar);
150
        }
151
        else
152
        {
153
1
            _gx_widget_event_to_parent((GX_WIDGET *)progress_bar, event_ptr);
154
        }
155
26
        break;
156
157
9
    case GX_EVENT_PEN_DRAG:
158
9
        if (progress_bar -> gx_widget_status & GX_STATUS_OWNS_INPUT)
159
        {
160
8
            _gx_radial_progress_bar_value_calculate(progress_bar, event_ptr -> gx_event_payload.gx_event_pointdata);
161
        }
162
        else
163
        {
164
1
            _gx_widget_event_to_parent((GX_WIDGET *)progress_bar, event_ptr);
165
        }
166
9
        break;
167
168
38
    default:
169
170
        /* Call the widget default processing.  */
171
38
        status = _gx_widget_event_process((GX_WIDGET *)progress_bar, event_ptr);
172
    }
173
174
    /* Return completion status.  */
175
963
    return(status);
176
}
177