Skip to content

Commit b374182

Browse files
author
Ting Zhu
authored
Improve logic of GUIX Studio generated gx_studio_auto_event_handler. (#95)
1 parent 1dbd7b7 commit b374182

File tree

30 files changed

+428
-539
lines changed

30 files changed

+428
-539
lines changed

guix_studio/screen_generator.cpp

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,21 +1381,6 @@ CString out("");
13811381

13821382
/* Set output file to the default file: Empty means default output file. */
13831383
SetOutFile(out);
1384-
1385-
out = "static VOID gx_studio_screen_toggle(GX_WIDGET *target1, GX_WIDGET *target2)\n"
1386-
"{\n"
1387-
" GX_WIDGET *parent = target1->gx_widget_parent;\n"
1388-
" if (parent)\n"
1389-
" {\n"
1390-
" gx_widget_detach(target1);\n"
1391-
" gx_widget_attach(parent, target2);\n"
1392-
" if (target1->gx_widget_status & GX_STATUS_STUDIO_CREATED)\n"
1393-
" {\n"
1394-
" gx_widget_delete(target1);\n"
1395-
" }\n"
1396-
" }\n"
1397-
"}\n\n";
1398-
FileWrite(out);
13991384

14001385
out = "static GX_WIDGET *gx_studio_action_target_get(GX_WIDGET *current, GX_CONST GX_STUDIO_ACTION *action)\n"
14011386
"{\n"
@@ -1586,7 +1571,17 @@ CString out("");
15861571
" break;\n\n"
15871572
" case GX_ACTION_TYPE_TOGGLE:\n"
15881573
" target = gx_studio_action_target_get(widget, action);\n"
1589-
" gx_studio_screen_toggle(widget, target);\n"
1574+
" parent = widget->gx_widget_parent;\n"
1575+
" if (parent)\n"
1576+
" {\n"
1577+
" gx_widget_detach(widget);\n"
1578+
" gx_widget_attach(parent, target);\n"
1579+
" if (widget->gx_widget_status & GX_STATUS_STUDIO_CREATED)\n"
1580+
" {\n"
1581+
" gx_widget_delete(widget);\n"
1582+
" widget = GX_NULL;\n"
1583+
" }\n"
1584+
" }\n"
15901585
" break;\n\n"
15911586
" case GX_ACTION_TYPE_SHOW:\n"
15921587
" target = gx_studio_action_target_get(widget, action);\n"
@@ -1663,7 +1658,17 @@ CString out("");
16631658
" {\n"
16641659
" target = gx_studio_action_target_get(widget, action);\n"
16651660
" }\n"
1666-
" gx_studio_screen_toggle(widget, target);\n"
1661+
" parent = widget->gx_widget_parent;\n"
1662+
" if (parent)\n"
1663+
" {\n"
1664+
" gx_widget_detach(widget);\n"
1665+
" gx_widget_attach(parent, target);\n"
1666+
" if (widget->gx_widget_status & GX_STATUS_STUDIO_CREATED)\n"
1667+
" {\n"
1668+
" gx_widget_delete(widget);\n"
1669+
" widget = GX_NULL;\n"
1670+
" }\n"
1671+
" }\n"
16671672
" break;\n\n"
16681673
" case GX_ACTION_TYPE_SHOW:\n"
16691674
" target = gx_studio_action_target_get(widget, action);\n"
@@ -1728,7 +1733,7 @@ CString out("");
17281733
" entry++;\n"
17291734
" }\n\n"
17301735

1731-
" if (record->chain_event_handler)\n"
1736+
" if (widget && record->chain_event_handler)\n"
17321737
" {\n"
17331738
" status = record->chain_event_handler(widget, event_ptr);\n"
17341739
" }\n"

samples/demo_guix_car_infotainment/demo_guix_car_infotainment_specifications.c

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
/* specification file(s). For more information please refer to the Azure RTOS */
66
/* GUIX Studio User Guide, or visit our web site at azure.com/rtos */
77
/* */
8-
/* GUIX Studio Revision 6.3.0.0 */
9-
/* Date (dd.mm.yyyy): 24.11.2023 Time (hh:mm): 16:33 */
8+
/* GUIX Studio Revision 6.3.0.1 */
9+
/* Date (dd.mm.yyyy): 22.12.2023 Time (hh:mm): 16:01 */
1010
/*******************************************************************************/
1111

1212

@@ -51,20 +51,6 @@ GX_STUDIO_DISPLAY_INFO demo_guix_car_infotainment_display_table[1] =
5151
}
5252
};
5353

54-
static VOID gx_studio_screen_toggle(GX_WIDGET *target1, GX_WIDGET *target2)
55-
{
56-
GX_WIDGET *parent = target1->gx_widget_parent;
57-
if (parent)
58-
{
59-
gx_widget_detach(target1);
60-
gx_widget_attach(parent, target2);
61-
if (target1->gx_widget_status & GX_STATUS_STUDIO_CREATED)
62-
{
63-
gx_widget_delete(target1);
64-
}
65-
}
66-
}
67-
6854
static GX_WIDGET *gx_studio_action_target_get(GX_WIDGET *current, GX_CONST GX_STUDIO_ACTION *action)
6955
{
7056
GX_WIDGET *parent = GX_NULL;
@@ -267,7 +253,17 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
267253
{
268254
target = gx_studio_action_target_get(widget, action);
269255
}
270-
gx_studio_screen_toggle(widget, target);
256+
parent = widget->gx_widget_parent;
257+
if (parent)
258+
{
259+
gx_widget_detach(widget);
260+
gx_widget_attach(parent, target);
261+
if (widget->gx_widget_status & GX_STATUS_STUDIO_CREATED)
262+
{
263+
gx_widget_delete(widget);
264+
widget = GX_NULL;
265+
}
266+
}
271267
break;
272268

273269
case GX_ACTION_TYPE_SHOW:
@@ -340,7 +336,7 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
340336
entry++;
341337
}
342338

343-
if (record->chain_event_handler)
339+
if (widget && record->chain_event_handler)
344340
{
345341
status = record->chain_event_handler(widget, event_ptr);
346342
}

samples/demo_guix_home_automation/demo_guix_home_automation_specifications.c

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
/* specification file(s). For more information please refer to the Azure RTOS */
66
/* GUIX Studio User Guide, or visit our web site at azure.com/rtos */
77
/* */
8-
/* GUIX Studio Revision 6.3.0.0 */
9-
/* Date (dd.mm.yyyy): 24.11.2023 Time (hh:mm): 16:33 */
8+
/* GUIX Studio Revision 6.3.0.1 */
9+
/* Date (dd.mm.yyyy): 22.12.2023 Time (hh:mm): 16:01 */
1010
/*******************************************************************************/
1111

1212

@@ -65,20 +65,6 @@ GX_STUDIO_DISPLAY_INFO demo_guix_home_automation_display_table[1] =
6565
}
6666
};
6767

68-
static VOID gx_studio_screen_toggle(GX_WIDGET *target1, GX_WIDGET *target2)
69-
{
70-
GX_WIDGET *parent = target1->gx_widget_parent;
71-
if (parent)
72-
{
73-
gx_widget_detach(target1);
74-
gx_widget_attach(parent, target2);
75-
if (target1->gx_widget_status & GX_STATUS_STUDIO_CREATED)
76-
{
77-
gx_widget_delete(target1);
78-
}
79-
}
80-
}
81-
8268
static GX_WIDGET *gx_studio_action_target_get(GX_WIDGET *current, GX_CONST GX_STUDIO_ACTION *action)
8369
{
8470
GX_WIDGET *parent = GX_NULL;
@@ -281,7 +267,17 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
281267
{
282268
target = gx_studio_action_target_get(widget, action);
283269
}
284-
gx_studio_screen_toggle(widget, target);
270+
parent = widget->gx_widget_parent;
271+
if (parent)
272+
{
273+
gx_widget_detach(widget);
274+
gx_widget_attach(parent, target);
275+
if (widget->gx_widget_status & GX_STATUS_STUDIO_CREATED)
276+
{
277+
gx_widget_delete(widget);
278+
widget = GX_NULL;
279+
}
280+
}
285281
break;
286282

287283
case GX_ACTION_TYPE_SHOW:
@@ -354,7 +350,7 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
354350
entry++;
355351
}
356352

