mirror of https://github.com/odrling/Aegisub
Modernize some code in audio_timing_dialogue.cpp
This commit is contained in:
parent
66877105cb
commit
5d3bc0d0d2
|
@ -159,7 +159,7 @@ struct marker_ptr_cmp
|
||||||
/// markers to the tracked dialogue line.
|
/// markers to the tracked dialogue line.
|
||||||
class TimeableLine {
|
class TimeableLine {
|
||||||
/// The current tracked dialogue line
|
/// The current tracked dialogue line
|
||||||
AssDialogue *line;
|
AssDialogue *line = nullptr;
|
||||||
/// The rendering style of this line
|
/// The rendering style of this line
|
||||||
AudioRenderingStyle style;
|
AudioRenderingStyle style;
|
||||||
|
|
||||||
|
@ -179,23 +179,22 @@ public:
|
||||||
/// @param style_left The rendering style for the start marker
|
/// @param style_left The rendering style for the start marker
|
||||||
/// @param style_right The rendering style for the end marker
|
/// @param style_right The rendering style for the end marker
|
||||||
TimeableLine(AudioRenderingStyle style, const Pen *style_left, const Pen *style_right)
|
TimeableLine(AudioRenderingStyle style, const Pen *style_left, const Pen *style_right)
|
||||||
: line(nullptr)
|
: style(style)
|
||||||
, style(style)
|
, marker1(0, style_left, AudioMarker::Feet_Right, style, this)
|
||||||
, marker1(0, style_left, AudioMarker::Feet_Right, style, this)
|
, marker2(0, style_right, AudioMarker::Feet_Left, style, this)
|
||||||
, marker2(0, style_right, AudioMarker::Feet_Left, style, this)
|
, left_marker(&marker1)
|
||||||
, left_marker(&marker1)
|
, right_marker(&marker2)
|
||||||
, right_marker(&marker2)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Explicit copy constructor needed due to that the markers have a pointer to this
|
/// Explicit copy constructor needed due to that the markers have a pointer to this
|
||||||
TimeableLine(TimeableLine const& other)
|
TimeableLine(TimeableLine const& other)
|
||||||
: line(other.line)
|
: line(other.line)
|
||||||
, style(other.style)
|
, style(other.style)
|
||||||
, marker1(*other.left_marker, this)
|
, marker1(*other.left_marker, this)
|
||||||
, marker2(*other.right_marker, this)
|
, marker2(*other.right_marker, this)
|
||||||
, left_marker(&marker1)
|
, left_marker(&marker1)
|
||||||
, right_marker(&marker2)
|
, right_marker(&marker2)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,7 +318,7 @@ class AudioTimingControllerDialogue final : public AudioTimingController {
|
||||||
std::set<TimeableLine*> modified_lines;
|
std::set<TimeableLine*> modified_lines;
|
||||||
|
|
||||||
/// Commit id for coalescing purposes when in auto commit mode
|
/// Commit id for coalescing purposes when in auto commit mode
|
||||||
int commit_id;
|
int commit_id =-1;
|
||||||
|
|
||||||
/// The owning project context
|
/// The owning project context
|
||||||
agi::Context *context;
|
agi::Context *context;
|
||||||
|
@ -420,7 +419,6 @@ AudioTimingControllerDialogue::AudioTimingControllerDialogue(agi::Context *c)
|
||||||
, active_line(AudioStyle_Primary, &style_left, &style_right)
|
, active_line(AudioStyle_Primary, &style_left, &style_right)
|
||||||
, keyframes_provider(c, "Audio/Display/Draw/Keyframes in Dialogue Mode")
|
, keyframes_provider(c, "Audio/Display/Draw/Keyframes in Dialogue Mode")
|
||||||
, video_position_provider(c)
|
, video_position_provider(c)
|
||||||
, commit_id(-1)
|
|
||||||
, context(c)
|
, context(c)
|
||||||
, auto_commit(OPT_GET("Audio/Auto/Commit"))
|
, auto_commit(OPT_GET("Audio/Auto/Commit"))
|
||||||
, inactive_line_mode(OPT_GET("Audio/Inactive Lines Display Mode"))
|
, inactive_line_mode(OPT_GET("Audio/Inactive Lines Display Mode"))
|
||||||
|
@ -498,10 +496,10 @@ TimeRange AudioTimingControllerDialogue::GetActiveLineRange() const
|
||||||
void AudioTimingControllerDialogue::GetRenderingStyles(AudioRenderingStyleRanges &ranges) const
|
void AudioTimingControllerDialogue::GetRenderingStyles(AudioRenderingStyleRanges &ranges) const
|
||||||
{
|
{
|
||||||
active_line.GetStyleRange(&ranges);
|
active_line.GetStyleRange(&ranges);
|
||||||
for_each(selected_lines.begin(), selected_lines.end(),
|
for (auto const& line : selected_lines)
|
||||||
std::bind(&TimeableLine::GetStyleRange, std::placeholders::_1, &ranges));
|
line.GetStyleRange(&ranges);
|
||||||
for_each(inactive_lines.begin(), inactive_lines.end(),
|
for (auto const& line : inactive_lines)
|
||||||
std::bind(&TimeableLine::GetStyleRange, std::placeholders::_1, &ranges));
|
line.GetStyleRange(&ranges);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioTimingControllerDialogue::Next(NextMode mode)
|
void AudioTimingControllerDialogue::Next(NextMode mode)
|
||||||
|
@ -543,8 +541,8 @@ void AudioTimingControllerDialogue::DoCommit(bool user_triggered)
|
||||||
// Store back new times
|
// Store back new times
|
||||||
if (modified_lines.size())
|
if (modified_lines.size())
|
||||||
{
|
{
|
||||||
for_each(modified_lines.begin(), modified_lines.end(),
|
for (auto line : modified_lines)
|
||||||
std::mem_fn(&TimeableLine::Apply));
|
line->Apply();
|
||||||
|
|
||||||
commit_connection.Block();
|
commit_connection.Block();
|
||||||
if (user_triggered)
|
if (user_triggered)
|
||||||
|
@ -720,14 +718,9 @@ static bool noncomment_dialogue(AssDialogue const& diag)
|
||||||
return !diag.Comment;
|
return !diag.Comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool dialogue(AssDialogue const&)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioTimingControllerDialogue::RegenerateInactiveLines()
|
void AudioTimingControllerDialogue::RegenerateInactiveLines()
|
||||||
{
|
{
|
||||||
auto predicate = inactive_line_comments->GetBool() ? dialogue : noncomment_dialogue;
|
auto predicate = inactive_line_comments->GetBool() ? [](AssDialogue const&) { return true; } : noncomment_dialogue;
|
||||||
|
|
||||||
bool was_empty = inactive_lines.empty();
|
bool was_empty = inactive_lines.empty();
|
||||||
inactive_lines.clear();
|
inactive_lines.clear();
|
||||||
|
@ -815,11 +808,10 @@ void AudioTimingControllerDialogue::RegenerateMarkers()
|
||||||
markers.clear();
|
markers.clear();
|
||||||
|
|
||||||
active_line.GetMarkers(&markers);
|
active_line.GetMarkers(&markers);
|
||||||
for_each(selected_lines.begin(), selected_lines.end(),
|
for (auto const& line : selected_lines)
|
||||||
std::bind(&TimeableLine::GetMarkers, std::placeholders::_1, &markers));
|
line.GetMarkers(&markers);
|
||||||
for_each(inactive_lines.begin(), inactive_lines.end(),
|
for (auto const& line : inactive_lines)
|
||||||
std::bind(&TimeableLine::GetMarkers, std::placeholders::_1, &markers));
|
line.GetMarkers(&markers);
|
||||||
sort(markers.begin(), markers.end(), marker_ptr_cmp());
|
|
||||||
|
|
||||||
AnnounceMarkerMoved();
|
AnnounceMarkerMoved();
|
||||||
}
|
}
|
||||||
|
@ -829,8 +821,8 @@ std::vector<AudioMarker*> AudioTimingControllerDialogue::GetLeftMarkers()
|
||||||
std::vector<AudioMarker*> ret;
|
std::vector<AudioMarker*> ret;
|
||||||
ret.reserve(selected_lines.size() + 1);
|
ret.reserve(selected_lines.size() + 1);
|
||||||
ret.push_back(active_line.GetLeftMarker());
|
ret.push_back(active_line.GetLeftMarker());
|
||||||
transform(selected_lines.begin(), selected_lines.end(), back_inserter(ret),
|
for (auto& line : selected_lines)
|
||||||
std::bind(&TimeableLine::GetLeftMarker, std::placeholders::_1));
|
ret.push_back(line.GetLeftMarker());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -839,8 +831,8 @@ std::vector<AudioMarker*> AudioTimingControllerDialogue::GetRightMarkers()
|
||||||
std::vector<AudioMarker*> ret;
|
std::vector<AudioMarker*> ret;
|
||||||
ret.reserve(selected_lines.size() + 1);
|
ret.reserve(selected_lines.size() + 1);
|
||||||
ret.push_back(active_line.GetRightMarker());
|
ret.push_back(active_line.GetRightMarker());
|
||||||
transform(selected_lines.begin(), selected_lines.end(), back_inserter(ret),
|
for (auto& line : selected_lines)
|
||||||
std::bind(&TimeableLine::GetRightMarker, std::placeholders::_1));
|
ret.push_back(line.GetRightMarker());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue