diff --git a/mrv2/docs/HISTORY.md b/mrv2/docs/HISTORY.md index 57d139091..e1aa6a176 100644 --- a/mrv2/docs/HISTORY.md +++ b/mrv2/docs/HISTORY.md @@ -16,6 +16,8 @@ v0.8.0 ones. - Added a cmd.getVersion() to get the version of mrv2 from Python. - Made playback play with audio when changing frame rate (slower or faster). +- Made audio play when stepping through frames. It is currently a hack and not + a proper fix yet. Also, the stepping buttons are not updated properly. - Fixed a locale change when using the FPS pull-down and there were thumbnails present. - Fixed macOS menu bar font size when switching from macOS menus back to normal @@ -32,7 +34,8 @@ v0.8.0 Python to set the input color space of the image. - Added image.ocioView(), image.setOcioView() and image.ocioViewList() to Python to set the Display/View color space and to retrieve a list of all - Display/Views. + Display/Views. +- Sped up and removed some bugs in reverse playback. v0.7.9 diff --git a/mrv2/lib/mrvFl/mrvTimelinePlayer.cpp b/mrv2/lib/mrvFl/mrvTimelinePlayer.cpp index e752ca521..354a727b9 100644 --- a/mrv2/lib/mrvFl/mrvTimelinePlayer.cpp +++ b/mrv2/lib/mrvFl/mrvTimelinePlayer.cpp @@ -396,22 +396,66 @@ namespace mrv timelineViewport->updateUndoRedoButtons(); } - void TimelinePlayer::framePrev() + struct StopData { - pushMessage("framePrev", 0); - _p->timelinePlayer->framePrev(); + TimelinePlayer* player; + double speed; + otio::RationalTime time; + }; + + void stop_playback_cb(StopData* data) + { + auto player = data->player; + player->player()->setPlayback(timeline::Playback::Stop); + player->seek(data->time); + player->setSpeed(data->speed); + player->updateUndoRedoButtons(); redrawPanelThumbnails(); + delete data; + } + + void TimelinePlayer::updateUndoRedoButtons() const + { if (timelineViewport) + { timelineViewport->updateUndoRedoButtons(); + timelineViewport->updatePlaybackButtons(); + } + } + + void TimelinePlayer::framePrev() + { + pushMessage("framePrev", 0); + //_p->timelinePlayer->framePrev(); + auto time = currentTime() - + otime::RationalTime(1.0, timeRange().duration().rate()); + _p->timelinePlayer->setPlayback(timeline::Playback::Reverse); + StopData* data = new StopData; + data->player = this; + data->time = time; + data->speed = speed(); + + Fl::add_timeout( + 1.75 / speed(), (Fl_Timeout_Handler)stop_playback_cb, data); } void TimelinePlayer::frameNext() { pushMessage("frameNext", 0); - _p->timelinePlayer->frameNext(); - redrawPanelThumbnails(); - if (timelineViewport) - timelineViewport->updateUndoRedoButtons(); + //_p->timelinePlayer->frameNext(); + + auto time = currentTime() + + otime::RationalTime(1.0, timeRange().duration().rate()); + _p->timelinePlayer->setPlayback(timeline::Playback::Forward); + StopData* data = new StopData; + data->player = this; + data->time = time; + data->speed = speed(); + Fl::add_timeout( + 1.75 / speed(), (Fl_Timeout_Handler)stop_playback_cb, data); + + // if (timelineViewport) + // timelineViewport->updateUndoRedoButtons(); } void TimelinePlayer::setInOutRange(const otime::TimeRange& value) diff --git a/mrv2/lib/mrvFl/mrvTimelinePlayer.h b/mrv2/lib/mrvFl/mrvTimelinePlayer.h index 60afee75d..dd582f661 100644 --- a/mrv2/lib/mrvFl/mrvTimelinePlayer.h +++ b/mrv2/lib/mrvFl/mrvTimelinePlayer.h @@ -364,6 +364,9 @@ namespace mrv //! Returns whtehr annotation at current time can be redone. bool hasRedo() const; + //! Update Undo/Redo draw buttons after a frame change. + void updateUndoRedoButtons() const; + protected: template < typename T > void pushMessage(const std::string& command, const T& value); diff --git a/mrv2/lib/mrvGL/mrvTimelineViewport.cpp b/mrv2/lib/mrvGL/mrvTimelineViewport.cpp index 1af910ad0..2c58eb6f5 100644 --- a/mrv2/lib/mrvGL/mrvTimelineViewport.cpp +++ b/mrv2/lib/mrvGL/mrvTimelineViewport.cpp @@ -299,7 +299,7 @@ namespace mrv } } - void TimelineViewport::_updatePlaybackButtons() const noexcept + void TimelineViewport::updatePlaybackButtons() const noexcept { TLRENDER_P(); if (p.timelinePlayers.empty()) @@ -337,7 +337,7 @@ namespace mrv { i->start(); } - _updatePlaybackButtons(); + updatePlaybackButtons(); p.skippedFrames = 0; } @@ -348,7 +348,7 @@ namespace mrv { i->framePrev(); } - _updatePlaybackButtons(); + updatePlaybackButtons(); p.skippedFrames = 0; } @@ -359,7 +359,7 @@ namespace mrv { i->frameNext(); } - _updatePlaybackButtons(); + updatePlaybackButtons(); } void TimelineViewport::endFrame() noexcept @@ -379,7 +379,7 @@ namespace mrv { i->setPlayback(timeline::Playback::Reverse); } - _updatePlaybackButtons(); + updatePlaybackButtons(); p.ui->uiMain->fill_menu(p.ui->uiMenuBar); } @@ -391,7 +391,7 @@ namespace mrv { i->setPlayback(timeline::Playback::Stop); } - _updatePlaybackButtons(); + updatePlaybackButtons(); p.ui->uiMain->fill_menu(p.ui->uiMenuBar); } @@ -403,7 +403,7 @@ namespace mrv { i->setPlayback(timeline::Playback::Forward); } - _updatePlaybackButtons(); + updatePlaybackButtons(); p.ui->uiMain->fill_menu(p.ui->uiMenuBar); } @@ -415,7 +415,7 @@ namespace mrv { i->togglePlayback(); } - _updatePlaybackButtons(); + updatePlaybackButtons(); p.ui->uiMain->fill_menu(p.ui->uiMenuBar); } diff --git a/mrv2/lib/mrvGL/mrvTimelineViewport.h b/mrv2/lib/mrvGL/mrvTimelineViewport.h index 33514d955..0e80e19fc 100644 --- a/mrv2/lib/mrvGL/mrvTimelineViewport.h +++ b/mrv2/lib/mrvGL/mrvTimelineViewport.h @@ -338,6 +338,9 @@ namespace mrv void editText( const std::shared_ptr< draw::Shape >&, const int index) noexcept; + //! Update the playback buttons. + void updatePlaybackButtons() const noexcept; + protected: virtual void _readPixel(image::Color4f& rgba) const noexcept = 0; math::Vector2i _getViewportCenter() const noexcept; @@ -413,8 +416,6 @@ namespace mrv bool _hasSecondaryViewport() const noexcept; - void _updatePlaybackButtons() const noexcept; - TLRENDER_PRIVATE(); }; } // namespace mrv diff --git a/mrv2/lib/mrvWidgets/mrViewer.fl b/mrv2/lib/mrvWidgets/mrViewer.fl index 4f82897dd..ffa4409dd 100644 --- a/mrv2/lib/mrvWidgets/mrViewer.fl +++ b/mrv2/lib/mrvWidgets/mrViewer.fl @@ -410,7 +410,7 @@ where Yn is the white reference (usually 1).} xywh {5 5 100 20} } } -widget_class TimelineClass { +widget_class TimelineClass {open xywh {130 292 690 29} resizable class Fl_Double_Window visible } { @@ -567,7 +567,7 @@ player->setLoop( loop );} callback {int idx = o->value(); double speed = atof( o->text( idx ) ); uiFPS->value( speed ); -uiFPS->do_callback();} +uiFPS->do_callback();} selected tooltip {Some default frame rate settings.} xywh {341 1 40 24} labelsize 10 align 16 code0 {o->disable_label();} class {mrv::PopupMenu} @@ -645,6 +645,8 @@ player->setSpeed( speed );} code0 {o->textcolor( FL_BLACK ); o->value(24);} code1 {o->step(0.001);} + code2 {o->minimum(1);} + code3 {o->maximum(60.0);} class Fl_Value_Input } } @@ -859,7 +861,7 @@ if (!player) return; player->setVideoLayer( o->value() ); auto model = v->app->filesModel(); auto item = model->observeA()->get(); -model->setLayer(item, o->value());} open selected +model->setLayer(item, o->value());} open tooltip {Allows you to select different image channels or layers.} xywh {3 26 122 25} box ROUNDED_BOX labelsize 12 class {mrv::PopupMenu} } {} diff --git a/tlRender b/tlRender index 8af1bc7bd..ebad73ca6 160000 --- a/tlRender +++ b/tlRender @@ -1 +1 @@ -Subproject commit 8af1bc7bd05cf2533af2c01484bbfdc234346009 +Subproject commit ebad73ca6dd7a5801e208700fa3d4bf85e13e600