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 |
|
|
/** Circular Gauge Management (Circular Gauge) */ |
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_icon.h" |
30 |
|
|
#include "gx_system.h" |
31 |
|
|
#include "gx_utility.h" |
32 |
|
|
#include "gx_circular_gauge.h" |
33 |
|
|
|
34 |
|
|
|
35 |
|
|
/**************************************************************************/ |
36 |
|
|
/* */ |
37 |
|
|
/* FUNCTION RELEASE */ |
38 |
|
|
/* */ |
39 |
|
|
/* _gx_circular_gauge_event_process PORTABLE C */ |
40 |
|
|
/* 6.1.10 */ |
41 |
|
|
/* AUTHOR */ |
42 |
|
|
/* */ |
43 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
44 |
|
|
/* */ |
45 |
|
|
/* DESCRIPTION */ |
46 |
|
|
/* */ |
47 |
|
|
/* This function processes events for the specified circular gauge */ |
48 |
|
|
/* widget. */ |
49 |
|
|
/* */ |
50 |
|
|
/* INPUT */ |
51 |
|
|
/* */ |
52 |
|
|
/* circular_gauge Circular gauge control block */ |
53 |
|
|
/* event_ptr Pointer to event to process */ |
54 |
|
|
/* */ |
55 |
|
|
/* OUTPUT */ |
56 |
|
|
/* */ |
57 |
|
|
/* status Completion status */ |
58 |
|
|
/* */ |
59 |
|
|
/* CALLS */ |
60 |
|
|
/* */ |
61 |
|
|
/* _gx_circular_gauge_info_get Retrieve the circular gauge */ |
62 |
|
|
/* information structure. */ |
63 |
|
|
/* _gx_circular_gauge_info_set Set the circular gauge info. */ |
64 |
|
|
/* _gx_widget_event_process Process event for specified */ |
65 |
|
|
/* widget. */ |
66 |
|
|
/* _gx_widget_pixelmap_get Get needle pixelmap. */ |
67 |
|
|
/* _gx_circular_gauge_needle_rectangle_calculate */ |
68 |
|
|
/* Calculate current needle */ |
69 |
|
|
/* rectangle. */ |
70 |
|
|
/* */ |
71 |
|
|
/* CALLED BY */ |
72 |
|
|
/* */ |
73 |
|
|
/* Application Code */ |
74 |
|
|
/* */ |
75 |
|
|
/**************************************************************************/ |
76 |
|
249 |
UINT _gx_circular_gauge_event_process(GX_CIRCULAR_GAUGE *gauge, GX_EVENT *event_ptr) |
77 |
|
|
{ |
78 |
|
249 |
UINT status = GX_SUCCESS; |
79 |
|
|
|
80 |
✓✓✓✓ ✓ |
249 |
switch (event_ptr -> gx_event_type) |
81 |
|
|
{ |
82 |
|
40 |
case GX_EVENT_SHOW: |
83 |
|
40 |
status = _gx_icon_event_process((GX_ICON *)gauge, event_ptr); |
84 |
|
|
|
85 |
|
|
/* Needle source being GX_NULL indicates it's the first time to show. So initialize the needle rectangle. */ |
86 |
✓✓ |
40 |
if (gauge -> gx_circular_gauge_needle_source == GX_NULL) |
87 |
|
|
{ |
88 |
|
38 |
_gx_widget_pixelmap_get((GX_WIDGET *)gauge, gauge -> gx_circular_gauge_info.gx_circular_gauge_info_needle_pixelmap, &(gauge -> gx_circular_gauge_needle_source)); |
89 |
|
38 |
_gx_circular_gauge_needle_rectangle_calculate(gauge, gauge -> gx_circular_gauge_current_angle, &(gauge -> gx_circular_gauge_current_needle_rectangle)); |
90 |
|
|
} |
91 |
|
|
|
92 |
|
|
/* Calculate needle increment angle, if any. */ |
93 |
|
40 |
_gx_circular_gauge_angle_increment_calculate(gauge); |
94 |
|
40 |
break; |
95 |
|
|
|
96 |
|
29 |
case GX_EVENT_HIDE: |
97 |
✓✓ |
29 |
if (gauge -> gx_circular_gauge_info.gx_circular_gauge_info_animation_steps > 0) |
98 |
|
|
{ |
99 |
|
|
/* Stop needle animation timer. */ |
100 |
|
26 |
_gx_system_timer_stop((GX_WIDGET *)gauge, GX_CIRCULAR_GAUGE_TIMER); |
101 |
|
|
} |
102 |
|
29 |
status = _gx_icon_event_process((GX_ICON *)gauge, event_ptr); |
103 |
|
29 |
break; |
104 |
|
|
|
105 |
|
74 |
case GX_EVENT_TIMER: |
106 |
✓✓ |
74 |
if (event_ptr -> gx_event_payload.gx_event_timer_id == GX_CIRCULAR_GAUGE_TIMER) |
107 |
|
|
{ |
108 |
|
|
|
109 |
|
|
/* Calculate current angle. */ |
110 |
|
73 |
gauge -> gx_circular_gauge_animation_step++; |
111 |
|
|
|
112 |
✓✓ |
73 |
if (gauge -> gx_circular_gauge_animation_step < gauge -> gx_circular_gauge_info.gx_circular_gauge_info_animation_steps) |
113 |
|
|
{ |
114 |
|
71 |
gauge -> gx_circular_gauge_current_angle = gauge -> gx_circular_gauge_start_angle; |
115 |
|
71 |
gauge -> gx_circular_gauge_current_angle += GX_FIXED_VAL_TO_INT(gauge -> gx_circular_gauge_angle_increment * |
116 |
|
|
gauge -> gx_circular_gauge_animation_step); |
117 |
|
|
} |
118 |
|
|
else |
119 |
|
|
{ |
120 |
|
2 |
gauge -> gx_circular_gauge_current_angle = gauge -> gx_circular_gauge_target_angle; |
121 |
|
|
|
122 |
|
|
/* Stop timer. */ |
123 |
|
2 |
_gx_system_timer_stop((GX_WIDGET *)gauge, GX_CIRCULAR_GAUGE_TIMER); |
124 |
|
2 |
gauge -> gx_circular_gauge_animation_step = 0; |
125 |
|
|
|
126 |
|
|
/* Inform the parent that the gauge animation is completed. */ |
127 |
|
2 |
_gx_widget_event_generate((GX_WIDGET *)gauge, GX_EVENT_ANIMATION_COMPLETE, 0); |
128 |
|
|
} |
129 |
|
73 |
_gx_circular_gauge_needle_dirty_mark(gauge); |
130 |
|
|
} |
131 |
|
|
else |
132 |
|
|
{ |
133 |
|
1 |
status = _gx_widget_event_process((GX_WIDGET *)gauge, event_ptr); |
134 |
|
|
} |
135 |
|
74 |
break; |
136 |
|
|
|
137 |
|
37 |
case GX_EVENT_RESIZED: |
138 |
|
|
|
139 |
|
|
/* Recalculate needle rectangle. */ |
140 |
|
37 |
_gx_circular_gauge_needle_rectangle_calculate(gauge, gauge -> gx_circular_gauge_current_angle, &(gauge -> gx_circular_gauge_current_needle_rectangle)); |
141 |
|
37 |
break; |
142 |
|
|
|
143 |
|
69 |
default: |
144 |
|
|
|
145 |
|
69 |
status = _gx_icon_event_process((GX_ICON *)gauge, event_ptr); |
146 |
|
|
} |
147 |
|
|
|
148 |
|
249 |
return status; |
149 |
|
|
} |
150 |
|
|
|