Add timecodes opened signal to VideoContext

Originally committed to SVN as r5080.
This commit is contained in:
Thomas Goyne 2010-12-31 21:03:18 +00:00
parent 824294078f
commit 17c07cc131
7 changed files with 24 additions and 12 deletions

View File

@ -106,7 +106,7 @@ private:
public: public:
AudioMarkerProviderKeyframes(AudioController *controller) AudioMarkerProviderKeyframes(AudioController *controller)
: vc(VideoContext::Get()) : 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)) , audio_open_slot(controller->AddAudioOpenListener(&AudioMarkerProviderKeyframes::OnAudioOpen, this))
, controller(controller) , controller(controller)
{ {

View File

@ -1135,7 +1135,6 @@ void FrameMain::LoadVideo(wxString file,bool autoload) {
} }
SetDisplayMode(1,-1); SetDisplayMode(1,-1);
EditBox->UpdateFrameTiming();
DetachVideo(VideoContext::Get()->IsLoaded() && OPT_GET("Video/Detached/Enabled")->GetBool()); DetachVideo(VideoContext::Get()->IsLoaded() && OPT_GET("Video/Detached/Enabled")->GetBool());
Thaw(); Thaw();
@ -1148,7 +1147,6 @@ void FrameMain::LoadVFR(wxString filename) {
else { else {
VideoContext::Get()->LoadTimecodes(filename); VideoContext::Get()->LoadTimecodes(filename);
} }
EditBox->UpdateFrameTiming();
} }
/// @brief Open help /// @brief Open help

View File

@ -211,6 +211,7 @@ SubsEditBox::SubsEditBox(wxWindow *parent, SubtitlesGrid *grid)
ByTime = new wxRadioButton(this,wxID_ANY,_("Time"),wxDefaultPosition,wxDefaultSize,wxRB_GROUP); ByTime = new wxRadioButton(this,wxID_ANY,_("Time"),wxDefaultPosition,wxDefaultSize,wxRB_GROUP);
ByFrame = new wxRadioButton(this,wxID_ANY,_("Frame")); ByFrame = new wxRadioButton(this,wxID_ANY,_("Frame"));
ByFrame->Enable(false);
// Tooltips // Tooltips
CommentBox->SetToolTip(_("Comment this line out. Commented lines don't show up on screen.")); 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->AddSelectionListener(this);
grid->ass->AddCommitListener(&SubsEditBox::Update, this); grid->ass->AddCommitListener(&SubsEditBox::Update, this);
VideoContext::Get()->AddTimecodesListener(&SubsEditBox::UpdateFrameTiming, this);
} }
SubsEditBox::~SubsEditBox() { SubsEditBox::~SubsEditBox() {
grid->RemoveSelectionListener(this); grid->RemoveSelectionListener(this);
@ -408,8 +410,10 @@ void SubsEditBox::OnSelectedSetChanged(const Selection &, const Selection &) {
sel = grid->GetSelectedSet(); sel = grid->GetSelectedSet();
} }
void SubsEditBox::UpdateFrameTiming () { void SubsEditBox::UpdateFrameTiming(agi::vfr::Framerate const& fps) {
if (VideoContext::Get()->TimecodesLoaded()) ByFrame->Enable(true); if (fps.IsLoaded()) {
ByFrame->Enable(true);
}
else { else {
ByFrame->Enable(false); ByFrame->Enable(false);
ByTime->SetValue(true); ByTime->SetValue(true);
@ -566,8 +570,6 @@ void SubsEditBox::SetControlsState(bool state) {
for (size_t i = 0; i < ToggableButtons.size(); ++i) for (size_t i = 0; i < ToggableButtons.size(); ++i)
ToggableButtons[i]->Enable(state); ToggableButtons[i]->Enable(state);
UpdateFrameTiming();
if (!state) { if (!state) {
SetEvtHandlerEnabled(false); SetEvtHandlerEnabled(false);
TextEdit->SetTextTo(""); TextEdit->SetTextTo("");

View File

@ -57,6 +57,8 @@ class wxStyledTextEvent;
class wxTextCtrl; class wxTextCtrl;
class AudioController; class AudioController;
namespace agi { namespace vfr { class Framerate; } }
/// DOCME /// DOCME
/// @class SubsEditBox /// @class SubsEditBox
/// @brief Main subtitle edit box /// @brief Main subtitle edit box
@ -186,6 +188,9 @@ class SubsEditBox : public wxPanel, protected SelectionListener<AssDialogue> {
/// @brief Reload the current line from the file /// @brief Reload the current line from the file
/// @param type AssFile::CommitType /// @param type AssFile::CommitType
void Update(int type); void Update(int type);
/// @brief Enable or disable frame timing mode
void UpdateFrameTiming(agi::vfr::Framerate const& fps);
public: public:
SubsTextEditCtrl *TextEdit; SubsTextEditCtrl *TextEdit;
@ -194,7 +199,4 @@ public:
/// @param grid Associated grid /// @param grid Associated grid
SubsEditBox(wxWindow *parent, SubtitlesGrid *grid); SubsEditBox(wxWindow *parent, SubtitlesGrid *grid);
~SubsEditBox(); ~SubsEditBox();
/// @brief Enable or disable frame timing mode
void UpdateFrameTiming();
}; };

View File

@ -133,7 +133,10 @@ void VideoContext::Reset() {
StandardPaths::SetPathValue(_T("?video"), ""); StandardPaths::SetPathValue(_T("?video"), "");
keyFrames.clear(); keyFrames.clear();
keyFramesFilename.clear();
videoFPS = agi::vfr::Framerate(); videoFPS = agi::vfr::Framerate();
KeyframesOpen(keyFrames);
if (!ovrFPS.IsLoaded()) TimecodesOpen(videoFPS);
// Remove video data // Remove video data
frame_n = 0; frame_n = 0;
@ -196,6 +199,7 @@ void VideoContext::SetVideo(const wxString &filename) {
grid->ass->AddCommitListener(&VideoContext::SubtitlesChanged, this); grid->ass->AddCommitListener(&VideoContext::SubtitlesChanged, this);
VideoOpen(); VideoOpen();
KeyframesOpen(keyFrames); KeyframesOpen(keyFrames);
TimecodesOpen(FPS());
} }
catch (agi::UserCancelException const&) { } catch (agi::UserCancelException const&) { }
catch (agi::FileNotAccessibleError const& err) { catch (agi::FileNotAccessibleError const& err) {
@ -462,6 +466,7 @@ void VideoContext::LoadKeyframes(wxString filename) {
ovrFPS = agi::vfr::Framerate(kf.second); ovrFPS = agi::vfr::Framerate(kf.second);
ovrTimecodeFile.clear(); ovrTimecodeFile.clear();
SubtitlesChanged(); SubtitlesChanged();
TimecodesOpen(ovrFPS);
} }
config::mru->Add("Keyframes", STD_STR(filename)); config::mru->Add("Keyframes", STD_STR(filename));
} }
@ -498,6 +503,7 @@ void VideoContext::LoadTimecodes(wxString filename) {
ovrTimecodeFile = filename; ovrTimecodeFile = filename;
config::mru->Add("Timecodes", STD_STR(filename)); config::mru->Add("Timecodes", STD_STR(filename));
SubtitlesChanged(); SubtitlesChanged();
TimecodesOpen(ovrFPS);
} }
catch (const agi::acs::AcsError&) { catch (const agi::acs::AcsError&) {
wxLogError(L"Could not open file " + filename); wxLogError(L"Could not open file " + filename);
@ -520,6 +526,7 @@ void VideoContext::CloseTimecodes() {
ovrFPS = agi::vfr::Framerate(); ovrFPS = agi::vfr::Framerate();
ovrTimecodeFile.clear(); ovrTimecodeFile.clear();
SubtitlesChanged(); SubtitlesChanged();
TimecodesOpen(videoFPS);
} }
int VideoContext::TimeAtFrame(int frame, agi::vfr::Time type) const { int VideoContext::TimeAtFrame(int frame, agi::vfr::Time type) const {

View File

@ -81,6 +81,8 @@ class VideoContext : public wxEvtHandler {
agi::signal::Signal<> VideoOpen; agi::signal::Signal<> VideoOpen;
/// New keyframes opened (new keyframe data) /// New keyframes opened (new keyframe data)
agi::signal::Signal<std::vector<int> const&> KeyframesOpen; agi::signal::Signal<std::vector<int> const&> KeyframesOpen;
/// New timecodes opened (new timecode data)
agi::signal::Signal<agi::vfr::Framerate const&> TimecodesOpen;
/// Aspect ratio was changed (type, value) /// Aspect ratio was changed (type, value)
agi::signal::Signal<int, double> ARChange; agi::signal::Signal<int, double> ARChange;
@ -254,7 +256,8 @@ public:
DEFINE_SIGNAL_ADDERS(Seek, AddSeekListener) DEFINE_SIGNAL_ADDERS(Seek, AddSeekListener)
DEFINE_SIGNAL_ADDERS(VideoOpen, AddVideoOpenListener) 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) DEFINE_SIGNAL_ADDERS(ARChange, AddARChangeListener)
const std::vector<int>& GetKeyFrames() const { return keyFrames; }; const std::vector<int>& GetKeyFrames() const { return keyFrames; };

View File

@ -74,7 +74,7 @@ VideoSlider::VideoSlider (wxWindow* parent, wxWindowID id)
assert(vc); assert(vc);
vc->AddSeekListener(&VideoSlider::SetValue, this); vc->AddSeekListener(&VideoSlider::SetValue, this);
vc->AddVideoOpenListener(&VideoSlider::VideoOpened, this); vc->AddVideoOpenListener(&VideoSlider::VideoOpened, this);
vc->AddKeyframesOpenListener(&VideoSlider::KeyframesChanged, this); vc->AddKeyframesListener(&VideoSlider::KeyframesChanged, this);
} }
VideoSlider::~VideoSlider() { VideoSlider::~VideoSlider() {