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 /**   Animation Management (Animation)                                    */
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_canvas.h"
30 #include "gx_animation.h"
31 
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _gx_animation_stop                                  PORTABLE C      */
38 /*                                                           6.1.3        */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Kenneth Maxwell, Microsoft Corporation                              */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function stops an animation sequence.                          */
46 /*                                                                        */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    animation                             Pointer to animation control  */
51 /*                                            block                       */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    status                                Completion status             */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*   tx_timer_deactivate                    Deactivate a timer            */
60 /*                                                                        */
61 /*  CALLED BY                                                             */
62 /*                                                                        */
63 /*    _gx_animation_complete                                              */
64 /*    _gx_animation_update                                                */
65 /*                                                                        */
66 /*  RELEASE HISTORY                                                       */
67 /*                                                                        */
68 /*    DATE              NAME                      DESCRIPTION             */
69 /*                                                                        */
70 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
71 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
72 /*                                            resulting in version 6.1    */
73 /*  12-31-2020     Kenneth Maxwell          Modified comment(s),          */
74 /*                                            added GX_DISABLE_THREADX_   */
75 /*                                            TIMER_SOURCE configuration, */
76 /*                                            resulting in version 6.1.3  */
77 /*                                                                        */
78 /**************************************************************************/
_gx_animation_stop(GX_ANIMATION * animation)79 UINT _gx_animation_stop(GX_ANIMATION *animation)
80 {
81 UINT          status = GX_SUCCESS;
82 GX_ANIMATION *previous;
83 
84     /* assign IDLE status to this animation structure */
85     animation -> gx_animation_status = GX_ANIMATION_IDLE;
86 
87     /* Remove the animation from the active list */
88     GX_ENTER_CRITICAL
89 
90     if (_gx_system_animation_list == animation)
91     {
92         /* animation is first in active list */
93         _gx_system_animation_list = _gx_system_animation_list -> gx_animation_next;
94 
95         /* if there are no other active animations or timers, stop the system timer */
96         if ((_gx_system_active_timer_list == NULL) && (_gx_system_animation_list == NULL))
97         {
98 #ifdef GX_THREADX_BINDING
99 #ifndef GX_DISABLE_THREADX_TIMER_SOURCE
100             tx_timer_deactivate(&_gx_system_timer);
101 #endif
102 #else
103             GX_TIMER_STOP;
104 #endif
105         }
106     }
107     else
108     {
109         /* the animation is not the first, find the previous and
110            adjust linked list
111         */
112         previous = _gx_system_animation_list;
113         while (previous)
114         {
115             if (previous -> gx_animation_next == animation)
116             {
117                 previous -> gx_animation_next = animation -> gx_animation_next;
118                 break;
119             }
120             previous = previous -> gx_animation_next;
121         }
122     }
123     GX_EXIT_CRITICAL
124     return(status);
125 }
126 
127