GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_radial_slider_animation_update.c Lines: 19 19 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
/**   Radial Slider Management (Slider)                                   */
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_system.h"
29
#include "gx_utility.h"
30
#include "gx_radial_slider.h"
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_radial_slider_animation_update                  PORTABLE C      */
37
/*                                                           6.1.11       */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function updates slider value for each animation step.         */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    slider                                Radial slider control block   */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    status                                Completion status             */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    _gx_utility_easing_function_calculate Calculate next slide angle    */
57
/*                                            with specified easing       */
58
/*                                            function type               */
59
/*    _gx_radial_slider_angle_set           Set radial slider angle       */
60
/*    _gx_system_dirty_mark                 Mark widget as dirty          */
61
/*    _gx_system_timer_stop                 Stop specified timer          */
62
/*    _gx_widget_event_generate             Send event its parent         */
63
/*                                                                        */
64
/*  CALLED BY                                                             */
65
/*                                                                        */
66
/*    GUIX Internal Code                                                  */
67
/*                                                                        */
68
/*  RELEASE HISTORY                                                       */
69
/*                                                                        */
70
/*    DATE              NAME                      DESCRIPTION             */
71
/*                                                                        */
72
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
73
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
74
/*                                            resulting in version 6.1    */
75
/*  04-25-2022     Ting Zhu                 Modified comment(s),          */
76
/*                                            added animation step test,  */
77
/*                                            resulting in version 6.1.11 */
78
/*                                                                        */
79
/**************************************************************************/
80
136
UINT _gx_radial_slider_animation_update(GX_RADIAL_SLIDER *slider)
81
{
82
136
GX_RADIAL_SLIDER_INFO *info = &slider -> gx_radial_slider_info;
83
136
INT                    current_val = info -> gx_radial_slider_info_current_angle;
84
85
136
    if (slider -> gx_radial_slider_animation_step > 0)
86
    {
87
135
        slider -> gx_radial_slider_animation_step--;
88
89
135
        _gx_utility_easing_function_calculate(slider -> gx_radial_slider_animation_style,
90
135
                                              slider -> gx_radial_slider_start_angle,
91
135
                                              slider -> gx_radial_slider_target_angle,
92
135
                                              slider -> gx_radial_slider_animation_total_steps - slider -> gx_radial_slider_animation_step,
93
135
                                              slider -> gx_radial_slider_animation_total_steps,
94
                                              &current_val);
95
96
        /* set radial slider value. */
97
135
        _gx_radial_slider_angle_set(slider, (GX_VALUE)current_val);
98
99
135
        if (slider -> gx_radial_slider_animation_update_callback)
100
        {
101
            /* Call callback function. */
102
30
            slider -> gx_radial_slider_animation_update_callback(slider);
103
        }
104
105
135
        if (slider -> gx_radial_slider_animation_step == 0)
106
        {
107
9
            _gx_system_timer_stop((GX_WIDGET *)slider, GX_RADIAL_SLIDER_TIMER);
108
109
9
            _gx_widget_event_generate((GX_WIDGET *)slider, GX_EVENT_ANIMATION_COMPLETE, current_val);
110
        }
111
112
135
        if (slider -> gx_widget_status & GX_STATUS_VISIBLE)
113
        {
114
120
            _gx_system_dirty_mark((GX_WIDGET *)slider);
115
        }
116
    }
117
118
136
    return GX_SUCCESS;
119
}
120