void CSobeyView::ComputerTimeLineLength(MaterialVector& timeLine) { m_timeLineLength = 0; if (timeLine.empty()) return; for (MaterialVector::iterator it = timeLine.begin(); it != timeLine.end(); ++it) { m_timeLineLength += abs(it->endTime - it->beginTime); } }
void CSobeyView::ComputerTimeLineRect(MaterialVector& timeLine) { ComputerTimeLineLength(timeLine); m_timeLineRect.clear(); if (timeLine.empty()) return; int top = 10; int left = 10; int width = 0; int height = 50; CRect windowRect; GetWindowRect(&windowRect); // 计算出窗体的大小作为比率 int base = windowRect.right - windowRect.left - 20; for (MaterialVector::iterator it = timeLine.begin(); it != timeLine.end(); ++it) { left += width + 1; // 素材的宽度等于素材时间长度和时间线总长的比值乘以窗体大小 width = abs(it->endTime - it->beginTime) * base / m_timeLineLength; m_timeLineRect.push_back(CRect(left, top, left + width, top + height)); } }