Implement the audio scroll commands

Originally committed to SVN as r5693.
This commit is contained in:
Thomas Goyne 2011-09-30 20:41:56 +00:00
parent 597dd4bb8e
commit 5c75c9f708
3 changed files with 49 additions and 3 deletions

View File

@ -62,6 +62,7 @@
#include "audio_controller.h"
#include "audio_display.h"
#include "audio_karaoke.h"
#include "audio_timing.h"
#include "command/command.h"
#include "libresrc/libresrc.h"
#include "main.h"
@ -203,3 +204,12 @@ void AudioBox::ShowKaraokeBar(bool show) {
SetMinSize(wxSize(-1, new_height));
GetParent()->Layout();
}
void AudioBox::ScrollAudioBy(int pixel_amount) {
audioDisplay->ScrollBy(pixel_amount);
}
void AudioBox::ScrollToActiveLine() {
if (controller->GetTimingController())
audioDisplay->ScrollSampleRangeInView(controller->GetTimingController()->GetIdealVisibleSampleRange());
}

View File

@ -89,5 +89,14 @@ public:
void ShowKaraokeBar(bool show);
/// @brief Scroll the audio display
/// @param pixel_amount Number of pixels to scroll the view
///
/// A positive amount moves the display to the right, making later parts of the audio visible.
void ScrollAudioBy(int pixel_amount);
/// Make the currently active line visible in the audio display
void ScrollToActiveLine();
DECLARE_EVENT_TABLE()
};

View File

@ -45,6 +45,7 @@
#include "command.h"
#include "../ass_dialogue.h"
#include "../audio_box.h"
#include "../audio_controller.h"
#include "../audio_karaoke.h"
#include "../audio_timing.h"
@ -333,15 +334,39 @@ struct audio_commit : public Command {
};
/// Scroll the audio display to the current selection
struct audio_go_to : public Command {
struct audio_go_to : public validate_audio_open {
CMD_NAME("audio/go_to")
STR_MENU("Go to selection")
STR_DISP("Go to selection")
STR_HELP("Go to selection")
void operator()(agi::Context *c) {
//if (c->audioController->GetTimingController())
//audioDisplay->ScrollSampleRangeInView(c->audioController->GetTimingController()->GetIdealVisibleSampleRange());
c->audioBox->ScrollToActiveLine();
}
};
/// Scroll the audio display left
struct audio_scroll_left : public validate_audio_open {
CMD_NAME("audio/scroll/left")
STR_MENU("Scroll left")
STR_DISP("Scroll left")
STR_HELP("Scroll the audio display left")
void operator()(agi::Context *c) {
c->audioBox->ScrollAudioBy(-128);
}
};
/// Scroll the audio display right
struct audio_scroll_right : public validate_audio_open {
CMD_NAME("audio/scroll/right")
STR_MENU("Scroll right")
STR_DISP("Scroll right")
STR_HELP("Scroll the audio display right")
void operator()(agi::Context *c) {
c->audioBox->ScrollAudioBy(128);
}
};
@ -475,6 +500,8 @@ namespace cmd {
reg(new audio_play_selection);
reg(new audio_play_to_end);
reg(new audio_save_clip);
reg(new audio_scroll_left);
reg(new audio_scroll_right);
reg(new audio_stop);
reg(new audio_toggle_spectrum);
reg(new audio_vertical_link);