Rearrange FrameMain initialization order to seperate context initialization and control creation a bit, and eliminate local pointers to non-view parts of the context

Originally committed to SVN as r5209.
This commit is contained in:
Thomas Goyne 2011-01-16 07:16:54 +00:00
parent 9f25b51a54
commit 8544565c0e
17 changed files with 357 additions and 415 deletions

View file

@ -90,7 +90,7 @@ struct am_manager : public Command {
} }
} }
else { else {
c->videoContext->Stop(); c->videoController->Stop();
DialogAutomation(c->parent, c->local_scripts).ShowModal(); DialogAutomation(c->parent, c->local_scripts).ShowModal();
} }
#endif #endif

View file

@ -64,11 +64,11 @@ struct edit_line_copy : public Command {
STR_HELP("Copy subtitles.") STR_HELP("Copy subtitles.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
if (c->parent->FindFocus() == c->EditBox->TextEdit) { if (c->parent->FindFocus() == c->editBox->TextEdit) {
c->EditBox->TextEdit->Copy(); c->editBox->TextEdit->Copy();
return; return;
} }
c->SubsGrid->CopyLines(c->SubsGrid->GetSelection()); c->subsGrid->CopyLines(c->subsGrid->GetSelection());
} }
}; };
@ -81,11 +81,11 @@ struct edit_line_cut: public Command {
STR_HELP("Cut subtitles.") STR_HELP("Cut subtitles.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
if (c->parent->FindFocus() == c->EditBox->TextEdit) { if (c->parent->FindFocus() == c->editBox->TextEdit) {
c->EditBox->TextEdit->Cut(); c->editBox->TextEdit->Cut();
return; return;
} }
c->SubsGrid->CutLines(c->SubsGrid->GetSelection()); c->subsGrid->CutLines(c->subsGrid->GetSelection());
} }
}; };
@ -98,7 +98,7 @@ struct edit_line_delete : public Command {
STR_HELP("Delete currently selected lines.") STR_HELP("Delete currently selected lines.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->SubsGrid->DeleteLines(c->SubsGrid->GetSelection()); c->subsGrid->DeleteLines(c->subsGrid->GetSelection());
} }
}; };
@ -111,8 +111,8 @@ struct edit_line_duplicate : public Command {
STR_HELP("Duplicate the selected lines.") STR_HELP("Duplicate the selected lines.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
wxArrayInt sels = c->SubsGrid->GetSelection(); wxArrayInt sels = c->subsGrid->GetSelection();
c->SubsGrid->DuplicateLines(sels.front(), sels.back(), false); c->subsGrid->DuplicateLines(sels.front(), sels.back(), false);
} }
}; };
@ -125,8 +125,8 @@ struct edit_line_duplicate_shift : public Command {
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) {
wxArrayInt sels = c->SubsGrid->GetSelection(); wxArrayInt sels = c->subsGrid->GetSelection();
c->SubsGrid->DuplicateLines(sels.front(), sels.back(), true); c->subsGrid->DuplicateLines(sels.front(), sels.back(), true);
} }
}; };
@ -139,8 +139,8 @@ struct edit_line_join_as_karaoke : public Command {
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) {
wxArrayInt sels = c->SubsGrid->GetSelection(); wxArrayInt sels = c->subsGrid->GetSelection();
c->SubsGrid->JoinAsKaraoke(sels.front(), sels.back()); c->subsGrid->JoinAsKaraoke(sels.front(), sels.back());
} }
}; };
@ -153,8 +153,8 @@ struct edit_line_join_concatenate : public Command {
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) {
wxArrayInt sels = c->SubsGrid->GetSelection(); wxArrayInt sels = c->subsGrid->GetSelection();
c->SubsGrid->JoinLines(sels.front(), sels.back(), true); c->subsGrid->JoinLines(sels.front(), sels.back(), true);
} }
}; };
@ -167,8 +167,8 @@ struct edit_line_join_keep_first : public Command {
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) {
wxArrayInt sels = c->SubsGrid->GetSelection(); wxArrayInt sels = c->subsGrid->GetSelection();
c->SubsGrid->JoinLines(sels.front(), sels.back(), false); c->subsGrid->JoinLines(sels.front(), sels.back(), false);
} }
}; };
@ -181,11 +181,11 @@ struct edit_line_paste : public Command {
STR_HELP("Paste subtitles.") STR_HELP("Paste subtitles.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
if (c->parent->FindFocus() == c->EditBox->TextEdit) { if (c->parent->FindFocus() == c->editBox->TextEdit) {
c->EditBox->TextEdit->Paste(); c->editBox->TextEdit->Paste();
return; return;
} }
c->SubsGrid->PasteLines(c->SubsGrid->GetFirstSelRow()); c->subsGrid->PasteLines(c->subsGrid->GetFirstSelRow());
} }
}; };
@ -198,7 +198,7 @@ struct edit_line_paste_over : public Command {
STR_HELP("Paste subtitles over others.") STR_HELP("Paste subtitles over others.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->SubsGrid->PasteLines(c->SubsGrid->GetFirstSelRow(),true); c->subsGrid->PasteLines(c->subsGrid->GetFirstSelRow(),true);
} }
}; };
@ -224,16 +224,16 @@ struct edit_line_split_by_karaoke : public Command {
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) {
c->SubsGrid->BeginBatch(); c->subsGrid->BeginBatch();
wxArrayInt sels = c->SubsGrid->GetSelection(); wxArrayInt sels = c->subsGrid->GetSelection();
bool didSplit = false; bool didSplit = false;
for (int i = sels.size() - 1; i >= 0; --i) { for (int i = sels.size() - 1; i >= 0; --i) {
didSplit |= c->SubsGrid->SplitLineByKaraoke(sels[i]); didSplit |= c->subsGrid->SplitLineByKaraoke(sels[i]);
} }
if (didSplit) { if (didSplit) {
c->ass->Commit(_("splitting")); c->ass->Commit(_("splitting"));
} }
c->SubsGrid->EndBatch(); c->subsGrid->EndBatch();
} }
}; };
@ -246,8 +246,8 @@ struct edit_line_swap : public Command {
STR_HELP("Swaps the two selected lines.") STR_HELP("Swaps the two selected lines.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
wxArrayInt sels = c->SubsGrid->GetSelection(); wxArrayInt sels = c->subsGrid->GetSelection();
c->SubsGrid->SwapLines(sels.front(), sels.back()); c->subsGrid->SwapLines(sels.front(), sels.back());
} }
}; };
@ -260,7 +260,7 @@ struct edit_redo : public Command {
STR_HELP("Redoes last action.") STR_HELP("Redoes last action.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->Stop(); c->videoController->Stop();
c->ass->Redo(); c->ass->Redo();
} }
}; };
@ -274,7 +274,7 @@ struct edit_search_replace : public Command {
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) {
c->videoContext->Stop(); c->videoController->Stop();
Search.OpenDialog(true); Search.OpenDialog(true);
} }
}; };
@ -288,7 +288,7 @@ struct edit_undo : public Command {
STR_HELP("Undoes last action.") STR_HELP("Undoes last action.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->Stop(); c->videoController->Stop();
c->ass->Undo(); c->ass->Undo();
} }
}; };

View file

@ -62,7 +62,7 @@ struct grid_line_next : public Command {
STR_HELP("Move to the next subtitle line.") STR_HELP("Move to the next subtitle line.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->SubsGrid->NextLine(); c->subsGrid->NextLine();
} }
}; };
@ -75,7 +75,7 @@ struct grid_line_prev : public Command {
STR_HELP("Move to the previous line.") STR_HELP("Move to the previous line.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->SubsGrid->PrevLine(); c->subsGrid->PrevLine();
} }
}; };

View file

@ -62,7 +62,7 @@ struct keyframe_close : public Command {
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) {
c->videoContext->CloseKeyframes(); c->videoController->CloseKeyframes();
} }
}; };
@ -86,7 +86,7 @@ struct keyframe_open : public Command {
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); c->videoController->LoadKeyframes(filename);
} }
}; };
@ -103,7 +103,7 @@ struct keyframe_save : public Command {
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.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->SaveKeyframes(filename); c->videoController->SaveKeyframes(filename);
} }
}; };

View file

@ -79,7 +79,7 @@ struct recent_keyframe_entry : public Command {
STR_HELP("Open recent keyframes.") STR_HELP("Open recent keyframes.")
void operator()(agi::Context *c, int id) { void operator()(agi::Context *c, int id) {
c->videoContext->LoadKeyframes(lagi_wxString(config::mru->GetEntry("Keyframes", id))); c->videoController->LoadKeyframes(lagi_wxString(config::mru->GetEntry("Keyframes", id)));
} }
}; };
@ -101,7 +101,7 @@ struct recent_timecode_entry : public Command {
STR_HELP("Open recent timecodes.") STR_HELP("Open recent timecodes.")
void operator()(agi::Context *c, int id) { void operator()(agi::Context *c, int id) {
c->videoContext->LoadTimecodes(lagi_wxString(config::mru->GetEntry("Timecodes", id))); c->videoController->LoadTimecodes(lagi_wxString(config::mru->GetEntry("Timecodes", id)));
} }
}; };
@ -112,7 +112,7 @@ struct recent_video_entry : public Command {
STR_HELP("Open recent videos.") STR_HELP("Open recent videos.")
void operator()(agi::Context *c, int id) { void operator()(agi::Context *c, int id) {
c->videoContext->SetVideo(lagi_wxString(config::mru->GetEntry("Video", id))); c->videoController->SetVideo(lagi_wxString(config::mru->GetEntry("Video", id)));
} }
}; };

View file

@ -75,7 +75,7 @@ struct subtitle_attachment : public Command {
STR_HELP("Open the attachment list.") STR_HELP("Open the attachment list.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->Stop(); c->videoController->Stop();
DialogAttachments(c->parent, c->ass).ShowModal(); DialogAttachments(c->parent, c->ass).ShowModal();
} }
}; };
@ -89,7 +89,7 @@ struct subtitle_find : public Command {
STR_HELP("Find words in subtitles.") STR_HELP("Find words in subtitles.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->Stop(); c->videoController->Stop();
Search.OpenDialog(false); Search.OpenDialog(false);
} }
}; };
@ -103,27 +103,27 @@ struct subtitle_find_next : public Command {
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) {
c->videoContext->Stop(); c->videoController->Stop();
Search.FindNext(); Search.FindNext();
} }
}; };
static void insert_subtitle_at_video(agi::Context *c, bool after) { static void insert_subtitle_at_video(agi::Context *c, bool after) {
int n = c->SubsGrid->GetFirstSelRow(); int n = c->subsGrid->GetFirstSelRow();
// Create line to add // Create line to add
AssDialogue *def = new AssDialogue; AssDialogue *def = new AssDialogue;
int video_ms = c->videoContext->TimeAtFrame(c->videoContext->GetFrameN(), agi::vfr::START); int video_ms = c->videoController->TimeAtFrame(c->videoController->GetFrameN(), agi::vfr::START);
def->Start.SetMS(video_ms); def->Start.SetMS(video_ms);
def->End.SetMS(video_ms + OPT_GET("Timing/Default Duration")->GetInt()); def->End.SetMS(video_ms + OPT_GET("Timing/Default Duration")->GetInt());
def->Style = c->SubsGrid->GetDialogue(n)->Style; def->Style = c->subsGrid->GetDialogue(n)->Style;
// Insert it // Insert it
c->SubsGrid->BeginBatch(); c->subsGrid->BeginBatch();
c->SubsGrid->InsertLine(def, n, after); c->subsGrid->InsertLine(def, n, after);
c->SubsGrid->SelectRow(n + after); c->subsGrid->SelectRow(n + after);
c->SubsGrid->SetActiveLine(def); c->subsGrid->SetActiveLine(def);
c->SubsGrid->EndBatch(); c->subsGrid->EndBatch();
} }
/// Inserts a line after current. /// Inserts a line after current.
@ -134,29 +134,29 @@ struct subtitle_insert_after : public Command {
STR_HELP("Inserts a line after current.") STR_HELP("Inserts a line after current.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
int n = c->SubsGrid->GetFirstSelRow(); int n = c->subsGrid->GetFirstSelRow();
int nrows = c->SubsGrid->GetRows(); int nrows = c->subsGrid->GetRows();
// Create line to add // Create line to add
AssDialogue *def = new AssDialogue; AssDialogue *def = new AssDialogue;
if (n == nrows-1) { if (n == nrows-1) {
def->Start = c->SubsGrid->GetDialogue(n)->End; def->Start = c->subsGrid->GetDialogue(n)->End;
def->End = c->SubsGrid->GetDialogue(n)->End; def->End = c->subsGrid->GetDialogue(n)->End;
def->End.SetMS(def->End.GetMS()+OPT_GET("Timing/Default Duration")->GetInt()); def->End.SetMS(def->End.GetMS()+OPT_GET("Timing/Default Duration")->GetInt());
} }
else { else {
def->Start = c->SubsGrid->GetDialogue(n)->End; def->Start = c->subsGrid->GetDialogue(n)->End;
def->End = c->SubsGrid->GetDialogue(n+1)->Start; 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()); 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; def->Style = c->subsGrid->GetDialogue(n)->Style;
// Insert it // Insert it
c->SubsGrid->BeginBatch(); c->subsGrid->BeginBatch();
c->SubsGrid->InsertLine(def, n, true); c->subsGrid->InsertLine(def, n, true);
c->SubsGrid->SelectRow(n + 1); c->subsGrid->SelectRow(n + 1);
c->SubsGrid->SetActiveLine(def); c->subsGrid->SetActiveLine(def);
c->SubsGrid->EndBatch(); c->subsGrid->EndBatch();
} }
}; };
@ -181,31 +181,31 @@ struct subtitle_insert_before : public Command {
STR_HELP("Inserts a line before current.") STR_HELP("Inserts a line before current.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
int n = c->SubsGrid->GetFirstSelRow(); int n = c->subsGrid->GetFirstSelRow();
// Create line to add // Create line to add
AssDialogue *def = new AssDialogue; AssDialogue *def = new AssDialogue;
if (n == 0) { if (n == 0) {
def->Start.SetMS(0); def->Start.SetMS(0);
def->End = c->SubsGrid->GetDialogue(n)->Start; def->End = c->subsGrid->GetDialogue(n)->Start;
} }
else if (c->SubsGrid->GetDialogue(n-1)->End.GetMS() > c->SubsGrid->GetDialogue(n)->Start.GetMS()) { 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->Start.SetMS(c->subsGrid->GetDialogue(n)->Start.GetMS()-OPT_GET("Timing/Default Duration")->GetInt());
def->End = c->SubsGrid->GetDialogue(n)->Start; def->End = c->subsGrid->GetDialogue(n)->Start;
} }
else { else {
def->Start = c->SubsGrid->GetDialogue(n-1)->End; def->Start = c->subsGrid->GetDialogue(n-1)->End;
def->End = c->SubsGrid->GetDialogue(n)->Start; 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()); 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; def->Style = c->subsGrid->GetDialogue(n)->Style;
// Insert it // Insert it
c->SubsGrid->BeginBatch(); c->subsGrid->BeginBatch();
c->SubsGrid->InsertLine(def, n, false); c->subsGrid->InsertLine(def, n, false);
c->SubsGrid->SelectRow(n); c->subsGrid->SelectRow(n);
c->SubsGrid->SetActiveLine(def); c->subsGrid->SetActiveLine(def);
c->SubsGrid->EndBatch(); c->subsGrid->EndBatch();
} }
}; };
@ -284,7 +284,7 @@ struct subtitle_open_video : public Command {
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(c->videoContext->videoName, "binary"); wxGetApp().frame->LoadSubtitles(c->videoController->videoName, "binary");
} }
}; };
@ -297,7 +297,7 @@ struct subtitle_properties : public Command {
STR_HELP("Open script properties window.") STR_HELP("Open script properties window.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->Stop(); c->videoController->Stop();
DialogProperties(c->parent, c->ass).ShowModal(); DialogProperties(c->parent, c->ass).ShowModal();
} }
}; };
@ -338,8 +338,8 @@ struct subtitle_select_visiblek : public Command {
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) {
c->videoContext->Stop(); c->videoController->Stop();
c->SubsGrid->SelectVisible(); c->subsGrid->SelectVisible();
} }
}; };
@ -352,7 +352,7 @@ struct subtitle_spellcheck : public Command {
STR_HELP("Open spell checker.") STR_HELP("Open spell checker.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->Stop(); c->videoController->Stop();
new DialogSpellChecker(c); new DialogSpellChecker(c);
} }
}; };

View file

@ -64,8 +64,8 @@ struct time_continous_end : public Command {
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) {
wxArrayInt sels = c->SubsGrid->GetSelection(); wxArrayInt sels = c->subsGrid->GetSelection();
c->SubsGrid->AdjoinLines(sels.front(), sels.back(), false); c->subsGrid->AdjoinLines(sels.front(), sels.back(), false);
} }
}; };
@ -78,8 +78,8 @@ struct time_continous_start : public Command {
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) {
wxArrayInt sels = c->SubsGrid->GetSelection(); wxArrayInt sels = c->subsGrid->GetSelection();
c->SubsGrid->AdjoinLines(sels.front(), sels.back(), true); c->subsGrid->AdjoinLines(sels.front(), sels.back(), true);
} }
}; };
@ -93,20 +93,20 @@ struct time_frame_current : public Command {
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 (!c->videoContext->IsLoaded()) return; if (!c->videoController->IsLoaded()) return;
wxArrayInt sels = c->SubsGrid->GetSelection(); wxArrayInt sels = c->subsGrid->GetSelection();
size_t n=sels.Count(); size_t n=sels.Count();
if (n == 0) return; if (n == 0) return;
// 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 = c->videoContext->TimeAtFrame(c->videoContext->GetFrameN(),agi::vfr::START) - cur->Start.GetMS(); int shiftBy = c->videoController->TimeAtFrame(c->videoController->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++) {
cur = c->SubsGrid->GetDialogue(sels[i]); cur = c->subsGrid->GetDialogue(sels[i]);
if (cur) { if (cur) {
cur->Start.SetMS(cur->Start.GetMS()+shiftBy); cur->Start.SetMS(cur->Start.GetMS()+shiftBy);
cur->End.SetMS(cur->End.GetMS()+shiftBy); cur->End.SetMS(cur->End.GetMS()+shiftBy);
@ -114,7 +114,7 @@ struct time_frame_current : public Command {
} }
// Commit // Commit
c->SubsGrid->ass->Commit(_("shift to frame"), AssFile::COMMIT_TIMES); c->subsGrid->ass->Commit(_("shift to frame"), AssFile::COMMIT_TIMES);
} }
}; };
@ -127,8 +127,8 @@ struct time_shift : public Command {
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) {
c->videoContext->Stop(); c->videoController->Stop();
DialogShiftTimes(c->parent, c->SubsGrid).ShowModal(); DialogShiftTimes(c->parent, c->subsGrid).ShowModal();
} }
}; };
@ -142,7 +142,7 @@ struct time_snap_end_video : public Command {
STR_HELP("Set end of selected subtitles to current video frame.") STR_HELP("Set end of selected subtitles to current video frame.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->SubsGrid->SetSubsToVideo(false); c->subsGrid->SetSubsToVideo(false);
} }
}; };
@ -155,17 +155,17 @@ struct time_snap_frame : public Command {
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) {
if (c->videoContext->IsLoaded()) return; if (c->videoController->IsLoaded()) return;
wxArrayInt sels = c->SubsGrid->GetSelection(); wxArrayInt sels = c->subsGrid->GetSelection();
if (sels.empty()) return; if (sels.empty()) return;
AssDialogue *cur = c->SubsGrid->GetDialogue(sels[0]); AssDialogue *cur = c->subsGrid->GetDialogue(sels[0]);
if (!cur) return; if (!cur) return;
int shiftBy = c->videoContext->TimeAtFrame(c->videoContext->GetFrameN(),agi::vfr::START) - cur->Start.GetMS(); int shiftBy = c->videoController->TimeAtFrame(c->videoController->GetFrameN(),agi::vfr::START) - cur->Start.GetMS();
for (size_t i = 0; i < sels.size(); ++i) { for (size_t i = 0; i < sels.size(); ++i) {
if (cur = c->SubsGrid->GetDialogue(sels[i])) { if (cur = c->subsGrid->GetDialogue(sels[i])) {
cur->Start.SetMS(cur->Start.GetMS() + shiftBy); cur->Start.SetMS(cur->Start.GetMS() + shiftBy);
cur->End.SetMS(cur->End.GetMS() + shiftBy); cur->End.SetMS(cur->End.GetMS() + shiftBy);
} }
@ -184,11 +184,11 @@ struct time_snap_scene : public Command {
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 = c->videoContext; VideoContext *con = c->videoController;
if (!con->IsLoaded() || !con->KeyFramesLoaded()) return; if (!con->IsLoaded() || !con->KeyFramesLoaded()) return;
// Get frames // Get frames
wxArrayInt sel = c->SubsGrid->GetSelection(); wxArrayInt sel = c->subsGrid->GetSelection();
int curFrame = con->GetFrameN(); int curFrame = con->GetFrameN();
int prev = 0; int prev = 0;
int next = 0; int next = 0;
@ -220,13 +220,13 @@ struct time_snap_scene : public Command {
// Update rows // Update rows
for (size_t i=0;i<sel.Count();i++) { for (size_t i=0;i<sel.Count();i++) {
cur = c->SubsGrid->GetDialogue(sel[i]); cur = c->subsGrid->GetDialogue(sel[i]);
cur->Start.SetMS(start_ms); cur->Start.SetMS(start_ms);
cur->End.SetMS(end_ms); cur->End.SetMS(end_ms);
} }
// Commit // Commit
c->SubsGrid->ass->Commit(_("snap to scene"), AssFile::COMMIT_TIMES); c->subsGrid->ass->Commit(_("snap to scene"), AssFile::COMMIT_TIMES);
} }
}; };
@ -239,7 +239,7 @@ struct time_snap_start_video : public Command {
STR_HELP("Set start of selected subtitles to current video frame.") STR_HELP("Set start of selected subtitles to current video frame.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->SubsGrid->SetSubsToVideo(false); c->subsGrid->SetSubsToVideo(false);
} }
}; };

View file

@ -63,7 +63,7 @@ struct timecode_close : public Command {
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) {
c->videoContext->CloseTimecodes(); c->videoController->CloseTimecodes();
} }
}; };
@ -80,7 +80,7 @@ struct timecode_open : public Command {
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()) {
c->videoContext->LoadTimecodes(filename); c->videoController->LoadTimecodes(filename);
OPT_SET("Path/Last/Timecodes")->SetString(STD_STR(filename)); OPT_SET("Path/Last/Timecodes")->SetString(STD_STR(filename));
} }
} }
@ -99,7 +99,7 @@ struct timecode_save : public Command {
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()) {
c->videoContext->SaveTimecodes(filename); c->videoController->SaveTimecodes(filename);
OPT_SET("Path/Last/Timecodes")->SetString(STD_STR(filename)); OPT_SET("Path/Last/Timecodes")->SetString(STD_STR(filename));
} }
} }

View file

