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 |
|
|
/** Accordion Menu Management (Menu) */ |
18 |
|
|
/** */ |
19 |
|
|
/**************************************************************************/ |
20 |
|
|
|
21 |
|
|
#define GX_SOURCE_CODE |
22 |
|
|
|
23 |
|
|
|
24 |
|
|
/* Include necessary system files. */ |
25 |
|
|
|
26 |
|
|
#include "gx_api.h" |
27 |
|
|
#include "gx_menu.h" |
28 |
|
|
#include "gx_widget.h" |
29 |
|
|
#include "gx_window.h" |
30 |
|
|
#include "gx_system.h" |
31 |
|
|
|
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _gx_accordion_menu_shift_helper PORTABLE C */ |
37 |
|
|
/* 6.1 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* Internal helper function to shift one accordion menu. */ |
45 |
|
|
/* */ |
46 |
|
|
/* INPUT */ |
47 |
|
|
/* */ |
48 |
|
|
/* accordion Pointer to accordion menu */ |
49 |
|
|
/* control block */ |
50 |
|
|
/* animation_target Animation target */ |
51 |
|
|
/* shift Shift value */ |
52 |
|
|
/* */ |
53 |
|
|
/* OUTPUT */ |
54 |
|
|
/* */ |
55 |
|
|
/* status Completion status */ |
56 |
|
|
/* */ |
57 |
|
|
/* CALLS */ |
58 |
|
|
/* */ |
59 |
|
|
/* _gx_widget_scroll_shift Change the widget position */ |
60 |
|
|
/* _gx_widget_resize Resize the widget */ |
61 |
|
|
/* _gx_menu_list_shift Change the menu list position */ |
62 |
|
|
/* */ |
63 |
|
|
/* CALLED BY */ |
64 |
|
|
/* */ |
65 |
|
|
/* _gx_accordion_menu_shift_helper */ |
66 |
|
|
/* */ |
67 |
|
|
/* RELEASE HISTORY */ |
68 |
|
|
/* */ |
69 |
|
|
/* DATE NAME DESCRIPTION */ |
70 |
|
|
/* */ |
71 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
72 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
73 |
|
|
/* resulting in version 6.1 */ |
74 |
|
|
/* */ |
75 |
|
|
/**************************************************************************/ |
76 |
|
620 |
static VOID _gx_accordion_menu_shift_helper(GX_ACCORDION_MENU *accordion, GX_WIDGET *animation_target, INT shift) |
77 |
|
|
{ |
78 |
|
|
GX_WIDGET *child; |
79 |
|
|
GX_MENU *menu; |
80 |
|
620 |
GX_BOOL shift_start = GX_FALSE; |
81 |
|
|
GX_RECTANGLE size; |
82 |
|
|
|
83 |
|
620 |
child = accordion -> gx_widget_first_child; |
84 |
✓✓ |
3150 |
while (child) |
85 |
|
|
{ |
86 |
✓✓✓ |
2530 |
switch (child -> gx_widget_type) |
87 |
|
|
{ |
88 |
|
1525 |
case GX_TYPE_MENU: |
89 |
✓✓ |
1525 |
if (shift_start) |
90 |
|
|
{ |
91 |
|
|
/* Shift the menu item. */ |
92 |
|
547 |
_gx_widget_scroll_shift(child, 0, shift, GX_TRUE); |
93 |
|
|
|
94 |
|
547 |
menu = (GX_MENU *)child; |
95 |
|
|
|
96 |
|
|
/* Shift the menu list which is a member of menu item. */ |
97 |
|
547 |
_gx_widget_scroll_shift((GX_WIDGET *)&menu -> gx_menu_list, 0, shift, GX_TRUE); |
98 |
|
|
} |
99 |
|
1525 |
break; |
100 |
|
|
|
101 |
|
838 |
case GX_TYPE_MENU_LIST: |
102 |
|
|
/* The shift work has done by the menu list owner. */ |
103 |
|
838 |
break; |
104 |
|
|
|
105 |
|
167 |
default: |
106 |
✓✓ |
167 |
if (shift_start) |
107 |
|
|
{ |
108 |
|
|
/* Shift other types of menu item. */ |
109 |
|
88 |
_gx_widget_scroll_shift(child, 0, shift, GX_TRUE); |
110 |
|
|
} |
111 |
|
167 |
break; |
112 |
|
|
} |
113 |
|
|
|
114 |
✓✓ |
2530 |
if (child == animation_target) |
115 |
|
|
{ |
116 |
|
620 |
shift_start = GX_TRUE; |
117 |
|
|
} |
118 |
|
|
|
119 |
|
2530 |
child = child -> gx_widget_next; |
120 |
|
|
} |
121 |
|
|
|
122 |
|
|
/* Resize accordion menu. */ |
123 |
|
620 |
size = accordion -> gx_widget_size; |
124 |
|
620 |
size.gx_rectangle_bottom = (GX_VALUE)(size.gx_rectangle_bottom + shift); |
125 |
|
620 |
_gx_widget_resize((GX_WIDGET *)accordion, &size); |
126 |
|
620 |
} |
127 |
|
|
|
128 |
|
|
/**************************************************************************/ |
129 |
|
|
/* */ |
130 |
|
|
/* FUNCTION RELEASE */ |
131 |
|
|
/* */ |
132 |
|
|
/* _gx_accordion_menu_shift PORTABLE C */ |
133 |
|
|
/* 6.1 */ |
134 |
|
|
/* AUTHOR */ |
135 |
|
|
/* */ |
136 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
137 |
|
|
/* */ |
138 |
|
|
/* DESCRIPTION */ |
139 |
|
|
/* */ |
140 |
|
|
/* Internal helper function to shift menu items for an accordion menu. */ |
141 |
|
|
/* */ |
142 |
|
|
/* INPUT */ |
143 |
|
|
/* */ |
144 |
|
|
/* accordion Pointer to accordion menu */ |
145 |
|
|
/* control block */ |
146 |
|
|
/* animation_target Animation target */ |
147 |
|
|
/* shift Shift value */ |
148 |
|
|
/* */ |
149 |
|
|
/* OUTPUT */ |
150 |
|
|
/* */ |
151 |
|
|
/* status Completion status */ |
152 |
|
|
/* */ |
153 |
|
|
/* CALLS */ |
154 |
|
|
/* */ |
155 |
|
|
/* _gx_widget_resize Resize the widget */ |
156 |
|
|
/* _gx_accordion_menu_shift_heloer Change the accordion menu */ |
157 |
|
|
/* position */ |
158 |
|
|
/* */ |
159 |
|
|
/* CALLED BY */ |
160 |
|
|
/* */ |
161 |
|
|
/* _gx_accordion_menu_close_animation_update */ |
162 |
|
|
/* _gx_accordion_menu_open_animation_update */ |
163 |
|
|
/* */ |
164 |
|
|
/* RELEASE HISTORY */ |
165 |
|
|
/* */ |
166 |
|
|
/* DATE NAME DESCRIPTION */ |
167 |
|
|
/* */ |
168 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
169 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
170 |
|
|
/* resulting in version 6.1 */ |
171 |
|
|
/* */ |
172 |
|
|
/**************************************************************************/ |
173 |
|
367 |
static UINT _gx_accordion_menu_shift(GX_ACCORDION_MENU *accordion, GX_WIDGET *animation_target, INT shift) |
174 |
|
|
{ |
175 |
|
|
GX_WIDGET *temp_target; |
176 |
|
|
GX_WIDGET *parent; |
177 |
|
|
GX_RECTANGLE size; |
178 |
|
|
GX_WIDGET *child; |
179 |
|
|
|
180 |
|
367 |
_gx_accordion_menu_shift_helper(accordion, animation_target, shift); |
181 |
|
|
|
182 |
|
367 |
temp_target = (GX_WIDGET *)accordion; |
183 |
|
367 |
parent = accordion -> gx_widget_parent; |
184 |
|
|
|
185 |
✓✓ |
620 |
while (parent) |
186 |
|
|
{ |
187 |
|
|
|
188 |
✓✓ |
619 |
if (parent -> gx_widget_type == GX_TYPE_MENU_LIST) |
189 |
|
|
{ |
190 |
|
|
/* If the accordion menu is the child of a menu list, |
191 |
|
|
Resize the menu list.*/ |
192 |
|
216 |
size = parent -> gx_widget_size; |
193 |
|
216 |
size.gx_rectangle_bottom = (GX_VALUE)(size.gx_rectangle_bottom + shift); |
194 |
|
216 |
_gx_widget_resize(parent, &size); |
195 |
|
|
|
196 |
|
|
/* Get the menu that owns the menu list. */ |
197 |
|
216 |
child = ((GX_MENU_LIST *)parent) -> gx_menu_list_owner; |
198 |
|
|
|
199 |
|
|
/* Get the parent of the menu*/ |
200 |
✓✓ |
216 |
if (child) |
201 |
|
|
{ |
202 |
|
215 |
parent = child -> gx_widget_parent; |
203 |
|
|
|
204 |
|
|
/* Check if the menu parent is an accordion menu. */ |
205 |
✓✓✓✓
|
215 |
if (parent && parent -> gx_widget_type == GX_TYPE_ACCORDION_MENU) |
206 |
|
|
{ |
207 |
|
213 |
_gx_accordion_menu_shift_helper((GX_ACCORDION_MENU *)parent, child, shift); |
208 |
|
|
} |
209 |
|
|
else |
210 |
|
|
{ |
211 |
|
|
break; /* Break out of the "while(parent)" loop and return. */ |
212 |
|
|
} |
213 |
|
|
} |
214 |
|
|
else |
215 |
|
|
{ |
216 |
|
1 |
break; /* Break out of the "while(parent)" loop and return. */ |
217 |
|
|
} |
218 |
|
|
} |
219 |
✓✓ |
403 |
else if (parent -> gx_widget_type == GX_TYPE_ACCORDION_MENU) |
220 |
|
|
{ |
221 |
|
40 |
_gx_accordion_menu_shift_helper((GX_ACCORDION_MENU *)parent, temp_target, shift); |
222 |
|
|
} |
223 |
|
|
else |
224 |
|
|
{ |
225 |
|
363 |
break; |
226 |
|
|
} |
227 |
|
|
|
228 |
|
253 |
temp_target = parent; |
229 |
|
253 |
parent = parent -> gx_widget_parent; |
230 |
|
|
} |
231 |
|
|
|
232 |
|
367 |
return GX_SUCCESS; |
233 |
|
|
} |
234 |
|
|
|
235 |
|
|
/**************************************************************************/ |
236 |
|
|
/* */ |
237 |
|
|
/* FUNCTION RELEASE */ |
238 |
|
|
/* */ |
239 |
|
|
/* _gx_accordion_menu_close_animation_update PORTABLE C */ |
240 |
|
|
/* 6.3.0 */ |
241 |
|
|
/* AUTHOR */ |
242 |
|
|
/* */ |
243 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
244 |
|
|
/* */ |
245 |
|
|
/* DESCRIPTION */ |
246 |
|
|
/* */ |
247 |
|
|
/* Internal helper function to execute one step in menu close */ |
248 |
|
|
/* animation. */ |
249 |
|
|
/* */ |
250 |
|
|
/* INPUT */ |
251 |
|
|
/* */ |
252 |
|
|
/* accordion Pointer to accordin menu */ |
253 |
|
|
/* control block */ |
254 |
|
|
/* */ |
255 |
|
|
/* OUTPUT */ |
256 |
|
|
/* */ |
257 |
|
|
/* status Completion status */ |
258 |
|
|
/* */ |
259 |
|
|
/* CALLS */ |
260 |
|
|
/* */ |
261 |
|
|
/* _gx_widget_height_get Get widget height */ |
262 |
|
|
/* _gx_system_timer_stop Stop a timer for widget */ |
263 |
|
|
/* _gx_widget_detach Detach widget from its parent */ |
264 |
|
|
/* _gx_widget_resize Resize a widget */ |
265 |
|
|
/* _gx_accordion_menu_shift Change accordion menu position*/ |
266 |
|
|
/* */ |
267 |
|
|
/* CALLED BY */ |
268 |
|
|
/* */ |
269 |
|
|
/* _gx_accordion_menu_event_process */ |
270 |
|
|
/* */ |
271 |
|
|
/* RELEASE HISTORY */ |
272 |
|
|
/* */ |
273 |
|
|
/* DATE NAME DESCRIPTION */ |
274 |
|
|
/* */ |
275 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
276 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
277 |
|
|
/* resulting in version 6.1 */ |
278 |
|
|
/* 10-31-2023 Ting Zhu Modified comment(s), */ |
279 |
|
|
/* added NULL pointer check, */ |
280 |
|
|
/* resulting in version 6.3.0 */ |
281 |
|
|
/* */ |
282 |
|
|
/**************************************************************************/ |
283 |
|
141 |
static UINT _gx_accordion_menu_close_animation_update(GX_ACCORDION_MENU *accordion) |
284 |
|
|
{ |
285 |
|
141 |
GX_MENU *deselected = (GX_MENU *)accordion -> gx_accordion_menu_collapse_item; |
286 |
|
141 |
GX_VALUE list_children_height = 0; |
287 |
|
|
GX_VALUE height; |
288 |
|
|
GX_VALUE shift; |
289 |
|
|
GX_RECTANGLE size; |
290 |
|
|
GX_WIDGET *child; |
291 |
|
|
|
292 |
✓✓ |
141 |
if (!deselected) |
293 |
|
|
{ |
294 |
|
1 |
return GX_SUCCESS; |
295 |
|
|
} |
296 |
|
|
|
297 |
|
140 |
child = deselected -> gx_menu_list.gx_widget_first_child; |
298 |
|
|
|
299 |
|
|
/* Calcualte total height of list children. */ |
300 |
✓✓ |
298 |
while (child) |
301 |
|
|
{ |
302 |
|
158 |
_gx_widget_height_get(child, &height); |
303 |
|
158 |
list_children_height = (GX_VALUE)(list_children_height + height); |
304 |
|
|
|
305 |
|
158 |
child = child -> gx_widget_next; |
306 |
|
|
} |
307 |
|
|
|
308 |
|
|
/* Calcualte shift value for each animation step. */ |
309 |
|
140 |
shift = (GX_VALUE)(list_children_height / 10); |
310 |
✓✓ |
140 |
if (shift == 0) |
311 |
|
|
{ |
312 |
|
4 |
shift = list_children_height; |
313 |
|
|
} |
314 |
|
|
|
315 |
|
|
/* Get menu list height. */ |
316 |
|
140 |
_gx_widget_height_get((GX_WIDGET *)&deselected -> gx_menu_list, &height); |
317 |
|
|
|
318 |
✓✓ |
140 |
if (shift > height) |
319 |
|
|
{ |
320 |
|
13 |
shift = height; |
321 |
|
13 |
_gx_system_timer_stop((GX_WIDGET *)accordion, GX_MENU_CLOSE_TIMER); |
322 |
|
13 |
deselected -> gx_widget_style &= (ULONG)(~GX_STYLE_MENU_EXPANDED); |
323 |
|
13 |
accordion -> gx_accordion_menu_animation_status &= (GX_UBYTE)(~GX_MENU_ANIMATION_CLOSE); |
324 |
|
13 |
accordion -> gx_accordion_menu_collapse_item = GX_NULL; |
325 |
|
13 |
_gx_widget_detach((GX_WIDGET *)&deselected -> gx_menu_list); |
326 |
|
|
} |
327 |
|
|
|
328 |
|
|
/* Resize menu list. */ |
329 |
|
140 |
size = deselected -> gx_menu_list.gx_widget_size; |
330 |
|
140 |
size.gx_rectangle_bottom = (GX_VALUE)(size.gx_rectangle_bottom - shift); |
331 |
|
140 |
_gx_widget_resize((GX_WIDGET *)&deselected -> gx_menu_list, &size); |
332 |
|
|
|
333 |
|
|
/* Shift menus that follow the opening menu. */ |
334 |
|
140 |
_gx_accordion_menu_shift(accordion, (GX_WIDGET *)deselected, -shift); |
335 |
|
|
|
336 |
|
140 |
return GX_SUCCESS; |
337 |
|
|
} |
338 |
|
|
|
339 |
|
|
/**************************************************************************/ |
340 |
|
|
/* */ |
341 |
|
|
/* FUNCTION RELEASE */ |
342 |
|
|
/* */ |
343 |
|
|
/* _gx_accordion_menu_open_animation_update PORTABLE C */ |
344 |
|
|
/* 6.3.0 */ |
345 |
|
|
/* AUTHOR */ |
346 |
|
|
/* */ |
347 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
348 |
|
|
/* */ |
349 |
|
|
/* DESCRIPTION */ |
350 |
|
|
/* */ |
351 |
|
|
/* Internal helper function to execute one step in menu open animation.*/ |
352 |
|
|
/* */ |
353 |
|
|
/* INPUT */ |
354 |
|
|
/* */ |
355 |
|
|
/* accordion Pointer to accordin menu */ |
356 |
|
|
/* control block */ |
357 |
|
|
/* */ |
358 |
|
|
/* OUTPUT */ |
359 |
|
|
/* */ |
360 |
|
|
/* status Completion status */ |
361 |
|
|
/* */ |
362 |
|
|
/* CALLS */ |
363 |
|
|
/* */ |
364 |
|
|
/* _gx_widget_height_get Get widget height */ |
365 |
|
|
/* _gx_system_timer_stop Stop a timer for widget */ |
366 |
|
|
/* _gx_widget_resize Resize widget */ |
367 |
|
|
/* _gx_accordion_menu_shift Change accordin menu position */ |
368 |
|
|
/* */ |
369 |
|
|
/* CALLED BY */ |
370 |
|
|
/* */ |
371 |
|
|
/* _gx_accordion_menu_event_process */ |
372 |
|
|
/* */ |
373 |
|
|
/* RELEASE HISTORY */ |
374 |
|
|
/* */ |
375 |
|
|
/* DATE NAME DESCRIPTION */ |
376 |
|
|
/* */ |
377 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
378 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
379 |
|
|
/* resulting in version 6.1 */ |
380 |
|
|
/* 10-31-2023 Ting Zhu Modified comment(s), */ |
381 |
|
|
/* added NULL pointer check, */ |
382 |
|
|
/* resulting in version 6.3.0 */ |
383 |
|
|
/* */ |
384 |
|
|
/**************************************************************************/ |
385 |
|
228 |
static UINT _gx_accordion_menu_open_animation_update(GX_ACCORDION_MENU *accordion) |
386 |
|
|
{ |
387 |
|
228 |
GX_MENU *selected = (GX_MENU *)accordion -> gx_accordion_menu_expand_item; |
388 |
|
|
GX_VALUE shift; |
389 |
|
|
GX_RECTANGLE size; |
390 |
|
228 |
GX_VALUE list_children_height = 0; |
391 |
|
228 |
GX_VALUE height = 0; |
392 |
|
|
GX_WIDGET *child; |
393 |
|
|
|
394 |
✓✓ |
228 |
if (!selected) |
395 |
|
|
{ |
396 |
|
1 |
return GX_SUCCESS; |
397 |
|
|
} |
398 |
|
|
|
399 |
|
227 |
child = selected -> gx_menu_list.gx_widget_first_child; |
400 |
|
|
|
401 |
|
|
/* Calcualte total height of list children. */ |
402 |
✓✓ |
492 |
while (child) |
403 |
|
|
{ |
404 |
|
265 |
_gx_widget_height_get(child, &height); |
405 |
|
265 |
list_children_height = (GX_VALUE)(list_children_height + height); |
406 |
|
|
|
407 |
|
265 |
child = child -> gx_widget_next; |
408 |
|
|
} |
409 |
|
|
|
410 |
|
|
/* Calcualte shift value for each animation step. */ |
411 |
|
227 |
shift = (GX_VALUE)(list_children_height / 10); |
412 |
✓✓ |
227 |
if (shift == 0) |
413 |
|
|
{ |
414 |
|
2 |
shift = list_children_height; |
415 |
|
|
} |
416 |
|
|
|
417 |
|
|
/* Get menu list height. */ |
418 |
|
227 |
_gx_widget_height_get((GX_WIDGET *)&selected -> gx_menu_list, &height); |
419 |
|
|
|
420 |
✓✓ |
227 |
if (height + shift >= list_children_height) |
421 |
|
|
{ |
422 |
|
21 |
shift = (GX_VALUE)(list_children_height - height); |
423 |
|
21 |
_gx_system_timer_stop((GX_WIDGET *)accordion, GX_MENU_OPEN_TIMER); |
424 |
|
21 |
accordion -> gx_accordion_menu_animation_status &= (GX_UBYTE)(~GX_MENU_ANIMATION_OPEN); |
425 |
|
21 |
selected -> gx_widget_style |= GX_STYLE_MENU_EXPANDED; |
426 |
|
|
} |
427 |
|
|
|
428 |
|
|
/* Resize menu list. */ |
429 |
|
227 |
size = selected -> gx_menu_list.gx_widget_size; |
430 |
|
227 |
size.gx_rectangle_bottom = (GX_VALUE)(size.gx_rectangle_bottom + shift); |
431 |
|
227 |
_gx_widget_resize((GX_WIDGET *)&selected -> gx_menu_list, &size); |
432 |
|
|
|
433 |
|
|
/* Shift menus that follow the opening menu. */ |
434 |
|
227 |
_gx_accordion_menu_shift(accordion, (GX_WIDGET *)selected, shift); |
435 |
|
|
|
436 |
|
227 |
return GX_SUCCESS; |
437 |
|
|
} |
438 |
|
|
|
439 |
|
|
/**************************************************************************/ |
440 |
|
|
/* */ |
441 |
|
|
/* FUNCTION RELEASE */ |
442 |
|
|
/* */ |
443 |
|
|
/* _gx_accordion_menu_pen_down_event_process PORTABLE C */ |
444 |
|
|
/* 6.1 */ |
445 |
|
|
/* AUTHOR */ |
446 |
|
|
/* */ |
447 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
448 |
|
|
/* */ |
449 |
|
|
/* DESCRIPTION */ |
450 |
|
|
/* */ |
451 |
|
|
/* Internal helper function to process pen down event for an accordion */ |
452 |
|
|
/* menu. */ |
453 |
|
|
/* */ |
454 |
|
|
/* INPUT */ |
455 |
|
|
/* */ |
456 |
|
|
/* accordion Pointer to accordion menu */ |
457 |
|
|
/* control block */ |
458 |
|
|
/* event_ptr Pointer to event to process */ |
459 |
|
|
/* */ |
460 |
|
|
/* OUTPUT */ |
461 |
|
|
/* */ |
462 |
|
|
/* status Completion status */ |
463 |
|
|
/* */ |
464 |
|
|
/* CALLS */ |
465 |
|
|
/* */ |
466 |
|
|
/* _gx_system_top_widget_find Find toppest widget that */ |
467 |
|
|
/* contain test point */ |
468 |
|
|
/* _gx_system_input_capture Temporarily direct all inputs */ |
469 |
|
|
/* to specified widget */ |
470 |
|
|
/* _gx_widget_event_process Default widget event procses */ |
471 |
|
|
/* */ |
472 |
|
|
/* CALLED BY */ |
473 |
|
|
/* */ |
474 |
|
|
/* Application Code */ |
475 |
|
|
/* */ |
476 |
|
|
/* RELEASE HISTORY */ |
477 |
|
|
/* */ |
478 |
|
|
/* DATE NAME DESCRIPTION */ |
479 |
|
|
/* */ |
480 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
481 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
482 |
|
|
/* resulting in version 6.1 */ |
483 |
|
|
/* */ |
484 |
|
|
/**************************************************************************/ |
485 |
|
30 |
static UINT _gx_accordion_menu_pen_down_event_process(GX_ACCORDION_MENU *accordion, GX_EVENT *event_ptr) |
486 |
|
|
{ |
487 |
|
30 |
GX_WIDGET *widget = (GX_WIDGET *)accordion; |
488 |
|
30 |
GX_WIDGET *child = GX_NULL; |
489 |
|
|
|
490 |
|
30 |
child = _gx_system_top_widget_find(widget, event_ptr -> gx_event_payload.gx_event_pointdata, GX_STATUS_SELECTABLE); |
491 |
|
|
|
492 |
✓✓✓✓
|
30 |
if (child && (child -> gx_widget_type == GX_TYPE_MENU) && |
493 |
✓✓ |
28 |
((GX_MENU *)child) -> gx_menu_list.gx_widget_first_child) |
494 |
|
|
{ |
495 |
✓✓ |
27 |
if ((accordion -> gx_accordion_menu_animation_status & GX_MENU_ANIMATION_CLOSE) || |
496 |
✓✓ |
26 |
(accordion -> gx_accordion_menu_animation_status & GX_MENU_ANIMATION_OPEN)) |
497 |
|
|
{ |
498 |
|
|
/* Animation is going on. */ |
499 |
|
2 |
return GX_SUCCESS; |
500 |
|
|
} |
501 |
|
|
|
502 |
|
|
/* Set expand and collapse menu items. */ |
503 |
✓✓ |
25 |
if (child -> gx_widget_style & GX_STYLE_MENU_EXPANDED) |
504 |
|
|
{ |
505 |
|
3 |
accordion -> gx_accordion_menu_collapse_item = child; |
506 |
|
3 |
accordion -> gx_accordion_menu_expand_item = GX_NULL; |
507 |
|
|
} |
508 |
|
|
else |
509 |
|
|
{ |
510 |
✓✓ |
22 |
if (accordion -> gx_accordion_menu_expand_item != child) |
511 |
|
|
{ |
512 |
|
21 |
accordion -> gx_accordion_menu_collapse_item = accordion -> gx_accordion_menu_expand_item; |
513 |
|
|
} |
514 |
|
22 |
accordion -> gx_accordion_menu_expand_item = child; |
515 |
|
|
} |
516 |
|
|
|
517 |
|
25 |
_gx_system_input_capture(widget); |
518 |
|
|
} |
519 |
|
|
else |
520 |
|
|
{ |
521 |
|
3 |
_gx_widget_event_process(widget, event_ptr); |
522 |
|
|
} |
523 |
|
|
|
524 |
|
28 |
return GX_SUCCESS; |
525 |
|
|
} |
526 |
|
|
|
527 |
|
|
/**************************************************************************/ |
528 |
|
|
/* */ |
529 |
|
|
/* FUNCTION RELEASE */ |
530 |
|
|
/* */ |
531 |
|
|
/* _gx_accordion_menu_pen_up_event_process PORTABLE C */ |
532 |
|
|
/* 6.1 */ |
533 |
|
|
/* AUTHOR */ |
534 |
|
|
/* */ |
535 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
536 |
|
|
/* */ |
537 |
|
|
/* DESCRIPTION */ |
538 |
|
|
/* */ |
539 |
|
|
/* Internal helper function to process pen up event for an accordion */ |
540 |
|
|
/* menu. */ |
541 |
|
|
/* */ |
542 |
|
|
/* INPUT */ |
543 |
|
|
/* */ |
544 |
|
|
/* accordion Pointer to accordion menu */ |
545 |
|
|
/* control block */ |
546 |
|
|
/* event_ptr Pointer to event to process */ |
547 |
|
|
/* */ |
548 |
|
|
/* OUTPUT */ |
549 |
|
|
/* */ |
550 |
|
|
/* status Completion status */ |
551 |
|
|
/* */ |
552 |
|
|
/* CALLS */ |
553 |
|
|
/* */ |
554 |
|
|
/* _gx_system_input_release Release event capture */ |
555 |
|
|
/* _gx_system_timer_start Start a timer for widget */ |
556 |
|
|
/* _gx_widget_link Link a widget to its parent */ |
557 |
|
|
/* _gx_widget_shift Change a widget's position */ |
558 |
|
|
/* _gx_widget_event_process Default widget event process */ |
559 |
|
|
/* */ |
560 |
|
|
/* CALLED BY */ |
561 |
|
|
/* */ |
562 |
|
|
/* Application Code */ |
563 |
|
|
/* */ |
564 |
|
|
/* RELEASE HISTORY */ |
565 |
|
|
/* */ |
566 |
|
|
/* DATE NAME DESCRIPTION */ |
567 |
|
|
/* */ |
568 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
569 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
570 |
|
|
/* resulting in version 6.1 */ |
571 |
|
|
/* */ |
572 |
|
|
/**************************************************************************/ |
573 |
|
29 |
static UINT _gx_accordion_menu_pen_up_event_process(GX_ACCORDION_MENU *accordion, GX_EVENT *event_ptr) |
574 |
|
|
{ |
575 |
|
29 |
GX_WIDGET *widget = (GX_WIDGET *)accordion; |
576 |
|
29 |
GX_WIDGET *child = GX_NULL; |
577 |
|
|
GX_MENU_LIST *menu_list; |
578 |
|
|
GX_VALUE x_shift; |
579 |
|
|
GX_VALUE y_shift; |
580 |
|
|
|
581 |
✓✓ |
29 |
if (accordion -> gx_widget_status & GX_STATUS_OWNS_INPUT) |
582 |
|
|
{ |
583 |
|
24 |
_gx_system_input_release(widget); |
584 |
|
|
|
585 |
✓✓ |
24 |
if (accordion -> gx_accordion_menu_collapse_item) |
586 |
|
|
{ |
587 |
|
|
/* Start a timer to collapse a menu. */ |
588 |
|
13 |
_gx_system_timer_start((GX_WIDGET *)accordion, GX_MENU_CLOSE_TIMER, 1, 1); |
589 |
|
13 |
accordion -> gx_accordion_menu_animation_status |= GX_MENU_ANIMATION_CLOSE; |
590 |
|
|
} |
591 |
|
|
|
592 |
✓✓ |
24 |
if (accordion -> gx_accordion_menu_expand_item) |
593 |
|
|
{ |
594 |
|
|
|
595 |
|
|
/* Start a timer to expand a menu. */ |
596 |
|
21 |
_gx_system_timer_start((GX_WIDGET *)accordion, GX_MENU_OPEN_TIMER, 1, 1); |
597 |
|
21 |
accordion -> gx_accordion_menu_animation_status |= GX_MENU_ANIMATION_OPEN; |
598 |
|
|
|
599 |
|
21 |
child = accordion -> gx_accordion_menu_expand_item; |
600 |
|
21 |
menu_list = &((GX_MENU *)child) -> gx_menu_list; |
601 |
|
|
|
602 |
|
|
/* Link menu list to menu's parent. */ |
603 |
|
21 |
_gx_widget_link(child -> gx_widget_parent, (GX_WIDGET *)menu_list); |
604 |
|
|
|
605 |
|
21 |
x_shift = (GX_VALUE)(child -> gx_widget_size.gx_rectangle_left - menu_list -> gx_widget_size.gx_rectangle_left); |
606 |
|
21 |
y_shift = (GX_VALUE)(child -> gx_widget_size.gx_rectangle_bottom + 1 - menu_list -> gx_widget_size.gx_rectangle_top); |
607 |
|
|
|
608 |
|
|
/* Shift menu list to the bottom of the menu. */ |
609 |
✓✓✓✓
|
21 |
if (x_shift || y_shift) |
610 |
|
|
{ |
611 |
|
7 |
_gx_widget_shift((GX_WIDGET *)menu_list, x_shift, y_shift, GX_FALSE); |
612 |
|
|
} |
613 |
|
|
} |
614 |
|
|
} |
615 |
|
|
else |
616 |
|
|
{ |
617 |
|
5 |
_gx_widget_event_process(widget, event_ptr); |
618 |
|
|
} |
619 |
|
|
|
620 |
|
29 |
return GX_SUCCESS; |
621 |
|
|
} |
622 |
|
|
|
623 |
|
|
/**************************************************************************/ |
624 |
|
|
/* */ |
625 |
|
|
/* FUNCTION RELEASE */ |
626 |
|
|
/* */ |
627 |
|
|
/* _gx_accordion_menu_event_process PORTABLE C */ |
628 |
|
|
/* 6.1 */ |
629 |
|
|
/* AUTHOR */ |
630 |
|
|
/* */ |
631 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
632 |
|
|
/* */ |
633 |
|
|
/* DESCRIPTION */ |
634 |
|
|
/* */ |
635 |
|
|
/* This service processes an event for the accordion menu. */ |
636 |
|
|
/* */ |
637 |
|
|
/* INPUT */ |
638 |
|
|
/* */ |
639 |
|
|
/* accordion Pointer to accordion menu */ |
640 |
|
|
/* control block */ |
641 |
|
|
/* event_ptr Pointer to event to process */ |
642 |
|
|
/* */ |
643 |
|
|
/* OUTPUT */ |
644 |
|
|
/* */ |
645 |
|
|
/* status Completion status */ |
646 |
|
|
/* */ |
647 |
|
|
/* CALLS */ |
648 |
|
|
/* */ |
649 |
|
|
/* _gx_widget_event_process Default widget event process */ |
650 |
|
|
/* _gx_accordion_menu_position Position an accordion menu */ |
651 |
|
|
/* _gx_accordion_menu_open_animation_update */ |
652 |
|
|
/* Execute one step menu open */ |
653 |
|
|
/* animation */ |
654 |
|
|
/* _gx_accordion_menu_close_animation_update */ |
655 |
|
|
/* Execute one step menu close */ |
656 |
|
|
/* animation */ |
657 |
|
|
/* _gx_accordion_menu_pen_down_event_process */ |
658 |
|
|
/* Handle pen down event */ |
659 |
|
|
/* _gx_accordion_menu_pen_up_event_process */ |
660 |
|
|
/* Handle pen up event */ |
661 |
|
|
/* */ |
662 |
|
|
/* CALLED BY */ |
663 |
|
|
/* */ |
664 |
|
|
/* Application Code */ |
665 |
|
|
/* */ |
666 |
|
|
/* RELEASE HISTORY */ |
667 |
|
|
/* */ |
668 |
|
|
/* DATE NAME DESCRIPTION */ |
669 |
|
|
/* */ |
670 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
671 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
672 |
|
|
/* resulting in version 6.1 */ |
673 |
|
|
/* */ |
674 |
|
|
/**************************************************************************/ |
675 |
|
661 |
UINT _gx_accordion_menu_event_process(GX_ACCORDION_MENU *accordion, GX_EVENT *event_ptr) |
676 |
|
|
{ |
677 |
|
|
UINT timer_id; |
678 |
|
|
|
679 |
✓✓✓✓ ✓ |
661 |
switch (event_ptr -> gx_event_type) |
680 |
|
|
{ |
681 |
|
115 |
case GX_EVENT_SHOW: |
682 |
|
115 |
_gx_widget_event_process((GX_WIDGET *)accordion, event_ptr); |
683 |
|
|
|
684 |
|
|
/* Check if the accordion parent is a menu list, if so, this is not a top level accordion, |
685 |
|
|
Do not call accordion menu position here. We should only call menu position for a top level accordion menu. */ |
686 |
✓✓✓✓
|
115 |
if (!(accordion -> gx_widget_parent && accordion -> gx_widget_parent -> gx_widget_type == GX_TYPE_MENU_LIST)) |
687 |
|
|
{ |
688 |
|
111 |
_gx_accordion_menu_position(accordion); |
689 |
|
|
} |
690 |
|
115 |
break; |
691 |
|
|
|
692 |
|
30 |
case GX_EVENT_PEN_DOWN: |
693 |
|
30 |
_gx_accordion_menu_pen_down_event_process(accordion, event_ptr); |
694 |
|
30 |
break; |
695 |
|
|
|
696 |
|
29 |
case GX_EVENT_PEN_UP: |
697 |
|
29 |
_gx_accordion_menu_pen_up_event_process(accordion, event_ptr); |
698 |
|
29 |
break; |
699 |
|
|
|
700 |
|
392 |
case GX_EVENT_TIMER: |
701 |
|
392 |
timer_id = event_ptr -> gx_event_payload.gx_event_timer_id; |
702 |
✓✓ |
392 |
if (timer_id == GX_MENU_CLOSE_TIMER) |
703 |
|
|
{ |
704 |
|
141 |
_gx_accordion_menu_close_animation_update(accordion); |
705 |
|
|
} |
706 |
✓✓ |
251 |
else if (timer_id == GX_MENU_OPEN_TIMER) |
707 |
|
|
{ |
708 |
|
228 |
_gx_accordion_menu_open_animation_update(accordion); |
709 |
|
|
} |
710 |
|
392 |
break; |
711 |
|
|
|
712 |
|
95 |
default: |
713 |
|
95 |
return _gx_widget_event_process((GX_WIDGET *)accordion, event_ptr); |
714 |
|
|
} |
715 |
|
|
|
716 |
|
566 |
return(GX_SUCCESS); |
717 |
|
|
} |
718 |
|
|
|