mirror of https://github.com/odrling/Aegisub
Applied Harukalover's patch #1 - Added play audio/video buttons to Translation Assistant
Originally committed to SVN as r2189.
This commit is contained in:
parent
37a50cd97d
commit
0de8190b21
|
@ -43,6 +43,7 @@
|
||||||
#include "ass_file.h"
|
#include "ass_file.h"
|
||||||
#include "subs_grid.h"
|
#include "subs_grid.h"
|
||||||
#include "video_display.h"
|
#include "video_display.h"
|
||||||
|
#include "video_context.h"
|
||||||
#include "subs_edit_box.h"
|
#include "subs_edit_box.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "audio_display.h"
|
#include "audio_display.h"
|
||||||
|
@ -66,15 +67,16 @@ DialogTranslation::DialogTranslation (wxWindow *parent,AssFile *_subs,SubtitlesG
|
||||||
subs = _subs;
|
subs = _subs;
|
||||||
grid = _grid;
|
grid = _grid;
|
||||||
audio = VideoContext::Get()->audio;
|
audio = VideoContext::Get()->audio;
|
||||||
|
video = video->Get();
|
||||||
|
|
||||||
// Translation controls
|
// Translation controls
|
||||||
OrigText = new ScintillaTextCtrl(this,TEXT_ORIGINAL,_T(""),wxDefaultPosition,wxSize(300,80));
|
OrigText = new ScintillaTextCtrl(this,TEXT_ORIGINAL,_T(""),wxDefaultPosition,wxSize(320,80));
|
||||||
OrigText->SetWrapMode(wxSTC_WRAP_WORD);
|
OrigText->SetWrapMode(wxSTC_WRAP_WORD);
|
||||||
OrigText->SetMarginWidth(1,0);
|
OrigText->SetMarginWidth(1,0);
|
||||||
OrigText->StyleSetForeground(1,wxColour(10,60,200));
|
OrigText->StyleSetForeground(1,wxColour(10,60,200));
|
||||||
OrigText->SetReadOnly(true);
|
OrigText->SetReadOnly(true);
|
||||||
//OrigText->PushEventHandler(new DialogTranslationEvent(this));
|
//OrigText->PushEventHandler(new DialogTranslationEvent(this));
|
||||||
TransText = new ScintillaTextCtrl(this,TEXT_TRANS,_T(""),wxDefaultPosition,wxSize(300,80));
|
TransText = new ScintillaTextCtrl(this,TEXT_TRANS,_T(""),wxDefaultPosition,wxSize(320,80));
|
||||||
TransText->SetWrapMode(wxSTC_WRAP_WORD);
|
TransText->SetWrapMode(wxSTC_WRAP_WORD);
|
||||||
TransText->SetMarginWidth(1,0);
|
TransText->SetMarginWidth(1,0);
|
||||||
TransText->PushEventHandler(new DialogTranslationEvent(this));
|
TransText->PushEventHandler(new DialogTranslationEvent(this));
|
||||||
|
@ -104,7 +106,9 @@ DialogTranslation::DialogTranslation (wxWindow *parent,AssFile *_subs,SubtitlesG
|
||||||
KeysInnerSizer->Add(new wxStaticText(this,-1,_("Next line")));
|
KeysInnerSizer->Add(new wxStaticText(this,-1,_("Next line")));
|
||||||
KeysInnerSizer->Add(new wxStaticText(this,-1,Hotkeys.GetText(_T("Translation Assistant Insert Original")) + _T(": ")));
|
KeysInnerSizer->Add(new wxStaticText(this,-1,Hotkeys.GetText(_T("Translation Assistant Insert Original")) + _T(": ")));
|
||||||
KeysInnerSizer->Add(new wxStaticText(this,-1,_("Insert original")));
|
KeysInnerSizer->Add(new wxStaticText(this,-1,_("Insert original")));
|
||||||
KeysInnerSizer->Add(new wxStaticText(this,-1,Hotkeys.GetText(_T("Translation Assistant Play")) + _T(": ")));
|
KeysInnerSizer->Add(new wxStaticText(this,-1,Hotkeys.GetText(_T("Translation Assistant Play Video")) + _T(": ")));
|
||||||
|
KeysInnerSizer->Add(new wxStaticText(this,-1,_("Play Video")));
|
||||||
|
KeysInnerSizer->Add(new wxStaticText(this,-1,Hotkeys.GetText(_T("Translation Assistant Play Audio")) + _T(": ")));
|
||||||
KeysInnerSizer->Add(new wxStaticText(this,-1,_("Play Audio")));
|
KeysInnerSizer->Add(new wxStaticText(this,-1,_("Play Audio")));
|
||||||
PreviewCheck = new wxCheckBox(this,PREVIEW_CHECK,_("Enable preview"));
|
PreviewCheck = new wxCheckBox(this,PREVIEW_CHECK,_("Enable preview"));
|
||||||
PreviewCheck->SetValue(preview);
|
PreviewCheck->SetValue(preview);
|
||||||
|
@ -112,20 +116,30 @@ DialogTranslation::DialogTranslation (wxWindow *parent,AssFile *_subs,SubtitlesG
|
||||||
KeysSizer->Add(KeysInnerSizer,0,wxEXPAND,0);
|
KeysSizer->Add(KeysInnerSizer,0,wxEXPAND,0);
|
||||||
KeysSizer->Add(PreviewCheck,0,wxTOP,5);
|
KeysSizer->Add(PreviewCheck,0,wxTOP,5);
|
||||||
|
|
||||||
|
// Tool sizer
|
||||||
|
wxStaticBoxSizer *ToolSizer = new wxStaticBoxSizer(wxVERTICAL,this, _("Actions"));
|
||||||
|
wxButton *PlayVideoButton = new wxButton(this,BUTTON_TRANS_PLAY_VIDEO,_("Play Video"));
|
||||||
|
wxButton *PlayAudioButton = new wxButton(this,BUTTON_TRANS_PLAY_AUDIO,_("Play Audio"));
|
||||||
|
PlayVideoButton->Enable(video->IsLoaded());
|
||||||
|
PlayAudioButton->Enable(audio->loaded);
|
||||||
|
ToolSizer->Add(PlayAudioButton,0,wxALL,5);
|
||||||
|
ToolSizer->Add(PlayVideoButton,0,wxLEFT | wxRIGHT | wxBOTTOM,5);
|
||||||
|
|
||||||
|
// Hotkeys + Tool sizer
|
||||||
|
wxBoxSizer *HTSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
HTSizer->Add(KeysSizer,1,wxRIGHT | wxEXPAND,5);
|
||||||
|
HTSizer->Add(ToolSizer,0);
|
||||||
|
|
||||||
// Button sizer
|
// Button sizer
|
||||||
wxStdDialogButtonSizer *ButtonSizer = new wxStdDialogButtonSizer();
|
wxStdDialogButtonSizer *ButtonSizer = new wxStdDialogButtonSizer();
|
||||||
wxButton *PlayButton = new wxButton(this,BUTTON_TRANS_PLAY,_("Play Audio"));
|
|
||||||
PlayButton->Enable(audio->loaded);
|
|
||||||
ButtonSizer->AddButton(PlayButton);
|
|
||||||
ButtonSizer->AddButton(new wxButton(this,wxID_CANCEL));
|
ButtonSizer->AddButton(new wxButton(this,wxID_CANCEL));
|
||||||
ButtonSizer->AddButton(new HelpButton(this,_T("Translation Assistant")));
|
ButtonSizer->AddButton(new HelpButton(this,_T("Translation Assistant")));
|
||||||
ButtonSizer->SetAffirmativeButton(PlayButton);
|
|
||||||
ButtonSizer->Realize();
|
ButtonSizer->Realize();
|
||||||
|
|
||||||
// General layout
|
// General layout
|
||||||
wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
|
wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
MainSizer->Add(TranslationSizer,1,wxALL | wxEXPAND,5);
|
MainSizer->Add(TranslationSizer,1,wxALL | wxEXPAND,5);
|
||||||
MainSizer->Add(KeysSizer,0,wxLEFT | wxBOTTOM | wxRIGHT | wxEXPAND,5);
|
MainSizer->Add(HTSizer,0,wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND,5);
|
||||||
MainSizer->Add(ButtonSizer,0,wxALIGN_RIGHT | wxLEFT | wxBOTTOM | wxRIGHT,5);
|
MainSizer->Add(ButtonSizer,0,wxALIGN_RIGHT | wxLEFT | wxBOTTOM | wxRIGHT,5);
|
||||||
|
|
||||||
// Set sizer
|
// Set sizer
|
||||||
|
@ -235,21 +249,12 @@ void DialogTranslation::UpdatePreview () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////
|
|
||||||
// Play audio
|
|
||||||
void DialogTranslation::Play() {
|
|
||||||
if (audio->loaded) {
|
|
||||||
audio->Play(current->Start.GetMS(),current->End.GetMS());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
// Event table
|
// Event table
|
||||||
BEGIN_EVENT_TABLE(DialogTranslation, wxDialog)
|
BEGIN_EVENT_TABLE(DialogTranslation, wxDialog)
|
||||||
EVT_BUTTON(wxID_CLOSE,DialogTranslation::OnClose)
|
EVT_BUTTON(wxID_CLOSE,DialogTranslation::OnClose)
|
||||||
EVT_BUTTON(BUTTON_TRANS_PLAY,DialogTranslation::OnPlayButton)
|
EVT_BUTTON(BUTTON_TRANS_PLAY_VIDEO,DialogTranslation::OnPlayVideoButton)
|
||||||
|
EVT_BUTTON(BUTTON_TRANS_PLAY_AUDIO,DialogTranslation::OnPlayAudioButton)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
|
@ -357,9 +362,21 @@ void DialogTranslation::OnTransBoxKey(wxKeyEvent &event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Play video
|
||||||
|
if (Hotkeys.IsPressed(_T("Translation Assistant Play Video"))) {
|
||||||
|
if (video->IsLoaded()) {
|
||||||
|
video->PlayLine();
|
||||||
|
TransText->SetFocus();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Play audio
|
// Play audio
|
||||||
if (Hotkeys.IsPressed(_T("Translation Assistant Play"))) {
|
if (Hotkeys.IsPressed(_T("Translation Assistant Play Audio"))) {
|
||||||
Play();
|
if (audio->loaded) {
|
||||||
|
audio->Play(current->Start.GetMS(),current->End.GetMS());
|
||||||
|
TransText->SetFocus();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,10 +391,18 @@ void DialogTranslation::OnTransBoxKey(wxKeyEvent &event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////
|
/////////////////////
|
||||||
// Play button
|
// Play video button
|
||||||
void DialogTranslation::OnPlayButton(wxCommandEvent &event) {
|
void DialogTranslation::OnPlayVideoButton(wxCommandEvent &event) {
|
||||||
Play();
|
video->PlayLine();
|
||||||
|
TransText->SetFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////
|
||||||
|
// Play audio button
|
||||||
|
void DialogTranslation::OnPlayAudioButton(wxCommandEvent &event) {
|
||||||
|
audio->Play(current->Start.GetMS(),current->End.GetMS());
|
||||||
TransText->SetFocus();
|
TransText->SetFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,13 +50,14 @@ class AssFile;
|
||||||
class AssDialogue;
|
class AssDialogue;
|
||||||
class SubtitlesGrid;
|
class SubtitlesGrid;
|
||||||
class AudioDisplay;
|
class AudioDisplay;
|
||||||
|
class VideoContext;
|
||||||
|
|
||||||
/////////
|
/////////
|
||||||
// Class
|
// Class
|
||||||
class DialogTranslation : public wxDialog {
|
class DialogTranslation : public wxDialog {
|
||||||
private:
|
private:
|
||||||
AudioDisplay *audio;
|
AudioDisplay *audio;
|
||||||
|
VideoContext *video;
|
||||||
AssFile *subs;
|
AssFile *subs;
|
||||||
SubtitlesGrid *grid;
|
SubtitlesGrid *grid;
|
||||||
AssDialogue *current;
|
AssDialogue *current;
|
||||||
|
@ -70,7 +71,8 @@ private:
|
||||||
wxCheckBox *PreviewCheck;
|
wxCheckBox *PreviewCheck;
|
||||||
|
|
||||||
void OnMinimize(wxIconizeEvent &event);
|
void OnMinimize(wxIconizeEvent &event);
|
||||||
void OnPlayButton(wxCommandEvent &event);
|
void OnPlayAudioButton(wxCommandEvent &event);
|
||||||
|
void OnPlayVideoButton(wxCommandEvent &event);
|
||||||
void OnClose(wxCommandEvent &event);
|
void OnClose(wxCommandEvent &event);
|
||||||
|
|
||||||
bool JumpToLine(int n,int block);
|
bool JumpToLine(int n,int block);
|
||||||
|
@ -82,7 +84,6 @@ public:
|
||||||
bool enablePreview;
|
bool enablePreview;
|
||||||
DialogTranslation (wxWindow *parent,AssFile *subs,SubtitlesGrid *grid,int startrow=0,bool preview=false);
|
DialogTranslation (wxWindow *parent,AssFile *subs,SubtitlesGrid *grid,int startrow=0,bool preview=false);
|
||||||
|
|
||||||
void Play();
|
|
||||||
void OnTransBoxKey(wxKeyEvent &event);
|
void OnTransBoxKey(wxKeyEvent &event);
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
@ -110,7 +111,8 @@ enum {
|
||||||
TEXT_ORIGINAL = 1100,
|
TEXT_ORIGINAL = 1100,
|
||||||
TEXT_TRANS,
|
TEXT_TRANS,
|
||||||
PREVIEW_CHECK,
|
PREVIEW_CHECK,
|
||||||
BUTTON_TRANS_PLAY
|
BUTTON_TRANS_PLAY_AUDIO,
|
||||||
|
BUTTON_TRANS_PLAY_VIDEO
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue