main.cpp,ui.cfg : Added 'print' button.

This commit is contained in:
kevin 2024-12-20 14:33:21 -05:00
parent 283b95d828
commit 02b558edfc
2 changed files with 29 additions and 1 deletions

View File

@ -17,6 +17,7 @@
select:{ name: pgmSelId, title:"Programs", children: {} }, select:{ name: pgmSelId, title:"Programs", children: {} },
select:{ name: pgmPresetSelId, title:"Presets", children: {}, enable:false }, select:{ name: pgmPresetSelId, title:"Presets", children: {}, enable:false },
button:{ name: pgmLoadBtnId, title:"Load", enable:false }, button:{ name: pgmLoadBtnId, title:"Load", enable:false },
button:{ name: pgmPrintBtnId, title:"Print", enable:false },
check: { name: runCheckId, title: "Run", enable:false }, check: { name: runCheckId, title: "Run", enable:false },
}, },

View File

@ -74,6 +74,7 @@ ui::appIdMap_t appIdMapA[] = {
{ kPanelDivId, kPgmSelId, "pgmSelId" }, { kPanelDivId, kPgmSelId, "pgmSelId" },
{ kPanelDivId, kPgmPresetSelId, "pgmPresetSelId" }, { kPanelDivId, kPgmPresetSelId, "pgmPresetSelId" },
{ kPanelDivId, kPgmLoadBtnId, "pgmLoadBtnId" }, { kPanelDivId, kPgmLoadBtnId, "pgmLoadBtnId" },
{ kPanelDivId, kPgmPrintBtnId, "pgmPrintBtnId" },
{ kPanelDivId, kRunCheckId, "runCheckId" }, { kPanelDivId, kRunCheckId, "runCheckId" },
{ kPanelDivId, kRootNetPanelId, "rootNetPanelId" }, { kPanelDivId, kRootNetPanelId, "rootNetPanelId" },
@ -168,6 +169,8 @@ rc_t _on_pgm_select(app_t* app, unsigned pgmSelOptId )
unsigned pgm_idx = kInvalidIdx; unsigned pgm_idx = kInvalidIdx;
unsigned pgmPresetSelUuId = io::uiFindElementUuId( app->ioH, kPgmPresetSelId ); unsigned pgmPresetSelUuId = io::uiFindElementUuId( app->ioH, kPgmPresetSelId );
unsigned pgmLoadBtnUuId = io::uiFindElementUuId( app->ioH, kPgmLoadBtnId ); unsigned pgmLoadBtnUuId = io::uiFindElementUuId( app->ioH, kPgmLoadBtnId );
unsigned pgmPrintBtnUuId = io::uiFindElementUuId( app->ioH, kPgmPrintBtnId );
unsigned runCheckUuId = io::uiFindElementUuId( app->ioH, kRunCheckId );
unsigned preset_cnt = 0; unsigned preset_cnt = 0;
if( !(kPgmBaseSelId <= pgmSelOptId && pgmSelOptId <= kPgmMaxSelId ) ) if( !(kPgmBaseSelId <= pgmSelOptId && pgmSelOptId <= kPgmMaxSelId ) )
@ -185,6 +188,8 @@ rc_t _on_pgm_select(app_t* app, unsigned pgmSelOptId )
uiSetEnable( app->ioH, pgmPresetSelUuId, false ); // Disable the preset menu and load btn in anticipation of error. uiSetEnable( app->ioH, pgmPresetSelUuId, false ); // Disable the preset menu and load btn in anticipation of error.
uiSetEnable( app->ioH, pgmLoadBtnUuId, false ); // uiSetEnable( app->ioH, pgmLoadBtnUuId, false ); //
uiSetEnable( app->ioH, pgmPrintBtnUuId, false ); //
uiSetEnable( app->ioH, runCheckUuId, false ); //
app->pgm_preset_idx = kInvalidIdx; // The preset menu is empty and so there can be no valid preset selected. app->pgm_preset_idx = kInvalidIdx; // The preset menu is empty and so there can be no valid preset selected.
pgm_idx = pgmSelOptId - kPgmBaseSelId; // Calc the ioFlowCtl preset index of the selected preset. pgm_idx = pgmSelOptId - kPgmBaseSelId; // Calc the ioFlowCtl preset index of the selected preset.
@ -232,6 +237,13 @@ rc_t _on_pgm_preset_select( app_t* app, unsigned pgmPresetSelOptId )
app->pgm_preset_idx = pgmPresetSelOptId - kPgmPresetBaseSelId; app->pgm_preset_idx = pgmPresetSelOptId - kPgmPresetBaseSelId;
if( program_is_initialized(app->ioFlowH) )
if((rc = program_apply_preset( app->ioFlowH, app->pgm_preset_idx )) == kOkRC )
{
// if the app isn't running then update the UI manually
if( !app->run_fl )
rc = send_ui_updates(app->ioFlowH);
}
errLabel: errLabel:
@ -265,6 +277,7 @@ rc_t _on_pgm_load(app_t* app )
} }
uiSetEnable(app->ioH, io::uiFindElementUuId( app->ioH, kRunCheckId ), true ); uiSetEnable(app->ioH, io::uiFindElementUuId( app->ioH, kRunCheckId ), true );
uiSetEnable(app->ioH, io::uiFindElementUuId( app->ioH, kPgmPrintBtnId ), true );
} }
@ -273,6 +286,15 @@ errLabel:
return rc; return rc;
} }
rc_t _on_pgm_print( app_t* app )
{
rc_t rc = kOkRC;
if( app->ioFlowH.isValid() )
print_network(app->ioFlowH);
return rc;
}
rc_t _on_pgm_run( app_t* app, bool run_check_fl ) rc_t _on_pgm_run( app_t* app, bool run_check_fl )
{ {
rc_t rc = kOkRC; rc_t rc = kOkRC;
@ -373,6 +395,10 @@ rc_t _ui_value_callback(app_t* app, const io::ui_msg_t& m )
case kPgmLoadBtnId: case kPgmLoadBtnId:
_on_pgm_load(app); _on_pgm_load(app);
break; break;
case kPgmPrintBtnId:
_on_pgm_print(app);
break;
case kRunCheckId: case kRunCheckId:
io::uiSetTitle(app->ioH,m.uuId,m.value->u.b ? "Off" : "On" ); io::uiSetTitle(app->ioH,m.uuId,m.value->u.b ? "Off" : "On" );
@ -727,8 +753,9 @@ void _test_stub( app_t& app )
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {
rc_t rc = kOkRC; rc_t rc = kOkRC;
app_t app = { .pgm_preset_idx=kInvalidIdx }; // all zero except ...
bool exec_complete_fl = false; bool exec_complete_fl = false;
app_t app = {}; // all zero
app.pgm_preset_idx = kInvalidIdx;
cw::log::createGlobal(); cw::log::createGlobal();