forked from mia/Aegisub
Add option to draw lines at each second in the audio display
Originally committed to SVN as r6721.
This commit is contained in:
parent
8b854283b7
commit
b275399fb1
5 changed files with 72 additions and 0 deletions
|
@ -141,3 +141,31 @@ void VideoPositionMarkerProvider::GetMarkers(const TimeRange &range, AudioMarker
|
||||||
if (marker && range.contains(*marker))
|
if (marker && range.contains(*marker))
|
||||||
out.push_back(marker.get());
|
out.push_back(marker.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SecondsMarkerProvider::SecondsMarkerProvider()
|
||||||
|
: pen(new Pen("Colour/Audio Display/Seconds Line", 1, wxPENSTYLE_DOT))
|
||||||
|
, enabled(OPT_GET("Audio/Display/Draw/Seconds"))
|
||||||
|
, enabled_opt_changed(OPT_SUB("Audio/Display/Draw/Seconds", &SecondsMarkerProvider::EnabledOptChanged, this))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SecondsMarkerProvider::EnabledOptChanged() {
|
||||||
|
AnnounceMarkerMoved();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SecondsMarkerProvider::GetMarkers(TimeRange const& range, AudioMarkerVector &out) const {
|
||||||
|
if (!enabled->GetBool()) return;
|
||||||
|
|
||||||
|
if ((range.length() + 999) / 1000 > (int)markers.size())
|
||||||
|
markers.resize((range.length() + 999) / 1000, Marker(pen.get()));
|
||||||
|
|
||||||
|
size_t i = 0;
|
||||||
|
for (int time = ((range.begin() + 999) / 1000) * 1000; time < range.end(); time += 1000) {
|
||||||
|
markers[i].position = time;
|
||||||
|
out.push_back(&markers[i++]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPen SecondsMarkerProvider::Marker::GetStyle() const {
|
||||||
|
return *style;
|
||||||
|
}
|
||||||
|
|
|
@ -176,3 +176,36 @@ public:
|
||||||
|
|
||||||
void GetMarkers(const TimeRange &range, AudioMarkerVector &out) const;
|
void GetMarkers(const TimeRange &range, AudioMarkerVector &out) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Marker provider for lines every second
|
||||||
|
class SecondsMarkerProvider : public AudioMarkerProvider {
|
||||||
|
struct Marker : public AudioMarker {
|
||||||
|
Pen *style;
|
||||||
|
int position;
|
||||||
|
|
||||||
|
Marker(Pen *style) : style(style) { }
|
||||||
|
int GetPosition() const { return position; }
|
||||||
|
FeetStyle GetFeet() const { return Feet_None; }
|
||||||
|
bool CanSnap() const { return false; }
|
||||||
|
wxPen GetStyle() const;
|
||||||
|
operator int() const { return position; }
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Pen used by all seconds markers, here for performance
|
||||||
|
agi::scoped_ptr<Pen> pen;
|
||||||
|
|
||||||
|
/// Markers returned from last call to GetMarkers
|
||||||
|
mutable std::vector<Marker> markers;
|
||||||
|
|
||||||
|
/// Cached reference to the option to enable/disable seconds markers
|
||||||
|
const agi::OptionValue *enabled;
|
||||||
|
|
||||||
|
/// Enabled option change connection
|
||||||
|
agi::signal::Connection enabled_opt_changed;
|
||||||
|
|
||||||
|
void EnabledOptChanged();
|
||||||
|
|
||||||
|
public:
|
||||||
|
SecondsMarkerProvider();
|
||||||
|
void GetMarkers(TimeRange const& range, AudioMarkerVector &out) const;
|
||||||
|
};
|
||||||
|
|
|
@ -308,6 +308,9 @@ class AudioTimingControllerDialogue : public AudioTimingController, private Sele
|
||||||
/// Marker provider for video playback position
|
/// Marker provider for video playback position
|
||||||
VideoPositionMarkerProvider video_position_provider;
|
VideoPositionMarkerProvider video_position_provider;
|
||||||
|
|
||||||
|
/// Marker provider for seconds lines
|
||||||
|
SecondsMarkerProvider seconds_provider;
|
||||||
|
|
||||||
/// The set of lines which have been modified and need to have their
|
/// The set of lines which have been modified and need to have their
|
||||||
/// changes applied on commit
|
/// changes applied on commit
|
||||||
std::set<TimeableLine*> modified_lines;
|
std::set<TimeableLine*> modified_lines;
|
||||||
|
@ -425,6 +428,7 @@ AudioTimingControllerDialogue::AudioTimingControllerDialogue(agi::Context *c)
|
||||||
c->selectionController->AddSelectionListener(this);
|
c->selectionController->AddSelectionListener(this);
|
||||||
keyframes_provider.AddMarkerMovedListener(std::tr1::bind(std::tr1::ref(AnnounceMarkerMoved)));
|
keyframes_provider.AddMarkerMovedListener(std::tr1::bind(std::tr1::ref(AnnounceMarkerMoved)));
|
||||||
video_position_provider.AddMarkerMovedListener(std::tr1::bind(std::tr1::ref(AnnounceMarkerMoved)));
|
video_position_provider.AddMarkerMovedListener(std::tr1::bind(std::tr1::ref(AnnounceMarkerMoved)));
|
||||||
|
seconds_provider.AddMarkerMovedListener(std::tr1::bind(std::tr1::ref(AnnounceMarkerMoved)));
|
||||||
|
|
||||||
sel = context->selectionController->GetSelectedSet();
|
sel = context->selectionController->GetSelectedSet();
|
||||||
Revert();
|
Revert();
|
||||||
|
@ -441,6 +445,8 @@ void AudioTimingControllerDialogue::GetMarkers(const TimeRange &range, AudioMark
|
||||||
// The order matters here; later markers are painted on top of earlier
|
// The order matters here; later markers are painted on top of earlier
|
||||||
// markers, so the markers that we want to end up on top need to appear last
|
// markers, so the markers that we want to end up on top need to appear last
|
||||||
|
|
||||||
|
seconds_provider.GetMarkers(range, out_markers);
|
||||||
|
|
||||||
// Copy inactive line markers in the range
|
// Copy inactive line markers in the range
|
||||||
copy(
|
copy(
|
||||||
lower_bound(markers.begin(), markers.end(), range.begin(), marker_ptr_cmp()),
|
lower_bound(markers.begin(), markers.end(), range.begin(), marker_ptr_cmp()),
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
"Inactive Comments" : true,
|
"Inactive Comments" : true,
|
||||||
"Keyframes in Dialogue Mode" : true,
|
"Keyframes in Dialogue Mode" : true,
|
||||||
"Keyframes in Karaoke Mode" : true,
|
"Keyframes in Karaoke Mode" : true,
|
||||||
|
"Seconds" : false,
|
||||||
"Video Position" : false
|
"Video Position" : false
|
||||||
},
|
},
|
||||||
"Waveform Style" : 1
|
"Waveform Style" : 1
|
||||||
|
@ -101,6 +102,7 @@
|
||||||
"Line boundary End" : "rgb(0, 0, 216)",
|
"Line boundary End" : "rgb(0, 0, 216)",
|
||||||
"Line boundary Start" : "rgb(216, 0, 0)",
|
"Line boundary Start" : "rgb(216, 0, 0)",
|
||||||
"Play Cursor" : "rgb(255,255,255)",
|
"Play Cursor" : "rgb(255,255,255)",
|
||||||
|
"Seconds Line" : "rgb(0,100,255)",
|
||||||
"Spectrum" : "Icy Blue",
|
"Spectrum" : "Icy Blue",
|
||||||
"Syllable Boundaries" : "rgb(255,255,0)",
|
"Syllable Boundaries" : "rgb(255,255,0)",
|
||||||
"Waveform" : "Green"
|
"Waveform" : "Green"
|
||||||
|
|
|
@ -150,6 +150,8 @@ Audio::Audio(wxTreebook *book, Preferences *parent): OptionPage(book, parent, _(
|
||||||
OptionAdd(display, _("Keyframes in karaoke mode"), "Audio/Display/Draw/Keyframes in Karaoke Mode");
|
OptionAdd(display, _("Keyframes in karaoke mode"), "Audio/Display/Draw/Keyframes in Karaoke Mode");
|
||||||
OptionAdd(display, _("Cursor time"), "Audio/Display/Draw/Cursor Time");
|
OptionAdd(display, _("Cursor time"), "Audio/Display/Draw/Cursor Time");
|
||||||
OptionAdd(display, _("Video position"), "Audio/Display/Draw/Video Position");
|
OptionAdd(display, _("Video position"), "Audio/Display/Draw/Video Position");
|
||||||
|
OptionAdd(display, _("Seconds boundaries"), "Audio/Display/Draw/Seconds");
|
||||||
|
CellSkip(display);
|
||||||
OptionChoice(display, _("Waveform Style"), AudioWaveformRenderer::GetWaveformStyles(), "Audio/Display/Waveform Style");
|
OptionChoice(display, _("Waveform Style"), AudioWaveformRenderer::GetWaveformStyles(), "Audio/Display/Waveform Style");
|
||||||
|
|
||||||
wxFlexGridSizer *label = PageSizer(_("Audio labels"));
|
wxFlexGridSizer *label = PageSizer(_("Audio labels"));
|
||||||
|
@ -224,6 +226,7 @@ Interface_Colours::Interface_Colours(wxTreebook *book, Preferences *parent): Opt
|
||||||
OptionAdd(audio, _("Line boundary end"), "Colour/Audio Display/Line boundary End");
|
OptionAdd(audio, _("Line boundary end"), "Colour/Audio Display/Line boundary End");
|
||||||
OptionAdd(audio, _("Line boundary inactive line"), "Colour/Audio Display/Line Boundary Inactive Line");
|
OptionAdd(audio, _("Line boundary inactive line"), "Colour/Audio Display/Line Boundary Inactive Line");
|
||||||
OptionAdd(audio, _("Syllable boundaries"), "Colour/Audio Display/Syllable Boundaries");
|
OptionAdd(audio, _("Syllable boundaries"), "Colour/Audio Display/Syllable Boundaries");
|
||||||
|
OptionAdd(audio, _("Seconds boundaries"), "Colour/Audio Display/Seconds Line");
|
||||||
|
|
||||||
wxFlexGridSizer *color_schemes = PageSizer(_("Audio Color Schemes"));
|
wxFlexGridSizer *color_schemes = PageSizer(_("Audio Color Schemes"));
|
||||||
wxArrayString schemes = vec_to_arrstr(OPT_GET("Audio/Colour Schemes")->GetListString());
|
wxArrayString schemes = vec_to_arrstr(OPT_GET("Audio/Colour Schemes")->GetListString());
|
||||||
|
|
Loading…
Reference in a new issue