@ -83,8 +83,8 @@ struct tool_export : public Command {
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) {
c->videoContext->Stop(); c->videoController->Stop();
DialogResample(c->parent, c->SubsGrid).ShowModal(); DialogResample(c->parent, c->subsGrid).ShowModal();
} }
}; };
@ -97,7 +97,7 @@ struct tool_font_collector : public Command {
STR_HELP("Open fonts collector.") STR_HELP("Open fonts collector.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->Stop(); c->videoController->Stop();
DialogFontsCollector(c->parent, c->ass).ShowModal(); DialogFontsCollector(c->parent, c->ass).ShowModal();
} }
}; };
@ -111,8 +111,8 @@ struct tool_line_select : public Command {
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) {
c->videoContext->Stop(); c->videoController->Stop();
DialogSelection(c->parent, c->SubsGrid).ShowModal(); DialogSelection(c->parent, c->subsGrid).ShowModal();
} }
}; };
@ -125,8 +125,8 @@ struct tool_resampleres : public Command {
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) {
c->videoContext->Stop(); c->videoController->Stop();
DialogResample(c->parent, c->SubsGrid).ShowModal(); DialogResample(c->parent, c->subsGrid).ShowModal();
} }
}; };
@ -139,8 +139,8 @@ struct tool_style_assistant : public Command {
STR_HELP("Open styling assistant.") STR_HELP("Open styling assistant.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->Stop(); c->videoController->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);
} }
}; };
@ -154,8 +154,8 @@ struct tool_style_manager : public Command {
STR_HELP("Open styles manager.") STR_HELP("Open styles manager.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->Stop(); c->videoController->Stop();
DialogStyleManager(c->parent, c->SubsGrid).ShowModal(); DialogStyleManager(c->parent, c->subsGrid).ShowModal();
} }
}; };
@ -168,7 +168,7 @@ struct tool_time_kanji : public Command {
STR_HELP("Open Kanji timer.") STR_HELP("Open Kanji timer.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
DialogKanjiTimer(c->parent, c->SubsGrid).ShowModal(); DialogKanjiTimer(c->parent, c->subsGrid).ShowModal();
} }
}; };
@ -181,7 +181,7 @@ struct tool_time_postprocess : public Command {
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(c->parent, c->SubsGrid).ShowModal(); DialogTimingProcessor(c->parent, c->subsGrid).ShowModal();
} }
}; };
@ -194,10 +194,10 @@ struct tool_translation_assistant : public Command {
STR_HELP("Open translation assistant.") STR_HELP("Open translation assistant.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->Stop(); c->videoController->Stop();
int start = c->SubsGrid->GetFirstSelRow(); int start = c->subsGrid->GetFirstSelRow();
if (start == -1) start = 0; if (start == -1) start = 0;
DialogTranslation(c->parent, c->ass, c->SubsGrid, start, true).ShowModal(); DialogTranslation(c->parent, c->ass, c->subsGrid, start, true).ShowModal();
} }
}; };

View file

@ -71,8 +71,8 @@ struct video_aspect_cinematic : public Command {
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) {
c->videoContext->Stop(); c->videoController->Stop();
c->videoContext->SetAspectRatio(3); c->videoController->SetAspectRatio(3);
wxGetApp().frame->SetDisplayMode(1,-1); wxGetApp().frame->SetDisplayMode(1,-1);
} }
}; };
@ -86,9 +86,9 @@ struct video_aspect_custom : public Command {
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) {
c->videoContext->Stop(); c->videoController->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(c->videoContext->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->videoController->GetAspectRatioValue()));
if (value.IsEmpty()) return; if (value.IsEmpty()) return;
value.MakeLower(); value.MakeLower();
@ -116,7 +116,7 @@ struct video_aspect_custom : public Command {
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 / c->videoContext->GetHeight()); if (scale) c->videoBox->videoDisplay->SetZoom(b / c->videoController->GetHeight());
} }
} }
else numval = 0.0; else numval = 0.0;
@ -127,7 +127,7 @@ struct video_aspect_custom : public Command {
// Set value // Set value
else { else {
c->videoContext->SetAspectRatio(4,numval); c->videoController->SetAspectRatio(4,numval);
wxGetApp().frame->SetDisplayMode(1,-1); wxGetApp().frame->SetDisplayMode(1,-1);
} }
} }
@ -143,8 +143,8 @@ struct video_aspect_default : public Command {
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) {
c->videoContext->Stop(); c->videoController->Stop();
c->videoContext->SetAspectRatio(0); c->videoController->SetAspectRatio(0);
wxGetApp().frame->SetDisplayMode(1,-1); wxGetApp().frame->SetDisplayMode(1,-1);
} }
}; };
@ -159,8 +159,8 @@ struct video_aspect_full : public Command {
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) {
c->videoContext->Stop(); c->videoController->Stop();
c->videoContext->SetAspectRatio(1); c->videoController->SetAspectRatio(1);
wxGetApp().frame->SetDisplayMode(1,-1); wxGetApp().frame->SetDisplayMode(1,-1);
} }
}; };
@ -174,8 +174,8 @@ struct video_aspect_wide : public Command {
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) {
c->videoContext->Stop(); c->videoController->Stop();
c->videoContext->SetAspectRatio(2); c->videoController->SetAspectRatio(2);
wxGetApp().frame->SetDisplayMode(1,-1); wxGetApp().frame->SetDisplayMode(1,-1);
} }
}; };
@ -189,7 +189,7 @@ struct video_close : public Command {
STR_HELP("Closes the currently open video file.") STR_HELP("Closes the currently open video file.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->SetVideo(""); c->videoController->SetVideo("");
} }
}; };
@ -216,7 +216,7 @@ struct video_details : public Command {
STR_HELP("Shows video details.") STR_HELP("Shows video details.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->Stop(); c->videoController->Stop();
DialogVideoDetails(c->parent).ShowModal(); DialogVideoDetails(c->parent).ShowModal();
} }
}; };
@ -232,10 +232,10 @@ struct video_focus_seek : public Command {
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
wxWindow *curFocus = wxWindow::FindFocus(); wxWindow *curFocus = wxWindow::FindFocus();
if (curFocus == c->videoBox->videoSlider) { if (curFocus == c->videoBox->videoSlider) {
if (c->PreviousFocus) c->PreviousFocus->SetFocus(); if (c->previousFocus) c->previousFocus->SetFocus();
} }
else { else {
c->PreviousFocus = curFocus; c->previousFocus = curFocus;
c->videoBox->videoSlider->SetFocus(); c->videoBox->videoSlider->SetFocus();
} }
} }
@ -250,7 +250,7 @@ struct video_frame_next : public Command {
STR_HELP("Seek to the next frame.") STR_HELP("Seek to the next frame.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->NextFrame(); c->videoController->NextFrame();
} }
}; };
@ -263,7 +263,7 @@ struct video_frame_play : public Command {
STR_HELP("Play video.") STR_HELP("Play video.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->Play(); c->videoController->Play();
} }
}; };
@ -276,7 +276,7 @@ struct video_frame_prev : public Command {
STR_HELP("Seek to the previous frame.") STR_HELP("Seek to the previous frame.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->PrevFrame(); c->videoController->PrevFrame();
} }
}; };
@ -289,8 +289,8 @@ struct video_jump : public Command {
STR_HELP("Jump to frame or time.") STR_HELP("Jump to frame or time.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->Stop(); c->videoController->Stop();
if (c->videoContext->IsLoaded()) { if (c->videoController->IsLoaded()) {
DialogJumpTo(c->parent).ShowModal(); DialogJumpTo(c->parent).ShowModal();
c->videoBox->videoSlider->SetFocus(); c->videoBox->videoSlider->SetFocus();
} }
@ -306,7 +306,7 @@ struct video_jump_end : public Command {
STR_HELP("Jumps the video to the end frame of current subtitle.") STR_HELP("Jumps the video to the end frame of current subtitle.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->SubsGrid->SetVideoToSubs(false); c->subsGrid->SetVideoToSubs(false);
} }
}; };
@ -319,7 +319,7 @@ struct video_jump_start : public Command {
STR_HELP("Jumps the video to the start frame of current subtitle.") STR_HELP("Jumps the video to the start frame of current subtitle.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->SubsGrid->SetVideoToSubs(true); c->subsGrid->SetVideoToSubs(true);
} }
}; };
@ -337,7 +337,7 @@ struct video_open : public Command {
+ _("All Files") + _T(" (*.*)|*.*"); + _("All Files") + _T(" (*.*)|*.*");
wxString filename = wxFileSelector(_("Open video file"),path,_T(""),_T(""),str,wxFD_OPEN | wxFD_FILE_MUST_EXIST); wxString filename = wxFileSelector(_("Open video file"),path,_T(""),_T(""),str,wxFD_OPEN | wxFD_FILE_MUST_EXIST);
if (!filename.empty()) { if (!filename.empty()) {
c->videoContext->SetVideo(filename); c->videoController->SetVideo(filename);
OPT_SET("Path/Last/Video")->SetString(STD_STR(filename)); OPT_SET("Path/Last/Video")->SetString(STD_STR(filename));
} }
} }
@ -354,7 +354,7 @@ struct video_open_dummy : public Command {
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
wxString fn; wxString fn;
if (DialogDummyVideo::CreateDummyVideo(c->parent, fn)) { if (DialogDummyVideo::CreateDummyVideo(c->parent, fn)) {
c->videoContext->SetVideo(fn); c->videoController->SetVideo(fn);
} }
} }
}; };
@ -370,7 +370,7 @@ struct video_show_overscan : public Command {
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());
c->videoContext->Stop(); c->videoController->Stop();
c->videoBox->videoDisplay->Render(); c->videoBox->videoDisplay->Render();
} }
}; };
@ -385,7 +385,7 @@ public:
STR_HELP("Set zoom to 100%.") STR_HELP("Set zoom to 100%.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->Stop(); c->videoController->Stop();
c->videoBox->videoDisplay->SetZoom(1.); c->videoBox->videoDisplay->SetZoom(1.);
} }
}; };
@ -401,7 +401,7 @@ public:
STR_HELP("Set zoom to 200%.") STR_HELP("Set zoom to 200%.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->Stop(); c->videoController->Stop();
c->videoBox->videoDisplay->SetZoom(2.); c->videoBox->videoDisplay->SetZoom(2.);
} }
}; };
@ -416,7 +416,7 @@ public:
STR_HELP("Set zoom to 50%.") STR_HELP("Set zoom to 50%.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoContext->Stop(); c->videoController->Stop();
c->videoBox->videoDisplay->SetZoom(.5); c->videoBox->videoDisplay->SetZoom(.5);
} }
}; };

View file

@ -42,6 +42,7 @@
#include <wx/display.h> /// Must be included last. #include <wx/display.h> /// Must be included last.
#endif #endif
#include "include/aegisub/context.h"
#include "dialog_detached_video.h" #include "dialog_detached_video.h"
#include "frame_main.h" #include "frame_main.h"
#include "main.h" #include "main.h"
@ -151,7 +152,7 @@ void DialogDetachedVideo::OnClose(wxCloseEvent &WXUNUSED(event)) {
FrameMain *par = parent; FrameMain *par = parent;
OPT_SET("Video/Detached/Enabled")->SetBool(false); OPT_SET("Video/Detached/Enabled")->SetBool(false);
Destroy(); Destroy();
par->detachedVideo = NULL; par->context->detachedVideo = 0;
par->SetDisplayMode(1,-1); par->SetDisplayMode(1,-1);
} }

View file

