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_system.h"
28 #include "gx_widget.h"
29 #include "gx_radial_slider.h"
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _gx_radial_slider_animation_start                   PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Kenneth Maxwell, Microsoft Corporation                              */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This service starts an animation to move the slider needle from     */
44 /*    current postion to the new position.                                */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    slider                                Radial slider control block   */
49 /*    target_angle                          Target angle value            */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    status                                Completion status             */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    _gx_system_timer_start                Start a timer                 */
58 /*    _gx_widget_event_generate             Generate child signal         */
59 /*    _gx_radial_slider_angle_set           Set new slider value          */
60 /*                                                                        */
61 /*  CALLED BY                                                             */
62 /*                                                                        */
63 /*    Application Code                                                    */
64 /*                                                                        */
65 /*  RELEASE HISTORY                                                       */
66 /*                                                                        */
67 /*    DATE              NAME                      DESCRIPTION             */
68 /*                                                                        */
69 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
70 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
71 /*                                            resulting in version 6.1    */
72 /*                                                                        */
73 /**************************************************************************/
_gx_radial_slider_animation_start(GX_RADIAL_SLIDER * slider,GX_VALUE target_angle)74 UINT _gx_radial_slider_animation_start(GX_RADIAL_SLIDER *slider, GX_VALUE target_angle)
75 {
76 GX_RADIAL_SLIDER_INFO *info = &slider -> gx_radial_slider_info;
77 USHORT                 delay;
78 
79     if (target_angle != info->gx_radial_slider_info_current_angle)
80     {
81         if ((slider -> gx_radial_slider_animation_total_steps > 1) && slider -> gx_radial_slider_animation_delay)
82         {
83             slider -> gx_radial_slider_start_angle = info -> gx_radial_slider_info_current_angle;
84             slider -> gx_radial_slider_target_angle = target_angle;
85             slider -> gx_radial_slider_animation_step = slider -> gx_radial_slider_animation_total_steps;
86             delay = slider -> gx_radial_slider_animation_delay;
87 
88             /* Start animation to move needle from current position to target position. */
89             _gx_system_timer_start((GX_WIDGET *)slider, GX_RADIAL_SLIDER_TIMER, delay, delay);
90 
91             _gx_widget_event_generate((GX_WIDGET *)slider, GX_EVENT_ANIMATION_START, slider -> gx_radial_slider_target_angle);
92         }
93         else
94         {
95             _gx_radial_slider_angle_set(slider, target_angle);
96         }
97     }
98 
99     return(GX_SUCCESS);
100 }
101 
102