cwPresetSel.h/cpp: Changed name of is_fragment_loc() to is_fragment_end_loc().

Fixed delete_fragment() to update 'end_loc' of previous frag. to 'end_loc' of deleted frag.
This commit is contained in:
kevin 2022-12-12 12:26:26 -05:00
parent c13a03abe5
commit fc379df197
2 changed files with 10 additions and 3 deletions

View File

@ -647,6 +647,7 @@ cw::rc_t cw::preset_sel::create_fragment( handle_t h, unsigned end_loc, time::sp
fragIdRef = f->fragId; fragIdRef = f->fragId;
// intiialize the preset array elements
for(unsigned i=0; i<p->presetLabelN; ++i) for(unsigned i=0; i<p->presetLabelN; ++i)
{ {
f->presetA[i].preset_idx = i; f->presetA[i].preset_idx = i;
@ -719,7 +720,12 @@ cw::rc_t cw::preset_sel::delete_fragment( handle_t h, unsigned fragId )
if( f->prev == nullptr ) if( f->prev == nullptr )
p->fragL = f->link; p->fragL = f->link;
else else
{
// the previous fragment's end-loc become the
// endloc of the deleted fragment
f->prev->endLoc = f->endLoc;
f->prev->link = f->link; f->prev->link = f->link;
}
if( f->link != nullptr ) if( f->link != nullptr )
f->link->prev = f->prev; f->link->prev = f->prev;
@ -734,13 +740,14 @@ cw::rc_t cw::preset_sel::delete_fragment( handle_t h, unsigned fragId )
return cwLogError(kInvalidArgRC,"The fragment '%i' could not be found to delete.",fragId); return cwLogError(kInvalidArgRC,"The fragment '%i' could not be found to delete.",fragId);
} }
bool cw::preset_sel::is_fragment_loc( handle_t h, unsigned loc ) bool cw::preset_sel::is_fragment_end_loc( handle_t h, unsigned loc )
{ {
preset_sel_t* p = _handleToPtr(h); preset_sel_t* p = _handleToPtr(h);
return _loc_to_frag(p,loc) != nullptr; return _loc_to_frag(p,loc) != nullptr;
} }
unsigned cw::preset_sel::ui_select_fragment_id( handle_t h ) unsigned cw::preset_sel::ui_select_fragment_id( handle_t h )
{ {
preset_sel_t* p = _handleToPtr(h); preset_sel_t* p = _handleToPtr(h);

View File

@ -88,7 +88,7 @@ namespace cw
rc_t create_fragment( handle_t h, unsigned end_loc, time::spec_t endTimestamp, unsigned& fragIdRef ); rc_t create_fragment( handle_t h, unsigned end_loc, time::spec_t endTimestamp, unsigned& fragIdRef );
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 ); bool is_fragment_end_loc( handle_t h, unsigned loc );
// Return the fragment id of the 'selected' fragment. // Return the fragment id of the 'selected' fragment.
unsigned ui_select_fragment_id( handle_t h ); unsigned ui_select_fragment_id( handle_t h );