mirror of https://github.com/odrling/Aegisub
Implement the video position marker in the audio display
Originally committed to SVN as r5728.
This commit is contained in:
parent
a260a998b3
commit
7dfaa6427c
|
@ -141,6 +141,91 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class VideoPositionMarker : public AudioMarker {
|
||||||
|
agi::signal::Connection colour_changed;
|
||||||
|
|
||||||
|
int64_t position;
|
||||||
|
wxPen style;
|
||||||
|
|
||||||
|
void OnColourChanged(agi::OptionValue const& opt)
|
||||||
|
{
|
||||||
|
style = wxPen(lagi_wxColour(opt.GetColour()), 1);
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
VideoPositionMarker()
|
||||||
|
: colour_changed(OPT_SUB("Colour/Audio Display/Play Cursor", &VideoPositionMarker::OnColourChanged, this))
|
||||||
|
, position(-1)
|
||||||
|
{
|
||||||
|
OnColourChanged(*OPT_GET("Colour/Audio Display/Play Cursor"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetPosition(int64_t new_pos)
|
||||||
|
{
|
||||||
|
position = new_pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t GetPosition() const { return position; }
|
||||||
|
FeetStyle GetFeet() const { return Feet_None; }
|
||||||
|
bool CanSnap() const { return true; }
|
||||||
|
wxPen GetStyle() const { return style; }
|
||||||
|
operator int64_t() const { return position; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class VideoPositionMarkerProvider : public AudioMarkerProvider {
|
||||||
|
AudioController *ac;
|
||||||
|
VideoContext *vc;
|
||||||
|
|
||||||
|
VideoPositionMarker marker;
|
||||||
|
|
||||||
|
agi::signal::Connection video_seek_slot;
|
||||||
|
agi::signal::Connection enable_opt_changed_slot;
|
||||||
|
|
||||||
|
void Update(int frame_number)
|
||||||
|
{
|
||||||
|
if (frame_number == -1)
|
||||||
|
{
|
||||||
|
marker.SetPosition(-1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
marker.SetPosition(ac->SamplesFromMilliseconds(vc->TimeAtFrame(frame_number)));
|
||||||
|
}
|
||||||
|
AnnounceMarkerMoved();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OptChanged(agi::OptionValue const& opt)
|
||||||
|
{
|
||||||
|
if (opt.GetBool())
|
||||||
|
{
|
||||||
|
video_seek_slot.Unblock();
|
||||||
|
Update(vc->GetFrameN());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
video_seek_slot.Block();
|
||||||
|
Update(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
VideoPositionMarkerProvider(agi::Context *c)
|
||||||
|
: ac(c->audioController)
|
||||||
|
, vc(c->videoController)
|
||||||
|
, video_seek_slot(vc->AddSeekListener(&VideoPositionMarkerProvider::Update, this))
|
||||||
|
, enable_opt_changed_slot(OPT_SUB("Audio/Display/Draw/Video Position", &VideoPositionMarkerProvider::OptChanged, this))
|
||||||
|
{
|
||||||
|
OptChanged(*OPT_GET("Audio/Display/Draw/Video Position"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetMarkers(const SampleRange &range, AudioMarkerVector &out) const
|
||||||
|
{
|
||||||
|
if (range.contains(marker))
|
||||||
|
{
|
||||||
|
out.push_back(&marker);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
AudioController::AudioController(agi::Context *context)
|
AudioController::AudioController(agi::Context *context)
|
||||||
: context(context)
|
: context(context)
|
||||||
, subtitle_save_slot(context->ass->AddFileSaveListener(&AudioController::OnSubtitlesSave, this))
|
, subtitle_save_slot(context->ass->AddFileSaveListener(&AudioController::OnSubtitlesSave, this))
|
||||||
|
@ -303,7 +388,12 @@ void AudioController::OpenAudio(const wxString &url)
|
||||||
// the audio controller is created
|
// the audio controller is created
|
||||||
keyframes_marker_provider.reset(new AudioMarkerProviderKeyframes(this, context));
|
keyframes_marker_provider.reset(new AudioMarkerProviderKeyframes(this, context));
|
||||||
keyframes_marker_provider->AddMarkerMovedListener(std::tr1::bind(std::tr1::ref(AnnounceMarkerMoved)));
|
keyframes_marker_provider->AddMarkerMovedListener(std::tr1::bind(std::tr1::ref(AnnounceMarkerMoved)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!video_position_marker_provider.get())
|
||||||
|
{
|
||||||
|
video_position_marker_provider.reset(new VideoPositionMarkerProvider(context));
|
||||||
|
video_position_marker_provider->AddMarkerMovedListener(std::tr1::bind(std::tr1::ref(AnnounceMarkerMoved)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell listeners about this.
|
// Tell listeners about this.
|
||||||
|
@ -465,6 +555,7 @@ void AudioController::GetMarkers(const SampleRange &range, AudioMarkerVector &ma
|
||||||
{
|
{
|
||||||
/// @todo Find all sources of markers
|
/// @todo Find all sources of markers
|
||||||
if (keyframes_marker_provider.get()) keyframes_marker_provider->GetMarkers(range, markers);
|
if (keyframes_marker_provider.get()) keyframes_marker_provider->GetMarkers(range, markers);
|
||||||
|
if (video_position_marker_provider.get()) video_position_marker_provider->GetMarkers(range, markers);
|
||||||
if (timing_controller.get()) timing_controller->GetMarkers(range, markers);
|
if (timing_controller.get()) timing_controller->GetMarkers(range, markers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -213,6 +213,9 @@ class AudioController : public wxEvtHandler, public AudioMarkerProvider, public
|
||||||
/// Provide keyframe data for audio displays
|
/// Provide keyframe data for audio displays
|
||||||
agi::scoped_ptr<AudioMarkerProvider> keyframes_marker_provider;
|
agi::scoped_ptr<AudioMarkerProvider> keyframes_marker_provider;
|
||||||
|
|
||||||
|
/// Provider current video position data for audio display
|
||||||
|
agi::scoped_ptr<AudioMarkerProvider> video_position_marker_provider;
|
||||||
|
|
||||||
/// The URL of the currently open audio, if any
|
/// The URL of the currently open audio, if any
|
||||||
wxString audio_url;
|
wxString audio_url;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue