GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_radial_progress_bar_size_update.c Lines: 16 16 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
/**   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_radial_progress_bar.h"
28
#include "gx_widget.h"
29
#include "gx_utility.h"
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_radial_prpgress_bar_size_update                 PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function calculate the size of the radial progress bar.        */
44
/*                                                                        */
45
/*  INPUT                                                                 */
46
/*                                                                        */
47
/*    radial_progress                       Radial progess bar control    */
48
/*                                            block                       */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    status                                Completion status             */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    _gx_widget_resize                     Resize the widget             */
57
/*                                                                        */
58
/*  CALLED BY                                                             */
59
/*                                                                        */
60
/*    Application Code                                                    */
61
/*                                                                        */
62
/*  RELEASE HISTORY                                                       */
63
/*                                                                        */
64
/*    DATE              NAME                      DESCRIPTION             */
65
/*                                                                        */
66
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
67
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
68
/*                                            resulting in version 6.1    */
69
/*                                                                        */
70
/**************************************************************************/
71
72
1729
UINT _gx_radial_progress_bar_size_update(GX_RADIAL_PROGRESS_BAR *radial_progress)
73
{
74
GX_RADIAL_PROGRESS_BAR_INFO *info;
75
GX_RECTANGLE                *size;
76
GX_RECTANGLE                 new_size;
77
GX_VALUE                     width;
78
79
1729
    info = &radial_progress -> gx_radial_progress_bar_info;
80
81
1729
    width = info -> gx_radial_progress_bar_info_selected_brush_width;
82
83
1729
    if (width < info -> gx_radial_progress_bar_info_normal_brush_width)
84
    {
85
451
        width = info -> gx_radial_progress_bar_info_normal_brush_width;
86
    }
87
88
1729
    width = (GX_VALUE)((width + 1) >> 1);
89
    /* Calculate new size.  */
90
1729
    new_size.gx_rectangle_left = (GX_VALUE)(info -> gx_radial_progress_bar_info_xcenter - info -> gx_radial_progress_bar_info_radius - width);
91
1729
    new_size.gx_rectangle_right = (GX_VALUE)(info -> gx_radial_progress_bar_info_xcenter + info -> gx_radial_progress_bar_info_radius + width);
92
1729
    new_size.gx_rectangle_top = (GX_VALUE)(info -> gx_radial_progress_bar_info_ycenter - info -> gx_radial_progress_bar_info_radius - width);
93
1729
    new_size.gx_rectangle_bottom = (GX_VALUE)(info -> gx_radial_progress_bar_info_ycenter + info -> gx_radial_progress_bar_info_radius + width);
94
95
    /* Retrieve old progress bar size.  */
96
1729
    size = &radial_progress -> gx_widget_size;
97
98
1729
    if ((new_size.gx_rectangle_left != size -> gx_rectangle_left) ||
99
372
        (new_size.gx_rectangle_right != size -> gx_rectangle_right) ||
100
370
        (new_size.gx_rectangle_top != size -> gx_rectangle_top))
101
    {
102
        /* Update radial progress bar size.  */
103
1360
        _gx_widget_resize((GX_WIDGET *)radial_progress, &new_size);
104
    }
105
106
1729
    return GX_SUCCESS;
107
}
108