Move the keyframe marker provider from the audio controller to the timing controllers

Originally committed to SVN as r5859.
This commit is contained in:
Thomas Goyne 2011-11-16 19:56:00 +00:00
parent 29518f585a
commit 91a62836a5
4 changed files with 22 additions and 21 deletions

View file

@ -47,7 +47,6 @@
#include "ass_file.h"
#include "audio_controller.h"
#include "audio_marker_provider_keyframes.h"
#include "audio_provider_dummy.h"
#include "audio_timing.h"
#include "compat.h"
@ -294,14 +293,6 @@ void AudioController::OpenAudio(const wxString &url)
config::mru->Add("Audio", STD_STR(url));
if (!keyframes_marker_provider.get())
{
// This is lazy-loaded as the video controller may not exist yet when
// the audio controller is created
keyframes_marker_provider.reset(new AudioMarkerProviderKeyframes(context));
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));

View file

@ -61,11 +61,6 @@ protected:
/// One or more rendering style ranges have changed in the timing controller.
agi::signal::Signal<> AnnounceUpdatedStyleRanges;
/// A marker has been updated in some way.
agi::signal::Signal<AudioMarker*> AnnounceMarkerMoved;
/// A label has been updated in some way.
agi::signal::Signal<AudioLabel*> AnnounceLabelChanged;
public:
/// @brief Get any warning message to show in the audio display
/// @return The warning message to show, may be empty if there is none
@ -148,8 +143,6 @@ public:
DEFINE_SIGNAL_ADDERS(AnnounceUpdatedPrimaryRange, AddUpdatedPrimaryRangeListener)
DEFINE_SIGNAL_ADDERS(AnnounceUpdatedStyleRanges, AddUpdatedStyleRangesListener)
DEFINE_SIGNAL_ADDERS(AnnounceMarkerMoved, AddMarkerMovedListener)
DEFINE_SIGNAL_ADDERS(AnnounceLabelChanged, AddLabelChangedListener)
};

View file

@ -43,6 +43,7 @@
#include "ass_file.h"
#include "ass_time.h"
#include "audio_controller.h"
#include "audio_marker_provider_keyframes.h"
#include "audio_timing.h"
#include "include/aegisub/context.h"
#include "main.h"
@ -125,6 +126,9 @@ class AudioTimingControllerDialogue : public AudioTimingController, private Sele
/// Start and end markers for the active line
AudioMarkerDialogueTiming markers[2];
/// Marker provider for video keyframes
AudioMarkerProviderKeyframes keyframes_provider;
/// Has the timing been modified by the user?
/// If auto commit is enabled this will only be true very briefly following
/// changes
@ -249,7 +253,8 @@ void AudioMarkerDialogueTiming::InitPair(AudioMarkerDialogueTiming *marker1, Aud
// AudioTimingControllerDialogue
AudioTimingControllerDialogue::AudioTimingControllerDialogue(agi::Context *c)
: timing_modified(false)
: keyframes_provider(c)
, timing_modified(false)
, commit_id(-1)
, context(c)
, auto_commit(OPT_GET("Audio/Auto/Commit"))
@ -264,6 +269,8 @@ AudioTimingControllerDialogue::AudioTimingControllerDialogue(agi::Context *c)
c->selectionController->AddSelectionListener(this);
commit_slot = c->ass->AddCommitListener(&AudioTimingControllerDialogue::OnFileChanged, this);
audio_open_slot = c->audioController->AddAudioOpenListener(&AudioTimingControllerDialogue::Revert, this);
keyframes_provider.AddMarkerMovedListener(std::tr1::bind(std::tr1::ref(AnnounceMarkerMoved)));
}
@ -302,6 +309,8 @@ void AudioTimingControllerDialogue::GetMarkers(const SampleRange &range, AudioMa
out_markers.push_back(&markers[0]);
if (range.contains(markers[1].GetPosition()))
out_markers.push_back(&markers[1]);
keyframes_provider.GetMarkers(range, out_markers);
}
void AudioTimingControllerDialogue::OnActiveLineChanged(AssDialogue *new_line)

View file

@ -28,6 +28,7 @@
#include "ass_dialogue.h"
#include "ass_file.h"
#include "ass_karaoke.h"
#include "audio_marker_provider_keyframes.h"
#include "audio_timing.h"
#include "include/aegisub/context.h"
#include "main.h"
@ -96,6 +97,9 @@ class AudioTimingControllerKaraoke : public AudioTimingController {
/// Mobile markers between each pair of syllables
std::vector<KaraokeMarker> markers;
/// Marker provider for video keyframes
AudioMarkerProviderKeyframes keyframes_provider;
/// Labels containing the stripped text of each syllable
std::vector<AudioLabel> labels;
@ -147,6 +151,7 @@ AudioTimingControllerKaraoke::AudioTimingControllerKaraoke(agi::Context *c, AssK
, end_pen("Colour/Audio Display/Line boundary End", "Audio/Line Boundaries Thickness")
, start_marker(ToSamples(active_line->Start.GetMS()), &start_pen, AudioMarker::Feet_Right)
, end_marker(ToSamples(active_line->End.GetMS()), &end_pen, AudioMarker::Feet_Left)
, keyframes_provider(c)
, auto_commit(OPT_GET("Audio/Auto/Commit")->GetBool())
, auto_next(OPT_GET("Audio/Next Line on Commit")->GetBool())
, commit_id(-1)
@ -155,6 +160,8 @@ AudioTimingControllerKaraoke::AudioTimingControllerKaraoke(agi::Context *c, AssK
slots.push_back(OPT_SUB("Audio/Auto/Commit", &AudioTimingControllerKaraoke::OnAutoCommitChange, this));
slots.push_back(OPT_SUB("Audio/Next Line on Commit", &AudioTimingControllerKaraoke::OnAutoNextChange, this));
keyframes_provider.AddMarkerMovedListener(std::tr1::bind(std::tr1::ref(AnnounceMarkerMoved)));
Revert();
}
@ -210,6 +217,8 @@ void AudioTimingControllerKaraoke::GetMarkers(SampleRange const& range, AudioMar
if (range.contains(start_marker)) out.push_back(&start_marker);
if (range.contains(end_marker)) out.push_back(&end_marker);
keyframes_provider.GetMarkers(range, out);
}
void AudioTimingControllerKaraoke::DoCommit() {
@ -249,7 +258,7 @@ void AudioTimingControllerKaraoke::Revert() {
}
AnnounceUpdatedPrimaryRange();
AnnounceMarkerMoved(0);
AnnounceMarkerMoved();
}
bool AudioTimingControllerKaraoke::IsNearbyMarker(int64_t sample, int sensitivity) const {
@ -294,12 +303,11 @@ void AudioTimingControllerKaraoke::OnMarkerDrag(AudioMarker *m, int64_t new_posi
if (syl == cur_syl || syl + 1 == cur_syl)
AnnounceUpdatedPrimaryRange();
AnnounceMarkerMoved(m);
AnnounceMarkerMoved();
labels[syl - 1].range = SampleRange(labels[syl - 1].range.begin(), new_position);
labels[syl].range = SampleRange(new_position, labels[syl].range.end());
AnnounceLabelChanged(&labels[syl - 1]);
AnnounceLabelChanged(&labels[syl]);
AnnounceLabelChanged();
if (auto_commit)
DoCommit();