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:
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)
{

View File

@ -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

View File

@ -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("");

View File

@ -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<AssDialogue> {
/// @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();
};

View File

@ -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 {

View File

@ -81,6 +81,8 @@ class VideoContext : public wxEvtHandler {
agi::signal::Signal<> VideoOpen;
/// New keyframes opened (new keyframe data)
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)
agi::signal::Signal<int, double> 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<int>& GetKeyFrames() const { return keyFrames; };

View File

@ -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() {