From d72e26caafe0fd45d18a9a8467727643e5aa4819 Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 13 Oct 2024 14:47:53 -0400 Subject: [PATCH] main.cpp,cawUi.cpp,cawUiDecl.h,css/caw.css,html/ui.cfg : Improved layout of var's in proc UI. --- examples/examples.cfg | 2 +- src/caw/cawUi.cpp | 126 ++++++++++++++++++++++++++++----------- src/caw/cawUiDecl.h | 1 - src/caw/html/css/caw.css | 78 +++++++----------------- src/caw/html/ui.cfg | 20 ++++--- src/caw/main.cpp | 10 ++-- 6 files changed, 130 insertions(+), 107 deletions(-) diff --git a/examples/examples.cfg b/examples/examples.cfg index ce45ef2..e985ffd 100644 --- a/examples/examples.cfg +++ b/examples/examples.cfg @@ -9,7 +9,7 @@ ex_00_rt_sine: { - //dur_limit_secs:5.0, + dur_limit_secs:5.0, network: { diff --git a/src/caw/cawUi.cpp b/src/caw/cawUi.cpp index 9f0374a..1029b2c 100644 --- a/src/caw/cawUi.cpp +++ b/src/caw/cawUi.cpp @@ -58,7 +58,7 @@ namespace caw { rc_t _create_bool_widgets( ui_t* p, unsigned widgetListUuId, const flow::ui_var_t* ui_var, unsigned& uuid_ref ) { rc_t rc = kOkRC; - if((rc = uiCreateCheck(p->ioH, uuid_ref, widgetListUuId, nullptr, kCheckWidgetId, kInvalidId, nullptr, ui_var->label )) != kOkRC ) + if((rc = uiCreateCheck(p->ioH, uuid_ref, widgetListUuId, nullptr, kCheckWidgetId, kInvalidId, nullptr, nullptr )) != kOkRC ) { rc = cwLogError(rc,"Check box widget create failed on '%s'.",cwStringNullGuard(ui_var->label)); } @@ -70,7 +70,7 @@ namespace caw { { rc_t rc; - if((rc = uiCreateNumb( p->ioH, uuid_ref, widgetListUuId, nullptr, appId, kInvalidId, nullptr, ui_var->label, min_val, max_val, step, dec_pl )) != kOkRC ) + if((rc = uiCreateNumb( p->ioH, uuid_ref, widgetListUuId, nullptr, appId, kInvalidId, nullptr, nullptr, min_val, max_val, step, dec_pl )) != kOkRC ) { rc = cwLogError(rc,"Integer widget create failed on '%s'.",cwStringNullGuard(ui_var->label)); goto errLabel; @@ -83,7 +83,7 @@ namespace caw { rc_t _create_string_widgets( ui_t* p, unsigned widgetListUuId, const flow::ui_var_t* ui_var, unsigned& uuid_ref ) { rc_t rc = kOkRC; - if((rc = uiCreateStr( p->ioH, uuid_ref, widgetListUuId, nullptr, kStringWidgetId, kInvalidId, nullptr, ui_var->label )) != kOkRC ) + if((rc = uiCreateStr( p->ioH, uuid_ref, widgetListUuId, nullptr, kStringWidgetId, kInvalidId, nullptr, nullptr )) != kOkRC ) { rc = cwLogError(rc,"String widget create failed on '%s'.",cwStringNullGuard(ui_var->label)); goto errLabel; @@ -93,6 +93,21 @@ namespace caw { return rc; } + rc_t _create_var_label( ui_t* p, unsigned parentListUuId, const flow::ui_var_t* ui_var, const char* label, unsigned var_idx ) + { + rc_t rc; + unsigned uuId; + if((rc = uiCreateStrDisplay( p->ioH, uuId, parentListUuId, nullptr, kInvalidId, kInvalidId, nullptr, label )) != kOkRC ) + { + rc = cwLogError(rc,"Label widget create failed on '%s'.",cwStringNullGuard(ui_var->label)); + goto errLabel; + + } + + errLabel: + return rc; + + } rc_t _create_var_ui( ui_t* p, unsigned parentListUuId, const flow::ui_var_t* ui_var, unsigned var_idx ) { @@ -178,11 +193,19 @@ namespace caw { } if( widget_uuId != kInvalidId ) + { uiSetBlob(p->ioH,widget_uuId, &ui_var, sizeof(&ui_var)); + // if this is a 'init' variable then disable it + if( ui_var->desc_flags & flow::kInitVarDescFl ) + uiClearEnable(p->ioH, widget_uuId ); + + + } + errLabel: if(rc != kOkRC ) - rc = cwLogError(rc,"Processor UI creation failed on %s:%i.",cwStringNullGuard(ui_var->label),ui_var->label_sfx_id); + rc = cwLogError(rc,"Variable UI creation failed on %s:%i.",cwStringNullGuard(ui_var->label),ui_var->label_sfx_id); return rc; @@ -202,66 +225,97 @@ namespace caw { rc_t _create_proc_ui( ui_t* p, unsigned parentListUuId, const flow::ui_proc_t* ui_proc, unsigned proc_idx ) { - rc_t rc = kOkRC; - unsigned procPanelUuId = kInvalidId; - unsigned chanListUuId = kInvalidId; - unsigned chN = _calc_max_chan_count(ui_proc); + rc_t rc = kOkRC; + unsigned procPanelUuId = kInvalidId; + unsigned chanPanelUuId = kInvalidId; + unsigned chanListUuId = kInvalidId; + unsigned chN = _calc_max_chan_count(ui_proc); + const unsigned label_buf_charN = 127; + char label_buf[ label_buf_charN+1 ]; if((rc = uiCreateFromRsrc( p->ioH, "proc", parentListUuId, proc_idx )) != kOkRC ) { goto errLabel; } - procPanelUuId = uiFindElementUuId( p->ioH, parentListUuId, kProcPanelId, proc_idx ); - chanListUuId = uiFindElementUuId( p->ioH, procPanelUuId, kChanListId, kInvalidId ); - + procPanelUuId = uiFindElementUuId( p->ioH, parentListUuId, kProcPanelId, proc_idx ); + chanPanelUuId = uiFindElementUuId( p->ioH, procPanelUuId, kChanPanelId, kInvalidId ); + chanListUuId = uiFindElementUuId( p->ioH, chanPanelUuId, kChanListId, kInvalidId ); //printf("proc_idx: %i %i %i : chN:%i\n",proc_idx, parentListUuId, procPanelUuId,chN); - uiSendValue( p->ioH, uiFindElementUuId(p->ioH, procPanelUuId, kProcInstLabelId, kInvalidId), ui_proc->label ); - uiSendValue( p->ioH, uiFindElementUuId(p->ioH, procPanelUuId, kProcInstSfxId, kInvalidId), ui_proc->label_sfx_id ); + snprintf(label_buf,label_buf_charN,"%s:%i",ui_proc->label,ui_proc->label_sfx_id); + + uiSendValue( p->ioH, uiFindElementUuId(p->ioH, procPanelUuId, kProcInstLabelId, kInvalidId), label_buf ); - // for each channel - for(unsigned ui_ch_idx=0; ui_ch_idxioH, "chan", chanListUuId, ui_ch_idx )) != kOkRC ) { goto errLabel; } - chanPanelUuId = uiFindElementUuId(p->ioH, chanListUuId, kChanPanelId, ui_ch_idx); - varListUuId = uiFindElementUuId(p->ioH, chanPanelUuId, kVarListId, kInvalidIdx ); - + varListUuId = uiFindElementUuId(p->ioH, chanListUuId, kVarListId, ui_ch_idx ); + + // for each var for(unsigned j=0; jvarN; ++j) { - const flow::ui_var_t* ui_var = ui_proc->varA + j; + const flow::ui_var_t* ui_var = ui_proc->varA + j; + // only create controls for certain value types + if( !(ui_var->value_tid & (flow::kBoolTFl | flow::kIntTFl | flow::kUIntTFl | flow::kFloatTFl | flow::kDoubleTFl | flow::kStringTFl ))) + continue; - // if this variable has no channelized duplicates and this is the 'any' ch. var - if( ui_var->ch_idx == flow::kAnyChIdx && ui_var->ch_cnt==flow::kAnyChIdx && ui_ch_idx==0 ) + + if( ui_ch_idx == 0 ) { + if( ui_var->ch_idx == flow::kAnyChIdx ) + { + snprintf(label_buf,label_buf_charN,"%s:%i",ui_var->label,ui_var->label_sfx_id); + if((rc = _create_var_label(p,varListUuId, ui_var, label_buf, j)) != kOkRC ) + { + goto errLabel; + } + } + } else { - // if this is a channelized variable and ui_ch_idx is the var's channel - if( ui_var->ch_idx != flow::kAnyChIdx && ui_var->ch_idx == ui_ch_idx ) + + // subtract one from ui_ch_idx to account for the leading label column with is associated with ui_ch_idx==0 + unsigned uiChIdx = ui_ch_idx - 1; + bool create_fl = false; + + // if this is the 'any' ch. var + if( ui_var->ch_idx == flow::kAnyChIdx ) { + // if this 'any' ch. var has no other channels + if( ui_var->ch_cnt == 0 ) + { + create_fl = true; // always create a control or a blank var + + // if the current ch. == 0 then create then control ... + if( ui_var->ch_cnt==0 && uiChIdx!=0 ) + ui_var = nullptr; // ... otherwise create a blank + } + } - else + else // otherwise create the var if it is on chan 'uiChIdx' { - //printf("proc_idx:%i %s : %i %i\n",proc_idx,ui_var->label,ui_var->ch_idx,ui_var->ch_cnt); - ui_var = nullptr; // insert a blank var panel + create_fl = ui_var->ch_idx == uiChIdx; + } + + if( create_fl ) + { + if((rc = _create_var_ui(p, varListUuId, ui_var, j)) != kOkRC ) + { + goto errLabel; + } } - } - - - if((rc = _create_var_ui(p, varListUuId, ui_var, j)) != kOkRC ) - { - goto errLabel; } } } @@ -335,8 +389,12 @@ cw::rc_t caw::ui::create( handle_t& hRef, rc = cwLogError(rc,"UI create failed."); goto errLabel; } + + hRef.set(p); } + + errLabel: return rc; } diff --git a/src/caw/cawUiDecl.h b/src/caw/cawUiDecl.h index 1ecee7a..ef5477a 100644 --- a/src/caw/cawUiDecl.h +++ b/src/caw/cawUiDecl.h @@ -23,7 +23,6 @@ namespace caw { kProcPanelId, kProcInstLabelId, - kProcInstSfxId, kChanListId, kChanPanelId, diff --git a/src/caw/html/css/caw.css b/src/caw/html/css/caw.css index d2e9051..6582232 100644 --- a/src/caw/html/css/caw.css +++ b/src/caw/html/css/caw.css @@ -13,68 +13,30 @@ .chanPanel { border: 1px solid Yellow; + + /*height: 100px;*/ + overflow-x: hidden; /* 'hidden' to remove horz scroll bar */ + overflow-y: auto; + +} + +.chanList { + display: flex; + flex-direction: row; +} + + + +.varList { + display: flex; + flex-direction: column; + overflow-y: hidden; + } .varPanel { border: 1px solid Green; + height: 20px; } - -.fragList { - border: 1px solid LightSteelBlue; - width: 1000px; - height: 450px; -} - -.fragList label { - width: 50px; - background-color: LightBlue; -} - -.fragList .uiNumbDisp { - width: 25px; -} - -.fragPanel { - border: 1px solid LightSteelBlue; - padding-bottom: 5px; - padding-top: 5px; -} - -.fragPanelRow { - padding-right: 15px; - padding-left: 15px; - justify-content: space-around; -} - -.fragPresetCtl { - width: 50px; -} - -.fragPresetCtl:nth-of-type(even){ - border: 1px solid Yellow; -} - -.fragPresetCtl .uiNumber { - border: 1px solid LightSteelBlue; - width: 80%; -} - -.fragPresetCtl .uiString { - border: 1px solid LightSteelBlue; - width: 80%; -} - -.fragNote { - width: 575px; -} - -.uiRow { - padding-bottom: 5px; - padding-top: 5px; -} - -.velTunerPanel { - border: 1px solid black; -} diff --git a/src/caw/html/ui.cfg b/src/caw/html/ui.cfg index bf67fb7..5019a9f 100644 --- a/src/caw/html/ui.cfg +++ b/src/caw/html/ui.cfg @@ -50,20 +50,22 @@ col: { str_disp: { name: procInstLabel, value:"" }, - numb_disp: { name:procInstSfxId, value:0 }, - hlist: { name: chanListId, addClassName: chanList } + + panel: { + name: chanPanelId, + addClassName: chanPanel, + + panel: { name: chanListId, addClassName: chanList } + } } } } + + chan: { - panel: { - name: chanPanelId, - addClassName: chanPanel, - - vlist: { name: varListId, addClassName: varList } - } + panel: { name: varListId, addClassName: varList } } var: { @@ -72,7 +74,7 @@ name: varPanelId, addClassName: varPanel, - hlist: { name: widgetListId, addClassName: widgetList } + panel: { name: widgetListId, addClassName: widgetList } } } diff --git a/src/caw/main.cpp b/src/caw/main.cpp index fa72284..785a04d 100644 --- a/src/caw/main.cpp +++ b/src/caw/main.cpp @@ -82,12 +82,11 @@ ui::appIdMap_t appIdMapA[] = { { kProcListId, kProcPanelId, "procPanelId" }, { kProcPanelId, kProcInstLabelId, "procInstLabel" }, - { kProcPanelId, kProcInstSfxId, "procInstSfxId" }, - { kProcPanelId, kChanListId, "chanListId" }, + { kProcPanelId, kChanPanelId, "chanPanelId" }, + { kChanPanelId, kChanListId, "chanListId" }, - { kChanListId, kChanPanelId, "chanPanelId" }, - { kChanPanelId, kVarListId, "varListId" }, + { kChanListId, kVarListId, "varListId" }, { kVarListId, kVarPanelId, "varPanelId" }, { kVarPanelId, kWidgetListId, "widgetListId" }, @@ -810,6 +809,9 @@ errLabel: if((rc = destroy(app.ioH)) != kOkRC ) rc = cwLogError(rc,"IO destroy failed."); + if((rc = destroy(app.uiH)) != kOkRC ) + rc = cwLogError(rc,"UI destroy failed."); + if( app.io_cfg != nullptr ) app.io_cfg->free();