Implement almost all stubbed-out commands other than the MRU ones

Originally committed to SVN as r5196.
This commit is contained in:
Thomas Goyne 2011-01-16 07:15:24 +00:00
parent 7afbce439d
commit 9779eacbf1
14 changed files with 213 additions and 136 deletions

View file

@ -70,8 +70,7 @@ public:
STR_HELP("About Aegisub.") STR_HELP("About Aegisub.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
AboutScreen About(c->parent); AboutScreen(c->parent).ShowModal();
About.ShowModal();
} }
}; };
@ -85,7 +84,6 @@ public:
STR_HELP("Display audio and subtitles only.") STR_HELP("Display audio and subtitles only.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
if (!c->audioController->IsAudioOpen()) return;
wxGetApp().frame->SetDisplayMode(0,1); wxGetApp().frame->SetDisplayMode(0,1);
} }
}; };
@ -100,7 +98,6 @@ public:
STR_HELP("Display audio, video and subtitles.") STR_HELP("Display audio, video and subtitles.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
if (!c->audioController->IsAudioOpen() || !VideoContext::Get()->IsLoaded()) return;
wxGetApp().frame->SetDisplayMode(1,1); wxGetApp().frame->SetDisplayMode(1,1);
} }
}; };
@ -143,7 +140,7 @@ public:
STR_HELP("Exit the application.") STR_HELP("Exit the application.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
printf("XXX: not working yet\n"); wxGetApp().frame->Close();
} }
}; };
@ -162,21 +159,16 @@ public:
int old = app->locale.curCode; int old = app->locale.curCode;
int newCode = app->locale.PickLanguage(); int newCode = app->locale.PickLanguage();
// Is OK? // Is OK?
if (newCode != -1) { if (newCode != -1 && newCode != old) {
// Set code // Set code
OPT_SET("App/Locale")->SetInt(newCode); OPT_SET("App/Locale")->SetInt(newCode);
// Language actually changed? // Ask to restart program
if (newCode != old) { int result = wxMessageBox(_T("Aegisub needs to be restarted so that the new language can be applied. Restart now?"),_T("Restart Aegisub?"),wxICON_QUESTION | wxYES_NO);
// Ask to restart program if (result == wxYES) {
int result = wxMessageBox(_T("Aegisub needs to be restarted so that the new language can be applied. Restart now?"),_T("Restart Aegisub?"),wxICON_QUESTION | wxYES_NO); // Restart Aegisub
if (result == wxYES) { if (wxGetApp().frame->Close()) {
// Restart Aegisub RestartAegisub();
if (wxGetApp().frame->Close()) {
RestartAegisub();
//wxStandardPaths stand;
//wxExecute(_T("\"") + stand.GetExecutablePath() + _T("\""));
}
} }
} }
} }
@ -193,8 +185,7 @@ public:
STR_HELP("Event log.") STR_HELP("Event log.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
LogWindow *log = new LogWindow(c->parent); (new LogWindow(c->parent))->Show(1);
log->Show(1);
} }
}; };
@ -223,8 +214,7 @@ public:
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
try { try {
Preferences pref(c->parent); Preferences(c->parent).ShowModal();
pref.ShowModal();
} catch (agi::Exception& e) { } catch (agi::Exception& e) {
LOG_E("config/init") << "Caught exception: " << e.GetName() << " -> " << e.GetMessage(); LOG_E("config/init") << "Caught exception: " << e.GetName() << " -> " << e.GetMessage();
} }

View file

@ -141,7 +141,7 @@ public:
STR_HELP("Display audio as a frequency-power spectrograph.") STR_HELP("Display audio as a frequency-power spectrograph.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
printf("XXX: fixme\n"); OPT_SET("Audio/Spectrum")->SetBool(true);
} }
}; };
@ -155,7 +155,7 @@ public:
STR_HELP("Display audio as a linear amplitude graph.") STR_HELP("Display audio as a linear amplitude graph.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
printf("XXX: fixme\n"); OPT_SET("Audio/Spectrum")->SetBool(false);
} }
}; };

View file

