cwPresetSel.h/cpp : Added ui_select_*() and is_fragment_loc() functions.
This commit is contained in:
parent
40465b335c
commit
af51831a39
@ -84,16 +84,40 @@ namespace cw
|
|||||||
{
|
{
|
||||||
rc_t rc = kOkRC;
|
rc_t rc = kOkRC;
|
||||||
if((fragPtrRef = _find_frag(p,fragId )) == nullptr )
|
if((fragPtrRef = _find_frag(p,fragId )) == nullptr )
|
||||||
rc = cwLogError(kInvalidId,"'%i' is not a valid fragment id.",fragId);
|
rc = cwLogError(kInvalidIdRC,"'%i' is not a valid fragment id.",fragId);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frag_t* _index_to_frag( preset_sel_t* p, unsigned frag_idx )
|
||||||
|
{
|
||||||
|
frag_t* f;
|
||||||
|
unsigned i = 0;
|
||||||
|
for(f=p->fragL; f!=nullptr; f=f->link,++i)
|
||||||
|
if( i == frag_idx )
|
||||||
|
break;
|
||||||
|
|
||||||
|
if( f == nullptr )
|
||||||
|
cwLogError(kInvalidArgRC,"'%i' is not a valid fragment index.",frag_idx);
|
||||||
|
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
frag_t* _loc_to_frag( preset_sel_t* p, unsigned loc )
|
||||||
|
{
|
||||||
|
frag_t* f;
|
||||||
|
for(f=p->fragL; f!=nullptr; f=f->link)
|
||||||
|
if( f->endLoc == loc )
|
||||||
|
return f;
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
rc_t _validate_preset_id( const frag_t* frag, unsigned preset_id )
|
rc_t _validate_preset_id( const frag_t* frag, unsigned preset_id )
|
||||||
{
|
{
|
||||||
bool fl = (preset_id < frag->presetN) && (frag->presetA[ preset_id ].preset_idx == preset_id);
|
bool fl = (preset_id < frag->presetN) && (frag->presetA[ preset_id ].preset_idx == preset_id);
|
||||||
|
|
||||||
return fl ? kOkRC : cwLogError(kInvalidId,"The preset id '%i' is invalid on the fragment at loc:%i.",preset_id,frag->endLoc);
|
return fl ? kOkRC : cwLogError(kInvalidIdRC,"The preset id '%i' is invalid on the fragment at loc:%i.",preset_id,frag->endLoc);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +162,7 @@ namespace cw
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
rc = cwLogError(kInvalidId,"There is no preset variable with var id:%i.",varId);
|
rc = cwLogError(kInvalidIdRC,"There is no preset variable with var id:%i.",varId);
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +218,7 @@ namespace cw
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
rc = cwLogError(kInvalidId,"There is no preset variable with var id:%i.",varId);
|
rc = cwLogError(kInvalidIdRC,"There is no preset variable with var id:%i.",varId);
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,6 +392,37 @@ cw::rc_t cw::preset_sel::delete_fragment( handle_t h, unsigned fragId )
|
|||||||
return kOkRC;
|
return kOkRC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cw::preset_sel::is_fragment_loc( handle_t h, unsigned loc )
|
||||||
|
{
|
||||||
|
preset_sel_t* p = _handleToPtr(h);
|
||||||
|
return _loc_to_frag(p,loc) != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned cw::preset_sel::ui_select_fragment_id( handle_t h )
|
||||||
|
{
|
||||||
|
preset_sel_t* p = _handleToPtr(h);
|
||||||
|
for(frag_t* f = p->fragL; f!= nullptr; f=f->link)
|
||||||
|
if( f->uiSelectFl )
|
||||||
|
return f->fragId;
|
||||||
|
|
||||||
|
return kInvalidId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void cw::preset_sel::ui_select_fragment( handle_t h, unsigned fragId, bool selectFl )
|
||||||
|
{
|
||||||
|
preset_sel_t* p = _handleToPtr(h);
|
||||||
|
frag_t* f = p->fragL;
|
||||||
|
|
||||||
|
for(; f!= nullptr; f=f->link)
|
||||||
|
if( f->fragId == fragId )
|
||||||
|
f->uiSelectFl = selectFl;
|
||||||
|
else
|
||||||
|
f->uiSelectFl = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
cw::rc_t cw::preset_sel::set_value( handle_t h, unsigned fragId, unsigned varId, unsigned presetId, bool value )
|
cw::rc_t cw::preset_sel::set_value( handle_t h, unsigned fragId, unsigned varId, unsigned presetId, bool value )
|
||||||
{ return _set_value(h,fragId,varId,presetId,value); }
|
{ return _set_value(h,fragId,varId,presetId,value); }
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@ namespace cw
|
|||||||
preset_t* presetA;
|
preset_t* presetA;
|
||||||
unsigned presetN;
|
unsigned presetN;
|
||||||
|
|
||||||
|
bool uiSelectFl;
|
||||||
|
|
||||||
struct frag_str* link;
|
struct frag_str* link;
|
||||||
} frag_t;
|
} frag_t;
|
||||||
|
|
||||||
@ -55,9 +57,16 @@ namespace cw
|
|||||||
const frag_t* get_fragment( handle_t h, unsigned fragId );
|
const frag_t* get_fragment( handle_t h, unsigned fragId );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
rc_t create_fragment( handle_t h, unsigned fragId, unsigned end_loc );
|
rc_t create_fragment( handle_t h, unsigned fragId, unsigned end_loc );
|
||||||
rc_t delete_fragment( handle_t h, unsigned fragId );
|
rc_t delete_fragment( handle_t h, unsigned fragId );
|
||||||
|
|
||||||
|
bool is_fragment_loc( handle_t h, unsigned loc );
|
||||||
|
|
||||||
|
unsigned ui_select_fragment_id( handle_t h );
|
||||||
|
void ui_select_fragment( handle_t h, unsigned fragId, bool selectFl );
|
||||||
|
|
||||||
|
|
||||||
rc_t set_value( handle_t h, unsigned fragId, unsigned varId, unsigned presetId, bool value );
|
rc_t set_value( handle_t h, unsigned fragId, unsigned varId, unsigned presetId, bool value );
|
||||||
rc_t set_value( handle_t h, unsigned fragId, unsigned varId, unsigned presetId, unsigned value );
|
rc_t set_value( handle_t h, unsigned fragId, unsigned varId, unsigned presetId, unsigned value );
|
||||||
rc_t set_value( handle_t h, unsigned fragId, unsigned varId, unsigned presetId, double value );
|
rc_t set_value( handle_t h, unsigned fragId, unsigned varId, unsigned presetId, double value );
|
||||||
|
Loading…
Reference in New Issue
Block a user