Fix cutting marks wasn't updated

This commit is contained in:
kamel5 2021-03-15 14:10:18 +01:00
parent 85df1e7f98
commit cef6ca78a2
3 changed files with 15 additions and 77 deletions

View File

@ -165,8 +165,6 @@ void cViewReplay::ClearVariables(void) {
veTimeshiftTimes->Set(cString(""), cString(""), cString(""));
if (veEndTime)
veEndTime->Set(cString(""));
if (veCutMarks)
veCutMarks->Reset();
timersLoaded = false;
globalTimers.ClearTimers();
}

View File

@ -375,6 +375,7 @@ bool cVeDrProgressBar::Parse(bool force) {
tokenContainer->AddIntToken((int)eDRProgressbarIT::timeshifttotal, timeshiftTotal);
SetDirty();
changed = false;
return true;
}
@ -383,13 +384,16 @@ bool cVeDrProgressBar::Parse(bool force) {
******************************************************************/
cVeDrCutMarks::cVeDrCutMarks(void) {
cutmarksIndex = -1;
lastMarks = NULL;
changed = true;
marks = NULL;
current = -1;
total = -1;
numMarksLast = 0;
timeShiftActive = NoRec;
Reset();
timeshiftTotal = -1;
}
cVeDrCutMarks::~cVeDrCutMarks(void) {
delete[] lastMarks;
}
void cVeDrCutMarks::SetTokenContainer(void) {
@ -406,31 +410,22 @@ void cVeDrCutMarks::SetTokenContainer(void) {
}
void cVeDrCutMarks::Set(const cMarks *marks, int current, int total, eRecType_t timeShiftActive, int timeshiftTotal) {
int numMarks = marks->Count();
if (!(this->current != current || this->total != total || this->marks != marks || numMarksLast != numMarks))
return;
this->marks = marks;
numMarksLast = numMarks;
this->current = current;
this->total = total;
this->timeShiftActive = timeShiftActive;
this->timeshiftTotal = timeshiftTotal;
}
void cVeDrCutMarks::Reset(void) {
marks = NULL;
current = -1;
total = -1;
numMarksLast = 0;
delete[] lastMarks;
lastMarks = NULL;
markActive = -1;
timeShiftActive = NoRec;
timeshiftTotal = -1;
changed = true;
}
bool cVeDrCutMarks::Parse(bool force) {
if (!cViewElement::Parse(force))
if (!cViewElement::Parse(force) || !changed)
return false;
if (!marks || !MarksChanged()) {
return false;
}
tokenContainer->Clear();
tokenContainer->AddIntToken((int)eDRCutmarksIT::timeshift, timeShiftActive);
int numMarks = marks->Count();
@ -459,61 +454,10 @@ bool cVeDrCutMarks::Parse(bool force) {
isStartMark = !isStartMark;
}
SetDirty();
changed = false;
return true;
}
bool cVeDrCutMarks::MarksChanged(void) {
bool redraw = false;
//if mark was active, we redraw always
if (markActive >= 0) {
markActive = -1;
redraw = true;
}
//check if current position in recording hits mark exactly
for (const cMark *m = marks->First(); m; m = marks->Next(m)) {
if (m->Position() == current) {
markActive = current;
redraw = true;
break;
}
}
if (redraw)
return true;
//if number of marks has changed, redraw
int numMarks = marks->Count();
if (numMarks != numMarksLast) {
RememberMarks();
return true;
}
if (!lastMarks)
return false;
//if position has changed, redraw
int i=0;
for (const cMark *m = marks->First(); m; m = marks->Next(m)) {
if (m->Position() != lastMarks[i]) {
RememberMarks();
return true;
}
i++;
}
return false;
}
void cVeDrCutMarks::RememberMarks(void) {
if (!marks)
return;
numMarksLast = marks->Count();
if (numMarksLast < 1)
return;
delete[] lastMarks;
lastMarks = new int[numMarksLast];
int i=0;
for (const cMark *m = marks->First(); m; m = marks->Next(m)) {
lastMarks[i] = m->Position();
i++;
}
}
/******************************************************************
* cVeDrControlIcons
******************************************************************/

View File

@ -140,16 +140,12 @@ private:
eRecType_t timeShiftActive;
int timeshiftTotal;
int numMarksLast;
int *lastMarks;
int markActive;
bool MarksChanged(void);
void RememberMarks(void);
bool changed;
public:
cVeDrCutMarks(void);
virtual ~cVeDrCutMarks(void);
void SetTokenContainer(void);
void Set(const cMarks *marks, int current, int total, eRecType_t timeShiftActive = NoRec, int timeshiftTotal = 0);
void Reset(void);
bool Parse(bool forced = false);
};