mirror of
https://github.com/odrling/Aegisub
synced 2025-04-11 22:56:02 +02:00
Audio/timing: minor style, comment
A bit more clarification of code logic. Follow predominant if/else style
This commit is contained in:
parent
85a3d1e7e1
commit
59f0fe2aeb
@ -221,14 +221,15 @@ void AudioKaraoke::RenderText() {
|
||||
// Draw each character in the line
|
||||
int y = (bmp_size.GetHeight() - char_height) / 2;
|
||||
for (size_t i = 0; i < spaced_text.size(); ++i) {
|
||||
if (!(marked_syl_start <= i && i < marked_syl_end)) {
|
||||
if (!(tap_syl_start <= i && i < tap_syl_end)) {
|
||||
// Only draw with normal color if _not_ the tap syllable
|
||||
dc.DrawText(spaced_text[i], char_x[i], y);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw marked syllable
|
||||
dc.SetTextForeground(*wxGREEN);
|
||||
for (size_t i = marked_syl_start; i < marked_syl_end; ++i)
|
||||
for (size_t i = tap_syl_start; i < tap_syl_end; ++i)
|
||||
dc.DrawText(spaced_text[i], char_x[i], y);
|
||||
|
||||
// Draw the lines between each syllable
|
||||
@ -343,15 +344,15 @@ void AudioKaraoke::OnScrollTimer(wxTimerEvent&) {
|
||||
}
|
||||
|
||||
void AudioKaraoke::OnTapMarkerChanged() {
|
||||
marked_syl_start = 0;
|
||||
marked_syl_end = 0;
|
||||
tap_syl_start = 0;
|
||||
tap_syl_end = 0;
|
||||
|
||||
if (OPT_GET("Timing/Tap To Time")->GetBool() && kara->size() > 0) {
|
||||
const AudioTimingController *tc = c->audioController->GetTimingController();
|
||||
const size_t marker_idx = tc->GetTapMarkerIndex();
|
||||
if (marker_idx > 0) {
|
||||
marked_syl_start = syl_start_points[marker_idx - 1];
|
||||
marked_syl_end =
|
||||
tap_syl_start = syl_start_points[marker_idx - 1];
|
||||
tap_syl_end =
|
||||
(marker_idx < syl_start_points.size() ?
|
||||
syl_start_points[marker_idx] :
|
||||
spaced_text.size());
|
||||
|
@ -106,8 +106,8 @@ class AudioKaraoke final : public wxWindow {
|
||||
|
||||
wxFont split_font; ///< Font used in the split/join interface
|
||||
|
||||
size_t marked_syl_start = 0;
|
||||
size_t marked_syl_end = 0;
|
||||
size_t tap_syl_start = 0; ///< Tap-to-time syllable start character index
|
||||
size_t tap_syl_end = 0; ///< Tap-to-time syllable end character index
|
||||
|
||||
bool enabled = false; ///< Is karaoke mode enabled?
|
||||
|
||||
|
@ -464,7 +464,8 @@ int AudioTimingControllerDialogue::GetTapMarkerPosition() const
|
||||
|
||||
if (tap_marker_idx == 0) {
|
||||
return *active_line.GetLeftMarker();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return *active_line.GetRightMarker();
|
||||
}
|
||||
}
|
||||
@ -612,7 +613,8 @@ void AudioTimingControllerDialogue::MoveTapMarker(int ms) {
|
||||
// Moving left marker (start time of the line)
|
||||
if (ms > *right) SetMarkers({ right }, ms, 0);
|
||||
SetMarkers({ left }, ms, 0);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Moving right marker (end time of the line)
|
||||
if (ms < *left) SetMarkers({ left }, ms, 0);
|
||||
SetMarkers({ right }, ms, 0);
|
||||
@ -705,10 +707,12 @@ std::vector<AudioMarker*> AudioTimingControllerDialogue::OnLeftClick(int ms, boo
|
||||
std::vector<AudioMarker*> AudioTimingControllerDialogue::OnRightClick(int ms, bool ctrl_down, int sensitivity, int snap_range)
|
||||
{
|
||||
if (ctrl_down) {
|
||||
// Ctrl-right-click: play audio
|
||||
context->audioController->PlayToEnd(ms);
|
||||
return {};
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Normal right-click: move right marker
|
||||
clicked_ms = INT_MIN;
|
||||
std::vector<AudioMarker*> ret = GetRightMarkers();
|
||||
SetMarkers(ret, ms, snap_range);
|
||||
|
@ -365,11 +365,11 @@ void AudioTimingControllerKaraoke::MoveTapMarker(int ms) {
|
||||
// Get syllable this time falls within
|
||||
const size_t syl = distance(markers.begin(), lower_bound(markers.begin(), markers.end(), ms));
|
||||
|
||||
// Tapping automatically all of the necessary markers for the tap marker to
|
||||
// land at the current audio position. Intuitively, it "pushes" or
|
||||
// "compresses" all of the markers in front of the tap marker. The
|
||||
// expectation is that the markers will reach their proper position once the
|
||||
// user finishes tapping to the line
|
||||
// Tapping automatically moves all of the necessary markers for the tap
|
||||
// marker to land at the current audio position. Intuitively, it "pushes" or
|
||||
// "compresses" the markers blocking the tap marker's way so they all end up
|
||||
// in the same position. The expectation is that the markers will reach their
|
||||
// proper position once the user finishes tapping to the line
|
||||
if (tap_marker_idx == 0) {
|
||||
// Moving the start time of first syllable (i.e. start time of the line)
|
||||
if (ms > end_marker) MoveEndMarker(ms);
|
||||
@ -381,11 +381,11 @@ void AudioTimingControllerKaraoke::MoveTapMarker(int ms) {
|
||||
if (ms < start_marker) MoveStartMarker(ms);
|
||||
else if (ms > end_marker) MoveEndMarker(ms);
|
||||
if (syl < tap_marker_idx) {
|
||||
// Moving marker left
|
||||
// Moving markers left
|
||||
CompressMarkers(syl, tap_marker_idx-1, ms);
|
||||
}
|
||||
else {
|
||||
// Moving marker right
|
||||
// Moving markers right
|
||||
CompressMarkers(syl-1, tap_marker_idx-1, ms);
|
||||
}
|
||||
}
|
||||
@ -455,9 +455,11 @@ std::vector<AudioMarker*> AudioTimingControllerKaraoke::OnLeftClick(int ms, bool
|
||||
|
||||
std::vector<AudioMarker*> AudioTimingControllerKaraoke::OnRightClick(int ms, bool ctrl_down, int, int) {
|
||||
if (ctrl_down) {
|
||||
// Ctrl-right-click: play audio
|
||||
c->audioController->PlayToEnd(ms);
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Normal right-click: select new syllable and play range
|
||||
cur_syl = distance(markers.begin(), lower_bound(markers.begin(), markers.end(), ms));
|
||||
AnnounceUpdatedPrimaryRange();
|
||||
AnnounceUpdatedStyleRanges();
|
||||
@ -531,7 +533,8 @@ void AudioTimingControllerKaraoke::CompressMarkers(size_t from, size_t to, int n
|
||||
MoveMarker(&markers[i], new_position);
|
||||
if (i == to) {
|
||||
break;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
i += incr;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user