implemented base for thumbnail display

This commit is contained in:
itsmattkc
2022-05-25 11:18:08 -07:00
parent 44b9888efb
commit 60f7f06de4
21 changed files with 503 additions and 328 deletions
@@ -1093,6 +1093,11 @@ void TimelineWidget::ShowContextMenu()
toggle_audio_units->setChecked(use_audio_time_units_);
connect(toggle_audio_units, &QAction::triggered, this, &TimelineWidget::SetUseAudioTimeUnits);
QAction* show_thumbnails = menu.addAction(tr("Show Thumbnails"));
show_thumbnails->setCheckable(true);
show_thumbnails->setChecked(views_.first()->view()->GetShowThumbnails());
connect(show_thumbnails, &QAction::triggered, this, &TimelineWidget::SetViewThumbnailsEnabled);
QAction* show_waveforms = menu.addAction(tr("Show Waveforms"));
show_waveforms->setCheckable(true);
show_waveforms->setChecked(views_.first()->view()->GetShowWaveforms());
@@ -1167,6 +1172,13 @@ void TimelineWidget::SetViewWaveformsEnabled(bool e)
}
}
void TimelineWidget::SetViewThumbnailsEnabled(bool e)
{
foreach (TimelineAndTrackView* tview, views_) {
tview->view()->SetShowThumbnails(e);
}
}
void TimelineWidget::FrameRateChanged()
{
SetTimebase(GetConnectedNode()->GetVideoParams().frame_rate_as_time_base());
@@ -415,6 +415,8 @@ private slots:
void SetViewWaveformsEnabled(bool e);
void SetViewThumbnailsEnabled(bool e);
void FrameRateChanged();
void SampleRateChanged();
+19 -10
View File
@@ -524,18 +524,27 @@ void TimelineView::DrawBlock(QPainter *painter, bool foreground, Block *block, q
// Draw clip thumbnails
if (clip->GetTrackType() == Track::kVideo && show_thumbnails_ && preview_rect.height() > r.height()/3) {
const int kTempThumbWidth = 120;
const int kTempThumbHeight = 68;
if (const FrameHashCache *thumbs = clip->thumbnails()) {
QRect thumb_rect;
painter->setClipRect(preview_rect);
painter->setRenderHint(QPainter::SmoothPixmapTransform);
for (int i=preview_rect.left(); i<preview_rect.right(); i+=thumb_rect.width()+1) {
rational time_here = SceneToTime(i - block_in, GetScale(), connected_track_list_->parent()->GetAudioParams().sample_rate_as_time_base()) + media_in;
QString thumbnail = thumbs->GetValidCacheFilename(time_here);
QRect thumb_rect;
painter->setClipRect(preview_rect);
for (int i=preview_rect.left(); i<preview_rect.right(); i+=thumb_rect.width()+1) {
double scale = double(preview_rect.height())/double(kTempThumbHeight);
thumb_rect = QRect(i, preview_rect.top(), kTempThumbWidth * scale, preview_rect.height());
painter->fillRect(thumb_rect, Qt::red);
if (thumbnail.isEmpty()) {
break;
} else {
QImage img;
if (img.load(thumbnail, "jpg")) {
double scale = double(preview_rect.height())/double(img.height());
thumb_rect = QRect(i, preview_rect.top(), img.width() * scale, preview_rect.height());
painter->drawImage(thumb_rect, img);
}
}
}
painter->setClipping(false);
}
painter->setClipping(false);
}
// Draw waveform
@@ -84,6 +84,17 @@ public:
viewport()->update();
}
bool GetShowThumbnails() const
{
return show_thumbnails_;
}
void SetShowThumbnails(bool e)
{
show_thumbnails_ = e;
viewport()->update();
}
signals:
void MousePressed(TimelineViewMouseEvent* event);
void MouseMoved(TimelineViewMouseEvent* event);
+2 -6
View File
@@ -148,6 +148,7 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
setAcceptDrops(true);
auto_cacher_ = new PreviewAutoCacher(this);
connect(display_widget_, &ViewerDisplayWidget::ColorProcessorChanged, auto_cacher_, &PreviewAutoCacher::SetDisplayColorProcessor);
connect(Core::instance(), &Core::ColorPickerEnabled, this, &ViewerWidget::SetSignalCursorColorEnabled);
connect(this, &ViewerWidget::CursorColor, Core::instance(), &Core::ColorPickerColorEmitted);
@@ -686,11 +687,6 @@ void ViewerWidget::UpdateTextureFromNode()
connect(watcher, &RenderTicketWatcher::Finished, this, &ViewerWidget::RendererGeneratedFrame);
nonqueue_watchers_.append(watcher);
// Clear queue because we want this frame more than any others
if (!GetConnectedNode()->video_frame_cache()->IsAutomatic() && !auto_cacher_->IsRenderingCustomRange()) {
ClearVideoAutoCacherQueue();
}
watcher->SetTicket(GetFrame(time, RenderTicketPriority::kHigh));
} else {
// There is definitely no frame here, we can immediately flip to showing nothing
@@ -718,8 +714,8 @@ void ViewerWidget::PlayInternal(int speed, bool in_to_out_only)
foreach (ViewerWidget* viewer, instances_) {
if (viewer != this) {
viewer->PauseInternal();
viewer->auto_cacher_->SetRendersPaused(true);
}
viewer->auto_cacher_->SetRendersPaused(true);
}
// Disarm recording if armed