diff --git a/aegisub/src/audio_controller.cpp b/aegisub/src/audio_controller.cpp index 515eebce2..92dae866d 100644 --- a/aegisub/src/audio_controller.cpp +++ b/aegisub/src/audio_controller.cpp @@ -106,7 +106,7 @@ private: public: AudioMarkerProviderKeyframes(AudioController *controller) : vc(VideoContext::Get()) - , keyframe_slot(vc->AddKeyframesOpenListener(&AudioMarkerProviderKeyframes::OnKeyframesOpen, this)) + , keyframe_slot(vc->AddKeyframesListener(&AudioMarkerProviderKeyframes::OnKeyframesOpen, this)) , audio_open_slot(controller->AddAudioOpenListener(&AudioMarkerProviderKeyframes::OnAudioOpen, this)) , controller(controller) { diff --git a/aegisub/src/frame_main.cpp b/aegisub/src/frame_main.cpp index 7bab5e90c..71e2029b3 100644 --- a/aegisub/src/frame_main.cpp +++ b/aegisub/src/frame_main.cpp @@ -1135,7 +1135,6 @@ void FrameMain::LoadVideo(wxString file,bool autoload) { } SetDisplayMode(1,-1); - EditBox->UpdateFrameTiming(); DetachVideo(VideoContext::Get()->IsLoaded() && OPT_GET("Video/Detached/Enabled")->GetBool()); Thaw(); @@ -1148,7 +1147,6 @@ void FrameMain::LoadVFR(wxString filename) { else { VideoContext::Get()->LoadTimecodes(filename); } - EditBox->UpdateFrameTiming(); } /// @brief Open help diff --git a/aegisub/src/subs_edit_box.cpp b/aegisub/src/subs_edit_box.cpp index 1b896563f..c99d58628 100644 --- a/aegisub/src/subs_edit_box.cpp +++ b/aegisub/src/subs_edit_box.cpp @@ -211,6 +211,7 @@ SubsEditBox::SubsEditBox(wxWindow *parent, SubtitlesGrid *grid) ByTime = new wxRadioButton(this,wxID_ANY,_("Time"),wxDefaultPosition,wxDefaultSize,wxRB_GROUP); ByFrame = new wxRadioButton(this,wxID_ANY,_("Frame")); + ByFrame->Enable(false); // Tooltips CommentBox->SetToolTip(_("Comment this line out. Commented lines don't show up on screen.")); @@ -330,6 +331,7 @@ SubsEditBox::SubsEditBox(wxWindow *parent, SubtitlesGrid *grid) grid->AddSelectionListener(this); grid->ass->AddCommitListener(&SubsEditBox::Update, this); + VideoContext::Get()->AddTimecodesListener(&SubsEditBox::UpdateFrameTiming, this); } SubsEditBox::~SubsEditBox() { grid->RemoveSelectionListener(this); @@ -408,8 +410,10 @@ void SubsEditBox::OnSelectedSetChanged(const Selection &, const Selection &) { sel = grid->GetSelectedSet(); } -void SubsEditBox::UpdateFrameTiming () { - if (VideoContext::Get()->TimecodesLoaded()) ByFrame->Enable(true); +void SubsEditBox::UpdateFrameTiming(agi::vfr::Framerate const& fps) { + if (fps.IsLoaded()) { + ByFrame->Enable(true); + } else { ByFrame->Enable(false); ByTime->SetValue(true); @@ -566,8 +570,6 @@ void SubsEditBox::SetControlsState(bool state) { for (size_t i = 0; i < ToggableButtons.size(); ++i) ToggableButtons[i]->Enable(state); - UpdateFrameTiming(); - if (!state) { SetEvtHandlerEnabled(false); TextEdit->SetTextTo(""); diff --git a/aegisub/src/subs_edit_box.h b/aegisub/src/subs_edit_box.h index a4729fa5e..5b5f69076 100644 --- a/aegisub/src/subs_edit_box.h +++ b/aegisub/src/subs_edit_box.h @@ -57,6 +57,8 @@ class wxStyledTextEvent; class wxTextCtrl; class AudioController; +namespace agi { namespace vfr { class Framerate; } } + /// DOCME /// @class SubsEditBox /// @brief Main subtitle edit box @@ -186,6 +188,9 @@ class SubsEditBox : public wxPanel, protected SelectionListener { /// @brief Reload the current line from the file /// @param type AssFile::CommitType void Update(int type); + + /// @brief Enable or disable frame timing mode + void UpdateFrameTiming(agi::vfr::Framerate const& fps); public: SubsTextEditCtrl *TextEdit; @@ -194,7 +199,4 @@ public: /// @param grid Associated grid SubsEditBox(wxWindow *parent, SubtitlesGrid *grid); ~SubsEditBox(); - - /// @brief Enable or disable frame timing mode - void UpdateFrameTiming(); }; diff --git a/aegisub/src/video_context.cpp b/aegisub/src/video_context.cpp index ee4a9536d..d2f53c55d 100644 --- a/aegisub/src/video_context.cpp +++ b/aegisub/src/video_context.cpp @@ -133,7 +133,10 @@ void VideoContext::Reset() { StandardPaths::SetPathValue(_T("?video"), ""); keyFrames.clear(); + keyFramesFilename.clear(); videoFPS = agi::vfr::Framerate(); + KeyframesOpen(keyFrames); + if (!ovrFPS.IsLoaded()) TimecodesOpen(videoFPS); // Remove video data frame_n = 0; @@ -196,6 +199,7 @@ void VideoContext::SetVideo(const wxString &filename) { grid->ass->AddCommitListener(&VideoContext::SubtitlesChanged, this); VideoOpen(); KeyframesOpen(keyFrames); + TimecodesOpen(FPS()); } catch (agi::UserCancelException const&) { } catch (agi::FileNotAccessibleError const& err) { @@ -462,6 +466,7 @@ void VideoContext::LoadKeyframes(wxString filename) { ovrFPS = agi::vfr::Framerate(kf.second); ovrTimecodeFile.clear(); SubtitlesChanged(); + TimecodesOpen(ovrFPS); } config::mru->Add("Keyframes", STD_STR(filename)); } @@ -498,6 +503,7 @@ void VideoContext::LoadTimecodes(wxString filename) { ovrTimecodeFile = filename; config::mru->Add("Timecodes", STD_STR(filename)); SubtitlesChanged(); + TimecodesOpen(ovrFPS); } catch (const agi::acs::AcsError&) { wxLogError(L"Could not open file " + filename); @@ -520,6 +526,7 @@ void VideoContext::CloseTimecodes() { ovrFPS = agi::vfr::Framerate(); ovrTimecodeFile.clear(); SubtitlesChanged(); + TimecodesOpen(videoFPS); } int VideoContext::TimeAtFrame(int frame, agi::vfr::Time type) const { diff --git a/aegisub/src/video_context.h b/aegisub/src/video_context.h index 6fbc896fd..7da07d7b4 100644 --- a/aegisub/src/video_context.h +++ b/aegisub/src/video_context.h @@ -81,6 +81,8 @@ class VideoContext : public wxEvtHandler { agi::signal::Signal<> VideoOpen; /// New keyframes opened (new keyframe data) agi::signal::Signal const&> KeyframesOpen; + /// New timecodes opened (new timecode data) + agi::signal::Signal TimecodesOpen; /// Aspect ratio was changed (type, value) agi::signal::Signal ARChange; @@ -254,7 +256,8 @@ public: DEFINE_SIGNAL_ADDERS(Seek, AddSeekListener) DEFINE_SIGNAL_ADDERS(VideoOpen, AddVideoOpenListener) - DEFINE_SIGNAL_ADDERS(KeyframesOpen, AddKeyframesOpenListener) + DEFINE_SIGNAL_ADDERS(KeyframesOpen, AddKeyframesListener) + DEFINE_SIGNAL_ADDERS(TimecodesOpen, AddTimecodesListener) DEFINE_SIGNAL_ADDERS(ARChange, AddARChangeListener) const std::vector& GetKeyFrames() const { return keyFrames; }; diff --git a/aegisub/src/video_slider.cpp b/aegisub/src/video_slider.cpp index 7c473ec46..379bc5e49 100644 --- a/aegisub/src/video_slider.cpp +++ b/aegisub/src/video_slider.cpp @@ -74,7 +74,7 @@ VideoSlider::VideoSlider (wxWindow* parent, wxWindowID id) assert(vc); vc->AddSeekListener(&VideoSlider::SetValue, this); vc->AddVideoOpenListener(&VideoSlider::VideoOpened, this); - vc->AddKeyframesOpenListener(&VideoSlider::KeyframesChanged, this); + vc->AddKeyframesListener(&VideoSlider::KeyframesChanged, this); } VideoSlider::~VideoSlider() {