forked from mia/Aegisub
Move the Next Line on Commit logic to the commit command so that other commands can do different things
Originally committed to SVN as r6718.
This commit is contained in:
parent
79282d7b89
commit
99a65974e4
5 changed files with 54 additions and 38 deletions
|
@ -82,11 +82,27 @@ public:
|
|||
/// @param[out] ranges Rendering ranges will be added to this
|
||||
virtual void GetRenderingStyles(AudioRenderingStyleRanges &ranges) const = 0;
|
||||
|
||||
/// @brief Go to next timing unit
|
||||
enum NextMode {
|
||||
/// Advance to the next timing unit, whether it's a line or a sub-part
|
||||
/// of a line such as a karaoke syllable
|
||||
TIMING_UNIT = 0,
|
||||
|
||||
/// @brief Advance to the next line
|
||||
///
|
||||
/// Advances the timing controller cursor to the next timing unit, for
|
||||
/// example the next dialogue line or the next karaoke syllable.
|
||||
virtual void Next() = 0;
|
||||
/// This may create a new line if there are no more lines in the file,
|
||||
/// but should never modify existing lines
|
||||
LINE,
|
||||
|
||||
/// @brief Advance to the next line using default timing
|
||||
///
|
||||
/// This may create new lines when needed, and should discard any
|
||||
/// existing timing data in favor of the defaults
|
||||
LINE_RESET_DEFAULT
|
||||
};
|
||||
|
||||
/// @brief Go to next timing unit
|
||||
/// @param mode What sort of timing unit should be advanced to
|
||||
virtual void Next(NextMode mode) = 0;
|
||||
|
||||
/// @brief Go to the previous timing unit
|
||||
///
|
||||
|
|
|
@ -382,7 +382,7 @@ public:
|
|||
TimeRange GetPrimaryPlaybackRange() const;
|
||||
void GetRenderingStyles(AudioRenderingStyleRanges &ranges) const;
|
||||
void GetLabels(TimeRange const& range, std::vector<AudioLabel> &out) const { }
|
||||
void Next();
|
||||
void Next(NextMode mode);
|
||||
void Prev();
|
||||
void Commit();
|
||||
void Revert();
|
||||
|
@ -495,9 +495,28 @@ void AudioTimingControllerDialogue::GetRenderingStyles(AudioRenderingStyleRanges
|
|||
bind(&TimeableLine::GetStyleRange, std::tr1::placeholders::_1, &ranges));
|
||||
}
|
||||
|
||||
void AudioTimingControllerDialogue::Next()
|
||||
void AudioTimingControllerDialogue::Next(NextMode mode)
|
||||
{
|
||||
if (mode == TIMING_UNIT)
|
||||
{
|
||||
context->selectionController->NextLine();
|
||||
return;
|
||||
}
|
||||
|
||||
int new_end_ms = *active_line.GetRightMarker();
|
||||
|
||||
cmd::call("grid/line/next/create", context);
|
||||
|
||||
if (mode == LINE_RESET_DEFAULT || *active_line.GetRightMarker() == 0) {
|
||||
const int default_duration = OPT_GET("Timing/Default Duration")->GetInt();
|
||||
// Setting right first here so that they don't get switched and the
|
||||
// same marker gets set twice
|
||||
active_line.GetRightMarker()->SetPosition(new_end_ms + default_duration);
|
||||
active_line.GetLeftMarker()->SetPosition(new_end_ms);
|
||||
sort(markers.begin(), markers.end(), marker_ptr_cmp());
|
||||
modified_lines.insert(&active_line);
|
||||
UpdateSelection();
|
||||
}
|
||||
}
|
||||
|
||||
void AudioTimingControllerDialogue::Prev()
|
||||
|
@ -533,24 +552,6 @@ void AudioTimingControllerDialogue::DoCommit(bool user_triggered)
|
|||
commit_connection.Unblock();
|
||||
modified_lines.clear();
|
||||
}
|
||||
|
||||
if (user_triggered && OPT_GET("Audio/Next Line on Commit")->GetBool())
|
||||
{
|
||||
int new_end_ms = *active_line.GetRightMarker();
|
||||
|
||||
cmd::call("grid/line/next/create", context);
|
||||
|
||||
if (*active_line.GetRightMarker() == 0) {
|
||||
const int default_duration = OPT_GET("Timing/Default Duration")->GetInt();
|
||||
// Setting right first here so that they don't get switched and the
|
||||
// same marker gets set twice
|
||||
active_line.GetRightMarker()->SetPosition(new_end_ms + default_duration);
|
||||
active_line.GetLeftMarker()->SetPosition(new_end_ms);
|
||||
sort(markers.begin(), markers.end(), marker_ptr_cmp());
|
||||
modified_lines.insert(&active_line);
|
||||
UpdateSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioTimingControllerDialogue::Revert()
|
||||
|
|
|
@ -108,11 +108,9 @@ class AudioTimingControllerKaraoke : public AudioTimingController {
|
|||
std::vector<AudioLabel> labels;
|
||||
|
||||
bool auto_commit; ///< Should changes be automatically commited?
|
||||
bool auto_next; ///< Should user-initiated commits automatically go to the next?
|
||||
int commit_id; ///< Last commit id used for an autocommit
|
||||
|
||||
void OnAutoCommitChange(agi::OptionValue const& opt);
|
||||
void OnAutoNextChange(agi::OptionValue const& opt);
|
||||
|
||||
void DoCommit();
|
||||
void ApplyLead(bool announce_primary);
|
||||
|
@ -125,7 +123,7 @@ public:
|
|||
void GetRenderingStyles(AudioRenderingStyleRanges &ranges) const;
|
||||
TimeRange GetPrimaryPlaybackRange() const;
|
||||
void GetLabels(const TimeRange &range, std::vector<AudioLabel> &out_labels) const;
|
||||
void Next();
|
||||
void Next(NextMode mode);
|
||||
void Prev();
|
||||
void Commit();
|
||||
void Revert();
|
||||
|
@ -158,12 +156,10 @@ AudioTimingControllerKaraoke::AudioTimingControllerKaraoke(agi::Context *c, AssK
|
|||
, keyframes_provider(c, "Audio/Display/Draw/Keyframes in Karaoke Mode")
|
||||
, video_position_provider(c)
|
||||
, auto_commit(OPT_GET("Audio/Auto/Commit")->GetBool())
|
||||
, auto_next(OPT_GET("Audio/Next Line on Commit")->GetBool())
|
||||
, commit_id(-1)
|
||||
{
|
||||
slots.push_back(kara->AddSyllablesChangedListener(&AudioTimingControllerKaraoke::Revert, this));
|
||||
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)));
|
||||
video_position_provider.AddMarkerMovedListener(std::tr1::bind(std::tr1::ref(AnnounceMarkerMoved)));
|
||||
|
@ -176,11 +172,12 @@ void AudioTimingControllerKaraoke::OnAutoCommitChange(agi::OptionValue const& op
|
|||
auto_commit = opt.GetBool();
|
||||
}
|
||||
|
||||
void AudioTimingControllerKaraoke::OnAutoNextChange(agi::OptionValue const& opt) {
|
||||
auto_next = opt.GetBool();
|
||||
}
|
||||
void AudioTimingControllerKaraoke::Next(NextMode mode) {
|
||||
// Don't create new lines since it's almost never useful to k-time a line
|
||||
// before dialogue timing it
|
||||
if (mode != TIMING_UNIT)
|
||||
cur_syl = markers.size();
|
||||
|
||||
void AudioTimingControllerKaraoke::Next() {
|
||||
++cur_syl;
|
||||
if (cur_syl > markers.size()) {
|
||||
--cur_syl;
|
||||
|
@ -253,8 +250,6 @@ void AudioTimingControllerKaraoke::DoCommit() {
|
|||
void AudioTimingControllerKaraoke::Commit() {
|
||||
if (!auto_commit)
|
||||
DoCommit();
|
||||
if (auto_next)
|
||||
c->selectionController->NextLine();
|
||||
}
|
||||
|
||||
void AudioTimingControllerKaraoke::Revert() {
|
||||
|
|
|
@ -339,7 +339,11 @@ struct audio_commit : public validate_audio_open {
|
|||
|
||||
void operator()(agi::Context *c) {
|
||||
AudioTimingController *tc = c->audioController->GetTimingController();
|
||||
if (tc) tc->Commit();
|
||||
if (tc) {
|
||||
tc->Commit();
|
||||
if(OPT_GET("Audio/Next Line on Commit")->GetBool())
|
||||
tc->Next(AudioTimingController::LINE);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -288,7 +288,7 @@ struct time_next : public Command {
|
|||
void operator()(agi::Context *c) {
|
||||
c->audioController->Stop();
|
||||
if (c->audioController->GetTimingController())
|
||||
c->audioController->GetTimingController()->Next();
|
||||
c->audioController->GetTimingController()->Next(AudioTimingController::TIMING_UNIT);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue