move loop when deleting in sample editor

This commit is contained in:
tildearrow 2023-05-24 03:33:51 -05:00
parent c7b24f706f
commit 3b688774fe
2 changed files with 29 additions and 2 deletions

View File

@ -584,7 +584,34 @@ bool DivSample::strip(unsigned int begin, unsigned int end) {
if (begin>samples) begin=samples;
if (end>samples) end=samples;
int count=samples-(end-begin);
if (count<=0) return resize(0);
if (count<=0) {
loopStart=-1;
loopEnd=-1;
loop=false;
return resize(0);
}
if (loopStart>(int)begin && loopEnd<(int)end) {
loopStart=-1;
loopEnd=-1;
loop=false;
} else {
if (loopStart<(int)end && loopStart>(int)begin) {
loopStart=end;
}
if (loopStart>(int)begin && loopEnd>(int)begin) {
loopStart-=end-begin;
loopEnd-=end-begin;
if (loopEnd<0) loopEnd=0;
if (loopStart<0) loopStart=0;
} else if (loopEnd>(int)begin) {
loopEnd=begin;
}
}
if (loopStart>loopEnd) {
loopStart=-1;
loopEnd=-1;
loop=false;
}
if (depth==DIV_SAMPLE_DEPTH_8BIT) {
if (data8!=NULL) {
signed char* oldData8=data8;

View File

@ -215,7 +215,7 @@ void FurnaceGUI::drawSampleEdit() {
}
popToggleColors();
ImGui::TableNextColumn();
bool doLoop=(sample->isLoopable());
bool doLoop=(sample->loop);
if (ImGui::Checkbox("Loop",&doLoop)) { MARK_MODIFIED
if (doLoop) {
sample->loop=true;