@ -68,12 +68,13 @@ public:
#ifdef __APPLE__ #ifdef __APPLE__
if (wxGetMouseState().CmdDown()) { if (wxGetMouseState().CmdDown()) {
#else #else
if (wxGetMouseState().ControlDown()) { if (wxGetMouseState().ControlDown()) {
#endif #endif
wxGetApp().global_scripts->Reload(); wxGetApp().global_scripts->Reload();
if (wxGetMouseState().ShiftDown()) {
const std::vector<Automation4::Script*> scripts = c->local_scripts->GetScripts(); if (wxGetMouseState().ShiftDown()) {
for (size_t i = 0; i < scripts.size(); ++i) { const std::vector<Automation4::Script*>& scripts = c->local_scripts->GetScripts();
for (size_t i = 0; i < scripts.size(); ++i) {
try { try {
scripts[i]->Reload(); scripts[i]->Reload();
} catch (const wchar_t *e) { } catch (const wchar_t *e) {
@ -84,13 +85,14 @@ public:
} }
wxGetApp().frame->StatusTimeout(_("Reloaded all Automation scripts")); wxGetApp().frame->StatusTimeout(_("Reloaded all Automation scripts"));
} else { }
else {
wxGetApp().frame->StatusTimeout(_("Reloaded autoload Automation scripts")); wxGetApp().frame->StatusTimeout(_("Reloaded autoload Automation scripts"));
} }
} else { }
VideoContext::Get()->Stop(); else {
DialogAutomation dlg(c->parent, c->local_scripts); c->videoContext->Stop();
dlg.ShowModal(); DialogAutomation(c->parent, c->local_scripts).ShowModal();
} }
#endif #endif
} }

View file

@ -101,7 +101,7 @@ public:
STR_HELP("Delete currently selected lines.") STR_HELP("Delete currently selected lines.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: subs_grid.cpp c->SubsGrid->DeleteLines(c->SubsGrid->GetSelection());
} }
}; };
@ -115,7 +115,8 @@ public:
STR_HELP("Duplicate the selected lines.") STR_HELP("Duplicate the selected lines.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: subs_grid.cpp wxArrayInt sels = c->SubsGrid->GetSelection();
c->SubsGrid->DuplicateLines(sels.front(), sels.back(), false);
} }
}; };
@ -129,7 +130,8 @@ public:
STR_HELP("Duplicate lines and shift by one frame.") STR_HELP("Duplicate lines and shift by one frame.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: subs_grid.cpp wxArrayInt sels = c->SubsGrid->GetSelection();
c->SubsGrid->DuplicateLines(sels.front(), sels.back(), true);
} }
}; };
@ -143,7 +145,8 @@ public:
STR_HELP("Joins selected lines in a single one, as karaoke.") STR_HELP("Joins selected lines in a single one, as karaoke.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: subs_grid.cpp wxArrayInt sels = c->SubsGrid->GetSelection();
c->SubsGrid->JoinAsKaraoke(sels.front(), sels.back());
} }
}; };
@ -157,7 +160,8 @@ public:
STR_HELP("Joins selected lines in a single one, concatenating text together.") STR_HELP("Joins selected lines in a single one, concatenating text together.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: subs_grid.cpp wxArrayInt sels = c->SubsGrid->GetSelection();
c->SubsGrid->JoinLines(sels.front(), sels.back(), true);
} }
}; };
@ -171,7 +175,8 @@ public:
STR_HELP("Joins selected lines in a single one, keeping text of first and discarding remaining.") STR_HELP("Joins selected lines in a single one, keeping text of first and discarding remaining.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: subs_grid.cpp wxArrayInt sels = c->SubsGrid->GetSelection();
c->SubsGrid->JoinLines(sels.front(), sels.back(), false);
} }
}; };
@ -217,7 +222,7 @@ public:
STR_HELP("Recombine subtitles when they have been split and merged.") STR_HELP("Recombine subtitles when they have been split and merged.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: subs_grid.cpp //XXX: subs_grid.cpp
} }
}; };
@ -231,7 +236,16 @@ public:
STR_HELP("Uses karaoke timing to split line into multiple smaller lines.") STR_HELP("Uses karaoke timing to split line into multiple smaller lines.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: subs_grid.cpp c->SubsGrid->BeginBatch();
wxArrayInt sels = c->SubsGrid->GetSelection();
bool didSplit = false;
for (int i = sels.size() - 1; i >= 0; --i) {
didSplit |= c->SubsGrid->SplitLineByKaraoke(sels[i]);
}
if (didSplit) {
c->ass->Commit(_("splitting"));
}
c->SubsGrid->EndBatch();
} }
}; };
@ -245,7 +259,8 @@ public:
STR_HELP("Swaps the two selected lines.") STR_HELP("Swaps the two selected lines.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: subs_grid.cpp wxArrayInt sels = c->SubsGrid->GetSelection();
c->SubsGrid->SwapLines(sels.front(), sels.back());
} }
}; };
@ -259,7 +274,7 @@ public:
STR_HELP("Redoes last action.") STR_HELP("Redoes last action.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
c->ass->Redo(); c->ass->Redo();
} }
}; };
@ -274,7 +289,7 @@ public:
STR_HELP("Find and replace words in subtitles.") STR_HELP("Find and replace words in subtitles.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
Search.OpenDialog(true); Search.OpenDialog(true);
} }
}; };
@ -289,7 +304,7 @@ public:
STR_HELP("Undoes last action.") STR_HELP("Undoes last action.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
c->ass->Undo(); c->ass->Undo();
} }
}; };

View file

@ -121,9 +121,8 @@ public:
STR_HELP("Hide override tags in the subtitle grid.") STR_HELP("Hide override tags in the subtitle grid.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
// XXX: Needs fixing. OPT_SET("Subtitle/Grid/Hide Overrides")->SetInt(2);
// OPT_SET("Subtitle/Grid/Hide Overrides")->SetInt(event.GetId() - cmd::id("subtitle/tags/show")); c->SubsGrid->Refresh(false);
// SubsGrid->Refresh(false);
} }
}; };
@ -137,7 +136,8 @@ public:
STR_HELP("Show full override tags in the subtitle grid.") STR_HELP("Show full override tags in the subtitle grid.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: see grid_tags_hide OPT_SET("Subtitle/Grid/Hide Overrides")->SetInt(0);
c->SubsGrid->Refresh(false);
} }
}; };
@ -151,7 +151,8 @@ public:
STR_HELP("Replace override tags in the subtitle grid with a simplified placeholder.") STR_HELP("Replace override tags in the subtitle grid with a simplified placeholder.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: see grid_tags_hide OPT_SET("Subtitle/Grid/Hide Overrides")->SetInt(1);
c->SubsGrid->Refresh(false);
} }
}; };

View file

@ -63,7 +63,7 @@ public:
STR_HELP("Closes the currently open keyframes list.") STR_HELP("Closes the currently open keyframes list.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->CloseKeyframes(); c->videoContext->CloseKeyframes();
} }
}; };
@ -88,10 +88,8 @@ public:
if (filename.empty()) return; if (filename.empty()) return;
OPT_SET("Path/Last/Keyframes")->SetString(STD_STR(filename)); OPT_SET("Path/Last/Keyframes")->SetString(STD_STR(filename));
c->videoContext->LoadKeyframes(filename);
// Load }
VideoContext::Get()->LoadKeyframes(filename);
}
}; };
@ -106,9 +104,9 @@ public:
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
wxString path = lagi_wxString(OPT_GET("Path/Last/Keyframes")->GetString()); wxString path = lagi_wxString(OPT_GET("Path/Last/Keyframes")->GetString());
wxString filename = wxFileSelector(_T("Select the Keyframes file to open"),path,_T(""),_T("*.key.txt"),_T("Text files (*.txt)|*.txt"),wxFD_OVERWRITE_PROMPT | wxFD_SAVE); wxString filename = wxFileSelector(_T("Select the Keyframes file to open"),path,_T(""),_T("*.key.txt"),_T("Text files (*.txt)|*.txt"),wxFD_OVERWRITE_PROMPT | wxFD_SAVE);
if (filename.IsEmpty()) return; if (filename.empty()) return;
OPT_SET("Path/Last/Keyframes")->SetString(STD_STR(filename)); OPT_SET("Path/Last/Keyframes")->SetString(STD_STR(filename));
VideoContext::Get()->SaveKeyframes(filename); c->videoContext->SaveKeyframes(filename);
} }
}; };

View file

@ -76,7 +76,7 @@ public:
STR_HELP("Recent keyframes.") STR_HELP("Recent keyframes.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
// VideoContext::Get()->LoadKeyframes(lagi_wxString(config::mru->GetEntry("Keyframes", event.GetId()-cmd::id("recent/keyframe")))); // c->videoContext->LoadKeyframes(lagi_wxString(config::mru->GetEntry("Keyframes", event.GetId()-cmd::id("recent/keyframe"))));
} }
}; };

View file

