Skip to content

Commit

Permalink
Improve logic of GUIX Studio generated gx_studio_auto_event_handler. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ting-ms authored Dec 26, 2023
1 parent 1dbd7b7 commit b374182
Show file tree
Hide file tree
Showing 30 changed files with 428 additions and 539 deletions.
41 changes: 23 additions & 18 deletions guix_studio/screen_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1381,21 +1381,6 @@ CString out("");

/* Set output file to the default file: Empty means default output file. */
SetOutFile(out);

out = "static VOID gx_studio_screen_toggle(GX_WIDGET *target1, GX_WIDGET *target2)\n"
"{\n"
" GX_WIDGET *parent = target1->gx_widget_parent;\n"
" if (parent)\n"
" {\n"
" gx_widget_detach(target1);\n"
" gx_widget_attach(parent, target2);\n"
" if (target1->gx_widget_status & GX_STATUS_STUDIO_CREATED)\n"
" {\n"
" gx_widget_delete(target1);\n"
" }\n"
" }\n"
"}\n\n";
FileWrite(out);

out = "static GX_WIDGET *gx_studio_action_target_get(GX_WIDGET *current, GX_CONST GX_STUDIO_ACTION *action)\n"
"{\n"
Expand Down Expand Up @@ -1586,7 +1571,17 @@ CString out("");
" break;\n\n"
" case GX_ACTION_TYPE_TOGGLE:\n"
" target = gx_studio_action_target_get(widget, action);\n"
" gx_studio_screen_toggle(widget, target);\n"
" parent = widget->gx_widget_parent;\n"
" if (parent)\n"
" {\n"
" gx_widget_detach(widget);\n"
" gx_widget_attach(parent, target);\n"
" if (widget->gx_widget_status & GX_STATUS_STUDIO_CREATED)\n"
" {\n"
" gx_widget_delete(widget);\n"
" widget = GX_NULL;\n"
" }\n"
" }\n"
" break;\n\n"
" case GX_ACTION_TYPE_SHOW:\n"
" target = gx_studio_action_target_get(widget, action);\n"
Expand Down Expand Up @@ -1663,7 +1658,17 @@ CString out("");
" {\n"
" target = gx_studio_action_target_get(widget, action);\n"
" }\n"
" gx_studio_screen_toggle(widget, target);\n"
" parent = widget->gx_widget_parent;\n"
" if (parent)\n"
" {\n"
" gx_widget_detach(widget);\n"
" gx_widget_attach(parent, target);\n"
" if (widget->gx_widget_status & GX_STATUS_STUDIO_CREATED)\n"
" {\n"
" gx_widget_delete(widget);\n"
" widget = GX_NULL;\n"
" }\n"
" }\n"
" break;\n\n"
" case GX_ACTION_TYPE_SHOW:\n"
" target = gx_studio_action_target_get(widget, action);\n"
Expand Down Expand Up @@ -1728,7 +1733,7 @@ CString out("");
" entry++;\n"
" }\n\n"

" if (record->chain_event_handler)\n"
" if (widget && record->chain_event_handler)\n"
" {\n"
" status = record->chain_event_handler(widget, event_ptr);\n"
" }\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/* specification file(s). For more information please refer to the Azure RTOS */
/* GUIX Studio User Guide, or visit our web site at azure.com/rtos */
/* */
/* GUIX Studio Revision 6.3.0.0 */
/* Date (dd.mm.yyyy): 24.11.2023 Time (hh:mm): 16:33 */
/* GUIX Studio Revision 6.3.0.1 */
/* Date (dd.mm.yyyy): 22.12.2023 Time (hh:mm): 16:01 */
/*******************************************************************************/


Expand Down Expand Up @@ -51,20 +51,6 @@ GX_STUDIO_DISPLAY_INFO demo_guix_car_infotainment_display_table[1] =
}
};

static VOID gx_studio_screen_toggle(GX_WIDGET *target1, GX_WIDGET *target2)
{
GX_WIDGET *parent = target1->gx_widget_parent;
if (parent)
{
gx_widget_detach(target1);
gx_widget_attach(parent, target2);
if (target1->gx_widget_status & GX_STATUS_STUDIO_CREATED)
{
gx_widget_delete(target1);
}
}
}

static GX_WIDGET *gx_studio_action_target_get(GX_WIDGET *current, GX_CONST GX_STUDIO_ACTION *action)
{
GX_WIDGET *parent = GX_NULL;
Expand Down Expand Up @@ -267,7 +253,17 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
{
target = gx_studio_action_target_get(widget, action);
}
gx_studio_screen_toggle(widget, target);
parent = widget->gx_widget_parent;
if (parent)
{
gx_widget_detach(widget);
gx_widget_attach(parent, target);
if (widget->gx_widget_status & GX_STATUS_STUDIO_CREATED)
{
gx_widget_delete(widget);
widget = GX_NULL;
}
}
break;

case GX_ACTION_TYPE_SHOW:
Expand Down Expand Up @@ -340,7 +336,7 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
entry++;
}

if (record->chain_event_handler)
if (widget && record->chain_event_handler)
{
status = record->chain_event_handler(widget, event_ptr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/* specification file(s). For more information please refer to the Azure RTOS */
/* GUIX Studio User Guide, or visit our web site at azure.com/rtos */
/* */
/* GUIX Studio Revision 6.3.0.0 */
/* Date (dd.mm.yyyy): 24.11.2023 Time (hh:mm): 16:33 */
/* GUIX Studio Revision 6.3.0.1 */
/* Date (dd.mm.yyyy): 22.12.2023 Time (hh:mm): 16:01 */
/*******************************************************************************/


Expand Down Expand Up @@ -65,20 +65,6 @@ GX_STUDIO_DISPLAY_INFO demo_guix_home_automation_display_table[1] =
}
};

static VOID gx_studio_screen_toggle(GX_WIDGET *target1, GX_WIDGET *target2)
{
GX_WIDGET *parent = target1->gx_widget_parent;
if (parent)
{
gx_widget_detach(target1);
gx_widget_attach(parent, target2);
if (target1->gx_widget_status & GX_STATUS_STUDIO_CREATED)
{
gx_widget_delete(target1);
}
}
}

static GX_WIDGET *gx_studio_action_target_get(GX_WIDGET *current, GX_CONST GX_STUDIO_ACTION *action)
{
GX_WIDGET *parent = GX_NULL;
Expand Down Expand Up @@ -281,7 +267,17 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
{
target = gx_studio_action_target_get(widget, action);
}
gx_studio_screen_toggle(widget, target);
parent = widget->gx_widget_parent;
if (parent)
{
gx_widget_detach(widget);
gx_widget_attach(parent, target);
if (widget->gx_widget_status & GX_STATUS_STUDIO_CREATED)
{
gx_widget_delete(widget);
widget = GX_NULL;
}
}
break;

case GX_ACTION_TYPE_SHOW:
Expand Down Expand Up @@ -354,7 +350,7 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
entry++;
}

if (record->chain_event_handler)
if (widget && record->chain_event_handler)
{
status = record->chain_event_handler(widget, event_ptr);
}
Expand Down
32 changes: 14 additions & 18 deletions samples/demo_guix_industrial/demo_guix_industrial_specifications.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/* specification file(s). For more information please refer to the Azure RTOS */
/* GUIX Studio User Guide, or visit our web site at azure.com/rtos */
/* */
/* GUIX Studio Revision 6.3.0.0 */
/* Date (dd.mm.yyyy): 24.11.2023 Time (hh:mm): 16:33 */
/* GUIX Studio Revision 6.3.0.1 */
/* Date (dd.mm.yyyy): 22.12.2023 Time (hh:mm): 16:01 */
/*******************************************************************************/


Expand Down Expand Up @@ -49,20 +49,6 @@ GX_STUDIO_DISPLAY_INFO demo_guix_industrial_display_table[1] =
}
};

static VOID gx_studio_screen_toggle(GX_WIDGET *target1, GX_WIDGET *target2)
{
GX_WIDGET *parent = target1->gx_widget_parent;
if (parent)
{
gx_widget_detach(target1);
gx_widget_attach(parent, target2);
if (target1->gx_widget_status & GX_STATUS_STUDIO_CREATED)
{
gx_widget_delete(target1);
}
}
}

static GX_WIDGET *gx_studio_action_target_get(GX_WIDGET *current, GX_CONST GX_STUDIO_ACTION *action)
{
GX_WIDGET *parent = GX_NULL;
Expand Down Expand Up @@ -265,7 +251,17 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
{
target = gx_studio_action_target_get(widget, action);
}
gx_studio_screen_toggle(widget, target);
parent = widget->gx_widget_parent;
if (parent)
{
gx_widget_detach(widget);
gx_widget_attach(parent, target);
if (widget->gx_widget_status & GX_STATUS_STUDIO_CREATED)
{
gx_widget_delete(widget);
widget = GX_NULL;
}
}
break;

case GX_ACTION_TYPE_SHOW:
Expand Down Expand Up @@ -338,7 +334,7 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
entry++;
}

