GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_animation_complete.c Lines: 53 53 100.0 %
Date: 2026-03-06 19:21:09 Branches: 28 28 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   Animation Management (Animation)                                    */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_widget.h"
29
#include "gx_system.h"
30
#include "gx_canvas.h"
31
#include "gx_animation.h"
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_animation_complete_event_send                   PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    Internal helper function to send an animation complete event.       */
46
/*                                                                        */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    animation                             Pointer to animation control  */
51
/*                                            block                       */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    None                                                                */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    _gx_system_event_send                 Send GUIX event               */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    _gx_animation_complete                                              */
64
/*    _gx_animation_slide_landing                                         */
65
/*                                                                        */
66
/**************************************************************************/
67
#if (GX_ANIMATION_POOL_SIZE > 0)
68
159
VOID _gx_animation_complete_event_send(GX_ANIMATION *animation)
69
{
70
GX_EVENT complete_event;
71
72
159
    if (animation -> gx_animation_info.gx_animation_id)
73
    {
74
148
        if (animation -> gx_animation_info.gx_animation_target)
75
        {
76
45
            complete_event.gx_event_target = animation -> gx_animation_info.gx_animation_target;
77
        }
78
        else
79
        {
80
103
            complete_event.gx_event_target = animation -> gx_animation_info.gx_animation_parent;
81
        }
82
83
        /* send event to notify the animation has been completed */
84
85
148
        complete_event.gx_event_type = GX_EVENT_ANIMATION_COMPLETE;
86
148
        complete_event.gx_event_sender = animation -> gx_animation_info.gx_animation_id;
87
148
        _gx_system_event_send(&complete_event);
88
    }
89
159
}
90
#endif
91
92
93
/**************************************************************************/
94
/*                                                                        */
95
/*  FUNCTION                                               RELEASE        */
96
/*                                                                        */
97
/*    _gx_animation_complete                              PORTABLE C      */
98
/*                                                           6.1.3        */
99
/*  AUTHOR                                                                */
100
/*                                                                        */
101
/*    Kenneth Maxwell, Microsoft Corporation                              */
102
/*                                                                        */
103
/*  DESCRIPTION                                                           */
104
/*                                                                        */
105
/*    Called internally when an animation sequence is finished.           */
106
/*                                                                        */
107
/*                                                                        */
108
/*  INPUT                                                                 */
109
/*                                                                        */
110
/*    animation                             Pointer to window control     */
111
/*                                            block                       */
112
/*                                                                        */
113
/*  OUTPUT                                                                */
114
/*                                                                        */
115
/*    None                                                                */
116
/*                                                                        */
117
/*  CALLS                                                                 */
118
/*                                                                        */
119
/*    _gx_animation_stop                    Stop an animation             */
120
/*    _gx_widget_detach                     Detach a widget from its      */
121
/*                                            parent                      */
122
/*    _gx_widget_hide                       Hide a widget                 */
123
/*    _gx_widget_shift                      Shift a widget                */
124
/*    _gx_widget_attach                     Attach a widget to its parent */
125
/*    _gx_system_event_send                 Send GUIX event               */
126
/*                                                                        */
127
/*  CALLED BY                                                             */
128
/*                                                                        */
129
/*    _gx_animation_update                                                */
130
/*                                                                        */
131
/**************************************************************************/
132
#if (GX_ANIMATION_POOL_SIZE > 0)
133
57
VOID _gx_animation_complete(GX_ANIMATION *animation)
134
{
135
GX_WIDGET *target;
136
GX_VALUE   xshift;
137
GX_VALUE   yshift;
138
139
    /* Remove animation from active list and assign idle status */
140
57
    _gx_animation_stop(animation);
141
142
    /* do final cleanup */
143
57
    target = animation -> gx_animation_info.gx_animation_target;
144
145
57
    if (animation -> gx_animation_canvas)
146
    {
147
        /* hide the animation root */
148
6
        if (target -> gx_widget_parent)
149
        {
150
5
            _gx_widget_hide(target -> gx_widget_parent);
151
        }
152
153
        /* Hide animation target. */
154
6
        _gx_widget_detach(target);
155
156
6
        if (animation -> gx_animation_info.gx_animation_style & GX_ANIMATION_PUSH_STACK)
157
        {
158
            /* Push animation target to system screen stack. */
159
1
            _gx_system_screen_stack_push(target);
160
        }
161
5
        else if (animation -> gx_animation_info.gx_animation_style & GX_ANIMATION_DETACH)
162
        {
163
3
            if (target -> gx_widget_status & GX_STATUS_STUDIO_CREATED)
164
            {
165
1
                _gx_widget_delete(target);
166
1
                animation -> gx_animation_info.gx_animation_target = GX_NULL;
167
            }
168
        }
169
        else
170
        {
171
            /* shift the target into final position */
172
2
            _gx_widget_shift(animation -> gx_animation_info.gx_animation_target,
173
2
                             animation -> gx_animation_info.gx_animation_end_position.gx_point_x,
174
2
                             animation -> gx_animation_info.gx_animation_end_position.gx_point_y, GX_FALSE);
175
176
            /* attach the widget to it's parent */
177
2
            _gx_widget_attach(animation -> gx_animation_info.gx_animation_parent, target);
178
        }
179
6
        _gx_canvas_hide(animation -> gx_animation_canvas);
180
6
        _gx_system_canvas_refresh();
181
    }
182
    else
183
    {
184
#if defined(GX_BRUSH_ALPHA_SUPPORT)
185
186
51
        if (animation -> gx_animation_info.gx_animation_start_alpha !=
187
51
            animation -> gx_animation_info.gx_animation_end_alpha)
188
        {
189
16
            animation -> gx_animation_info.gx_animation_target -> gx_widget_style &= ~GX_STYLE_USE_LOCAL_ALPHA;
190
16
            _gx_system_dirty_mark(animation -> gx_animation_info.gx_animation_target);
191
        }
192
#endif
193
194
51
        if (animation -> gx_animation_info.gx_animation_style & GX_ANIMATION_PUSH_STACK)
195
        {
196
            /* Push animation target to system screen stack. */
197
2
            _gx_system_screen_stack_push(target);
198
        }
199
49
        else if (animation -> gx_animation_info.gx_animation_style & GX_ANIMATION_DETACH)
200
        {
201
5
            _gx_widget_hide(target);
202
203
            /* if this target was created by the Studio generated code, then delete the widget here */
204
5
            if (target -> gx_widget_status & GX_STATUS_STUDIO_CREATED)
205
            {
206
1
                _gx_widget_delete(target);
207
1
                animation -> gx_animation_info.gx_animation_target = GX_NULL;
208
            }
209
        }
210
        else
211
        {
212
            /* test for shift translation */
213
44
            xshift = (GX_VALUE)(animation -> gx_animation_info.gx_animation_end_position.gx_point_x -
214
44
                                animation -> gx_animation_info.gx_animation_start_position.gx_point_x);
215
216
44
            yshift = (GX_VALUE)(animation -> gx_animation_info.gx_animation_end_position.gx_point_y -
217
44
                                animation -> gx_animation_info.gx_animation_start_position.gx_point_y);
218
219

44
            if (xshift || yshift)
220
            {
221
38
                xshift = (GX_VALUE)(animation -> gx_animation_info.gx_animation_end_position.gx_point_x -
222
38
                                    target -> gx_widget_size.gx_rectangle_left);
223
224
38
                yshift = (GX_VALUE)(animation -> gx_animation_info.gx_animation_end_position.gx_point_y -
225
38
                                    target -> gx_widget_size.gx_rectangle_top);
226
227
                /* shift the target into final position */
228
38
                _gx_widget_shift(target, xshift, yshift, GX_TRUE);
229
            }
230
        }
231
    }
232
233
57
    _gx_animation_complete_event_send(animation);
234
235
    /* If this animation came from the system pool, return it */
236
57
    if (animation -> gx_animation_system_allocated)
237
    {
238
19
        _gx_system_animation_free(animation);
239
    }
240
57
}
241
#endif