@ -48,6 +48,7 @@
#include "command.h" #include "command.h"
#include "../ass_dialogue.h"
#include "../ass_file.h" #include "../ass_file.h"
#include "../compat.h" #include "../compat.h"
#include "../dialog_attachments.h" #include "../dialog_attachments.h"
@ -75,9 +76,8 @@ public:
STR_HELP("Open the attachment list.") STR_HELP("Open the attachment list.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
DialogAttachments attachments(c->parent, c->ass); DialogAttachments(c->parent, c->ass).ShowModal();
attachments.ShowModal();
} }
}; };
@ -91,7 +91,7 @@ public:
STR_HELP("Find words in subtitles.") STR_HELP("Find words in subtitles.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
Search.OpenDialog(false); Search.OpenDialog(false);
} }
}; };
@ -106,11 +106,28 @@ public:
STR_HELP("Find next match of last word.") STR_HELP("Find next match of last word.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
Search.FindNext(); Search.FindNext();
} }
}; };
static void insert_subtitle_at_video(agi::Context *c, bool after) {
int n = c->SubsGrid->GetFirstSelRow();
// Create line to add
AssDialogue *def = new AssDialogue;
int video_ms = c->videoContext->TimeAtFrame(c->videoContext->GetFrameN(), agi::vfr::START);
def->Start.SetMS(video_ms);
def->End.SetMS(video_ms + OPT_GET("Timing/Default Duration")->GetInt());
def->Style = c->SubsGrid->GetDialogue(n)->Style;
// Insert it
c->SubsGrid->BeginBatch();
c->SubsGrid->InsertLine(def, n, after);
c->SubsGrid->SelectRow(n + after);
c->SubsGrid->SetActiveLine(def);
c->SubsGrid->EndBatch();
}
/// Inserts a line after current. /// Inserts a line after current.
class subtitle_insert_after: public Command { class subtitle_insert_after: public Command {
@ -121,11 +138,32 @@ public:
STR_HELP("Inserts a line after current.") STR_HELP("Inserts a line after current.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: subs_grid.cpp int n = c->SubsGrid->GetFirstSelRow();
int nrows = c->SubsGrid->GetRows();
// Create line to add
AssDialogue *def = new AssDialogue;
if (n == nrows-1) {
def->Start = c->SubsGrid->GetDialogue(n)->End;
def->End = c->SubsGrid->GetDialogue(n)->End;
def->End.SetMS(def->End.GetMS()+OPT_GET("Timing/Default Duration")->GetInt());
}
else {
def->Start = c->SubsGrid->GetDialogue(n)->End;
def->End = c->SubsGrid->GetDialogue(n+1)->Start;
}
if (def->End.GetMS() < def->Start.GetMS()) def->End.SetMS(def->Start.GetMS()+OPT_GET("Timing/Default Duration")->GetInt());
def->Style = c->SubsGrid->GetDialogue(n)->Style;
// Insert it
c->SubsGrid->BeginBatch();
c->SubsGrid->InsertLine(def, n, true);
c->SubsGrid->SelectRow(n + 1);
c->SubsGrid->SetActiveLine(def);
c->SubsGrid->EndBatch();
} }
}; };
/// Inserts a line after current, starting at video time. /// Inserts a line after current, starting at video time.
class subtitle_insert_after_videotime: public Command { class subtitle_insert_after_videotime: public Command {
public: public:
@ -135,7 +173,7 @@ public:
STR_HELP("Inserts a line after current, starting at video time.") STR_HELP("Inserts a line after current, starting at video time.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: subs_grid.cpp insert_subtitle_at_video(c, true);
} }
}; };
@ -149,7 +187,31 @@ public:
STR_HELP("Inserts a line before current.") STR_HELP("Inserts a line before current.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: subs_grid.cpp int n = c->SubsGrid->GetFirstSelRow();
// Create line to add
AssDialogue *def = new AssDialogue;
if (n == 0) {
def->Start.SetMS(0);
def->End = c->SubsGrid->GetDialogue(n)->Start;
}
else if (c->SubsGrid->GetDialogue(n-1)->End.GetMS() > c->SubsGrid->GetDialogue(n)->Start.GetMS()) {
def->Start.SetMS(c->SubsGrid->GetDialogue(n)->Start.GetMS()-OPT_GET("Timing/Default Duration")->GetInt());
def->End = c->SubsGrid->GetDialogue(n)->Start;
}
else {
def->Start = c->SubsGrid->GetDialogue(n-1)->End;
def->End = c->SubsGrid->GetDialogue(n)->Start;
}
if (def->End.GetMS() < def->Start.GetMS()) def->End.SetMS(def->Start.GetMS()+OPT_GET("Timing/Default Duration")->GetInt());
def->Style = c->SubsGrid->GetDialogue(n)->Style;
// Insert it
c->SubsGrid->BeginBatch();
c->SubsGrid->InsertLine(def, n, false);
c->SubsGrid->SelectRow(n);
c->SubsGrid->SetActiveLine(def);
c->SubsGrid->EndBatch();
} }
}; };
@ -163,7 +225,7 @@ public:
STR_HELP("Inserts a line before current, starting at video time.") STR_HELP("Inserts a line before current, starting at video time.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: subs_grid.cpp insert_subtitle_at_video(c, false);
} }
}; };
@ -236,7 +298,7 @@ public:
STR_HELP("Opens the subtitles from the current video file.") STR_HELP("Opens the subtitles from the current video file.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
wxGetApp().frame->LoadSubtitles(VideoContext::Get()->videoName, "binary"); wxGetApp().frame->LoadSubtitles(c->videoContext->videoName, "binary");
} }
}; };
@ -250,9 +312,8 @@ public:
STR_HELP("Open script properties window.") STR_HELP("Open script properties window.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
DialogProperties Properties(c->parent, c->ass); DialogProperties(c->parent, c->ass).ShowModal();
Properties.ShowModal();
} }
}; };
@ -295,7 +356,7 @@ public:
STR_HELP("Selects all lines that are currently visible on video frame.") STR_HELP("Selects all lines that are currently visible on video frame.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
c->SubsGrid->SelectVisible(); c->SubsGrid->SelectVisible();
} }
}; };
@ -311,8 +372,8 @@ public:
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: This is obscene, requires refactoring the spellchecker. //XXX: This is obscene, requires refactoring the spellchecker.
// VideoContext::Get()->Stop(); c->videoContext->Stop();
// new DialogSpellChecker; new DialogSpellChecker(wxGetApp().frame);
} }
}; };

