mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-05 15:30:00 +01:00
Improved Timeline Flags API
This commit is contained in:
@@ -957,7 +957,7 @@ float *Timeline::flagsArray()
|
||||
return flagsArray_;
|
||||
}
|
||||
|
||||
bool Timeline::addFlag(GstClockTime t, int type)
|
||||
bool Timeline::addFlagAt(GstClockTime t, int type)
|
||||
{
|
||||
if (t > timing_.begin + (step_ * 2)
|
||||
&& t < timing_.end - (step_ * 2)
|
||||
@@ -979,16 +979,27 @@ bool Timeline::addFlag(GstClockTime t, int type)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Timeline::addFlag(TimeInterval s, int type)
|
||||
bool Timeline::addFlag(TimeInterval f)
|
||||
{
|
||||
if ( s.is_valid() ) {
|
||||
s.type = type;
|
||||
if ( f.is_valid() ) {
|
||||
flags_array_need_update_ = true;
|
||||
return flags_.insert(s).second;
|
||||
return flags_.insert(f).second;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Timeline::replaceFlag(TimeInterval f)
|
||||
{
|
||||
if ( f.is_valid() ) {
|
||||
|
||||
if (!removeFlagAt(f.midpoint()))
|
||||
return false;
|
||||
|
||||
flags_array_need_update_ = true;
|
||||
return flags_.insert(f).second;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Timeline::removeFlagAt(GstClockTime t)
|
||||
{
|
||||
@@ -1033,6 +1044,19 @@ void Timeline::setFlagTypeAt(GstClockTime t, int type)
|
||||
}
|
||||
}
|
||||
|
||||
TimeInterval Timeline::getFlagAt(GstClockTime t) const
|
||||
{
|
||||
TimeInterval ret;
|
||||
|
||||
TimeIntervalSet::iterator f = std::find_if(flags_.begin(), flags_.end(), includesTime(t));
|
||||
|
||||
if ( f != flags_.end() ) {
|
||||
ret = *f;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
TimeInterval Timeline::getNextFlag(GstClockTime t) const
|
||||
{
|
||||
if ( !flags_.empty() ) {
|
||||
@@ -1054,6 +1078,27 @@ TimeInterval Timeline::getNextFlag(GstClockTime t) const
|
||||
return TimeInterval();
|
||||
}
|
||||
|
||||
TimeInterval Timeline::getPreviousFlag(GstClockTime t) const
|
||||
{
|
||||
if ( !flags_.empty() ) {
|
||||
// loop over flags
|
||||
auto f = flags_.rbegin();
|
||||
for (; f != flags_.rend(); ++f) {
|
||||
// gap before target?
|
||||
if ( f->end < t )
|
||||
// done
|
||||
break;
|
||||
}
|
||||
|
||||
if ( f != flags_.rend() )
|
||||
return (*f);
|
||||
else
|
||||
return *(flags_.rbegin());
|
||||
}
|
||||
|
||||
return TimeInterval();
|
||||
}
|
||||
|
||||
void Timeline::clearFlags()
|
||||
{
|
||||
flags_.clear();
|
||||
|
||||
@@ -69,6 +69,7 @@ struct TimeInterval
|
||||
if (this != &b) {
|
||||
this->begin = b.begin;
|
||||
this->end = b.end;
|
||||
this->type = b.type;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -150,13 +151,16 @@ public:
|
||||
inline TimeIntervalSet flags() const { return flags_; };
|
||||
inline size_t numFlags() const { return flags_.size(); };
|
||||
float *flagsArray();
|
||||
bool addFlag(GstClockTime t, int type = 0);
|
||||
bool addFlag(TimeInterval s, int type = 0);
|
||||
bool addFlag(TimeInterval f);
|
||||
bool replaceFlag(TimeInterval f);
|
||||
bool addFlagAt(GstClockTime t, int type = 0);
|
||||
bool removeFlagAt(GstClockTime t);
|
||||
bool isFlagged(GstClockTime t) const;
|
||||
int flagTypeAt(GstClockTime t) const;
|
||||
void setFlagTypeAt(GstClockTime t, int type);
|
||||
TimeInterval getFlagAt(GstClockTime t) const;
|
||||
TimeInterval getNextFlag(GstClockTime t) const;
|
||||
TimeInterval getPreviousFlag(GstClockTime t) const;
|
||||
void clearFlags();
|
||||
|
||||
// inverse of gaps: sections of play areas
|
||||
|
||||
Reference in New Issue
Block a user