Add option to show the previous and next inactive lines in the audio display in addition to previous, all or none. Updates #1386.

Originally committed to SVN as r6260.
This commit is contained in:
Thomas Goyne 2012-01-10 01:16:39 +00:00
parent a0fcd535c1
commit d451cf3e9c
2 changed files with 37 additions and 21 deletions

View File

@ -192,6 +192,10 @@ class AudioTimingControllerDialogue : public AudioTimingController, private Sele
/// Regenerate markers for inactive lines
void RegenerateInactiveLines();
/// Add the inactive line markers for a single line
/// @param line Line to add markers for. May be NULL.
void AddInactiveMarkers(AssDialogue *line);
/// @brief Set the position of a marker and announce the change to the world
/// @param marker Marker to move
/// @param sample New position of the marker
@ -552,39 +556,38 @@ void AudioTimingControllerDialogue::SetMarker(AudioMarkerDialogueTiming *marker,
void AudioTimingControllerDialogue::RegenerateInactiveLines()
{
switch (inactive_line_mode->GetInt())
switch (int mode = inactive_line_mode->GetInt())
{
case 1: // Preview line only
case 1: // Previous line only
case 2: // Previous and next lines
inactive_markers.clear();
if (AssDialogue *line = context->selectionController->GetActiveLine())
{
std::list<AssEntry*>::iterator it = find(context->ass->Line.begin(), context->ass->Line.end(), line);
while (--it != context->ass->Line.begin() && !dynamic_cast<AssDialogue*>(*it)) ;
if (AssDialogue *prev = dynamic_cast<AssDialogue*>(*it))
std::list<AssEntry*>::iterator current_line =
find(context->ass->Line.begin(), context->ass->Line.end(), line);
std::list<AssEntry*>::iterator prev = current_line;
while (--prev != context->ass->Line.begin() && !dynamic_cast<AssDialogue*>(*prev)) ;
AddInactiveMarkers(dynamic_cast<AssDialogue*>(*prev));
if (mode == 2)
{
inactive_markers.push_back(InactiveLineMarker(
context->audioController->SamplesFromMilliseconds(prev->Start), true));
inactive_markers.push_back(InactiveLineMarker(
context->audioController->SamplesFromMilliseconds(prev->End), false));
std::list<AssEntry*>::iterator next =
find_if(++current_line, context->ass->Line.end(), cast<AssDialogue*>());
if (next != context->ass->Line.end())
AddInactiveMarkers(dynamic_cast<AssDialogue*>(*next));
}
}
break;
case 2: // All inactive lines
case 3: // All inactive lines
{
inactive_markers.clear();
AssDialogue *active_line = context->selectionController->GetActiveLine();
for (std::list<AssEntry*>::const_iterator it = context->ass->Line.begin(); it != context->ass->Line.end(); ++it)
{
AssDialogue *line = dynamic_cast<AssDialogue*>(*it);
if (line && line != active_line)
{
inactive_markers.push_back(InactiveLineMarker(
context->audioController->SamplesFromMilliseconds(line->Start), true));
inactive_markers.push_back(InactiveLineMarker(
context->audioController->SamplesFromMilliseconds(line->End), false));
}
if (*it != active_line)
AddInactiveMarkers(dynamic_cast<AssDialogue*>(*it));
}
sort(inactive_markers.begin(), inactive_markers.end());
break;
}
default:
@ -592,6 +595,8 @@ void AudioTimingControllerDialogue::RegenerateInactiveLines()
return;
inactive_markers.clear();
}
sort(inactive_markers.begin(), inactive_markers.end());
AnnounceUpdatedStyleRanges();
}
@ -619,3 +624,14 @@ int64_t AudioTimingControllerDialogue::SnapPosition(int64_t position, int64_t sn
return snap_marker->GetPosition();
return position;
}
void AudioTimingControllerDialogue::AddInactiveMarkers(AssDialogue *line)
{
if (line)
{
inactive_markers.push_back(InactiveLineMarker(
context->audioController->SamplesFromMilliseconds(line->Start), true));
inactive_markers.push_back(InactiveLineMarker(
context->audioController->SamplesFromMilliseconds(line->End), false));
}
}

View File

@ -152,8 +152,8 @@ Audio::Audio(wxTreebook *book, Preferences *parent): OptionPage(book, parent, _(
OptionAdd(general, _("Default lead-in length"), "Audio/Lead/IN", 0, 36000);
OptionAdd(general, _("Default lead-out length"), "Audio/Lead/OUT", 0, 36000);
const wxString dtl_arr[3] = { _("Don't show"), _("Show previous"), _("Show all") };
wxArrayString choice_dtl(3, dtl_arr);
const wxString dtl_arr[] = { _("Don't show"), _("Show previous"), _("Show previous and next"), _("Show all") };
wxArrayString choice_dtl(4, dtl_arr);
OptionChoice(general, _("Show inactive lines"), choice_dtl, "Audio/Inactive Lines Display Mode");
OptionAdd(general, _("Start-marker drag sensitivity"), "Audio/Start Drag Sensitivity", 1, 15);
OptionAdd(general, _("Line boundry thickness"), "Audio/Line Boundaries Thickness", 1, 5);