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 {
c->videoContext->Stop();
c->videoController->Stop();
DialogAutomation(c->parent, c->local_scripts).ShowModal();
}
#endif

View File

@ -64,11 +64,11 @@ struct edit_line_copy : public Command {
STR_HELP("Copy subtitles.")
void operator()(agi::Context *c) {
if (c->parent->FindFocus() == c->EditBox->TextEdit) {
c->EditBox->TextEdit->Copy();
if (c->parent->FindFocus() == c->editBox->TextEdit) {
c->editBox->TextEdit->Copy();
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.")
void operator()(agi::Context *c) {
if (c->parent->FindFocus() == c->EditBox->TextEdit) {
c->EditBox->TextEdit->Cut();
if (c->parent->FindFocus() == c->editBox->TextEdit) {
c->editBox->TextEdit->Cut();
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.")
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.")
void operator()(agi::Context *c) {
wxArrayInt sels = c->SubsGrid->GetSelection();
c->SubsGrid->DuplicateLines(sels.front(), sels.back(), false);
wxArrayInt sels = c->subsGrid->GetSelection();
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.")
void operator()(agi::Context *c) {
wxArrayInt sels = c->SubsGrid->GetSelection();
c->SubsGrid->DuplicateLines(sels.front(), sels.back(), true);
wxArrayInt sels = c->subsGrid->GetSelection();
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.")
void operator()(agi::Context *c) {
wxArrayInt sels = c->SubsGrid->GetSelection();
c->SubsGrid->JoinAsKaraoke(sels.front(), sels.back());
wxArrayInt sels = c->subsGrid->GetSelection();
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.")
void operator()(agi::Context *c) {
wxArrayInt sels = c->SubsGrid->GetSelection();
c->SubsGrid->JoinLines(sels.front(), sels.back(), true);
wxArrayInt sels = c->subsGrid->GetSelection();
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.")
void operator()(agi::Context *c) {
wxArrayInt sels = c->SubsGrid->GetSelection();
c->SubsGrid->JoinLines(sels.front(), sels.back(), false);
wxArrayInt sels = c->subsGrid->GetSelection();
c->subsGrid->JoinLines(sels.front(), sels.back(), false);
}
};
@ -181,11 +181,11 @@ struct edit_line_paste : public Command {
STR_HELP("Paste subtitles.")
void operator()(agi::Context *c) {
if (c->parent->FindFocus() == c->EditBox->TextEdit) {
c->EditBox->TextEdit->Paste();
if (c->parent->FindFocus() == c->editBox->TextEdit) {
c->editBox->TextEdit->Paste();
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.")
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.")
void operator()(agi::Context *c) {
c->SubsGrid->BeginBatch();
wxArrayInt sels = c->SubsGrid->GetSelection();
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]);
didSplit |= c->subsGrid->SplitLineByKaraoke(sels[i]);
}
if (didSplit) {
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.")
void operator()(agi::Context *c) {
wxArrayInt sels = c->SubsGrid->GetSelection();
c->SubsGrid->SwapLines(sels.front(), sels.back());
wxArrayInt sels = c->subsGrid->GetSelection();
c->subsGrid->SwapLines(sels.front(), sels.back());
}
};
@ -260,7 +260,7 @@ struct edit_redo : public Command {
STR_HELP("Redoes last action.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
c->videoController->Stop();
c->ass->Redo();
}
};
@ -274,7 +274,7 @@ struct edit_search_replace : public Command {
STR_HELP("Find and replace words in subtitles.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
c->videoController->Stop();
Search.OpenDialog(true);
}
};
@ -288,7 +288,7 @@ struct edit_undo : public Command {
STR_HELP("Undoes last action.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
c->videoController->Stop();
c->ass->Undo();
}
};

View File

@ -62,7 +62,7 @@ struct grid_line_next : public Command {
STR_HELP("Move to the next subtitle line.")
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.")
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.")
void operator()(agi::Context *c) {
c->videoContext->CloseKeyframes();
c->videoController->CloseKeyframes();
}
};
@ -86,7 +86,7 @@ struct keyframe_open : public Command {
if (filename.empty()) return;
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);
if (filename.empty()) return;
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.")
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.")
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.")
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.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
c->videoController->Stop();
DialogAttachments(c->parent, c->ass).ShowModal();
}
};
@ -89,7 +89,7 @@ struct subtitle_find : public Command {
STR_HELP("Find words in subtitles.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
c->videoController->Stop();
Search.OpenDialog(false);
}
};
@ -103,27 +103,27 @@ struct subtitle_find_next : public Command {
STR_HELP("Find next match of last word.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
c->videoController->Stop();
Search.FindNext();
}
};
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
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->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
c->SubsGrid->BeginBatch();
c->SubsGrid->InsertLine(def, n, after);
c->SubsGrid->SelectRow(n + after);
c->SubsGrid->SetActiveLine(def);
c->SubsGrid->EndBatch();
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.
@ -134,29 +134,29 @@ struct subtitle_insert_after : public Command {
STR_HELP("Inserts a line after current.")
void operator()(agi::Context *c) {
int n = c->SubsGrid->GetFirstSelRow();
int nrows = c->SubsGrid->GetRows();
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->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;
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;
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();
c->subsGrid->BeginBatch();
c->subsGrid->InsertLine(def, n, true);
c->subsGrid->SelectRow(n + 1);
c->subsGrid->SetActiveLine(def);
c->subsGrid->EndBatch();
}
};
@ -181,31 +181,31 @@ struct subtitle_insert_before : public Command {
STR_HELP("Inserts a line before current.")
void operator()(agi::Context *c) {
int n = c->SubsGrid->GetFirstSelRow();
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;
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 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;
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;
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();
c->subsGrid->BeginBatch();
c->subsGrid->InsertLine(def, n, false);
c->subsGrid->SelectRow(n);
c->subsGrid->SetActiveLine(def);
c->subsGrid->EndBatch();
}
};
@ -284,7 +284,7 @@ struct subtitle_open_video : public Command {
STR_HELP("Opens the subtitles from the current video file.")
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.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
c->videoController->Stop();
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.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
c->SubsGrid->SelectVisible();
c->videoController->Stop();
c->subsGrid->SelectVisible();
}
};
@ -352,7 +352,7 @@ struct subtitle_spellcheck : public Command {
STR_HELP("Open spell checker.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
c->videoController->Stop();
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.")
void operator()(agi::Context *c) {
wxArrayInt sels = c->SubsGrid->GetSelection();
c->SubsGrid->AdjoinLines(sels.front(), sels.back(), false);
wxArrayInt sels = c->subsGrid->GetSelection();
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.")
void operator()(agi::Context *c) {
wxArrayInt sels = c->SubsGrid->GetSelection();
c->SubsGrid->AdjoinLines(sels.front(), sels.back(), true);
wxArrayInt sels = c->subsGrid->GetSelection();
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.")
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();
if (n == 0) return;
// Get shifting in ms
AssDialogue *cur = c->SubsGrid->GetDialogue(sels[0]);
AssDialogue *cur = c->subsGrid->GetDialogue(sels[0]);
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
for (size_t i=0;i<n;i++) {
cur = c->SubsGrid->GetDialogue(sels[i]);
cur = c->subsGrid->GetDialogue(sels[i]);
if (cur) {
cur->Start.SetMS(cur->Start.GetMS()+shiftBy);
cur->End.SetMS(cur->End.GetMS()+shiftBy);
@ -114,7 +114,7 @@ struct time_frame_current : public Command {
}
// 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.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
DialogShiftTimes(c->parent, c->SubsGrid).ShowModal();
c->videoController->Stop();
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.")
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.")
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;
AssDialogue *cur = c->SubsGrid->GetDialogue(sels[0]);
AssDialogue *cur = c->subsGrid->GetDialogue(sels[0]);
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) {
if (cur = c->SubsGrid->GetDialogue(sels[i])) {
if (cur = c->subsGrid->GetDialogue(sels[i])) {
cur->Start.SetMS(cur->Start.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.")
void operator()(agi::Context *c) {
VideoContext *con = c->videoContext;
VideoContext *con = c->videoController;
if (!con->IsLoaded() || !con->KeyFramesLoaded()) return;
// Get frames
wxArrayInt sel = c->SubsGrid->GetSelection();
wxArrayInt sel = c->subsGrid->GetSelection();
int curFrame = con->GetFrameN();
int prev = 0;
int next = 0;
@ -220,13 +220,13 @@ struct time_snap_scene : public Command {
// Update rows
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->End.SetMS(end_ms);
}
// 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.")
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.")
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 filename = wxFileSelector(_("Open timecodes file"),path,_T(""),_T(""),str,wxFD_OPEN | wxFD_FILE_MUST_EXIST);
if (!filename.empty()) {
c->videoContext->LoadTimecodes(filename);
c->videoController->LoadTimecodes(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 filename = wxFileSelector(_("Save timecodes file"),path,_T(""),_T(""),str,wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
if (!filename.empty()) {
c->videoContext->SaveTimecodes(filename);
c->videoController->SaveTimecodes(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.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
DialogResample(c->parent, c->SubsGrid).ShowModal();
c->videoController->Stop();
DialogResample(c->parent, c->subsGrid).ShowModal();
}
};
@ -97,7 +97,7 @@ struct tool_font_collector : public Command {
STR_HELP("Open fonts collector.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
c->videoController->Stop();
DialogFontsCollector(c->parent, c->ass).ShowModal();
}
};
@ -111,8 +111,8 @@ struct tool_line_select : public Command {
STR_HELP("Selects lines based on defined criterea.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
DialogSelection(c->parent, c->SubsGrid).ShowModal();
c->videoController->Stop();
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.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
DialogResample(c->parent, c->SubsGrid).ShowModal();
c->videoController->Stop();
DialogResample(c->parent, c->subsGrid).ShowModal();
}
};
@ -139,8 +139,8 @@ struct tool_style_assistant : public Command {
STR_HELP("Open styling assistant.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
if (!c->stylingAssistant) c->stylingAssistant = new DialogStyling(c->parent, c->SubsGrid);
c->videoController->Stop();
if (!c->stylingAssistant) c->stylingAssistant = new DialogStyling(c->parent, c->subsGrid);
c->stylingAssistant->Show(true);
}
};
@ -154,8 +154,8 @@ struct tool_style_manager : public Command {
STR_HELP("Open styles manager.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
DialogStyleManager(c->parent, c->SubsGrid).ShowModal();
c->videoController->Stop();
DialogStyleManager(c->parent, c->subsGrid).ShowModal();
}
};
@ -168,7 +168,7 @@ struct tool_time_kanji : public Command {
STR_HELP("Open Kanji timer.")
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.")
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.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
int start = c->SubsGrid->GetFirstSelRow();
c->videoController->Stop();
int start = c->subsGrid->GetFirstSelRow();
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.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
c->videoContext->SetAspectRatio(3);
c->videoController->Stop();
c->videoController->SetAspectRatio(3);
wxGetApp().frame->SetDisplayMode(1,-1);
}
};
@ -86,9 +86,9 @@ struct video_aspect_custom : public Command {
STR_HELP("Forces video to a custom aspect ratio.")
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;
value.MakeLower();
@ -116,7 +116,7 @@ struct video_aspect_custom : public Command {
wxString denum = value.Mid(pos+1);
if (num.ToDouble(&a) && denum.ToDouble(&b) && b!=0) {
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;
@ -127,7 +127,7 @@ struct video_aspect_custom : public Command {
// Set value
else {
c->videoContext->SetAspectRatio(4,numval);
c->videoController->SetAspectRatio(4,numval);
wxGetApp().frame->SetDisplayMode(1,-1);
}
}
@ -143,8 +143,8 @@ struct video_aspect_default : public Command {
STR_HELP("Leave video on original aspect ratio.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
c->videoContext->SetAspectRatio(0);
c->videoController->Stop();
c->videoController->SetAspectRatio(0);
wxGetApp().frame->SetDisplayMode(1,-1);
}
};
@ -159,8 +159,8 @@ struct video_aspect_full : public Command {
STR_HELP("Forces video to 4:3 aspect ratio.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
c->videoContext->SetAspectRatio(1);
c->videoController->Stop();
c->videoController->SetAspectRatio(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.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
c->videoContext->SetAspectRatio(2);
c->videoController->Stop();
c->videoController->SetAspectRatio(2);
wxGetApp().frame->SetDisplayMode(1,-1);
}
};
@ -189,7 +189,7 @@ struct video_close : public Command {
STR_HELP("Closes the currently open video file.")
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.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
c->videoController->Stop();
DialogVideoDetails(c->parent).ShowModal();
}
};
@ -232,10 +232,10 @@ struct video_focus_seek : public Command {
void operator()(agi::Context *c) {
wxWindow *curFocus = wxWindow::FindFocus();
if (curFocus == c->videoBox->videoSlider) {
if (c->PreviousFocus) c->PreviousFocus->SetFocus();
if (c->previousFocus) c->previousFocus->SetFocus();
}
else {
c->PreviousFocus = curFocus;
c->previousFocus = curFocus;
c->videoBox->videoSlider->SetFocus();
}
}
@ -250,7 +250,7 @@ struct video_frame_next : public Command {
STR_HELP("Seek to the next frame.")
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.")
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.")
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.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
if (c->videoContext->IsLoaded()) {
c->videoController->Stop();
if (c->videoController->IsLoaded()) {
DialogJumpTo(c->parent).ShowModal();
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.")
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.")
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(" (*.*)|*.*");
wxString filename = wxFileSelector(_("Open video file"),path,_T(""),_T(""),str,wxFD_OPEN | wxFD_FILE_MUST_EXIST);
if (!filename.empty()) {
c->videoContext->SetVideo(filename);
c->videoController->SetVideo(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) {
wxString 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) {
//XXX: Fix to not require using an event. (maybe)
// OPT_SET("Video/Overscan Mask")->SetBool(event.IsChecked());
c->videoContext->Stop();
c->videoController->Stop();
c->videoBox->videoDisplay->Render();
}
};
@ -385,7 +385,7 @@ public:
STR_HELP("Set zoom to 100%.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
c->videoController->Stop();
c->videoBox->videoDisplay->SetZoom(1.);
}
};
@ -401,7 +401,7 @@ public:
STR_HELP("Set zoom to 200%.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
c->videoController->Stop();
c->videoBox->videoDisplay->SetZoom(2.);
}
};
@ -416,7 +416,7 @@ public:
STR_HELP("Set zoom to 50%.")
void operator()(agi::Context *c) {
c->videoContext->Stop();
c->videoController->Stop();
c->videoBox->videoDisplay->SetZoom(.5);
}
};

View File

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

View File

@ -196,7 +196,7 @@ bool DialogSpellChecker::FindNext(int startLine,int startPos) {
if (startPos != -1) lastPos = 0;
// Get grid
SubtitlesGrid *grid = context->SubsGrid;
SubtitlesGrid *grid = context->subsGrid;
int rows = grid->GetRows();
// 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]);
// Show word on the main program interface
SubtitlesGrid *grid = context->SubsGrid;
SubtitlesGrid *grid = context->subsGrid;
int line = lastLine % grid->GetRows();
grid->SelectRow(line,false);
grid->MakeCellVisible(line,0);
@ -382,7 +382,7 @@ bool DialogSpellChecker::FindOrDie() {
///
void DialogSpellChecker::Replace() {
// Get dialog
SubtitlesGrid *grid = context->SubsGrid;
SubtitlesGrid *grid = context->subsGrid;
AssDialogue *diag = grid->GetDialogue(lastLine % grid->GetRows());
// Replace
@ -435,7 +435,7 @@ void DialogSpellChecker::OnTakeSuggestion(wxCommandEvent &event) {
///
bool DialogSpellChecker::GetFirstMatch() {
// Get selection
SubtitlesGrid *grid = context->SubsGrid;
SubtitlesGrid *grid = context->subsGrid;
wxArrayInt sel = grid->GetSelection();
firstLine = (sel.Count()>0) ? sel[0] : 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)
: 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"));
temp_context->parent = this;
StartupLog("Entering FrameMain constructor");
// 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.
int count = cmd::count();
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"));
#endif
#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);
StartupLog("Install PNG handler");
wxImage::AddHandler(new wxPNGHandler);
wxSafeYield();
// Storage for subs-file-local scripts
#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"));
StartupLog("Apply saved Maximized state");
if (OPT_GET("App/Maximized")->GetBool()) Maximize(true);
StartupLog(_T("Initialize toolbar"));
StartupLog("Initialize toolbar");
InitToolbar();
StartupLog(_T("Initialize menu bar"));
StartupLog("Initialize menu bar");
InitMenu();
// Create status bar
StartupLog(_T("Create status bar"));
StartupLog("Create status bar");
CreateStatusBar(2);
// Set icon
StartupLog(_T("Set icon"));
StartupLog("Set icon");
#ifdef _WIN32
SetIcon(wxICON(wxicon));
#else
@ -183,17 +185,12 @@ FrameMain::FrameMain (wxArrayString args)
SetIcon(icon);
#endif
// Contents
showVideo = true;
showAudio = true;
detachedVideo = NULL;
stylingAssistant = NULL;
temp_context->stylingAssistant = stylingAssistant;
StartupLog(_T("Initialize inner main window controls"));
StartupLog("Create views and inner main window controls");
context->detachedVideo = 0;
context->stylingAssistant = 0;
InitContents();
// Set autosave timer
StartupLog(_T("Set up Auto Save"));
StartupLog("Set up Auto Save");
AutoSave.SetOwner(this, ID_APP_TIMER_AUTOSAVE);
int time = OPT_GET("App/Auto/Save Every Seconds")->GetInt();
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);
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"));
StartupLog("Set up drag/drop target");
SetDropTarget(new AegisubFileDropTarget(this));
// Parse arguments
StartupLog(_T("Load files specified on command line"));
StartupLog("Load default file");
context->ass->LoadDefault();
StartupLog("Load files specified on command line");
LoadList(args);
// Version checker
StartupLog(_T("Possibly perform automatic updates check"));
StartupLog("Possibly perform automatic updates check");
if (OPT_GET("App/First Start")->GetBool()) {
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);
@ -223,37 +217,31 @@ FrameMain::FrameMain (wxArrayString args)
PerformVersionCheck(false);
StartupLog(_T("Display main window"));
StartupLog("Display main window");
Show();
Freeze();
SetDisplayMode(1, 1);
Thaw();
//ShowFullScreen(true,wxFULLSCREEN_NOBORDER | wxFULLSCREEN_NOCAPTION);
StartupLog(_T("Leaving FrameMain constructor"));
StartupLog("Leaving FrameMain constructor");
}
/// @brief FrameMain destructor
FrameMain::~FrameMain () {
temp_context->videoContext->SetVideo(_T(""));
audioController->CloseAudio();
context->videoController->SetVideo("");
context->audioController->CloseAudio();
DeInitContents();
delete audioController;
delete context->audioController;
#ifdef WITH_AUTOMATION
delete local_scripts;
delete context->local_scripts;
#endif
}
void FrameMain::cmd_call(wxCommandEvent& event) {
int id = event.GetId();
LOG_D("event/select") << "Id: " << id;
cmd::call(temp_context.get(), id);
cmd::call(context.get(), id);
}
/// @brief Initialize toolbar
void FrameMain::InitToolbar () {
// Create toolbar
@ -295,58 +283,38 @@ void FrameMain::InitMenu() {
/// @brief Initialize contents
void FrameMain::InitContents() {
AssFile::top = ass = new AssFile;
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"));
StartupLog("Create background panel");
Panel = new wxPanel(this,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL | wxCLIP_CHILDREN);
// Video area;
StartupLog(_T("Create video box"));
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);
StartupLog("Create video box");
context->videoBox = videoBox = new VideoBox(Panel, false, ZoomBox, context->ass);
wxBoxSizer *videoSizer = new wxBoxSizer(wxVERTICAL);
videoSizer->Add(videoBox, 0, wxEXPAND);
videoSizer->Add(videoBox , 0, wxEXPAND);
videoSizer->AddStretchSpacer(1);
// Subtitles area
StartupLog(_T("Create subtitles grid"));
SubsGrid = new SubtitlesGrid(this,Panel,-1,ass,wxDefaultPosition,wxSize(600,100),wxWANTS_CHARS | wxSUNKEN_BORDER,_T("Subs grid"));
temp_context->SubsGrid = SubsGrid;
videoBox->videoSlider->grid = SubsGrid;
temp_context->videoContext->grid = SubsGrid;
StartupLog("Create subtitles grid");
context->subsGrid = SubsGrid = new SubtitlesGrid(this,Panel,-1,context->ass,wxDefaultPosition,wxSize(600,100),wxWANTS_CHARS | wxSUNKEN_BORDER,"Subs grid");
context->videoBox->videoSlider->grid = SubsGrid;
context->videoController->grid = SubsGrid;
Search.grid = SubsGrid;
// Tools area
StartupLog(_T("Create tool area splitter window"));
StartupLog("Create tool area splitter window");
audioSash = new wxSashWindow(Panel, ID_SASH_MAIN_AUDIO, wxDefaultPosition, wxDefaultSize, wxSW_3D|wxCLIP_CHILDREN);
wxBoxSizer *audioSashSizer = new wxBoxSizer(wxHORIZONTAL);
audioSash->SetSashVisible(wxSASH_BOTTOM, true);
// Audio area
StartupLog(_T("Create audio box"));
audioBox = new AudioBox(audioSash, audioController, SubsGrid, ass);
temp_context->audioBox = audioBox;
StartupLog("Create audio box");
context->audioBox = audioBox = new AudioBox(audioSash, context->audioController, SubsGrid, context->ass);
audioBox->frameMain = this;
audioSashSizer->Add(audioBox, 1, wxEXPAND);
audioSash->SetSizer(audioSashSizer);
audioBox->Fit();
audioSash->SetMinimumSizeY(audioBox->GetSize().GetHeight());
// Editing area
StartupLog(_T("Create subtitle editing box"));
EditBox = new SubsEditBox(Panel,SubsGrid);
temp_context->EditBox = EditBox;
StartupLog("Create subtitle editing box");
context->editBox = EditBox = new SubsEditBox(Panel, SubsGrid);
// Set sizers/hints
StartupLog(_T("Arrange main sizers"));
StartupLog("Arrange main sizers");
ToolsSizer = new wxBoxSizer(wxVERTICAL);
ToolsSizer->Add(audioSash, 0, wxEXPAND);
ToolsSizer->Add(EditBox, 1, wxEXPAND);
@ -361,40 +329,39 @@ void FrameMain::InitContents() {
//MainSizer->SetSizeHints(Panel);
//SetSizer(MainSizer);
// Set display
StartupLog(_T("Perform layout"));
StartupLog("Perform layout");
Layout();
StartupLog(_T("Set focus to edting box"));
StartupLog("Set focus to edting box");
EditBox->TextEdit->SetFocus();
StartupLog(_T("Leaving InitContents"));
StartupLog("Leaving InitContents");
}
/// @brief Deinitialize controls
void FrameMain::DeInitContents() {
if (detachedVideo) detachedVideo->Destroy();
if (stylingAssistant) stylingAssistant->Destroy();
if (context->detachedVideo) context->detachedVideo->Destroy();
if (context->stylingAssistant) context->stylingAssistant->Destroy();
SubsGrid->ClearMaps();
delete audioBox;
delete EditBox;
delete videoBox;
delete ass;
delete context->ass;
HelpButton::ClearPages();
temp_context->videoContext->audio = NULL;
context->videoController->audio = 0;
}
/// @brief Update toolbar
void FrameMain::UpdateToolbar() {
// Collect flags
bool isVideo = temp_context->videoContext->IsLoaded();
bool isVideo = context->videoController->IsLoaded();
HasSelection = true;
int selRows = SubsGrid->GetNumberSelection();
// Update
wxToolBar* toolbar = GetToolBar();
toolbar->FindById(cmd::id("video/jump"))->Enable(isVideo);
toolbar->FindById(cmd::id("video/zoom/in"))->Enable(isVideo && !detachedVideo);
toolbar->FindById(cmd::id("video/zoom/out"))->Enable(isVideo && !detachedVideo);
ZoomBox->Enable(isVideo && !detachedVideo);
toolbar->FindById(cmd::id("video/zoom/in"))->Enable(isVideo && !context->detachedVideo);
toolbar->FindById(cmd::id("video/zoom/out"))->Enable(isVideo && !context->detachedVideo);
ZoomBox->Enable(isVideo && !context->detachedVideo);
toolbar->FindById(cmd::id("video/jump/start"))->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 charset
void FrameMain::LoadSubtitles(wxString filename,wxString charset) {
if (ass->loaded) {
if (context->ass->loaded) {
if (TryToCloseSubs() == wxCANCEL) return;
}
@ -422,7 +389,7 @@ void FrameMain::LoadSubtitles(wxString filename,wxString charset) {
TextFileReader testSubs(filename,charset);
wxString cur = testSubs.ReadLineFromFile();
if (cur.Left(10) == _T("# timecode")) {
temp_context->videoContext->LoadTimecodes(filename);
context->videoController->LoadTimecodes(filename);
return;
}
}
@ -431,7 +398,7 @@ void FrameMain::LoadSubtitles(wxString filename,wxString charset) {
// 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&) {
wxMessageBox(filename + L" not found.", L"Error", wxOK | wxICON_ERROR, NULL);
@ -458,14 +425,14 @@ void FrameMain::LoadSubtitles(wxString filename,wxString charset) {
/// @return
bool FrameMain::SaveSubtitles(bool saveas, bool withCharset) {
wxString filename;
if (!saveas && ass->CanSave()) {
filename = ass->filename;
if (!saveas && context->ass->CanSave()) {
filename = context->ass->filename;
}
if (filename.empty()) {
temp_context->videoContext->Stop();
context->videoController->Stop();
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);
}
if (filename.empty()) {
@ -479,7 +446,7 @@ bool FrameMain::SaveSubtitles(bool saveas, bool withCharset) {
}
try {
ass->Save(filename, true, true, charset);
context->ass->Save(filename, true, true, charset);
}
catch (const agi::Exception& err) {
wxMessageBox(lagi_wxString(err.GetMessage()), "Error", wxOK | wxICON_ERROR, NULL);
@ -500,7 +467,7 @@ bool FrameMain::SaveSubtitles(bool saveas, bool withCharset) {
/// @param enableCancel
/// @return
int FrameMain::TryToCloseSubs(bool enableCancel) {
if (ass->IsModified()) {
if (context->ass->IsModified()) {
int flags = wxYES_NO;
if (enableCancel) flags |= wxCANCEL;
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;
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;
else if (audio) sa = audioController->IsAudioOpen();
else if (audio) sa = context->audioController->IsAudioOpen();
// See if anything changed
if (sv == showVideo && sa == showAudio) return;
@ -537,7 +504,7 @@ void FrameMain::SetDisplayMode(int video, int audio) {
bool didFreeze = !IsFrozen();
if (didFreeze) Freeze();
temp_context->videoContext->Stop();
context->videoController->Stop();
// Set display
TopSizer->Show(videoBox, showVideo, true);
@ -555,11 +522,9 @@ void FrameMain::SetDisplayMode(int video, int audio) {
/// @brief Update title bar
void FrameMain::UpdateTitle() {
bool subsMod = ass->IsModified();
wxString newTitle;
if (subsMod) newTitle << _T("* ");
if (ass->filename.empty()) {
if (context->ass->IsModified()) newTitle << _T("* ");
if (context->ass->filename.empty()) {
// Apple HIG says "untitled" should not be capitalised
// and the window is a document window, it shouldn't contain the app name
// (The app name is already present in the menu bar)
@ -570,7 +535,7 @@ void FrameMain::UpdateTitle() {
#endif
}
else {
wxFileName file (ass->filename);
wxFileName file (context->ass->filename);
newTitle << file.GetFullName();
}
@ -580,7 +545,7 @@ void FrameMain::UpdateTitle() {
#if defined(__WXMAC__) && !defined(__LP64__)
// On Mac, set the mark in the close button
OSXSetModified(subsMod);
OSXSetModified(context->ass->IsModified());
#endif
if (GetTitle() != newTitle) SetTitle(newTitle);
@ -593,37 +558,37 @@ void FrameMain::SynchronizeProject() {
wxString seekpos = _T("0");
wxString ar = _T("0");
wxString zoom = _T("6");
if (temp_context->videoContext->IsLoaded()) {
seekpos = wxString::Format(_T("%i"),temp_context->videoContext->GetFrameN());
if (context->videoController->IsLoaded()) {
seekpos = wxString::Format(_T("%i"),context->videoController->GetFrameN());
zoom = wxString::Format(_T("%f"),videoBox->videoDisplay->GetZoom());
int arType = temp_context->videoContext->GetAspectRatioType();
if (arType == 4) ar = wxString(_T("c")) + AegiFloatToString(temp_context->videoContext->GetAspectRatioValue());
int arType = context->videoController->GetAspectRatioType();
if (arType == 4) ar = wxString(_T("c")) + AegiFloatToString(context->videoController->GetAspectRatioValue());
else ar = wxString::Format(_T("%i"),arType);
}
// 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
ass->SetScriptInfo(_T("Video File"),MakeRelativePath(temp_context->videoContext->videoName,ass->filename));
ass->SetScriptInfo(_T("Video Aspect Ratio"),ar);
ass->SetScriptInfo(_T("Video Zoom Percent"),zoom);
ass->SetScriptInfo(_T("Video Position"),seekpos);
ass->SetScriptInfo(_T("VFR File"),MakeRelativePath(temp_context->videoContext->GetTimecodesName(),ass->filename));
ass->SetScriptInfo(_T("Keyframes File"),MakeRelativePath(temp_context->videoContext->GetKeyFramesName(),ass->filename));
context->ass->SetScriptInfo(_T("Video File"),MakeRelativePath(context->videoController->videoName,context->ass->filename));
context->ass->SetScriptInfo(_T("Video Aspect Ratio"),ar);
context->ass->SetScriptInfo(_T("Video Zoom Percent"),zoom);
context->ass->SetScriptInfo(_T("Video Position"),seekpos);
context->ass->SetScriptInfo(_T("VFR File"),MakeRelativePath(context->videoController->GetTimecodesName(),context->ass->filename));
context->ass->SetScriptInfo(_T("Keyframes File"),MakeRelativePath(context->videoController->GetKeyFramesName(),context->ass->filename));
}
void FrameMain::OnVideoOpen() {
if (!temp_context->videoContext->IsLoaded()) {
if (!context->videoController->IsLoaded()) {
SetDisplayMode(0, -1);
DetachVideo(false);
return;
}
Freeze();
int vidx = temp_context->videoContext->GetWidth(),
vidy = temp_context->videoContext->GetHeight();
int vidx = context->videoController->GetWidth(),
vidy = context->videoController->GetHeight();
// Set zoom level based on video resolution and window size
double zoom = videoBox->videoDisplay->GetZoom();
@ -634,8 +599,8 @@ void FrameMain::OnVideoOpen() {
videoBox->videoDisplay->SetZoom(zoom * .5);
// Check that the video size matches the script video size specified
int scriptx = ass->GetScriptInfoAsInt("PlayResX");
int scripty = ass->GetScriptInfoAsInt("PlayResY");
int scriptx = context->ass->GetScriptInfoAsInt("PlayResX");
int scripty = context->ass->GetScriptInfoAsInt("PlayResY");
if (scriptx != vidx || scripty != vidy) {
switch (OPT_GET("Video/Check Script Res")->GetInt()) {
case 1:
@ -645,9 +610,9 @@ void FrameMain::OnVideoOpen() {
// Fallthrough to case 2
case 2:
// Always change script res
ass->SetScriptInfo("PlayResX", wxString::Format("%d", vidx));
ass->SetScriptInfo("PlayResY", wxString::Format("%d", vidy));
ass->Commit(_("Change script resolution"));
context->ass->SetScriptInfo("PlayResX", wxString::Format("%d", vidx));
context->ass->SetScriptInfo("PlayResY", wxString::Format("%d", vidy));
context->ass->Commit(_("Change script resolution"));
break;
case 0:
default:
@ -664,10 +629,10 @@ void FrameMain::OnVideoOpen() {
void FrameMain::LoadVFR(wxString filename) {
if (filename.empty()) {
temp_context->videoContext->CloseTimecodes();
context->videoController->CloseTimecodes();
}
else {
temp_context->videoContext->LoadTimecodes(filename);
context->videoController->LoadTimecodes(filename);
}
}
@ -680,15 +645,14 @@ void FrameMain::OpenHelp(wxString) {
/// @param detach
void FrameMain::DetachVideo(bool detach) {
if (detach) {
if (!detachedVideo) {
detachedVideo = new DialogDetachedVideo(this, videoBox->videoDisplay->GetClientSize());
temp_context->detachedVideo = detachedVideo;
detachedVideo->Show();
if (!context->detachedVideo) {
context->detachedVideo = new DialogDetachedVideo(this, videoBox->videoDisplay->GetClientSize());
context->detachedVideo->Show();
}
}
else if (detachedVideo) {
detachedVideo->Destroy();
detachedVideo = NULL;
else if (context->detachedVideo) {
context->detachedVideo->Destroy();
context->detachedVideo = 0;
SetDisplayMode(1,-1);
}
UpdateToolbar();
@ -779,10 +743,10 @@ bool FrameMain::LoadList(wxArrayString list) {
}
if (blockVideoLoad) {
blockVideoLoad = false;
temp_context->videoContext->SetVideo(video);
context->videoController->SetVideo(video);
}
if (!audio.empty())
audioController->OpenAudio(audio);
context->audioController->OpenAudio(audio);
// Result
return subs.size() || audio.size() || video.size();
@ -792,8 +756,8 @@ bool FrameMain::LoadList(wxArrayString list) {
/// @brief Sets the descriptions for undo/redo
void FrameMain::SetUndoRedoDesc() {
wxMenu *editMenu = menu::menu->GetMenu("main/edit");
editMenu->SetHelpString(0,_T("Undo ")+ass->GetUndoDescription());
editMenu->SetHelpString(1,_T("Redo ")+ass->GetRedoDescription());
editMenu->SetHelpString(0,_T("Undo ")+context->ass->GetUndoDescription());
editMenu->SetHelpString(1,_T("Redo ")+context->ass->GetRedoDescription());
}
/// @brief Check if ASSDraw is available
@ -893,14 +857,14 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
// Rebuild recent
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
else if (curMenu == menu::menu->GetMenu("main/view")) {
// Flags
bool aud = audioController->IsAudioOpen();
bool vid = temp_context->videoContext->IsLoaded() && !detachedVideo;
bool aud = context->audioController->IsAudioOpen();
bool vid = context->videoController->IsLoaded() && !context->detachedVideo;
// Set states
MenuBar->Enable(cmd::id("app/display/audio_subs"),aud);
@ -923,8 +887,8 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
// Video menu
else if (curMenu == menu::menu->GetMenu("main/video")) {
bool state = temp_context->videoContext->IsLoaded();
bool attached = state && !detachedVideo;
bool state = context->videoController->IsLoaded();
bool attached = state && !context->detachedVideo;
// Set states
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/custom"),attached);
MenuBar->Enable(cmd::id("video/detach"),state);
MenuBar->Enable(cmd::id("timecode/save"),temp_context->videoContext->TimecodesLoaded());
MenuBar->Enable(cmd::id("timecode/close"),temp_context->videoContext->OverTimecodesLoaded());
MenuBar->Enable(cmd::id("keyframe/close"),temp_context->videoContext->OverKeyFramesLoaded());
MenuBar->Enable(cmd::id("keyframe/save"),temp_context->videoContext->KeyFramesLoaded());
MenuBar->Enable(cmd::id("timecode/save"),context->videoController->TimecodesLoaded());
MenuBar->Enable(cmd::id("timecode/close"),context->videoController->OverTimecodesLoaded());
MenuBar->Enable(cmd::id("keyframe/close"),context->videoController->OverKeyFramesLoaded());
MenuBar->Enable(cmd::id("keyframe/save"),context->videoController->KeyFramesLoaded());
MenuBar->Enable(cmd::id("video/details"),state);
MenuBar->Enable(cmd::id("video/show_overscan"),state);
// 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/full"),false);
MenuBar->Check(cmd::id("video/aspect/wide"),false);
@ -975,8 +939,8 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
// Audio menu
else if (curMenu == menu::menu->GetMenu("main/audio")) {
bool state = audioController->IsAudioOpen();
bool vidstate = temp_context->videoContext->IsLoaded();
bool state = context->audioController->IsAudioOpen();
bool vidstate = context->videoController->IsLoaded();
MenuBar->Enable(cmd::id("audio/open/video"),vidstate);
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("edit/line/split/by_karaoke"),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/after/videotime"),state2);
MenuBar->Enable(cmd::id("main/subtitle/insert lines"),state);
state = count > 0 && continuous;
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);
state = count == 2;
MenuBar->Enable(cmd::id("edit/line/swap"),state);
@ -1026,7 +990,7 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
int count = sels.Count();
// 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/end_video"),state);
MenuBar->Enable(cmd::id("time/snap/scene"),state);
@ -1046,18 +1010,18 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
wxMenuItem *item;
//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
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->SetItemLabel(undo_text);
item->Enable(!ass->IsUndoStackEmpty());
item->Enable(!context->ass->IsUndoStackEmpty());
// Redo state
//H wxString redo_text = _("&Redo") + wxString(_T(" ")) + ass->GetRedoDescription() + wxString(_T("\t")) + Hotkeys.GetText(_T("Redo"));
// 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->SetItemLabel(redo_text);
item->Enable(!ass->IsRedoStackEmpty());
item->Enable(!context->ass->IsRedoStackEmpty());
// Copy/cut/paste
wxArrayInt sels = SubsGrid->GetSelection();
@ -1092,7 +1056,7 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
// Add new ones
int added = 0;
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 (added == 0) {
@ -1149,8 +1113,8 @@ void FrameMain::OnAutomationMacro (wxCommandEvent &event) {
/// @param event
void FrameMain::OnCloseWindow (wxCloseEvent &event) {
// Stop audio and video
temp_context->videoContext->Stop();
audioController->Stop();
context->videoController->Stop();
context->audioController->Stop();
// Ask user if he wants to save first
bool canVeto = event.CanVeto();
@ -1170,9 +1134,9 @@ void FrameMain::OnCloseWindow (wxCloseEvent &event) {
/// @brief Autosave the currently open file, if any
void FrameMain::OnAutoSave(wxTimerEvent &) {
try {
if (ass->loaded && ass->IsModified()) {
if (context->ass->loaded && context->ass->IsModified()) {
// Set path
wxFileName origfile(ass->filename);
wxFileName origfile(context->ass->filename);
wxString path = lagi_wxString(OPT_GET("Path/Auto/Save")->GetString());
if (path.IsEmpty()) path = origfile.GetPath();
wxFileName dstpath(path);
@ -1188,7 +1152,7 @@ void FrameMain::OnAutoSave(wxTimerEvent &) {
dstpath.SetFullName(name + L".AUTOSAVE.ass");
}
ass->Save(dstpath.GetFullPath(),false,false);
context->ass->Save(dstpath.GetFullPath(),false,false);
// Set status bar
StatusTimeout(_("File backup saved as \"") + dstpath.GetFullPath() + _T("\"."));
@ -1240,7 +1204,7 @@ void FrameMain::OnAudioClose()
void FrameMain::OnSubtitlesCommit() {
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();
@ -1253,21 +1217,21 @@ void FrameMain::OnSubtitlesOpen() {
/// prompting for each file loaded/unloaded
// Load stuff from the new script
wxString curSubsVideo = DecodeRelativePath(ass->GetScriptInfo("Video File"),ass->filename);
wxString curSubsVFR = DecodeRelativePath(ass->GetScriptInfo("VFR File"),ass->filename);
wxString curSubsKeyframes = DecodeRelativePath(ass->GetScriptInfo("Keyframes File"),ass->filename);
wxString curSubsAudio = DecodeRelativePath(ass->GetScriptInfo("Audio URI"),ass->filename);
wxString AutoScriptString = ass->GetScriptInfo("Automation Scripts");
wxString curSubsVideo = DecodeRelativePath(context->ass->GetScriptInfo("Video File"),context->ass->filename);
wxString curSubsVFR = DecodeRelativePath(context->ass->GetScriptInfo("VFR File"),context->ass->filename);
wxString curSubsKeyframes = DecodeRelativePath(context->ass->GetScriptInfo("Keyframes File"),context->ass->filename);
wxString curSubsAudio = DecodeRelativePath(context->ass->GetScriptInfo("Audio URI"),context->ass->filename);
wxString AutoScriptString = context->ass->GetScriptInfo("Automation Scripts");
// Check if there is anything to change
int autoLoadMode = OPT_GET("App/Auto/Load Linked Files")->GetInt();
bool doLoad = false;
if (curSubsAudio != audioController->GetAudioURL() ||
curSubsVFR != temp_context->videoContext->GetTimecodesName() ||
curSubsVideo != temp_context->videoContext->videoName ||
curSubsKeyframes != temp_context->videoContext->GetKeyFramesName()
if (curSubsAudio != context->audioController->GetAudioURL() ||
curSubsVFR != context->videoController->GetTimecodesName() ||
curSubsVideo != context->videoController->videoName ||
curSubsKeyframes != context->videoController->GetKeyFramesName()
#ifdef WITH_AUTOMATION
|| !AutoScriptString.IsEmpty() || local_scripts->GetScripts().size() > 0
|| !AutoScriptString.IsEmpty() || context->local_scripts->GetScripts().size() > 0
#endif
)
{
@ -1281,17 +1245,17 @@ void FrameMain::OnSubtitlesOpen() {
if (doLoad) {
// Video
if (!blockVideoLoad && curSubsVideo != temp_context->videoContext->videoName) {
temp_context->videoContext->SetVideo(curSubsVideo);
if (temp_context->videoContext->IsLoaded()) {
if (!blockVideoLoad && curSubsVideo != context->videoController->videoName) {
context->videoController->SetVideo(curSubsVideo);
if (context->videoController->IsLoaded()) {
long videoPos = 0;
long videoAr = 0;
double videoArValue = 0.0;
double videoZoom = 0.;
ass->GetScriptInfo("Video Position").ToLong(&videoPos);
ass->GetScriptInfo("Video Zoom Percent").ToDouble(&videoZoom);
wxString arString = ass->GetScriptInfo("Video Aspect Ratio");
context->ass->GetScriptInfo("Video Position").ToLong(&videoPos);
context->ass->GetScriptInfo("Video Zoom Percent").ToDouble(&videoZoom);
wxString arString = context->ass->GetScriptInfo("Video Aspect Ratio");
if (arString.Left(1) == "c") {
videoAr = 4;
arString = arString.Mid(1);
@ -1301,25 +1265,25 @@ void FrameMain::OnSubtitlesOpen() {
arString.ToLong(&videoAr);
}
temp_context->videoContext->SetAspectRatio(videoAr,videoArValue);
context->videoController->SetAspectRatio(videoAr,videoArValue);
videoBox->videoDisplay->SetZoom(videoZoom);
temp_context->videoContext->JumpToFrame(videoPos);
context->videoController->JumpToFrame(videoPos);
}
}
temp_context->videoContext->LoadTimecodes(curSubsVFR);
temp_context->videoContext->LoadKeyframes(curSubsKeyframes);
context->videoController->LoadTimecodes(curSubsVFR);
context->videoController->LoadKeyframes(curSubsKeyframes);
// Audio
if (curSubsAudio != audioController->GetAudioURL()) {
audioController->OpenAudio(curSubsAudio);
if (curSubsAudio != context->audioController->GetAudioURL()) {
context->audioController->OpenAudio(curSubsAudio);
}
// Automation scripts
#ifdef WITH_AUTOMATION
local_scripts->RemoveAll();
context->local_scripts->RemoveAll();
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()));
while (tok.HasMoreTokens()) {
wxString sfnames = tok.GetNextToken().Trim(true).Trim(false);
@ -1341,7 +1305,7 @@ void FrameMain::OnSubtitlesOpen() {
sfname.MakeAbsolute(basepath);
if (sfname.FileExists()) {
sfnames = sfname.GetFullPath();
local_scripts->Add(Automation4::ScriptFactory::CreateFromFile(sfnames, true));
context->local_scripts->Add(Automation4::ScriptFactory::CreateFromFile(sfnames, true));
} else {
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());
@ -1367,7 +1331,7 @@ void FrameMain::OnSubtitlesSave() {
wxString scripts_string;
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++) {
Automation4::Script *script = scripts[i];
@ -1377,7 +1341,7 @@ void FrameMain::OnSubtitlesSave() {
wxString autobase_rel, assfile_rel;
wxString scriptfn(script->GetFilename());
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()) {
scriptfn = _T("$") + autobase_rel;
@ -1389,7 +1353,7 @@ void FrameMain::OnSubtitlesSave() {
scripts_string += scriptfn;
}
ass->SetScriptInfo(_T("Automation Scripts"), scripts_string);
context->ass->SetScriptInfo(_T("Automation Scripts"), scripts_string);
#endif
}

View File

@ -93,14 +93,11 @@ public:
void DetachVideo(bool detach=true);
void LoadVFR(wxString filename);
agi::scoped_ptr<agi::Context> temp_context;
agi::scoped_ptr<agi::Context> context;
private:
void cmd_call(wxCommandEvent& event);
AssFile *ass;
/// DOCME
/// DOCME
@ -132,17 +129,6 @@ private:
/// DOCME
wxComboBox *ZoomBox;
/// DOCME
wxWindow *PreviousFocus;
#ifdef WITH_AUTOMATION
/// DOCME
Automation4::ScriptManager *local_scripts;
#endif
/// DOCME
std::vector<Automation4::FeatureMacro*> activeMacroItems;
int AddMacroMenuItems(wxMenu *menu, const std::vector<Automation4::FeatureMacro*> &macros);
@ -194,16 +180,6 @@ public:
/// The video area
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
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.
/// This is to avoid pointless exceptions.
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
AudioController *audioController;
VideoContext *videoContext;
VideoContext *videoController;
// Things that should probably be in some sort of UI-context-model
wxWindow *parent;
@ -29,8 +29,8 @@ struct Context {
AudioBox *audioBox;
DialogDetachedVideo *detachedVideo;
DialogStyling *stylingAssistant;
SubsEditBox *EditBox;
SubtitlesGrid *SubsGrid;
SubsEditBox *editBox;
SubtitlesGrid *subsGrid;
VideoBox *videoBox;
};

View File

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