357-
if (record->chain_event_handler)
353+
if (widget && record->chain_event_handler)
358354
{
359355
status = record->chain_event_handler(widget, event_ptr);
360356
}

samples/demo_guix_industrial/demo_guix_industrial_specifications.c

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
/* specification file(s). For more information please refer to the Azure RTOS */
66
/* GUIX Studio User Guide, or visit our web site at azure.com/rtos */
77
/* */
8-
/* GUIX Studio Revision 6.3.0.0 */
9-
/* Date (dd.mm.yyyy): 24.11.2023 Time (hh:mm): 16:33 */
8+
/* GUIX Studio Revision 6.3.0.1 */
9+
/* Date (dd.mm.yyyy): 22.12.2023 Time (hh:mm): 16:01 */
1010
/*******************************************************************************/
1111

1212

@@ -49,20 +49,6 @@ GX_STUDIO_DISPLAY_INFO demo_guix_industrial_display_table[1] =
4949
}
5050
};
5151

52-
static VOID gx_studio_screen_toggle(GX_WIDGET *target1, GX_WIDGET *target2)
53-
{
54-
GX_WIDGET *parent = target1->gx_widget_parent;
55-
if (parent)
56-
{
57-
gx_widget_detach(target1);
58-
gx_widget_attach(parent, target2);
59-
if (target1->gx_widget_status & GX_STATUS_STUDIO_CREATED)
60-
{
61-
gx_widget_delete(target1);
62-
}
63-
}
64-
}
65-
6652
static GX_WIDGET *gx_studio_action_target_get(GX_WIDGET *current, GX_CONST GX_STUDIO_ACTION *action)
6753
{
6854
GX_WIDGET *parent = GX_NULL;
@@ -265,7 +251,17 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
265251
{
266252
target = gx_studio_action_target_get(widget, action);
267253
}
268-
gx_studio_screen_toggle(widget, target);
254+
parent = widget->gx_widget_parent;
255+
if (parent)
256+
{
257+
gx_widget_detach(widget);
258+
gx_widget_attach(parent, target);
259+
if (widget->gx_widget_status & GX_STATUS_STUDIO_CREATED)
260+
{
261+
gx_widget_delete(widget);
262+
widget = GX_NULL;
263+
}
264+
}
269265
break;
270266

271267
case GX_ACTION_TYPE_SHOW:
@@ -338,7 +334,7 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
338334
entry++;
339335
}
340336

341-
if (record->chain_event_handler)
337+
if (widget && record->chain_event_handler)
342338
{
343339
status = record->chain_event_handler(widget, event_ptr);
344340
}

samples/demo_guix_medical/guix_medical_specifications.c

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
/* specification file(s). For more information please refer to the Azure RTOS */
66
/* GUIX Studio User Guide, or visit our web site at azure.com/rtos */
77
/* */
8-
/* GUIX Studio Revision 6.3.0.0 */
9-
/* Date (dd.mm.yyyy): 24.11.2023 Time (hh:mm): 16:33 */
8+
/* GUIX Studio Revision 6.3.0.1 */
9+
/* Date (dd.mm.yyyy): 22.12.2023 Time (hh:mm): 16:01 */
1010
/*******************************************************************************/
1111

1212

@@ -48,20 +48,6 @@ GX_STUDIO_DISPLAY_INFO guix_medical_display_table[1] =
4848
}
4949
};
5050

51-
static VOID gx_studio_screen_toggle(GX_WIDGET *target1, GX_WIDGET *target2)
52-
{
53-
GX_WIDGET *parent = target1->gx_widget_parent;
54-
if (parent)
55-
{
56-
gx_widget_detach(target1);
57-
gx_widget_attach(parent, target2);
58-
if (target1->gx_widget_status & GX_STATUS_STUDIO_CREATED)
59-
{
60-
gx_widget_delete(target1);
61-
}
62-
}
63-
}
64-
6551
static GX_WIDGET *gx_studio_action_target_get(GX_WIDGET *current, GX_CONST GX_STUDIO_ACTION *action)
6652
{
6753
GX_WIDGET *parent = GX_NULL;
@@ -264,7 +250,17 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
264250
{
265251
target = gx_studio_action_target_get(widget, action);
266252
}
267-
gx_studio_screen_toggle(widget, target);
253+
parent = widget->gx_widget_parent;
254+
if (parent)
255+
{
256+
gx_widget_detach(widget);
257+
gx_widget_attach(parent, target);
258+
if (widget->gx_widget_status & GX_STATUS_STUDIO_CREATED)
259+
{
260+
gx_widget_delete(widget);
261+
widget = GX_NULL;
262+
}
263+
}
268264
break;
269265

270266
case GX_ACTION_TYPE_SHOW:
@@ -337,7 +333,7 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
337333
entry++;
338334
}
339335

340-
if (record->chain_event_handler)
336+
if (widget && record->chain_event_handler)
341337
{
342338
status = record->chain_event_handler(widget, event_ptr);
343339
}

samples/demo_guix_widget_types/guix_widget_types_specifications.c

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
/* specification file(s). For more information please refer to the Azure RTOS */
66
/* GUIX Studio User Guide, or visit our web site at azure.com/rtos */
77
/* */
8-
/* GUIX Studio Revision 6.3.0.0 */
9-
/* Date (dd.mm.yyyy): 24.11.2023 Time (hh:mm): 16:33 */
8+
/* GUIX Studio Revision 6.3.0.1 */
9+
/* Date (dd.mm.yyyy): 22.12.2023 Time (hh:mm): 16:01 */
1010
/*******************************************************************************/
1111

1212

@@ -52,20 +52,6 @@ GX_STUDIO_DISPLAY_INFO guix_widget_types_display_table[1] =
5252
}
5353
};
5454

55-
static VOID gx_studio_screen_toggle(GX_WIDGET *target1, GX_WIDGET *target2)
56-
{
57-
GX_WIDGET *parent = target1->gx_widget_parent;
58-
if (parent)
59-
{
60-
gx_widget_detach(target1);
61-
gx_widget_attach(parent, target2);
62-
if (target1->gx_widget_status & GX_STATUS_STUDIO_CREATED)
63-
{
64-
gx_widget_delete(target1);
65-
}
66-
}
67-
}
68-
6955
static GX_WIDGET *gx_studio_action_target_get(GX_WIDGET *current, GX_CONST GX_STUDIO_ACTION *action)
7056
{
7157
GX_WIDGET *parent = GX_NULL;
@@ -268,7 +254,17 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
268254
{
269255
target = gx_studio_action_target_get(widget, action);
270256
}
271-
gx_studio_screen_toggle(widget, target);
257+
parent = widget->gx_widget_parent;
258+
if (parent)
259+
{
260+
gx_widget_detach(widget);
261+
gx_widget_attach(parent, target);
262+
if (widget->gx_widget_status & GX_STATUS_STUDIO_CREATED)
263+
{
264+
gx_widget_delete(widget);
265+
widget = GX_NULL;
266+
}
267+
}
272268
break;
273269

274270
case GX_ACTION_TYPE_SHOW:
@@ -341,7 +337,7 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
341337
entry++;
342338
}
343339

344-
if (record->chain_event_handler)
340+
if (widget && record->chain_event_handler)
345341
{
346342
status = record->chain_event_handler(widget, event_ptr);
347343
}

0 commit comments

Comments
 (0)