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("")); veTimeshiftTimes->Set(cString(""), cString(""), cString(""));
if (veEndTime) if (veEndTime)
veEndTime->Set(cString("")); veEndTime->Set(cString(""));
if (veCutMarks)
veCutMarks->Reset();
timersLoaded = false; timersLoaded = false;
globalTimers.ClearTimers(); globalTimers.ClearTimers();
} }

View File

@ -375,6 +375,7 @@ bool cVeDrProgressBar::Parse(bool force) {
tokenContainer->AddIntToken((int)eDRProgressbarIT::timeshifttotal, timeshiftTotal); tokenContainer->AddIntToken((int)eDRProgressbarIT::timeshifttotal, timeshiftTotal);
SetDirty(); SetDirty();
changed = false;
return true; return true;
} }
@ -383,13 +384,16 @@ bool cVeDrProgressBar::Parse(bool force) {
******************************************************************/ ******************************************************************/
cVeDrCutMarks::cVeDrCutMarks(void) { cVeDrCutMarks::cVeDrCutMarks(void) {
cutmarksIndex = -1; cutmarksIndex = -1;
lastMarks = NULL; changed = true;
marks = NULL;
current = -1;
total = -1;
numMarksLast = 0;
timeShiftActive = NoRec; timeShiftActive = NoRec;
Reset(); timeshiftTotal = -1;
} }
cVeDrCutMarks::~cVeDrCutMarks(void) { cVeDrCutMarks::~cVeDrCutMarks(void) {
delete[] lastMarks;
} }
void cVeDrCutMarks::SetTokenContainer(void) { 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) { 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; this->marks = marks;
numMarksLast = numMarks;
this->current = current; this->current = current;
this->total = total; this->total = total;
this->timeShiftActive = timeShiftActive; this->timeShiftActive = timeShiftActive;
this->timeshiftTotal = timeshiftTotal; this->timeshiftTotal = timeshiftTotal;
}
void cVeDrCutMarks::Reset(void) { changed = true;
marks = NULL;
current = -1;
total = -1;
numMarksLast = 0;
delete[] lastMarks;
lastMarks = NULL;
markActive = -1;
timeShiftActive = NoRec;
timeshiftTotal = -1;
} }
bool cVeDrCutMarks::Parse(bool force) { bool cVeDrCutMarks::Parse(bool force) {
if (!cViewElement::Parse(force)) if (!cViewElement::Parse(force) || !changed)
return false; return false;
if (!marks || !MarksChanged()) {
return false;
}
tokenContainer->Clear(); tokenContainer->Clear();
tokenContainer->AddIntToken((int)eDRCutmarksIT::timeshift, timeShiftActive); tokenContainer->AddIntToken((int)eDRCutmarksIT::timeshift, timeShiftActive);
int numMarks = marks->Count(); int numMarks = marks->Count();
@ -459,61 +454,10 @@ bool cVeDrCutMarks::Parse(bool force) {
isStartMark = !isStartMark; isStartMark = !isStartMark;
} }
SetDirty(); SetDirty();
changed = false;
return true; 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 * cVeDrControlIcons
******************************************************************/ ******************************************************************/

View File

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