@ -196,7 +196,7 @@ bool DialogSpellChecker::FindNext(int startLine,int startPos) {
if (startPos != -1) lastPos = 0; if (startPos != -1) lastPos = 0;
// Get grid // Get grid
SubtitlesGrid *grid = context->SubsGrid; SubtitlesGrid *grid = context->subsGrid;
int rows = grid->GetRows(); int rows = grid->GetRows();
// Loop through lines // Loop through lines
@ -269,7 +269,7 @@ void DialogSpellChecker::SetWord(wxString word) {
for (size_t i=0;i<sugs.Count();i++) suggestList->Append(sugs[i]); for (size_t i=0;i<sugs.Count();i++) suggestList->Append(sugs[i]);
// Show word on the main program interface // Show word on the main program interface
SubtitlesGrid *grid = context->SubsGrid; SubtitlesGrid *grid = context->subsGrid;
int line = lastLine % grid->GetRows(); int line = lastLine % grid->GetRows();
grid->SelectRow(line,false); grid->SelectRow(line,false);
grid->MakeCellVisible(line,0); grid->MakeCellVisible(line,0);
@ -382,7 +382,7 @@ bool DialogSpellChecker::FindOrDie() {
/// ///
void DialogSpellChecker::Replace() { void DialogSpellChecker::Replace() {
// Get dialog // Get dialog
SubtitlesGrid *grid = context->SubsGrid; SubtitlesGrid *grid = context->subsGrid;
AssDialogue *diag = grid->GetDialogue(lastLine % grid->GetRows()); AssDialogue *diag = grid->GetDialogue(lastLine % grid->GetRows());
// Replace // Replace
@ -435,7 +435,7 @@ void DialogSpellChecker::OnTakeSuggestion(wxCommandEvent &event) {
/// ///
bool DialogSpellChecker::GetFirstMatch() { bool DialogSpellChecker::GetFirstMatch() {
// Get selection // Get selection
SubtitlesGrid *grid = context->SubsGrid; SubtitlesGrid *grid = context->subsGrid;
wxArrayInt sel = grid->GetSelection(); wxArrayInt sel = grid->GetSelection();
firstLine = (sel.Count()>0) ? sel[0] : 0; firstLine = (sel.Count()>0) ? sel[0] : 0;
bool hasTypos = FindNext(firstLine,0); bool hasTypos = FindNext(firstLine,0);

View file

@ -103,12 +103,53 @@ static void autosave_timer_changed(wxTimer *timer, const agi::OptionValue &opt);
FrameMain::FrameMain (wxArrayString args) FrameMain::FrameMain (wxArrayString args)
: wxFrame ((wxFrame*)NULL,-1,_T(""),wxDefaultPosition,wxSize(920,700),wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN) : wxFrame ((wxFrame*)NULL,-1,_T(""),wxDefaultPosition,wxSize(920,700),wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN)
, temp_context(new agi::Context) , context(new agi::Context)
, showVideo(true)
, showAudio(true)
, HasSelection(false)
, menuCreated(false)
, blockVideoLoad(false)
{ {
StartupLog(_T("Entering FrameMain constructor")); StartupLog("Entering FrameMain constructor");
temp_context->parent = this;
// Bind all commands. #ifdef __WXGTK__
/* XXX HACK XXX
* Gtk just got initialized. And if we're using the SCIM IME,
* it just did a setlocale(LC_ALL, ""). so, BOOM.
*/
StartupLog("Setting locale");
setlocale(LC_ALL, "");
setlocale(LC_CTYPE, "C");
setlocale(LC_NUMERIC, "C");
/* XXX HACK XXX */
#endif
StartupLog("Initializing context models");
AssFile::top = context->ass = new AssFile;
context->ass->AddCommitListener(&FrameMain::OnSubtitlesCommit, this);
context->ass->AddFileOpenListener(&FrameMain::OnSubtitlesOpen, this);
context->ass->AddFileSaveListener(&FrameMain::UpdateTitle, this);
#ifdef WITH_AUTOMATION
context->local_scripts = new Automation4::ScriptManager();
#endif
StartupLog("Initializing context controls");
context->audioController = new AudioController;
context->audioController->AddAudioOpenListener(&FrameMain::OnAudioOpen, this);
context->audioController->AddAudioCloseListener(&FrameMain::OnAudioClose, this);
context->videoController = VideoContext::Get(); // derp
context->videoController->audio = context->audioController;
context->videoController->AddVideoOpenListener(&FrameMain::OnVideoOpen, this);
StartupLog("Initializing context frames");
context->parent = this;
context->previousFocus = 0;
AegisubApp::Get()->frame = this;
StartupLog("Binding commands");
// XXX: This is a hack for now, it will need to be dealt with when other frames are involved. // XXX: This is a hack for now, it will need to be dealt with when other frames are involved.
int count = cmd::count(); int count = cmd::count();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
@ -119,62 +160,23 @@ FrameMain::FrameMain (wxArrayString args)
// Bind(FrameMain::OnAbout, &FrameMain::cmd_call, this, cmd::id("app/about")); // Bind(FrameMain::OnAbout, &FrameMain::cmd_call, this, cmd::id("app/about"));
#endif #endif
StartupLog("Install PNG handler");
wxImage::AddHandler(new wxPNGHandler);
#ifdef __WXGTK__
/* XXX HACK XXX
* Gtk just got initialized. And if we're using the SCIM IME,
* it just did a setlocale(LC_ALL, ""). so, BOOM.
*/
setlocale(LC_ALL, "");
setlocale(LC_CTYPE, "C");
setlocale(LC_NUMERIC, "C");
/* XXX HACK XXX */
#endif
// Set application's frame
AegisubApp::Get()->frame = this;
// Initialize flags
HasSelection = false;
menuCreated = false;
blockVideoLoad = false;
StartupLog(_T("Install PNG handler"));
// Create PNG handler
wxPNGHandler *png = new wxPNGHandler;
wxImage::AddHandler(png);
wxSafeYield(); wxSafeYield();
// Storage for subs-file-local scripts StartupLog("Apply saved Maximized state");
#ifdef WITH_AUTOMATION
StartupLog(_T("Create local Automation script manager"));
local_scripts = new Automation4::ScriptManager();
temp_context->local_scripts = local_scripts;
#endif
// Contexts and controllers
audioController = new AudioController;
temp_context->audioController = audioController;
audioController->AddAudioOpenListener(&FrameMain::OnAudioOpen, this);
audioController->AddAudioCloseListener(&FrameMain::OnAudioClose, this);
// Create menu and tool bars
StartupLog(_T("Apply saved Maximized state"));
if (OPT_GET("App/Maximized")->GetBool()) Maximize(true); if (OPT_GET("App/Maximized")->GetBool()) Maximize(true);
StartupLog(_T("Initialize toolbar"));
StartupLog("Initialize toolbar");
InitToolbar(); InitToolbar();
StartupLog(_T("Initialize menu bar"));
StartupLog("Initialize menu bar");
InitMenu(); InitMenu();
// Create status bar StartupLog("Create status bar");
StartupLog(_T("Create status bar"));
CreateStatusBar(2); CreateStatusBar(2);
// Set icon StartupLog("Set icon");
StartupLog(_T("Set icon"));
#ifdef _WIN32 #ifdef _WIN32
SetIcon(wxICON(wxicon)); SetIcon(wxICON(wxicon));
#else #else
@ -183,17 +185,12 @@ FrameMain::FrameMain (wxArrayString args)
SetIcon(icon); SetIcon(icon);
#endif #endif
// Contents StartupLog("Create views and inner main window controls");
showVideo = true; context->detachedVideo = 0;
showAudio = true; context->stylingAssistant = 0;
detachedVideo = NULL;
stylingAssistant = NULL;
temp_context->stylingAssistant = stylingAssistant;
StartupLog(_T("Initialize inner main window controls"));
InitContents(); InitContents();
// Set autosave timer StartupLog("Set up Auto Save");
StartupLog(_T("Set up Auto Save"));
AutoSave.SetOwner(this, ID_APP_TIMER_AUTOSAVE); AutoSave.SetOwner(this, ID_APP_TIMER_AUTOSAVE);
int time = OPT_GET("App/Auto/Save Every Seconds")->GetInt(); int time = OPT_GET("App/Auto/Save Every Seconds")->GetInt();
if (time > 0) { if (time > 0) {
@ -201,20 +198,17 @@ FrameMain::FrameMain (wxArrayString args)
} }
OPT_SUB("App/Auto/Save Every Seconds", autosave_timer_changed, &AutoSave, agi::signal::_1); OPT_SUB("App/Auto/Save Every Seconds", autosave_timer_changed, &AutoSave, agi::signal::_1);
StartupLog("Set up drag/drop target");
PreviousFocus = NULL; // Artifact from old hotkey removal not sure what it does.
temp_context->PreviousFocus = PreviousFocus; // Artifact from old hotkey removal not sure what it does.
// Set drop target
StartupLog(_T("Set up drag/drop target"));
SetDropTarget(new AegisubFileDropTarget(this)); SetDropTarget(new AegisubFileDropTarget(this));
// Parse arguments StartupLog("Load default file");
StartupLog(_T("Load files specified on command line")); context->ass->LoadDefault();
StartupLog("Load files specified on command line");
LoadList(args); LoadList(args);
// Version checker // Version checker
StartupLog(_T("Possibly perform automatic updates check")); StartupLog("Possibly perform automatic updates check");
if (OPT_GET("App/First Start")->GetBool()) { if (OPT_GET("App/First Start")->GetBool()) {
OPT_SET("App/First Start")->SetBool(false); OPT_SET("App/First Start")->SetBool(false);
int result = wxMessageBox(_("Do you want Aegisub to check for updates whenever it starts? You can still do it manually via the Help menu."),_("Check for updates?"),wxYES_NO); int result = wxMessageBox(_("Do you want Aegisub to check for updates whenever it starts? You can still do it manually via the Help menu."),_("Check for updates?"),wxYES_NO);
@ -223,37 +217,31 @@ FrameMain::FrameMain (wxArrayString args)
PerformVersionCheck(false); PerformVersionCheck(false);
StartupLog(_T("Display main window")); StartupLog("Display main window");
Show(); Show();
Freeze();
SetDisplayMode(1, 1); SetDisplayMode(1, 1);
Thaw();
//ShowFullScreen(true,wxFULLSCREEN_NOBORDER | wxFULLSCREEN_NOCAPTION); //ShowFullScreen(true,wxFULLSCREEN_NOBORDER | wxFULLSCREEN_NOCAPTION);
StartupLog(_T("Leaving FrameMain constructor")); StartupLog("Leaving FrameMain constructor");
} }
/// @brief FrameMain destructor /// @brief FrameMain destructor
FrameMain::~FrameMain () { FrameMain::~FrameMain () {
temp_context->videoContext->SetVideo(_T("")); context->videoController->SetVideo("");
audioController->CloseAudio(); context->audioController->CloseAudio();
DeInitContents(); DeInitContents();
delete audioController; delete context->audioController;
#ifdef WITH_AUTOMATION #ifdef WITH_AUTOMATION
delete local_scripts; delete context->local_scripts;
#endif #endif
} }
void FrameMain::cmd_call(wxCommandEvent& event) { void FrameMain::cmd_call(wxCommandEvent& event) {
int id = event.GetId(); int id = event.GetId();
LOG_D("event/select") << "Id: " << id; LOG_D("event/select") << "Id: " << id;
cmd::call(temp_context.get(), id); cmd::call(context.get(), id);
} }
/// @brief Initialize toolbar /// @brief Initialize toolbar
void FrameMain::InitToolbar () { void FrameMain::InitToolbar () {
// Create toolbar // Create toolbar
@ -295,58 +283,38 @@ void FrameMain::InitMenu() {
/// @brief Initialize contents /// @brief Initialize contents
void FrameMain::InitContents() { void FrameMain::InitContents() {
AssFile::top = ass = new AssFile; StartupLog("Create background panel");
temp_context->ass = ass;
ass->AddCommitListener(&FrameMain::OnSubtitlesCommit, this);
ass->AddFileOpenListener(&FrameMain::OnSubtitlesOpen, this);
ass->AddFileSaveListener(&FrameMain::UpdateTitle, this);
// Set a background panel
StartupLog(_T("Create background panel"));
Panel = new wxPanel(this,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL | wxCLIP_CHILDREN); Panel = new wxPanel(this,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL | wxCLIP_CHILDREN);
// Video area; StartupLog("Create video box");
StartupLog(_T("Create video box")); context->videoBox = videoBox = new VideoBox(Panel, false, ZoomBox, context->ass);
videoBox = new VideoBox(Panel, false, ZoomBox, ass);
temp_context->videoBox = videoBox;
temp_context->videoContext = VideoContext::Get();
temp_context->videoContext->audio = audioController;
temp_context->videoContext->AddVideoOpenListener(&FrameMain::OnVideoOpen, this);
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);
// Subtitles area StartupLog("Create subtitles grid");
StartupLog(_T("Create subtitles grid")); context->subsGrid = SubsGrid = new SubtitlesGrid(this,Panel,-1,context->ass,wxDefaultPosition,wxSize(600,100),wxWANTS_CHARS | wxSUNKEN_BORDER,"Subs grid");
SubsGrid = new SubtitlesGrid(this,Panel,-1,ass,wxDefaultPosition,wxSize(600,100),wxWANTS_CHARS | wxSUNKEN_BORDER,_T("Subs grid")); context->videoBox->videoSlider->grid = SubsGrid;
temp_context->SubsGrid = SubsGrid; context->videoController->grid = SubsGrid;
videoBox->videoSlider->grid = SubsGrid;
temp_context->videoContext->grid = SubsGrid;
Search.grid = SubsGrid; Search.grid = SubsGrid;
// Tools area StartupLog("Create tool area splitter window");
StartupLog(_T("Create tool area splitter window"));
audioSash = new wxSashWindow(Panel, ID_SASH_MAIN_AUDIO, wxDefaultPosition, wxDefaultSize, wxSW_3D|wxCLIP_CHILDREN); audioSash = new wxSashWindow(Panel, ID_SASH_MAIN_AUDIO, wxDefaultPosition, wxDefaultSize, wxSW_3D|wxCLIP_CHILDREN);
wxBoxSizer *audioSashSizer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *audioSashSizer = new wxBoxSizer(wxHORIZONTAL);
audioSash->SetSashVisible(wxSASH_BOTTOM, true); audioSash->SetSashVisible(wxSASH_BOTTOM, true);
// Audio area StartupLog("Create audio box");
StartupLog(_T("Create audio box")); context->audioBox = audioBox = new AudioBox(audioSash, context->audioController, SubsGrid, context->ass);
audioBox = new AudioBox(audioSash, audioController, SubsGrid, ass);
temp_context->audioBox = audioBox;
audioBox->frameMain = this; audioBox->frameMain = this;
audioSashSizer->Add(audioBox, 1, wxEXPAND); audioSashSizer->Add(audioBox, 1, wxEXPAND);
audioSash->SetSizer(audioSashSizer); audioSash->SetSizer(audioSashSizer);
audioBox->Fit(); audioBox->Fit();
audioSash->SetMinimumSizeY(audioBox->GetSize().GetHeight()); audioSash->SetMinimumSizeY(audioBox->GetSize().GetHeight());
// Editing area StartupLog("Create subtitle editing box");
StartupLog(_T("Create subtitle editing box")); context->editBox = EditBox = new SubsEditBox(Panel, SubsGrid);
EditBox = new SubsEditBox(Panel,SubsGrid);
temp_context->EditBox = EditBox;
// Set sizers/hints StartupLog("Arrange main sizers");
StartupLog(_T("Arrange main sizers"));
ToolsSizer = new wxBoxSizer(wxVERTICAL); ToolsSizer = new wxBoxSizer(wxVERTICAL);
ToolsSizer->Add(audioSash, 0, wxEXPAND); ToolsSizer->Add(audioSash, 0, wxEXPAND);
ToolsSizer->Add(EditBox, 1, wxEXPAND); ToolsSizer->Add(EditBox, 1, wxEXPAND);
@ -361,40 +329,39 @@ void FrameMain::InitContents() {
//MainSizer->SetSizeHints(Panel); //MainSizer->SetSizeHints(Panel);
//SetSizer(MainSizer); //SetSizer(MainSizer);
// Set display StartupLog("Perform layout");
StartupLog(_T("Perform layout"));
Layout(); Layout();
StartupLog(_T("Set focus to edting box")); StartupLog("Set focus to edting box");
EditBox->TextEdit->SetFocus(); EditBox->TextEdit->SetFocus();
StartupLog(_T("Leaving InitContents")); StartupLog("Leaving InitContents");
} }
/// @brief Deinitialize controls /// @brief Deinitialize controls
void FrameMain::DeInitContents() { void FrameMain::DeInitContents() {
if (detachedVideo) detachedVideo->Destroy(); if (context->detachedVideo) context->detachedVideo->Destroy();
if (stylingAssistant) stylingAssistant->Destroy(); if (context->stylingAssistant) context->stylingAssistant->Destroy();
SubsGrid->ClearMaps(); SubsGrid->ClearMaps();
delete audioBox; delete audioBox;
delete EditBox; delete EditBox;
delete videoBox; delete videoBox;
delete ass; delete context->ass;
HelpButton::ClearPages(); HelpButton::ClearPages();
temp_context->videoContext->audio = NULL; context->videoController->audio = 0;
} }
/// @brief Update toolbar /// @brief Update toolbar
void FrameMain::UpdateToolbar() { void FrameMain::UpdateToolbar() {
// Collect flags // Collect flags
bool isVideo = temp_context->videoContext->IsLoaded(); bool isVideo = context->videoController->IsLoaded();
HasSelection = true; HasSelection = true;
int selRows = SubsGrid->GetNumberSelection(); int selRows = SubsGrid->GetNumberSelection();
// Update // Update
wxToolBar* toolbar = GetToolBar(); wxToolBar* toolbar = GetToolBar();
toolbar->FindById(cmd::id("video/jump"))->Enable(isVideo); toolbar->FindById(cmd::id("video/jump"))->Enable(isVideo);
toolbar->FindById(cmd::id("video/zoom/in"))->Enable(isVideo && !detachedVideo); toolbar->FindById(cmd::id("video/zoom/in"))->Enable(isVideo && !context->detachedVideo);
toolbar->FindById(cmd::id("video/zoom/out"))->Enable(isVideo && !detachedVideo); toolbar->FindById(cmd::id("video/zoom/out"))->Enable(isVideo && !context->detachedVideo);
ZoomBox->Enable(isVideo && !detachedVideo); ZoomBox->Enable(isVideo && !context->detachedVideo);
toolbar->FindById(cmd::id("video/jump/start"))->Enable(isVideo && selRows > 0); toolbar->FindById(cmd::id("video/jump/start"))->Enable(isVideo && selRows > 0);
toolbar->FindById(cmd::id("video/jump/end"))->Enable(isVideo && selRows > 0); toolbar->FindById(cmd::id("video/jump/end"))->Enable(isVideo && selRows > 0);
@ -412,7 +379,7 @@ void FrameMain::UpdateToolbar() {
/// @param filename /// @param filename
/// @param charset /// @param charset
void FrameMain::LoadSubtitles(wxString filename,wxString charset) { void FrameMain::LoadSubtitles(wxString filename,wxString charset) {
if (ass->loaded) { if (context->ass->loaded) {
if (TryToCloseSubs() == wxCANCEL) return; if (TryToCloseSubs() == wxCANCEL) return;
} }
@ -422,7 +389,7 @@ void FrameMain::LoadSubtitles(wxString filename,wxString charset) {
TextFileReader testSubs(filename,charset); TextFileReader testSubs(filename,charset);
wxString cur = testSubs.ReadLineFromFile(); wxString cur = testSubs.ReadLineFromFile();
if (cur.Left(10) == _T("# timecode")) { if (cur.Left(10) == _T("# timecode")) {
temp_context->videoContext->LoadTimecodes(filename); context->videoController->LoadTimecodes(filename);
return; return;
} }
} }
@ -431,7 +398,7 @@ void FrameMain::LoadSubtitles(wxString filename,wxString charset) {
// safe to assume that it is in fact not a timecode file // safe to assume that it is in fact not a timecode file
} }
ass->Load(filename,charset); context->ass->Load(filename,charset);
} }
catch (agi::acs::AcsNotFound const&) { catch (agi::acs::AcsNotFound const&) {
wxMessageBox(filename + L" not found.", L"Error", wxOK | wxICON_ERROR, NULL); wxMessageBox(filename + L" not found.", L"Error", wxOK | wxICON_ERROR, NULL);
@ -458,14 +425,14 @@ void FrameMain::LoadSubtitles(wxString filename,wxString charset) {
/// @return /// @return
bool FrameMain::SaveSubtitles(bool saveas, bool withCharset) { bool FrameMain::SaveSubtitles(bool saveas, bool withCharset) {
wxString filename; wxString filename;
if (!saveas && ass->CanSave()) { if (!saveas && context->ass->CanSave()) {
filename = ass->filename; filename = context->ass->filename;
} }
if (filename.empty()) { if (filename.empty()) {
temp_context->videoContext->Stop(); context->videoController->Stop();
wxString path = lagi_wxString(OPT_GET("Path/Last/Subtitles")->GetString()); wxString path = lagi_wxString(OPT_GET("Path/Last/Subtitles")->GetString());
wxFileName origPath(ass->filename); wxFileName origPath(context->ass->filename);
filename = wxFileSelector(_("Save subtitles file"), path, origPath.GetName() + ".ass", "ass", AssFile::GetWildcardList(1), wxFD_SAVE | wxFD_OVERWRITE_PROMPT, this); filename = wxFileSelector(_("Save subtitles file"), path, origPath.GetName() + ".ass", "ass", AssFile::GetWildcardList(1), wxFD_SAVE | wxFD_OVERWRITE_PROMPT, this);
} }
if (filename.empty()) { if (filename.empty()) {
@ -479,7 +446,7 @@ bool FrameMain::SaveSubtitles(bool saveas, bool withCharset) {
} }
try { try {
ass->Save(filename, true, true, charset); context->ass->Save(filename, true, true, charset);
} }
catch (const agi::Exception& err) { catch (const agi::Exception& err) {
wxMessageBox(lagi_wxString(err.GetMessage()), "Error", wxOK | wxICON_ERROR, NULL); wxMessageBox(lagi_wxString(err.GetMessage()), "Error", wxOK | wxICON_ERROR, NULL);
@ -500,7 +467,7 @@ bool FrameMain::SaveSubtitles(bool saveas, bool withCharset) {
/// @param enableCancel /// @param enableCancel
/// @return /// @return
int FrameMain::TryToCloseSubs(bool enableCancel) { int FrameMain::TryToCloseSubs(bool enableCancel) {
if (ass->IsModified()) { if (context->ass->IsModified()) {
int flags = wxYES_NO; int flags = wxYES_NO;
if (enableCancel) flags |= wxCANCEL; if (enableCancel) flags |= wxCANCEL;
int result = wxMessageBox(_("Save before continuing?"), _("Unsaved changes"), flags,this); int result = wxMessageBox(_("Save before continuing?"), _("Unsaved changes"), flags,this);
@ -523,10 +490,10 @@ void FrameMain::SetDisplayMode(int video, int audio) {
bool sv = false, sa = false; bool sv = false, sa = false;
if (video == -1) sv = showVideo; if (video == -1) sv = showVideo;
else if (video) sv = temp_context->videoContext->IsLoaded() && !detachedVideo; else if (video) sv = context->videoController->IsLoaded() && !context->detachedVideo;
if (audio == -1) sa = showAudio; if (audio == -1) sa = showAudio;
else if (audio) sa = audioController->IsAudioOpen(); else if (audio) sa = context->audioController->IsAudioOpen();
// See if anything changed // See if anything changed
if (sv == showVideo && sa == showAudio) return; if (sv == showVideo && sa == showAudio) return;
@ -537,7 +504,7 @@ void FrameMain::SetDisplayMode(int video, int audio) {
bool didFreeze = !IsFrozen(); bool didFreeze = !IsFrozen();
if (didFreeze) Freeze(); if (didFreeze) Freeze();
temp_context->videoContext->Stop(); context->videoController->Stop();
// Set display // Set display
TopSizer->Show(videoBox, showVideo, true); TopSizer->Show(videoBox, showVideo, true);
@ -555,11 +522,9 @@ void FrameMain::SetDisplayMode(int video, int audio) {
/// @brief Update title bar /// @brief Update title bar
void FrameMain::UpdateTitle() { void FrameMain::UpdateTitle() {
bool subsMod = ass->IsModified();
wxString newTitle; wxString newTitle;
if (subsMod) newTitle << _T("* "); if (context->ass->IsModified()) newTitle << _T("* ");
if (ass->filename.empty()) { if (context->ass->filename.empty()) {
// Apple HIG says "untitled" should not be capitalised // Apple HIG says "untitled" should not be capitalised
// and the window is a document window, it shouldn't contain the app name // and the window is a document window, it shouldn't contain the app name
// (The app name is already present in the menu bar) // (The app name is already present in the menu bar)
@ -570,7 +535,7 @@ void FrameMain::UpdateTitle() {
#endif #endif
} }
else { else {
wxFileName file (ass->filename); wxFileName file (context->ass->filename);
newTitle << file.GetFullName(); newTitle << file.GetFullName();
} }
@ -580,7 +545,7 @@ void FrameMain::UpdateTitle() {
#if defined(__WXMAC__) && !defined(__LP64__) #if defined(__WXMAC__) && !defined(__LP64__)
// On Mac, set the mark in the close button // On Mac, set the mark in the close button
OSXSetModified(subsMod); OSXSetModified(context->ass->IsModified());
#endif #endif
if (GetTitle() != newTitle) SetTitle(newTitle); if (GetTitle() != newTitle) SetTitle(newTitle);
@ -593,37 +558,37 @@ void FrameMain::SynchronizeProject() {
wxString seekpos = _T("0"); wxString seekpos = _T("0");
wxString ar = _T("0"); wxString ar = _T("0");
wxString zoom = _T("6"); wxString zoom = _T("6");
if (temp_context->videoContext->IsLoaded()) { if (context->videoController->IsLoaded()) {
seekpos = wxString::Format(_T("%i"),temp_context->videoContext->GetFrameN()); seekpos = wxString::Format(_T("%i"),context->videoController->GetFrameN());
zoom = wxString::Format(_T("%f"),videoBox->videoDisplay->GetZoom()); zoom = wxString::Format(_T("%f"),videoBox->videoDisplay->GetZoom());
int arType = temp_context->videoContext->GetAspectRatioType(); int arType = context->videoController->GetAspectRatioType();
if (arType == 4) ar = wxString(_T("c")) + AegiFloatToString(temp_context->videoContext->GetAspectRatioValue()); if (arType == 4) ar = wxString(_T("c")) + AegiFloatToString(context->videoController->GetAspectRatioValue());
else ar = wxString::Format(_T("%i"),arType); else ar = wxString::Format(_T("%i"),arType);
} }
// Store audio data // Store audio data
ass->SetScriptInfo(_T("Audio URI"),MakeRelativePath(audioController->GetAudioURL(),ass->filename)); context->ass->SetScriptInfo(_T("Audio URI"),MakeRelativePath(context->audioController->GetAudioURL(),context->ass->filename));
// Store video data // Store video data
ass->SetScriptInfo(_T("Video File"),MakeRelativePath(temp_context->videoContext->videoName,ass->filename)); context->ass->SetScriptInfo(_T("Video File"),MakeRelativePath(context->videoController->videoName,context->ass->filename));
ass->SetScriptInfo(_T("Video Aspect Ratio"),ar); context->ass->SetScriptInfo(_T("Video Aspect Ratio"),ar);
ass->SetScriptInfo(_T("Video Zoom Percent"),zoom); context->ass->SetScriptInfo(_T("Video Zoom Percent"),zoom);
ass->SetScriptInfo(_T("Video Position"),seekpos); context->ass->SetScriptInfo(_T("Video Position"),seekpos);
ass->SetScriptInfo(_T("VFR File"),MakeRelativePath(temp_context->videoContext->GetTimecodesName(),ass->filename)); context->ass->SetScriptInfo(_T("VFR File"),MakeRelativePath(context->videoController->GetTimecodesName(),context->ass->filename));
ass->SetScriptInfo(_T("Keyframes File"),MakeRelativePath(temp_context->videoContext->GetKeyFramesName(),ass->filename)); context->ass->SetScriptInfo(_T("Keyframes File"),MakeRelativePath(context->videoController->GetKeyFramesName(),context->ass->filename));
} }
void FrameMain::OnVideoOpen() { void FrameMain::OnVideoOpen() {
if (!temp_context->videoContext->IsLoaded()) { if (!context->videoController->IsLoaded()) {
SetDisplayMode(0, -1); SetDisplayMode(0, -1);
DetachVideo(false); DetachVideo(false);
return; return;
} }
Freeze(); Freeze();
int vidx = temp_context->videoContext->GetWidth(), int vidx = context->videoController->GetWidth(),
vidy = temp_context->videoContext->GetHeight(); vidy = context->videoController->GetHeight();
// Set zoom level based on video resolution and window size // Set zoom level based on video resolution and window size
double zoom = videoBox->videoDisplay->GetZoom(); double zoom = videoBox->videoDisplay->GetZoom();
@ -634,8 +599,8 @@ void FrameMain::OnVideoOpen() {
videoBox->videoDisplay->SetZoom(zoom * .5); videoBox->videoDisplay->SetZoom(zoom * .5);
// Check that the video size matches the script video size specified // Check that the video size matches the script video size specified
int scriptx = ass->GetScriptInfoAsInt("PlayResX"); int scriptx = context->ass->GetScriptInfoAsInt("PlayResX");
int scripty = ass->GetScriptInfoAsInt("PlayResY"); int scripty = context->ass->GetScriptInfoAsInt("PlayResY");
if (scriptx != vidx || scripty != vidy) { if (scriptx != vidx || scripty != vidy) {
switch (OPT_GET("Video/Check Script Res")->GetInt()) { switch (OPT_GET("Video/Check Script Res")->GetInt()) {
case 1: case 1:
@ -645,9 +610,9 @@ void FrameMain::OnVideoOpen() {
// Fallthrough to case 2 // Fallthrough to case 2
case 2: case 2:
// Always change script res // Always change script res
ass->SetScriptInfo("PlayResX", wxString::Format("%d", vidx)); context->ass->SetScriptInfo("PlayResX", wxString::Format("%d", vidx));
ass->SetScriptInfo("PlayResY", wxString::Format("%d", vidy)); context->ass->SetScriptInfo("PlayResY", wxString::Format("%d", vidy));
ass->Commit(_("Change script resolution")); context->ass->Commit(_("Change script resolution"));
break; break;
case 0: case 0:
default: default:
@ -664,10 +629,10 @@ void FrameMain::OnVideoOpen() {
void FrameMain::LoadVFR(wxString filename) { void FrameMain::LoadVFR(wxString filename) {
if (filename.empty()) { if (filename.empty()) {
temp_context->videoContext->CloseTimecodes(); context->videoController->CloseTimecodes();
} }
else { else {
temp_context->videoContext->LoadTimecodes(filename); context->videoController->LoadTimecodes(filename);
} }
} }
@ -680,15 +645,14 @@ void FrameMain::OpenHelp(wxString) {
/// @param detach /// @param detach
void FrameMain::DetachVideo(bool detach) { void FrameMain::DetachVideo(bool detach) {
if (detach) { if (detach) {
if (!detachedVideo) { if (!context->detachedVideo) {
detachedVideo = new DialogDetachedVideo(this, videoBox->videoDisplay->GetClientSize()); context->detachedVideo = new DialogDetachedVideo(this, videoBox->videoDisplay->GetClientSize());
temp_context->detachedVideo = detachedVideo; context->detachedVideo->Show();
detachedVideo->Show();
} }
} }
else if (detachedVideo) { else if (context->detachedVideo) {
detachedVideo->Destroy(); context->detachedVideo->Destroy();
detachedVideo = NULL; context->detachedVideo = 0;
SetDisplayMode(1,-1); SetDisplayMode(1,-1);
} }
UpdateToolbar(); UpdateToolbar();
@ -779,10 +743,10 @@ bool FrameMain::LoadList(wxArrayString list) {
} }
if (blockVideoLoad) { if (blockVideoLoad) {
blockVideoLoad = false; blockVideoLoad = false;
temp_context->videoContext->SetVideo(video); context->videoController->SetVideo(video);
} }
if (!audio.empty()) if (!audio.empty())
audioController->OpenAudio(audio); context->audioController->OpenAudio(audio);
// Result // Result
return subs.size() || audio.size() || video.size(); return subs.size() || audio.size() || video.size();
@ -792,8 +756,8 @@ bool FrameMain::LoadList(wxArrayString list) {
/// @brief Sets the descriptions for undo/redo /// @brief Sets the descriptions for undo/redo
void FrameMain::SetUndoRedoDesc() { void FrameMain::SetUndoRedoDesc() {
wxMenu *editMenu = menu::menu->GetMenu("main/edit"); wxMenu *editMenu = menu::menu->GetMenu("main/edit");
editMenu->SetHelpString(0,_T("Undo ")+ass->GetUndoDescription()); editMenu->SetHelpString(0,_T("Undo ")+context->ass->GetUndoDescription());
editMenu->SetHelpString(1,_T("Redo ")+ass->GetRedoDescription()); editMenu->SetHelpString(1,_T("Redo ")+context->ass->GetRedoDescription());
} }
/// @brief Check if ASSDraw is available /// @brief Check if ASSDraw is available
@ -893,14 +857,14 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
// Rebuild recent // Rebuild recent
RebuildRecentList("recent/subtitle", "Subtitle"); RebuildRecentList("recent/subtitle", "Subtitle");
MenuBar->Enable(cmd::id("subtitle/open/video"),temp_context->videoContext->HasSubtitles()); MenuBar->Enable(cmd::id("subtitle/open/video"),context->videoController->HasSubtitles());
} }
// View menu // View menu
else if (curMenu == menu::menu->GetMenu("main/view")) { else if (curMenu == menu::menu->GetMenu("main/view")) {
// Flags // Flags
bool aud = audioController->IsAudioOpen(); bool aud = context->audioController->IsAudioOpen();
bool vid = temp_context->videoContext->IsLoaded() && !detachedVideo; bool vid = context->videoController->IsLoaded() && !context->detachedVideo;
// Set states // Set states
MenuBar->Enable(cmd::id("app/display/audio_subs"),aud); MenuBar->Enable(cmd::id("app/display/audio_subs"),aud);
@ -923,8 +887,8 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
// Video menu // Video menu
else if (curMenu == menu::menu->GetMenu("main/video")) { else if (curMenu == menu::menu->GetMenu("main/video")) {
bool state = temp_context->videoContext->IsLoaded(); bool state = context->videoController->IsLoaded();
bool attached = state && !detachedVideo; bool attached = state && !context->detachedVideo;
// Set states // Set states
MenuBar->Enable(cmd::id("video/jump"),state); MenuBar->Enable(cmd::id("video/jump"),state);
@ -942,15 +906,15 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
MenuBar->Enable(cmd::id("video/aspect/cinematic"),attached); MenuBar->Enable(cmd::id("video/aspect/cinematic"),attached);
MenuBar->Enable(cmd::id("video/aspect/custom"),attached); MenuBar->Enable(cmd::id("video/aspect/custom"),attached);
MenuBar->Enable(cmd::id("video/detach"),state); MenuBar->Enable(cmd::id("video/detach"),state);
MenuBar->Enable(cmd::id("timecode/save"),temp_context->videoContext->TimecodesLoaded()); MenuBar->Enable(cmd::id("timecode/save"),context->videoController->TimecodesLoaded());
MenuBar->Enable(cmd::id("timecode/close"),temp_context->videoContext->OverTimecodesLoaded()); MenuBar->Enable(cmd::id("timecode/close"),context->videoController->OverTimecodesLoaded());
MenuBar->Enable(cmd::id("keyframe/close"),temp_context->videoContext->OverKeyFramesLoaded()); MenuBar->Enable(cmd::id("keyframe/close"),context->videoController->OverKeyFramesLoaded());
MenuBar->Enable(cmd::id("keyframe/save"),temp_context->videoContext->KeyFramesLoaded()); MenuBar->Enable(cmd::id("keyframe/save"),context->videoController->KeyFramesLoaded());
MenuBar->Enable(cmd::id("video/details"),state); MenuBar->Enable(cmd::id("video/details"),state);
MenuBar->Enable(cmd::id("video/show_overscan"),state); MenuBar->Enable(cmd::id("video/show_overscan"),state);
// Set AR radio // Set AR radio
int arType = temp_context->videoContext->GetAspectRatioType(); int arType = context->videoController->GetAspectRatioType();
MenuBar->Check(cmd::id("video/aspect/default"),false); MenuBar->Check(cmd::id("video/aspect/default"),false);
MenuBar->Check(cmd::id("video/aspect/full"),false); MenuBar->Check(cmd::id("video/aspect/full"),false);
MenuBar->Check(cmd::id("video/aspect/wide"),false); MenuBar->Check(cmd::id("video/aspect/wide"),false);
@ -975,8 +939,8 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
// Audio menu // Audio menu
else if (curMenu == menu::menu->GetMenu("main/audio")) { else if (curMenu == menu::menu->GetMenu("main/audio")) {
bool state = audioController->IsAudioOpen(); bool state = context->audioController->IsAudioOpen();
bool vidstate = temp_context->videoContext->IsLoaded(); bool vidstate = context->videoController->IsLoaded();
MenuBar->Enable(cmd::id("audio/open/video"),vidstate); MenuBar->Enable(cmd::id("audio/open/video"),vidstate);
MenuBar->Enable(cmd::id("audio/close"),state); MenuBar->Enable(cmd::id("audio/close"),state);
@ -999,13 +963,13 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
MenuBar->Enable(cmd::id("subtitle/insert/after"),state); MenuBar->Enable(cmd::id("subtitle/insert/after"),state);
MenuBar->Enable(cmd::id("edit/line/split/by_karaoke"),state); MenuBar->Enable(cmd::id("edit/line/split/by_karaoke"),state);
MenuBar->Enable(cmd::id("edit/line/delete"),state); MenuBar->Enable(cmd::id("edit/line/delete"),state);
state2 = count > 0 && temp_context->videoContext->IsLoaded(); state2 = count > 0 && context->videoController->IsLoaded();
MenuBar->Enable(cmd::id("subtitle/insert/before/videotime"),state2); MenuBar->Enable(cmd::id("subtitle/insert/before/videotime"),state2);
MenuBar->Enable(cmd::id("subtitle/insert/after/videotime"),state2); MenuBar->Enable(cmd::id("subtitle/insert/after/videotime"),state2);
MenuBar->Enable(cmd::id("main/subtitle/insert lines"),state); MenuBar->Enable(cmd::id("main/subtitle/insert lines"),state);
state = count > 0 && continuous; state = count > 0 && continuous;
MenuBar->Enable(cmd::id("edit/line/duplicate"),state); MenuBar->Enable(cmd::id("edit/line/duplicate"),state);
state = count > 0 && continuous && temp_context->videoContext->TimecodesLoaded(); state = count > 0 && continuous && context->videoController->TimecodesLoaded();
MenuBar->Enable(cmd::id("edit/line/duplicate/shift"),state); MenuBar->Enable(cmd::id("edit/line/duplicate/shift"),state);
state = count == 2; state = count == 2;
MenuBar->Enable(cmd::id("edit/line/swap"),state); MenuBar->Enable(cmd::id("edit/line/swap"),state);
@ -1026,7 +990,7 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
int count = sels.Count(); int count = sels.Count();
// Video related // Video related
bool state = temp_context->videoContext->IsLoaded(); bool state = context->videoController->IsLoaded();
MenuBar->Enable(cmd::id("time/snap/start_video"),state); MenuBar->Enable(cmd::id("time/snap/start_video"),state);
MenuBar->Enable(cmd::id("time/snap/end_video"),state); MenuBar->Enable(cmd::id("time/snap/end_video"),state);
MenuBar->Enable(cmd::id("time/snap/scene"),state); MenuBar->Enable(cmd::id("time/snap/scene"),state);
@ -1046,18 +1010,18 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
wxMenuItem *item; wxMenuItem *item;
//H wxString undo_text = _("&Undo") + wxString(_T(" ")) + ass->GetUndoDescription() + wxString(_T("\t")) + Hotkeys.GetText(_T("Undo")); //H wxString undo_text = _("&Undo") + wxString(_T(" ")) + ass->GetUndoDescription() + wxString(_T("\t")) + Hotkeys.GetText(_T("Undo"));
// The bottom line needs to be fixed for the new hotkey system // The bottom line needs to be fixed for the new hotkey system
wxString undo_text = _("&Undo") + wxString(_T(" ")) + ass->GetUndoDescription() + wxString(_T("\t")) + _T("Undo"); wxString undo_text = _("&Undo") + wxString(_T(" ")) + context->ass->GetUndoDescription() + wxString(_T("\t")) + _T("Undo");
item = editMenu->FindItem(cmd::id("edit/undo")); item = editMenu->FindItem(cmd::id("edit/undo"));
item->SetItemLabel(undo_text); item->SetItemLabel(undo_text);
item->Enable(!ass->IsUndoStackEmpty()); item->Enable(!context->ass->IsUndoStackEmpty());
// Redo state // Redo state
//H wxString redo_text = _("&Redo") + wxString(_T(" ")) + ass->GetRedoDescription() + wxString(_T("\t")) + Hotkeys.GetText(_T("Redo")); //H wxString redo_text = _("&Redo") + wxString(_T(" ")) + ass->GetRedoDescription() + wxString(_T("\t")) + Hotkeys.GetText(_T("Redo"));
// Same as above. // Same as above.
wxString redo_text = _("&Redo") + wxString(_T(" ")) + ass->GetRedoDescription() + wxString(_T("\t")) + _T("Redo"); wxString redo_text = _("&Redo") + wxString(_T(" ")) + context->ass->GetRedoDescription() + wxString(_T("\t")) + _T("Redo");
item = editMenu->FindItem(cmd::id("edit/redo")); item = editMenu->FindItem(cmd::id("edit/redo"));
item->SetItemLabel(redo_text); item->SetItemLabel(redo_text);
item->Enable(!ass->IsRedoStackEmpty()); item->Enable(!context->ass->IsRedoStackEmpty());
// Copy/cut/paste // Copy/cut/paste
wxArrayInt sels = SubsGrid->GetSelection(); wxArrayInt sels = SubsGrid->GetSelection();
@ -1092,7 +1056,7 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
// Add new ones // Add new ones
int added = 0; int added = 0;
added += AddMacroMenuItems(automationMenu, wxGetApp().global_scripts->GetMacros()); added += AddMacroMenuItems(automationMenu, wxGetApp().global_scripts->GetMacros());
added += AddMacroMenuItems(automationMenu, local_scripts->GetMacros()); added += AddMacroMenuItems(automationMenu, context->local_scripts->GetMacros());
// If none were added, show a ghosted notice // If none were added, show a ghosted notice
if (added == 0) { if (added == 0) {
@ -1149,8 +1113,8 @@ void FrameMain::OnAutomationMacro (wxCommandEvent &event) {
/// @param event /// @param event
void FrameMain::OnCloseWindow (wxCloseEvent &event) { void FrameMain::OnCloseWindow (wxCloseEvent &event) {
// Stop audio and video // Stop audio and video
temp_context->videoContext->Stop(); context->videoController->Stop();
audioController->Stop(); context->audioController->Stop();
// Ask user if he wants to save first // Ask user if he wants to save first
bool canVeto = event.CanVeto(); bool canVeto = event.CanVeto();
@ -1170,9 +1134,9 @@ void FrameMain::OnCloseWindow (wxCloseEvent &event) {
/// @brief Autosave the currently open file, if any /// @brief Autosave the currently open file, if any
void FrameMain::OnAutoSave(wxTimerEvent &) { void FrameMain::OnAutoSave(wxTimerEvent &) {
try { try {
if (ass->loaded && ass->IsModified()) { if (context->ass->loaded && context->ass->IsModified()) {
// Set path // Set path
wxFileName origfile(ass->filename); wxFileName origfile(context->ass->filename);
wxString path = lagi_wxString(OPT_GET("Path/Auto/Save")->GetString()); wxString path = lagi_wxString(OPT_GET("Path/Auto/Save")->GetString());
if (path.IsEmpty()) path = origfile.GetPath(); if (path.IsEmpty()) path = origfile.GetPath();
wxFileName dstpath(path); wxFileName dstpath(path);
@ -1188,7 +1152,7 @@ void FrameMain::OnAutoSave(wxTimerEvent &) {
dstpath.SetFullName(name + L".AUTOSAVE.ass"); dstpath.SetFullName(name + L".AUTOSAVE.ass");
} }
ass->Save(dstpath.GetFullPath(),false,false); context->ass->Save(dstpath.GetFullPath(),false,false);
// Set status bar // Set status bar
StatusTimeout(_("File backup saved as \"") + dstpath.GetFullPath() + _T("\".")); StatusTimeout(_("File backup saved as \"") + dstpath.GetFullPath() + _T("\"."));
@ -1240,7 +1204,7 @@ void FrameMain::OnAudioClose()
void FrameMain::OnSubtitlesCommit() { void FrameMain::OnSubtitlesCommit() {
if (OPT_GET("App/Auto/Save on Every Change")->GetBool()) { if (OPT_GET("App/Auto/Save on Every Change")->GetBool()) {
if (ass->IsModified() && !ass->filename.empty()) SaveSubtitles(false); if (context->ass->IsModified() && !context->ass->filename.empty()) SaveSubtitles(false);
} }
UpdateTitle(); UpdateTitle();
@ -1253,21 +1217,21 @@ void FrameMain::OnSubtitlesOpen() {
/// prompting for each file loaded/unloaded /// prompting for each file loaded/unloaded
// Load stuff from the new script // Load stuff from the new script
wxString curSubsVideo = DecodeRelativePath(ass->GetScriptInfo("Video File"),ass->filename); wxString curSubsVideo = DecodeRelativePath(context->ass->GetScriptInfo("Video File"),context->ass->filename);
wxString curSubsVFR = DecodeRelativePath(ass->GetScriptInfo("VFR File"),ass->filename); wxString curSubsVFR = DecodeRelativePath(context->ass->GetScriptInfo("VFR File"),context->ass->filename);
wxString curSubsKeyframes = DecodeRelativePath(ass->GetScriptInfo("Keyframes File"),ass->filename); wxString curSubsKeyframes = DecodeRelativePath(context->ass->GetScriptInfo("Keyframes File"),context->ass->filename);
wxString curSubsAudio = DecodeRelativePath(ass->GetScriptInfo("Audio URI"),ass->filename); wxString curSubsAudio = DecodeRelativePath(context->ass->GetScriptInfo("Audio URI"),context->ass->filename);
wxString AutoScriptString = ass->GetScriptInfo("Automation Scripts"); wxString AutoScriptString = context->ass->GetScriptInfo("Automation Scripts");
// Check if there is anything to change // Check if there is anything to change
int autoLoadMode = OPT_GET("App/Auto/Load Linked Files")->GetInt(); int autoLoadMode = OPT_GET("App/Auto/Load Linked Files")->GetInt();
bool doLoad = false; bool doLoad = false;
if (curSubsAudio != audioController->GetAudioURL() || if (curSubsAudio != context->audioController->GetAudioURL() ||
curSubsVFR != temp_context->videoContext->GetTimecodesName() || curSubsVFR != context->videoController->GetTimecodesName() ||
curSubsVideo != temp_context->videoContext->videoName || curSubsVideo != context->videoController->videoName ||
curSubsKeyframes != temp_context->videoContext->GetKeyFramesName() curSubsKeyframes != context->videoController->GetKeyFramesName()
#ifdef WITH_AUTOMATION #ifdef WITH_AUTOMATION
|| !AutoScriptString.IsEmpty() || local_scripts->GetScripts().size() > 0 || !AutoScriptString.IsEmpty() || context->local_scripts->GetScripts().size() > 0
#endif #endif
) )
{ {
@ -1281,17 +1245,17 @@ void FrameMain::OnSubtitlesOpen() {
if (doLoad) { if (doLoad) {
// Video // Video
if (!blockVideoLoad && curSubsVideo != temp_context->videoContext->videoName) { if (!blockVideoLoad && curSubsVideo != context->videoController->videoName) {
temp_context->videoContext->SetVideo(curSubsVideo); context->videoController->SetVideo(curSubsVideo);
if (temp_context->videoContext->IsLoaded()) { if (context->videoController->IsLoaded()) {
long videoPos = 0; long videoPos = 0;
long videoAr = 0; long videoAr = 0;
double videoArValue = 0.0; double videoArValue = 0.0;
double videoZoom = 0.; double videoZoom = 0.;
ass->GetScriptInfo("Video Position").ToLong(&videoPos); context->ass->GetScriptInfo("Video Position").ToLong(&videoPos);
ass->GetScriptInfo("Video Zoom Percent").ToDouble(&videoZoom); context->ass->GetScriptInfo("Video Zoom Percent").ToDouble(&videoZoom);
wxString arString = ass->GetScriptInfo("Video Aspect Ratio"); wxString arString = context->ass->GetScriptInfo("Video Aspect Ratio");
if (arString.Left(1) == "c") { if (arString.Left(1) == "c") {
videoAr = 4; videoAr = 4;
arString = arString.Mid(1); arString = arString.Mid(1);
@ -1301,25 +1265,25 @@ void FrameMain::OnSubtitlesOpen() {
arString.ToLong(&videoAr); arString.ToLong(&videoAr);
} }
temp_context->videoContext->SetAspectRatio(videoAr,videoArValue); context->videoController->SetAspectRatio(videoAr,videoArValue);
videoBox->videoDisplay->SetZoom(videoZoom); videoBox->videoDisplay->SetZoom(videoZoom);
temp_context->videoContext->JumpToFrame(videoPos); context->videoController->JumpToFrame(videoPos);
} }
} }
temp_context->videoContext->LoadTimecodes(curSubsVFR); context->videoController->LoadTimecodes(curSubsVFR);
temp_context->videoContext->LoadKeyframes(curSubsKeyframes); context->videoController->LoadKeyframes(curSubsKeyframes);
// Audio // Audio
if (curSubsAudio != audioController->GetAudioURL()) { if (curSubsAudio != context->audioController->GetAudioURL()) {
audioController->OpenAudio(curSubsAudio); context->audioController->OpenAudio(curSubsAudio);
} }
// Automation scripts // Automation scripts
#ifdef WITH_AUTOMATION #ifdef WITH_AUTOMATION
local_scripts->RemoveAll(); context->local_scripts->RemoveAll();
wxStringTokenizer tok(AutoScriptString, _T("|"), wxTOKEN_STRTOK); wxStringTokenizer tok(AutoScriptString, _T("|"), wxTOKEN_STRTOK);
wxFileName assfn(ass->filename); wxFileName assfn(context->ass->filename);
wxString autobasefn(lagi_wxString(OPT_GET("Path/Automation/Base")->GetString())); wxString autobasefn(lagi_wxString(OPT_GET("Path/Automation/Base")->GetString()));
while (tok.HasMoreTokens()) { while (tok.HasMoreTokens()) {
wxString sfnames = tok.GetNextToken().Trim(true).Trim(false); wxString sfnames = tok.GetNextToken().Trim(true).Trim(false);
@ -1341,7 +1305,7 @@ void FrameMain::OnSubtitlesOpen() {
sfname.MakeAbsolute(basepath); sfname.MakeAbsolute(basepath);
if (sfname.FileExists()) { if (sfname.FileExists()) {
sfnames = sfname.GetFullPath(); sfnames = sfname.GetFullPath();
local_scripts->Add(Automation4::ScriptFactory::CreateFromFile(sfnames, true)); context->local_scripts->Add(Automation4::ScriptFactory::CreateFromFile(sfnames, true));
} else { } else {
wxLogWarning(_T("Automation Script referenced could not be found.\nFilename specified: %s%s\nSearched relative to: %s\nResolved filename: %s"), wxLogWarning(_T("Automation Script referenced could not be found.\nFilename specified: %s%s\nSearched relative to: %s\nResolved filename: %s"),
sfnamel.c_str(), sfnames.c_str(), basepath.c_str(), sfname.GetFullPath().c_str()); sfnamel.c_str(), sfnames.c_str(), basepath.c_str(), sfname.GetFullPath().c_str());
@ -1367,7 +1331,7 @@ void FrameMain::OnSubtitlesSave() {
wxString scripts_string; wxString scripts_string;
wxString autobasefn(lagi_wxString(OPT_GET("Path/Automation/Base")->GetString())); wxString autobasefn(lagi_wxString(OPT_GET("Path/Automation/Base")->GetString()));
const std::vector<Automation4::Script*> &scripts = local_scripts->GetScripts(); const std::vector<Automation4::Script*> &scripts = context->local_scripts->GetScripts();
for (unsigned int i = 0; i < scripts.size(); i++) { for (unsigned int i = 0; i < scripts.size(); i++) {
Automation4::Script *script = scripts[i]; Automation4::Script *script = scripts[i];
@ -1377,7 +1341,7 @@ void FrameMain::OnSubtitlesSave() {
wxString autobase_rel, assfile_rel; wxString autobase_rel, assfile_rel;
wxString scriptfn(script->GetFilename()); wxString scriptfn(script->GetFilename());
autobase_rel = MakeRelativePath(scriptfn, autobasefn); autobase_rel = MakeRelativePath(scriptfn, autobasefn);
assfile_rel = MakeRelativePath(scriptfn, ass->filename); assfile_rel = MakeRelativePath(scriptfn, context->ass->filename);
if (autobase_rel.size() <= scriptfn.size() && autobase_rel.size() <= assfile_rel.size()) { if (autobase_rel.size() <= scriptfn.size() && autobase_rel.size() <= assfile_rel.size()) {
scriptfn = _T("$") + autobase_rel; scriptfn = _T("$") + autobase_rel;
@ -1389,7 +1353,7 @@ void FrameMain::OnSubtitlesSave() {
scripts_string += scriptfn; scripts_string += scriptfn;
} }
ass->SetScriptInfo(_T("Automation Scripts"), scripts_string); context->ass->SetScriptInfo(_T("Automation Scripts"), scripts_string);
#endif #endif
} }

View file

@ -93,14 +93,11 @@ public:
void DetachVideo(bool detach=true); void DetachVideo(bool detach=true);
void LoadVFR(wxString filename); void LoadVFR(wxString filename);
agi::scoped_ptr<agi::Context> temp_context; agi::scoped_ptr<agi::Context> context;
private: private:
void cmd_call(wxCommandEvent& event); void cmd_call(wxCommandEvent& event);
AssFile *ass;
/// DOCME /// DOCME
/// DOCME /// DOCME
@ -132,17 +129,6 @@ private:
/// DOCME /// DOCME
wxComboBox *ZoomBox; wxComboBox *ZoomBox;
/// DOCME
wxWindow *PreviousFocus;
#ifdef WITH_AUTOMATION
/// DOCME
Automation4::ScriptManager *local_scripts;
#endif
/// DOCME /// DOCME
std::vector<Automation4::FeatureMacro*> activeMacroItems; std::vector<Automation4::FeatureMacro*> activeMacroItems;
int AddMacroMenuItems(wxMenu *menu, const std::vector<Automation4::FeatureMacro*> &macros); int AddMacroMenuItems(wxMenu *menu, const std::vector<Automation4::FeatureMacro*> &macros);
@ -194,16 +180,6 @@ public:
/// The video area /// The video area
VideoBox *videoBox; VideoBox *videoBox;
/// DOCME
DialogDetachedVideo *detachedVideo;
/// DOCME
DialogStyling *stylingAssistant;
/// The audio controller for the open project
AudioController *audioController;
/// Arranges things from top to bottom in the window /// Arranges things from top to bottom in the window
wxBoxSizer *MainSizer; wxBoxSizer *MainSizer;

View file

@ -72,7 +72,7 @@ void check(std::string context, int key_code, wchar_t key_char, int modifier) {
/// The bottom line should be removed after all the hotkey commands are fixed. /// The bottom line should be removed after all the hotkey commands are fixed.
/// This is to avoid pointless exceptions. /// This is to avoid pointless exceptions.
if (command.find("/") != std::string::npos) if (command.find("/") != std::string::npos)
(*cmd::get(command))(wxGetApp().frame->temp_context.get()); (*cmd::get(command))(wxGetApp().frame->context.get());
} }
} }

View file

@ -19,7 +19,7 @@ struct Context {
// Controllers // Controllers
AudioController *audioController; AudioController *audioController;
VideoContext *videoContext; VideoContext *videoController;
// Things that should probably be in some sort of UI-context-model // Things that should probably be in some sort of UI-context-model
wxWindow *parent; wxWindow *parent;
@ -29,8 +29,8 @@ struct Context {
AudioBox *audioBox; AudioBox *audioBox;
DialogDetachedVideo *detachedVideo; DialogDetachedVideo *detachedVideo;
DialogStyling *stylingAssistant; DialogStyling *stylingAssistant;
SubsEditBox *EditBox; SubsEditBox *editBox;
SubtitlesGrid *SubsGrid; SubtitlesGrid *subsGrid;
VideoBox *videoBox; VideoBox *videoBox;
}; };

View file

@ -46,6 +46,7 @@
#include <wx/tokenzr.h> #include <wx/tokenzr.h>
#endif #endif
#include "include/aegisub/context.h"
#include "include/aegisub/hotkey.h" #include "include/aegisub/hotkey.h"
#include "include/aegisub/audio_provider.h" #include "include/aegisub/audio_provider.h"
@ -227,7 +228,7 @@ void SubtitlesGrid::OnPopupMenu(bool alternate) {
menu.AppendSeparator(); menu.AppendSeparator();
//Make audio clip //Make audio clip
state = parentFrame->audioController->IsAudioOpen()==true; state = parentFrame->context->audioController->IsAudioOpen()==true;
menu.Append(MENU_AUDIOCLIP,_("Create audio clip"),_("Create an audio clip of the selected line"))->Enable(state); menu.Append(MENU_AUDIOCLIP,_("Create audio clip"),_("Create an audio clip of the selected line"))->Enable(state);
menu.AppendSeparator(); menu.AppendSeparator();
@ -676,7 +677,7 @@ void SubtitlesGrid::OnRecombine(wxCommandEvent &) {
/// @brief Export audio clip of line /// @brief Export audio clip of line
void SubtitlesGrid::OnAudioClip(wxCommandEvent &) { void SubtitlesGrid::OnAudioClip(wxCommandEvent &) {
int64_t num_samples,start=0,end=0,temp; int64_t num_samples,start=0,end=0,temp;
AudioController *audioController = parentFrame->audioController; AudioController *audioController = parentFrame->context->audioController;
const AudioProvider *provider = audioController->GetAudioProvider(); const AudioProvider *provider = audioController->GetAudioProvider();
AssDialogue *cur; AssDialogue *cur;
wxArrayInt sel = GetSelection(); wxArrayInt sel = GetSelection();