View file

@ -65,7 +65,8 @@ public:
STR_HELP("Changes times of subs so end times begin on next's start time.") STR_HELP("Changes times of subs so end times begin on next's start time.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: subs_grid.cpp wxArrayInt sels = c->SubsGrid->GetSelection();
c->SubsGrid->AdjoinLines(sels.front(), sels.back(), false);
} }
}; };
@ -79,7 +80,8 @@ public:
STR_HELP("Changes times of subs so start times begin on previous's end time.") STR_HELP("Changes times of subs so start times begin on previous's end time.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: subs_grid.cpp wxArrayInt sels = c->SubsGrid->GetSelection();
c->SubsGrid->AdjoinLines(sels.front(), sels.back(), true);
} }
}; };
@ -94,7 +96,7 @@ public:
STR_HELP("Shift selection so first selected line starts at current frame.") STR_HELP("Shift selection so first selected line starts at current frame.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
if (!VideoContext::Get()->IsLoaded()) return; if (!c->videoContext->IsLoaded()) return;
wxArrayInt sels = c->SubsGrid->GetSelection(); wxArrayInt sels = c->SubsGrid->GetSelection();
size_t n=sels.Count(); size_t n=sels.Count();
@ -103,7 +105,7 @@ public:
// Get shifting in ms // Get shifting in ms
AssDialogue *cur = c->SubsGrid->GetDialogue(sels[0]); AssDialogue *cur = c->SubsGrid->GetDialogue(sels[0]);
if (!cur) return; if (!cur) return;
int shiftBy = VideoContext::Get()->TimeAtFrame(VideoContext::Get()->GetFrameN(),agi::vfr::START) - cur->Start.GetMS(); int shiftBy = c->videoContext->TimeAtFrame(c->videoContext->GetFrameN(),agi::vfr::START) - cur->Start.GetMS();
// Update // Update
for (size_t i=0;i<n;i++) { for (size_t i=0;i<n;i++) {
@ -129,9 +131,8 @@ public:
STR_HELP("Shift subtitles by time or frames.") STR_HELP("Shift subtitles by time or frames.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
DialogShiftTimes Shift(c->parent, c->SubsGrid); DialogShiftTimes(c->parent, c->SubsGrid).ShowModal();
Shift.ShowModal();
} }
}; };
@ -160,7 +161,23 @@ public:
STR_HELP("Shift selected subtitles so first selected starts at this frame.") STR_HELP("Shift selected subtitles so first selected starts at this frame.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: needs contents. if (c->videoContext->IsLoaded()) return;
wxArrayInt sels = c->SubsGrid->GetSelection();
if (sels.empty()) return;
AssDialogue *cur = c->SubsGrid->GetDialogue(sels[0]);
if (!cur) return;
int shiftBy = c->videoContext->TimeAtFrame(c->videoContext->GetFrameN(),agi::vfr::START) - cur->Start.GetMS();
for (size_t i = 0; i < sels.size(); ++i) {
if (cur = c->SubsGrid->GetDialogue(sels[i])) {
cur->Start.SetMS(cur->Start.GetMS() + shiftBy);
cur->End.SetMS(cur->End.GetMS() + shiftBy);
}
}
c->ass->Commit(_("shift to frame"));
} }
}; };
@ -174,7 +191,7 @@ public:
STR_HELP("Set start and end of subtitles to the keyframes around current video frame.") STR_HELP("Set start and end of subtitles to the keyframes around current video frame.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext *con = VideoContext::Get(); VideoContext *con = c->videoContext;
if (!con->IsLoaded() || !con->KeyFramesLoaded()) return; if (!con->IsLoaded() || !con->KeyFramesLoaded()) return;
// Get frames // Get frames

View file

@ -64,7 +64,7 @@ public:
STR_HELP("Closes the currently open timecodes file.") STR_HELP("Closes the currently open timecodes file.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->CloseTimecodes(); c->videoContext->CloseTimecodes();
} }
}; };
@ -82,7 +82,7 @@ public:
wxString str = wxString(_("All Supported Types")) + _T("(*.txt)|*.txt|") + _("All Files") + _T(" (*.*)|*.*"); wxString str = wxString(_("All Supported Types")) + _T("(*.txt)|*.txt|") + _("All Files") + _T(" (*.*)|*.*");
wxString filename = wxFileSelector(_("Open timecodes file"),path,_T(""),_T(""),str,wxFD_OPEN | wxFD_FILE_MUST_EXIST); wxString filename = wxFileSelector(_("Open timecodes file"),path,_T(""),_T(""),str,wxFD_OPEN | wxFD_FILE_MUST_EXIST);
if (!filename.empty()) { if (!filename.empty()) {
VideoContext::Get()->LoadTimecodes(filename); c->videoContext->LoadTimecodes(filename);
OPT_SET("Path/Last/Timecodes")->SetString(STD_STR(filename)); OPT_SET("Path/Last/Timecodes")->SetString(STD_STR(filename));
} }
} }
@ -102,7 +102,7 @@ public:
wxString str = wxString(_("All Supported Types")) + _T("(*.txt)|*.txt|") + _("All Files") + _T(" (*.*)|*.*"); wxString str = wxString(_("All Supported Types")) + _T("(*.txt)|*.txt|") + _("All Files") + _T(" (*.*)|*.*");
wxString filename = wxFileSelector(_("Save timecodes file"),path,_T(""),_T(""),str,wxFD_SAVE | wxFD_OVERWRITE_PROMPT); wxString filename = wxFileSelector(_("Save timecodes file"),path,_T(""),_T(""),str,wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
if (!filename.empty()) { if (!filename.empty()) {
VideoContext::Get()->SaveTimecodes(filename); c->videoContext->SaveTimecodes(filename);
OPT_SET("Path/Last/Timecodes")->SetString(STD_STR(filename)); OPT_SET("Path/Last/Timecodes")->SetString(STD_STR(filename));
} }
} }