if (record->chain_event_handler)
if (widget && record->chain_event_handler)
{
status = record->chain_event_handler(widget, event_ptr);
}
Expand Down
32 changes: 14 additions & 18 deletions samples/demo_guix_medical/guix_medical_specifications.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/* specification file(s). For more information please refer to the Azure RTOS */
/* GUIX Studio User Guide, or visit our web site at azure.com/rtos */
/* */
/* GUIX Studio Revision 6.3.0.0 */
/* Date (dd.mm.yyyy): 24.11.2023 Time (hh:mm): 16:33 */
/* GUIX Studio Revision 6.3.0.1 */
/* Date (dd.mm.yyyy): 22.12.2023 Time (hh:mm): 16:01 */
/*******************************************************************************/


Expand Down Expand Up @@ -48,20 +48,6 @@ GX_STUDIO_DISPLAY_INFO guix_medical_display_table[1] =
}
};

static VOID gx_studio_screen_toggle(GX_WIDGET *target1, GX_WIDGET *target2)
{
GX_WIDGET *parent = target1->gx_widget_parent;
if (parent)
{
gx_widget_detach(target1);
gx_widget_attach(parent, target2);
if (target1->gx_widget_status & GX_STATUS_STUDIO_CREATED)
{
gx_widget_delete(target1);
}
}
}

static GX_WIDGET *gx_studio_action_target_get(GX_WIDGET *current, GX_CONST GX_STUDIO_ACTION *action)
{
GX_WIDGET *parent = GX_NULL;
Expand Down Expand Up @@ -264,7 +250,17 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
{
target = gx_studio_action_target_get(widget, action);
}
gx_studio_screen_toggle(widget, target);
parent = widget->gx_widget_parent;
if (parent)
{
gx_widget_detach(widget);
gx_widget_attach(parent, target);
if (widget->gx_widget_status & GX_STATUS_STUDIO_CREATED)
{
gx_widget_delete(widget);
widget = GX_NULL;
}
}
break;

case GX_ACTION_TYPE_SHOW:
Expand Down Expand Up @@ -337,7 +333,7 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
entry++;
}

if (record->chain_event_handler)
if (widget && record->chain_event_handler)
{
status = record->chain_event_handler(widget, event_ptr);
}
Expand Down
32 changes: 14 additions & 18 deletions samples/demo_guix_widget_types/guix_widget_types_specifications.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/* specification file(s). For more information please refer to the Azure RTOS */
/* GUIX Studio User Guide, or visit our web site at azure.com/rtos */
/* */
/* GUIX Studio Revision 6.3.0.0 */
/* Date (dd.mm.yyyy): 24.11.2023 Time (hh:mm): 16:33 */
/* GUIX Studio Revision 6.3.0.1 */
/* Date (dd.mm.yyyy): 22.12.2023 Time (hh:mm): 16:01 */
/*******************************************************************************/


Expand Down Expand Up @@ -52,20 +52,6 @@ GX_STUDIO_DISPLAY_INFO guix_widget_types_display_table[1] =
}
};

static VOID gx_studio_screen_toggle(GX_WIDGET *target1, GX_WIDGET *target2)
{
GX_WIDGET *parent = target1->gx_widget_parent;
if (parent)
{
gx_widget_detach(target1);
gx_widget_attach(parent, target2);
if (target1->gx_widget_status & GX_STATUS_STUDIO_CREATED)
{
gx_widget_delete(target1);
}
}
}

static GX_WIDGET *gx_studio_action_target_get(GX_WIDGET *current, GX_CONST GX_STUDIO_ACTION *action)
{
GX_WIDGET *parent = GX_NULL;
Expand Down Expand Up @@ -268,7 +254,17 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
{
target = gx_studio_action_target_get(widget, action);
}
gx_studio_screen_toggle(widget, target);
parent = widget->gx_widget_parent;
if (parent)
{
gx_widget_detach(widget);
gx_widget_attach(parent, target);
if (widget->gx_widget_status & GX_STATUS_STUDIO_CREATED)
{
gx_widget_delete(widget);
widget = GX_NULL;
}
}
break;

case GX_ACTION_TYPE_SHOW:
Expand Down Expand Up @@ -341,7 +337,7 @@ UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CON
entry++;
}

if (record->chain_event_handler)
if (widget && record->chain_event_handler)
{
status = record->chain_event_handler(widget, event_ptr);
}
Expand Down
Loading

0 comments on commit b374182

Please sign in to comment.