View file

@ -85,9 +85,8 @@ public:
STR_HELP("Saves a copy of subtitles with processing applied to it.") STR_HELP("Saves a copy of subtitles with processing applied to it.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
DialogResample diag(c->parent, c->SubsGrid); DialogResample(c->parent, c->SubsGrid).ShowModal();
diag.ShowModal();
} }
}; };
@ -101,9 +100,8 @@ public:
STR_HELP("Open fonts collector.") STR_HELP("Open fonts collector.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
DialogFontsCollector Collector(c->parent, c->ass); DialogFontsCollector(c->parent, c->ass).ShowModal();
Collector.ShowModal();
} }
}; };
@ -117,9 +115,8 @@ public:
STR_HELP("Selects lines based on defined criterea.") STR_HELP("Selects lines based on defined criterea.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
DialogSelection select(c->parent, c->SubsGrid); DialogSelection(c->parent, c->SubsGrid).ShowModal();
select.ShowModal();
} }
}; };
@ -133,9 +130,8 @@ public:
STR_HELP("Changes resolution and modifies subtitles to conform to change.") STR_HELP("Changes resolution and modifies subtitles to conform to change.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
DialogResample diag(c->parent, c->SubsGrid); DialogResample(c->parent, c->SubsGrid).ShowModal();
diag.ShowModal();
} }
}; };
@ -149,7 +145,7 @@ public:
STR_HELP("Open styling assistant.") STR_HELP("Open styling assistant.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
if (!c->stylingAssistant) c->stylingAssistant = new DialogStyling(c->parent, c->SubsGrid); if (!c->stylingAssistant) c->stylingAssistant = new DialogStyling(c->parent, c->SubsGrid);
c->stylingAssistant->Show(true); c->stylingAssistant->Show(true);
} }
@ -165,9 +161,8 @@ public:
STR_HELP("Open styles manager.") STR_HELP("Open styles manager.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
DialogStyleManager StyleManager(c->parent, c->SubsGrid); DialogStyleManager(c->parent, c->SubsGrid).ShowModal();
StyleManager.ShowModal();
} }
}; };
@ -181,8 +176,7 @@ public:
STR_HELP("Open Kanji timer.") STR_HELP("Open Kanji timer.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
DialogKanjiTimer kanjitimer(c->parent, c->SubsGrid); DialogKanjiTimer(c->parent, c->SubsGrid).ShowModal();
kanjitimer.ShowModal();
} }
}; };
@ -196,8 +190,7 @@ public:
STR_HELP("Runs a post-processor for timing to deal with lead-ins, lead-outs, scene timing and etc.") STR_HELP("Runs a post-processor for timing to deal with lead-ins, lead-outs, scene timing and etc.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
DialogTimingProcessor timing(c->parent, c->SubsGrid); DialogTimingProcessor(c->parent, c->SubsGrid).ShowModal();
timing.ShowModal();
} }
}; };
@ -211,11 +204,10 @@ public:
STR_HELP("Open translation assistant.") STR_HELP("Open translation assistant.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
int start = c->SubsGrid->GetFirstSelRow(); int start = c->SubsGrid->GetFirstSelRow();
if (start == -1) start = 0; if (start == -1) start = 0;
DialogTranslation Trans(c->parent, c->ass, c->SubsGrid, start, true); DialogTranslation(c->parent, c->ass, c->SubsGrid, start, true).ShowModal();
Trans.ShowModal();
} }
}; };

View file

@ -72,8 +72,8 @@ public:
STR_HELP("Forces video to 2.35 aspect ratio.") STR_HELP("Forces video to 2.35 aspect ratio.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
VideoContext::Get()->SetAspectRatio(3); c->videoContext->SetAspectRatio(3);
wxGetApp().frame->SetDisplayMode(1,-1); wxGetApp().frame->SetDisplayMode(1,-1);
} }
}; };
@ -88,9 +88,9 @@ public:
STR_HELP("Forces video to a custom aspect ratio.") STR_HELP("Forces video to a custom aspect ratio.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
wxString value = wxGetTextFromUser(_("Enter aspect ratio in either:\n decimal (e.g. 2.35)\n fractional (e.g. 16:9)\n specific resolution (e.g. 853x480)"),_("Enter aspect ratio"),AegiFloatToString(VideoContext::Get()->GetAspectRatioValue())); wxString value = wxGetTextFromUser(_("Enter aspect ratio in either:\n decimal (e.g. 2.35)\n fractional (e.g. 16:9)\n specific resolution (e.g. 853x480)"),_("Enter aspect ratio"),AegiFloatToString(c->videoContext->GetAspectRatioValue()));
if (value.IsEmpty()) return; if (value.IsEmpty()) return;
value.MakeLower(); value.MakeLower();
@ -118,7 +118,7 @@ public:
wxString denum = value.Mid(pos+1); wxString denum = value.Mid(pos+1);
if (num.ToDouble(&a) && denum.ToDouble(&b) && b!=0) { if (num.ToDouble(&a) && denum.ToDouble(&b) && b!=0) {
numval = a/b; numval = a/b;
if (scale) c->videoBox->videoDisplay->SetZoom(b / VideoContext::Get()->GetHeight()); if (scale) c->videoBox->videoDisplay->SetZoom(b / c->videoContext->GetHeight());
} }
} }
else numval = 0.0; else numval = 0.0;
@ -129,7 +129,7 @@ public:
// Set value // Set value
else { else {
VideoContext::Get()->SetAspectRatio(4,numval); c->videoContext->SetAspectRatio(4,numval);
wxGetApp().frame->SetDisplayMode(1,-1); wxGetApp().frame->SetDisplayMode(1,-1);
} }
} }
@ -146,8 +146,8 @@ public:
STR_HELP("Leave video on original aspect ratio.") STR_HELP("Leave video on original aspect ratio.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
VideoContext::Get()->SetAspectRatio(0); c->videoContext->SetAspectRatio(0);
wxGetApp().frame->SetDisplayMode(1,-1); wxGetApp().frame->SetDisplayMode(1,-1);
} }
}; };
@ -163,8 +163,8 @@ public:
STR_HELP("Forces video to 4:3 aspect ratio.") STR_HELP("Forces video to 4:3 aspect ratio.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
VideoContext::Get()->SetAspectRatio(1); c->videoContext->SetAspectRatio(1);
wxGetApp().frame->SetDisplayMode(1,-1); wxGetApp().frame->SetDisplayMode(1,-1);
} }
}; };
@ -179,8 +179,8 @@ public:
STR_HELP("Forces video to 16:9 aspect ratio.") STR_HELP("Forces video to 16:9 aspect ratio.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
VideoContext::Get()->SetAspectRatio(2); c->videoContext->SetAspectRatio(2);
wxGetApp().frame->SetDisplayMode(1,-1); wxGetApp().frame->SetDisplayMode(1,-1);
} }
}; };
@ -224,9 +224,8 @@ public:
STR_HELP("Shows video details.") STR_HELP("Shows video details.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
DialogVideoDetails videodetails(c->parent); DialogVideoDetails(c->parent).ShowModal();
videodetails.ShowModal();
} }
}; };
@ -275,7 +274,7 @@ public:
STR_HELP("Play video.") STR_HELP("Play video.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Play(); c->videoContext->Play();
} }
}; };
@ -303,10 +302,9 @@ public:
STR_HELP("Jump to frame or time.") STR_HELP("Jump to frame or time.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
if (VideoContext::Get()->IsLoaded()) { if (c->videoContext->IsLoaded()) {
DialogJumpTo JumpTo(c->parent); DialogJumpTo(c->parent).ShowModal();
JumpTo.ShowModal();
c->videoBox->videoSlider->SetFocus(); c->videoBox->videoSlider->SetFocus();
} }
} }
@ -390,7 +388,7 @@ public:
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
//XXX: Fix to not require using an event. (maybe) //XXX: Fix to not require using an event. (maybe)
// OPT_SET("Video/Overscan Mask")->SetBool(event.IsChecked()); // OPT_SET("Video/Overscan Mask")->SetBool(event.IsChecked());
VideoContext::Get()->Stop(); c->videoContext->Stop();
c->videoBox->videoDisplay->Render(); c->videoBox->videoDisplay->Render();
} }
}; };
@ -405,7 +403,7 @@ public:
STR_HELP("Set zoom to 100%.") STR_HELP("Set zoom to 100%.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
c->videoBox->videoDisplay->SetZoom(1.); c->videoBox->videoDisplay->SetZoom(1.);
} }
}; };
@ -421,7 +419,7 @@ public:
STR_HELP("Set zoom to 200%.") STR_HELP("Set zoom to 200%.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
c->videoBox->videoDisplay->SetZoom(2.); c->videoBox->videoDisplay->SetZoom(2.);
} }
}; };
@ -436,7 +434,7 @@ public:
STR_HELP("Set zoom to 50%.") STR_HELP("Set zoom to 50%.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
VideoContext::Get()->Stop(); c->videoContext->Stop();
c->videoBox->videoDisplay->SetZoom(.5); c->videoBox->videoDisplay->SetZoom(.5);
} }
}; };

View file

@ -306,7 +306,8 @@ void FrameMain::InitContents() {
StartupLog(_T("Create video box")); StartupLog(_T("Create video box"));
videoBox = new VideoBox(Panel, false, ZoomBox, ass); videoBox = new VideoBox(Panel, false, ZoomBox, ass);
temp_context.videoBox = videoBox; temp_context.videoBox = videoBox;
VideoContext::Get()->audio = audioController; temp_context.videoContext = VideoContext::Get();
temp_context.videoContext->audio = audioController;
wxBoxSizer *videoSizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer *videoSizer = new wxBoxSizer(wxVERTICAL);
videoSizer->Add(videoBox, 0, wxEXPAND); videoSizer->Add(videoBox, 0, wxEXPAND);
videoSizer->AddStretchSpacer(1); videoSizer->AddStretchSpacer(1);
@ -316,7 +317,7 @@ void FrameMain::InitContents() {
SubsGrid = new SubtitlesGrid(this,Panel,-1,ass,wxDefaultPosition,wxSize(600,100),wxWANTS_CHARS | wxSUNKEN_BORDER,_T("Subs grid")); SubsGrid = new SubtitlesGrid(this,Panel,-1,ass,wxDefaultPosition,wxSize(600,100),wxWANTS_CHARS | wxSUNKEN_BORDER,_T("Subs grid"));
temp_context.SubsGrid = SubsGrid; temp_context.SubsGrid = SubsGrid;
videoBox->videoSlider->grid = SubsGrid; videoBox->videoSlider->grid = SubsGrid;
VideoContext::Get()->grid = SubsGrid; temp_context.videoContext->grid = SubsGrid;
Search.grid = SubsGrid; Search.grid = SubsGrid;
// Tools area // Tools area

View file

@ -10,6 +10,7 @@ namespace Automation4 { class ScriptManager; }
class SubsEditBox; class SubsEditBox;
class SubtitlesGrid; class SubtitlesGrid;
class VideoBox; class VideoBox;
class VideoContext;
namespace agi { namespace agi {
@ -28,6 +29,7 @@ struct Context {
SubsEditBox *EditBox; SubsEditBox *EditBox;
SubtitlesGrid *SubsGrid; SubtitlesGrid *SubsGrid;
VideoBox *videoBox; VideoBox *videoBox;
VideoContext *videoContext;
}; };
} }