Eliminate almost all uses of AssFile::top.

Originally committed to SVN as r4669.
This commit is contained in:
Thomas Goyne 2010-07-09 07:31:48 +00:00
parent 5e22a0f151
commit c40aa7080a
20 changed files with 137 additions and 224 deletions

View file

@ -1014,9 +1014,8 @@ namespace Automation4 {
description = wxString(lua_tostring(L, 1), wxConvUTF8);
lua_pop(L, 1);
}
AssFile::top->Commit(description);
laf->ass->Commit(description);
laf->ass = AssFile::top; // make sure we're still working on the most recent undo point
return 0;
}

View file

@ -981,18 +981,6 @@ void BaseGrid::SetColumnWidths() {
endLen = fw + 10;
}
// Style length
if (false && AssFile::top) {
AssStyle *curStyle;
for (entryIter curIter=AssFile::top->Line.begin();curIter!=AssFile::top->Line.end();curIter++) {
curStyle = dynamic_cast<AssStyle*>(*curIter);
if (curStyle) {
dc.GetTextExtent(curStyle->name, &fw, &fh, NULL, NULL, &font);
if (fw > styleLen) styleLen = fw;
}
}
}
// Finish actor/effect/style
if (actorLen) actorLen += 10;
if (effectLen) effectLen += 10;

View file

@ -62,8 +62,9 @@
/// @brief Constructor
/// @param parent
///
DialogAttachments::DialogAttachments(wxWindow *parent)
DialogAttachments::DialogAttachments(wxWindow *parent, AssFile *ass)
: wxDialog(parent,-1,_("Attachment List"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE)
, ass(ass)
{
// Set icon
SetIcon(BitmapToIcon(GETIMAGE(attach_button_24)));
@ -111,7 +112,7 @@ void DialogAttachments::UpdateList() {
// Fill list
AssAttachment *attach;
for (std::list<AssEntry*>::iterator cur = AssFile::top->Line.begin();cur != AssFile::top->Line.end();cur++) {
for (std::list<AssEntry*>::iterator cur = ass->Line.begin();cur != ass->Line.end();cur++) {
attach = dynamic_cast<AssAttachment*>(*cur);
if (attach) {
// Add item
@ -132,14 +133,14 @@ DialogAttachments::~DialogAttachments() {
// Remove empty attachments sections from the file
std::list<AssEntry*>::iterator cur = AssFile::top->Line.end();
std::list<AssEntry*>::iterator cur = ass->Line.end();
--cur;
bool found_attachments = false;
bool removed_any = false;
wxString last_section_name;
while (cur != AssFile::top->Line.begin()) {
while (cur != ass->Line.begin()) {
if (!((*cur)->group == L"[Fonts]" || (*cur)->group == L"[Graphics]"))
break;
@ -151,15 +152,15 @@ DialogAttachments::~DialogAttachments() {
// found section heading with no attachments in, remove it
wxString delgroup = (*cur)->group;
std::list<AssEntry*>::iterator di = cur;
while (++di != AssFile::top->Line.end() && (*di)->group == delgroup) {
while (++di != ass->Line.end() && (*di)->group == delgroup) {
delete *di;
AssFile::top->Line.erase(di);
ass->Line.erase(di);
di = cur;
}
di = cur;
--cur;
delete *di;
AssFile::top->Line.erase(di);
ass->Line.erase(di);
removed_any = true;
continue;
}
@ -174,7 +175,7 @@ DialogAttachments::~DialogAttachments() {
}
if (removed_any) {
AssFile::top->Commit(_("remove empty attachments sections"));
ass->Commit(_("remove empty attachments sections"));
}
}
@ -220,10 +221,10 @@ void DialogAttachments::OnAttachFont(wxCommandEvent &event) {
return;
}
newAttach->group = _T("[Fonts]");
AssFile::top->InsertAttachment(newAttach);
ass->InsertAttachment(newAttach);
}
AssFile::top->Commit(_("attach font file"));
ass->Commit(_("attach font file"));
// Update
UpdateList();
@ -258,10 +259,10 @@ void DialogAttachments::OnAttachGraphics(wxCommandEvent &event) {
return;
}
newAttach->group = _T("[Graphics]");
AssFile::top->InsertAttachment(newAttach);
ass->InsertAttachment(newAttach);
}
AssFile::top->Commit(_("attach graphics file"));
ass->Commit(_("attach graphics file"));
// Update
UpdateList();
@ -312,11 +313,11 @@ void DialogAttachments::OnDelete(wxCommandEvent &event) {
// Loop through items in list
int i = listView->GetFirstSelected();
while (i != -1) {
AssFile::top->Line.remove((AssEntry*)wxUIntToPtr(listView->GetItemData(i)));
ass->Line.remove((AssEntry*)wxUIntToPtr(listView->GetItemData(i)));
i = listView->GetNextSelected(i);
}
AssFile::top->Commit(_("remove attachment"));
ass->Commit(_("remove attachment"));
// Update list
UpdateList();

View file

@ -34,27 +34,17 @@
/// @ingroup tools_ui
///
///////////
// Headers
//////////////
// Prototypes
class AssFile;
class wxListView;
class wxListEvent;
/// DOCME
/// @class DialogAttachments
/// @brief DOCME
///
/// DOCME
class DialogAttachments : public wxDialog {
private:
AssFile *ass;
/// DOCME
wxListView *listView;
@ -74,31 +64,17 @@ private:
void UpdateList();
public:
DialogAttachments(wxWindow *parent);
DialogAttachments(wxWindow *parent, AssFile *ass);
~DialogAttachments();
DECLARE_EVENT_TABLE()
};
///////
// IDs
/// Event IDs
enum {
/// DOCME
BUTTON_ATTACH_FONT = 1300,
/// DOCME
BUTTON_ATTACH_GRAPHICS,
/// DOCME
BUTTON_EXTRACT,
/// DOCME
BUTTON_DELETE,
/// DOCME
ATTACHMENT_LIST
};

View file

@ -54,12 +54,12 @@
/// @brief Constructor
/// @param parent
///
DialogExport::DialogExport (wxWindow *parent)
DialogExport::DialogExport (wxWindow *parent, AssFile *subs)
: wxDialog (parent, -1, _("Export"), wxDefaultPosition, wxSize(200,100), wxCAPTION | wxCLOSE_BOX, _T("Export"))
{
// Filter list
wxSizer *TopSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Filters"));
Export = new AssExporter(AssFile::top);
Export = new AssExporter(subs);
wxArrayString filters = Export->GetAllFilterNames();
FilterList = new wxCheckListBox(this, Filter_List_Box, wxDefaultPosition, wxSize(200,100), filters);

View file

@ -104,7 +104,7 @@ private:
void RefreshOptions();
public:
DialogExport(wxWindow *parent);
DialogExport(wxWindow *parent, AssFile *subs);
~DialogExport();
DECLARE_EVENT_TABLE()

View file

@ -88,8 +88,9 @@ DEFINE_EVENT_TYPE(EVT_ADD_TEXT)
/// @brief Constructor
/// @param parent
///
DialogFontsCollector::DialogFontsCollector(wxWindow *parent)
DialogFontsCollector::DialogFontsCollector(wxWindow *parent, AssFile *ass)
: wxDialog(parent,-1,_("Fonts Collector"),wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
, subs(ass)
{
// Set icon
SetIcon(BitmapToIcon(GETIMAGE(font_collector_button_24)));
@ -100,7 +101,7 @@ DialogFontsCollector::DialogFontsCollector(wxWindow *parent)
// Destination box
wxString dest = lagi_wxString(OPT_GET("Path/Fonts Collector Destination")->GetString());
if (dest == _T("?script")) {
wxFileName filename(AssFile::top->filename);
wxFileName filename(subs->filename);
dest = filename.GetPath();
}
while (dest.Right(1) == _T("/")) dest = dest.Left(dest.Length()-1);
@ -232,14 +233,14 @@ void DialogFontsCollector::OnStart(wxCommandEvent &event) {
}
// Start thread
wxThread *worker = new FontsCollectorThread(AssFile::top,foldername,this);
wxThread *worker = new FontsCollectorThread(subs,foldername,this);
worker->Create();
worker->Run();
// Set options
if (action == 1 || action == 2) {
wxString dest = foldername;
wxFileName filename(AssFile::top->filename);
wxFileName filename(subs->filename);
if (filename.GetPath() == dest) {
dest = _T("?script");
}

View file

@ -34,11 +34,6 @@
/// @ingroup tools_ui font_collector
///
////////////
// Includes
#ifndef AGI_PRE
#include <wx/button.h>
#include <wx/dialog.h>
@ -48,9 +43,6 @@
#include <wx/textctrl.h>
#endif
//////////////
// Prototypes
class AssFile;
class AssOverrideParameter;
class DialogFontsCollector;
@ -58,16 +50,12 @@ class FrameMain;
class wxZipOutputStream;
class ScintillaTextCtrl;
/// DOCME
/// @class FontsCollectorThread
/// @brief DOCME
///
/// DOCME
class FontsCollectorThread : public wxThread {
private:
/// DOCME
AssFile *subs;
@ -114,8 +102,6 @@ public:
static void GetFonts (wxString tagName,int par_n,AssOverrideParameter *param,void *usr);
};
/// DOCME
/// @class DialogFontsCollector
/// @brief DOCME
@ -124,7 +110,7 @@ public:
class DialogFontsCollector : public wxDialog {
friend class FontsCollectorThread;
private:
AssFile *subs;
/// DOCME
wxTextCtrl *DestBox;
@ -158,7 +144,7 @@ private:
void Update(int value=-1);
public:
DialogFontsCollector(wxWindow *parent);
DialogFontsCollector(wxWindow *parent, AssFile *subs);
~DialogFontsCollector();
DECLARE_EVENT_TABLE()

View file

@ -829,7 +829,7 @@ DialogKanjiTimer::DialogKanjiTimer(wxWindow *parent, SubtitlesGrid *_grid)
SetIcon(BitmapToIcon(GETIMAGE(kara_timing_copier_24)));
// Variables
subs = AssFile::top;
subs = _grid->ass;
grid = _grid;
currentSourceLine = subs->Line.begin();
currentDestinationLine = subs->Line.begin();

View file

@ -34,9 +34,6 @@
/// @ingroup secondary_ui
///
///////////
// Headers
#include "config.h"
#ifndef AGI_PRE
@ -61,15 +58,13 @@
/// @brief Constructor
/// @param parent
///
DialogProperties::DialogProperties (wxWindow *parent)
DialogProperties::DialogProperties (wxWindow *parent, AssFile *subs)
: wxDialog(parent, -1, _("Script Properties"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
, subs(subs)
{
// Set icon
SetIcon(BitmapToIcon(GETIMAGE(properties_toolbutton_24)));
// Setup
AssFile *subs = AssFile::top;
// Script details crap
wxSizer *TopSizer = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Script"));
wxStaticText *TitleLabel = new wxStaticText(this,-1,_("Title:"));
@ -173,23 +168,16 @@ DialogProperties::DialogProperties (wxWindow *parent)
CenterOnParent();
}
/// @brief Destructor
///
DialogProperties::~DialogProperties () {
}
///////////////
// Event table
BEGIN_EVENT_TABLE(DialogProperties,wxDialog)
EVT_BUTTON(wxID_OK,DialogProperties::OnOK)
EVT_BUTTON(BUTTON_FROM_VIDEO,DialogProperties::OnSetFromVideo)
END_EVENT_TABLE()
/// @brief Apply changes
/// @param event
///
@ -211,23 +199,17 @@ void DialogProperties::OnOK(wxCommandEvent &event) {
count += SetInfoIfDifferent(_T("Collisions"),col[collision->GetSelection()]);
count += SetInfoIfDifferent(_T("ScaledBorderAndShadow"),ScaleBorder->GetValue()? _T("yes") : _T("no"));
if (count) AssFile::top->Commit(_("property changes"));
if (count) subs->Commit(_("property changes"));
EndModal(count?1:0);
}
/// @brief Only set script info if it changed
/// @param key
/// @param value
/// @return
///
int DialogProperties::SetInfoIfDifferent(wxString key,wxString value) {
// Get script
AssFile *subs = AssFile::top;
// Compare
if (subs->GetScriptInfo(key) != value) {
subs->SetScriptInfo(key,value);
return 1;
@ -235,8 +217,6 @@ int DialogProperties::SetInfoIfDifferent(wxString key,wxString value) {
else return 0;
}
/// @brief Set res to match video
/// @param event
///
@ -245,5 +225,3 @@ void DialogProperties::OnSetFromVideo(wxCommandEvent &event) {
ResY->SetValue(wxString::Format(_T("%i"),VideoContext::Get()->GetHeight()));
event.Skip();
}

View file

@ -34,17 +34,13 @@
/// @ingroup secondary_ui
///
///////////
// Headers
#ifndef AGI_PRE
#include <wx/checkbox.h>
#include <wx/combobox.h>
#include <wx/textctrl.h>
#endif
class AssFile;
/// DOCME
/// @class DialogProperties
@ -52,7 +48,7 @@
///
/// DOCME
class DialogProperties : public wxDialog {
private:
AssFile *subs;
/// DOCME
wxTextCtrl *TitleEdit;
@ -106,19 +102,13 @@ private:
int SetInfoIfDifferent(wxString key,wxString value);
public:
DialogProperties(wxWindow *parent);
DialogProperties(wxWindow *parent, AssFile *subs);
~DialogProperties();
DECLARE_EVENT_TABLE()
};
///////
// IDs
enum {
/// DOCME
BUTTON_FROM_VIDEO = 1100
};

View file

@ -64,7 +64,7 @@ DialogResample::DialogResample(wxWindow *parent, SubtitlesGrid *_grid)
SetIcon(BitmapToIcon(GETIMAGE(resample_toolbutton_24)));
// Variables
AssFile *subs = AssFile::top;
AssFile *subs = _grid->ass;
grid = _grid;
// Margins
@ -224,7 +224,7 @@ void DialogResample::DoResampleTags (wxString name,int n,AssOverrideParameter *c
///
void DialogResample::OnResample (wxCommandEvent &event) {
// Resolutions
AssFile *subs = AssFile::top;
AssFile *subs = grid->ass;
int x1,y1;
subs->GetResolution(x1,y1);
long x2 = 0;

View file

@ -260,7 +260,7 @@ void DialogShiftTimes::OnOK(wxCommandEvent &event) {
if (didSomething) {
if (backward) len = -len;
wxString message = _T("");
wxFileName assfile(AssFile::top->filename);
wxFileName assfile(grid->ass->filename);
wxString filename = assfile.GetFullName();
// File

View file

@ -581,7 +581,7 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
*style = *work;
style->UpdateData();
if (isLocal) {
AssFile::top->Commit(_("style change"));
grid->ass->Commit(_("style change"));
grid->CommitChanges();
}

View file

@ -194,7 +194,7 @@ DialogStyleManager::DialogStyleManager (wxWindow *parent,SubtitlesGrid *_grid)
// Populate lists
LoadCatalog();
LoadCurrentStyles(AssFile::top);
LoadCurrentStyles(grid->ass);
//Set key handlers for lists
CatalogList->PushEventHandler(new DialogStyleManagerEvent(this));
@ -227,7 +227,7 @@ DialogStyleManager::DialogStyleManager (wxWindow *parent,SubtitlesGrid *_grid)
DialogStyleManager::~DialogStyleManager() {
int sel = CatalogList->GetSelection();
if (sel != wxNOT_FOUND) {
AssFile::top->SetScriptInfo(_T("Last Style Storage"),CatalogList->GetString(sel));
grid->ass->SetScriptInfo(_T("Last Style Storage"),CatalogList->GetString(sel));
}
CatalogList->PopEventHandler(true);
StorageList->PopEventHandler(true);
@ -268,7 +268,7 @@ void DialogStyleManager::LoadCatalog () {
// Set to default if available
StorageActions(false);
wxString pickStyle = AssFile::top->GetScriptInfo(_T("Last Style Storage"));
wxString pickStyle = grid->ass->GetScriptInfo(_T("Last Style Storage"));
if (pickStyle.IsEmpty()) pickStyle = _T("Default");
int opt = CatalogList->FindString(pickStyle, false);
if (opt != wxNOT_FOUND) {
@ -568,11 +568,11 @@ void DialogStyleManager::OnCopyToCurrent (wxCommandEvent &) {
}
if (addStyle) {
AssStyle *temp = new AssStyle(*styleStorageMap.at(selections[i]));
AssFile::top->InsertStyle(temp);
grid->ass->InsertStyle(temp);
copied.push_back(styleName);
}
}
LoadCurrentStyles(AssFile::top);
LoadCurrentStyles(grid->ass);
for (list<wxString>::iterator name = copied.begin(); name != copied.end(); ++name) {
CurrentList->SetStringSelection(*name, true);
}
@ -619,8 +619,8 @@ void DialogStyleManager::OnCurrentCopy (wxCommandEvent &) {
DialogStyleEditor editor(this,temp,grid,true,&Store,true);
int modified = editor.ShowModal();
if (modified) {
AssFile::top->InsertStyle(temp);
LoadCurrentStyles(AssFile::top);
grid->ass->InsertStyle(temp);
LoadCurrentStyles(grid->ass);
CurrentList->SetStringSelection(temp->name); // but even without this, the copy/delete/copy-to-storage buttons stay enabled?
}
else delete temp;
@ -671,12 +671,12 @@ void DialogStyleManager::PasteToCurrent() {
try {
s = new AssStyle(st.GetNextToken().Trim(true));
if (s->Valid) {
while (AssFile::top->GetStyle(s->name) != NULL)
while (grid->ass->GetStyle(s->name) != NULL)
s->name = _T("Copy of ") + s->name;
s->UpdateData();
AssFile::top->InsertStyle(s);
LoadCurrentStyles(AssFile::top);
grid->ass->InsertStyle(s);
LoadCurrentStyles(grid->ass);
grid->ass->Commit(_("style paste"));
grid->CommitChanges();
@ -753,8 +753,8 @@ void DialogStyleManager::OnCurrentNew (wxCommandEvent &) {
DialogStyleEditor editor(this,temp,grid,true,&Store,true);
int modified = editor.ShowModal();
if (modified) {
AssFile::top->InsertStyle(temp);
LoadCurrentStyles(AssFile::top);
grid->ass->InsertStyle(temp);
LoadCurrentStyles(grid->ass);
}
else delete temp;
UpdateMoveButtons();
@ -869,7 +869,7 @@ void DialogStyleManager::OnCurrentImport(wxCommandEvent &) {
// The GetString->FindString mess is a silly workaround for the fact that to vsfilter
// (and the duplicate check a few lines above), style names aren't case sensitive, but to the
// rest of Aegisub they are.
*(AssFile::top->GetStyle(CurrentList->GetString(CurrentList->FindString(styles[selections[i]], false)))) = *temp.GetStyle(styles[selections[i]]);
*(grid->ass->GetStyle(CurrentList->GetString(CurrentList->FindString(styles[selections[i]], false)))) = *temp.GetStyle(styles[selections[i]]);
}
continue;
}
@ -878,7 +878,7 @@ void DialogStyleManager::OnCurrentImport(wxCommandEvent &) {
modified = true;
AssStyle *tempStyle = new AssStyle;
*tempStyle = *temp.GetStyle(styles[selections[i]]);
AssFile::top->InsertStyle(tempStyle);
grid->ass->InsertStyle(tempStyle);
}
// Update
@ -963,7 +963,7 @@ void DialogStyleManager::OnCurrentSort (wxCommandEvent &) { MoveStyles(false,4);
/// @param type
void DialogStyleManager::MoveStyles(bool storage, int type) {
// Variables
AssFile *subs = AssFile::top;
AssFile *subs = grid->ass;
wxListBox *list;
if (storage) list = StorageList;
else list = CurrentList;

View file

@ -570,7 +570,7 @@ void FrameMain::InitMenu() {
/// @brief Initialize contents
void FrameMain::InitContents() {
AssFile::top = new AssFile;
AssFile::top = ass = new AssFile;
// Set a background panel
StartupLog(_T("Create background panel"));
Panel = new wxPanel(this,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL | wxCLIP_CHILDREN);
@ -589,7 +589,7 @@ void FrameMain::InitContents() {
// Subtitles area
StartupLog(_T("Create subtitles grid"));
SubsGrid = new SubtitlesGrid(this,Panel,-1,wxDefaultPosition,wxSize(600,100),wxWANTS_CHARS | wxSUNKEN_BORDER,_T("Subs grid"));
SubsGrid = new SubtitlesGrid(this,Panel,-1,ass,wxDefaultPosition,wxSize(600,100),wxWANTS_CHARS | wxSUNKEN_BORDER,_T("Subs grid"));
BottomSizer->Add(SubsGrid,1,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,0);
videoBox->videoSlider->grid = SubsGrid;
VideoContext::Get()->grid = SubsGrid;
@ -637,7 +637,7 @@ void FrameMain::DeInitContents() {
SubsGrid->ClearMaps();
delete EditBox;
delete videoBox;
delete AssFile::top;
delete ass;
HelpButton::ClearPages();
VideoContext::Get()->audio = NULL;
}
@ -670,7 +670,7 @@ void FrameMain::UpdateToolbar() {
/// @param charset
void FrameMain::LoadSubtitles (wxString filename,wxString charset) {
// First check if there is some loaded
if (AssFile::top && AssFile::top->loaded) {
if (ass && ass->loaded) {
if (TryToCloseSubs() == wxCANCEL) return;
}
@ -707,7 +707,7 @@ void FrameMain::LoadSubtitles (wxString filename,wxString charset) {
// Proceed into loading
SubsGrid->ClearMaps();
if (isFile) {
AssFile::top->Load(filename,charset);
ass->Load(filename,charset);
SubsGrid->UpdateMaps();
if (SubsGrid->GetRows()) {
SubsGrid->SetActiveLine(SubsGrid->GetDialogue(0));
@ -768,13 +768,13 @@ void FrameMain::LoadSubtitles (wxString filename,wxString charset) {
bool FrameMain::SaveSubtitles(bool saveas,bool withCharset) {
// Try to get filename from file
wxString filename;
if (saveas == false && AssFile::top->CanSave()) filename = AssFile::top->filename;
if (saveas == false && ass->CanSave()) filename = ass->filename;
// Failed, ask user
if (filename.IsEmpty()) {
VideoContext::Get()->Stop();
wxString path = lagi_wxString(OPT_GET("Path/Last/Subtitles")->GetString());
wxFileName origPath(AssFile::top->filename);
wxFileName origPath(ass->filename);
filename = wxFileSelector(_("Save subtitles file"),path,origPath.GetName() + _T(".ass"),_T("ass"),AssFile::GetWildcardList(1),wxFD_SAVE | wxFD_OVERWRITE_PROMPT,this);
}
@ -785,7 +785,7 @@ bool FrameMain::SaveSubtitles(bool saveas,bool withCharset) {
OPT_SET("Path/Last/Subtitles")->SetString(STD_STR(filepath.GetPath()));
// Fix me, ghetto hack for correct relative path generation in SynchronizeProject()
AssFile::top->filename = filename;
ass->filename = filename;
// Synchronize
SynchronizeProject();
@ -799,7 +799,7 @@ bool FrameMain::SaveSubtitles(bool saveas,bool withCharset) {
// Save
try {
AssFile::top->Save(filename,true,true,charset);
ass->Save(filename,true,true,charset);
UpdateTitle();
}
catch (const wchar_t *err) {
@ -819,7 +819,6 @@ bool FrameMain::SaveSubtitles(bool saveas,bool withCharset) {
/// @param enableCancel
/// @return
int FrameMain::TryToCloseSubs(bool enableCancel) {
AssFile *ass = AssFile::top;
if (ass->IsModified()) {
int flags = wxYES_NO;
if (enableCancel) flags |= wxCANCEL;
@ -878,14 +877,14 @@ void FrameMain::SetDisplayMode(int video, int audio) {
/// @brief Update title bar
void FrameMain::UpdateTitle() {
// Determine if current subs are modified
bool subsMod = AssFile::top->IsModified();
bool subsMod = ass->IsModified();
// Create ideal title
wxString newTitle = _T("");
#ifndef __WXMAC__
if (subsMod) newTitle << _T("* ");
if (AssFile::top->filename != _T("")) {
wxFileName file (AssFile::top->filename);
if (ass->filename != _T("")) {
wxFileName file (ass->filename);
newTitle << file.GetFullName();
}
else newTitle << _("Untitled");
@ -894,8 +893,8 @@ void FrameMain::UpdateTitle() {
// 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)
if (AssFile::top->filename != _T("")) {
wxFileName file (AssFile::top->filename);
if (ass->filename != _T("")) {
wxFileName file (ass->filename);
newTitle << file.GetFullName();
}
else newTitle << _("untitled");
@ -915,9 +914,6 @@ void FrameMain::UpdateTitle() {
/// @brief Updates subs with video/whatever data
/// @param fromSubs
void FrameMain::SynchronizeProject(bool fromSubs) {
// Gather current data
AssFile *subs = AssFile::top;
// Retrieve data from subs
if (fromSubs) {
// Reset the state
@ -927,7 +923,7 @@ void FrameMain::SynchronizeProject(bool fromSubs) {
double videoZoom = 0.;
// Get AR
wxString arString = subs->GetScriptInfo(_T("Video Aspect Ratio"));
wxString arString = ass->GetScriptInfo(_T("Video Aspect Ratio"));
if (arString.Left(1) == _T("c")) {
videoAr = 4;
arString = arString.Mid(1);
@ -936,21 +932,21 @@ void FrameMain::SynchronizeProject(bool fromSubs) {
else if (arString.IsNumber()) arString.ToLong(&videoAr);
// Get new state info
subs->GetScriptInfo(_T("Video Position")).ToLong(&videoPos);
subs->GetScriptInfo(_T("Video Zoom Percent")).ToDouble(&videoZoom);
wxString curSubsVideo = DecodeRelativePath(subs->GetScriptInfo(_T("Video File")),AssFile::top->filename);
wxString curSubsVFR = DecodeRelativePath(subs->GetScriptInfo(_T("VFR File")),AssFile::top->filename);
wxString curSubsKeyframes = DecodeRelativePath(subs->GetScriptInfo(_T("Keyframes File")),AssFile::top->filename);
wxString curSubsAudio = DecodeRelativePath(subs->GetScriptInfo(_T("Audio File")),AssFile::top->filename);
wxString AutoScriptString = subs->GetScriptInfo(_T("Automation Scripts"));
ass->GetScriptInfo(_T("Video Position")).ToLong(&videoPos);
ass->GetScriptInfo(_T("Video Zoom Percent")).ToDouble(&videoZoom);
wxString curassVideo = DecodeRelativePath(ass->GetScriptInfo(_T("Video File")),ass->filename);
wxString curassVFR = DecodeRelativePath(ass->GetScriptInfo(_T("VFR File")),ass->filename);
wxString curassKeyframes = DecodeRelativePath(ass->GetScriptInfo(_T("Keyframes File")),ass->filename);
wxString curassAudio = DecodeRelativePath(ass->GetScriptInfo(_T("Audio File")),ass->filename);
wxString AutoScriptString = ass->GetScriptInfo(_T("Automation Scripts"));
// Check if there is anything to change
int autoLoadMode = OPT_GET("App/Auto/Load Linked Files")->GetInt();
bool hasToLoad = false;
if (curSubsAudio != audioBox->audioName ||
curSubsVFR != VideoContext::Get()->GetTimecodesName() ||
curSubsVideo != VideoContext::Get()->videoName ||
curSubsKeyframes != VideoContext::Get()->GetKeyFramesName()
if (curassAudio != audioBox->audioName ||
curassVFR != VideoContext::Get()->GetTimecodesName() ||
curassVideo != VideoContext::Get()->videoName ||
curassKeyframes != VideoContext::Get()->GetKeyFramesName()
#ifdef WITH_AUTOMATION
|| !AutoScriptString.IsEmpty() || local_scripts->GetScripts().size() > 0
#endif
@ -970,8 +966,8 @@ void FrameMain::SynchronizeProject(bool fromSubs) {
if (doLoad) {
// Video
if (curSubsVideo != VideoContext::Get()->videoName) {
LoadVideo(curSubsVideo);
if (curassVideo != VideoContext::Get()->videoName) {
LoadVideo(curassVideo);
if (VideoContext::Get()->IsLoaded()) {
VideoContext::Get()->SetAspectRatio(videoAr,videoArValue);
videoBox->videoDisplay->SetZoom(videoZoom);
@ -979,20 +975,20 @@ void FrameMain::SynchronizeProject(bool fromSubs) {
}
}
VideoContext::Get()->LoadTimecodes(curSubsVFR);
VideoContext::Get()->LoadKeyframes(curSubsKeyframes);
VideoContext::Get()->LoadTimecodes(curassVFR);
VideoContext::Get()->LoadKeyframes(curassKeyframes);
// Audio
if (curSubsAudio != audioBox->audioName) {
if (curSubsAudio == _T("?video")) LoadAudio(_T(""),true);
else LoadAudio(curSubsAudio);
if (curassAudio != audioBox->audioName) {
if (curassAudio == _T("?video")) LoadAudio(_T(""),true);
else LoadAudio(curassAudio);
}
// Automation scripts
#ifdef WITH_AUTOMATION
local_scripts->RemoveAll();
wxStringTokenizer tok(AutoScriptString, _T("|"), wxTOKEN_STRTOK);
wxFileName subsfn(subs->filename);
wxFileName assfn(ass->filename);
wxString autobasefn(lagi_wxString(OPT_GET("Path/Automation/Base")->GetString()));
while (tok.HasMoreTokens()) {
wxString sfnames = tok.GetNextToken().Trim(true).Trim(false);
@ -1000,7 +996,7 @@ void FrameMain::SynchronizeProject(bool fromSubs) {
sfnames.Remove(0, 1);
wxString basepath;
if (sfnamel == _T("~")) {
basepath = subsfn.GetPath();
basepath = assfn.GetPath();
} else if (sfnamel == _T("$")) {
basepath = autobasefn;
} else if (sfnamel == _T("/")) {
@ -1027,7 +1023,7 @@ void FrameMain::SynchronizeProject(bool fromSubs) {
SetDisplayMode(1,1);
}
// Store data on subs
// Store data on ass
else {
// Setup
wxString seekpos = _T("0");
@ -1043,22 +1039,22 @@ void FrameMain::SynchronizeProject(bool fromSubs) {
}
// Store audio data
subs->SetScriptInfo(_T("Audio File"),MakeRelativePath(audioBox->audioName,AssFile::top->filename));
ass->SetScriptInfo(_T("Audio File"),MakeRelativePath(audioBox->audioName,ass->filename));
// Store video data
subs->SetScriptInfo(_T("Video File"),MakeRelativePath(VideoContext::Get()->videoName,AssFile::top->filename));
subs->SetScriptInfo(_T("Video Aspect Ratio"),ar);
subs->SetScriptInfo(_T("Video Zoom Percent"),zoom);
subs->SetScriptInfo(_T("Video Position"),seekpos);
subs->SetScriptInfo(_T("VFR File"),MakeRelativePath(VideoContext::Get()->GetTimecodesName(),AssFile::top->filename));
subs->SetScriptInfo(_T("Keyframes File"),MakeRelativePath(VideoContext::Get()->GetKeyFramesName(),AssFile::top->filename));
ass->SetScriptInfo(_T("Video File"),MakeRelativePath(VideoContext::Get()->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(VideoContext::Get()->GetTimecodesName(),ass->filename));
ass->SetScriptInfo(_T("Keyframes File"),MakeRelativePath(VideoContext::Get()->GetKeyFramesName(),ass->filename));
// Store Automation script data
// Algorithm:
// 1. If script filename has Automation Base Path as a prefix, the path is relative to that (ie. "$")
// 2. Otherwise try making it relative to the subs filename
// 3. If step 2 failed, or absolut path is shorter than path relative to subs, use absolute path ("/")
// 4. Otherwise, use path relative to subs ("~")
// 2. Otherwise try making it relative to the ass filename
// 3. If step 2 failed, or absolut path is shorter than path relative to ass, use absolute path ("/")
// 4. Otherwise, use path relative to ass ("~")
#ifdef WITH_AUTOMATION
wxString scripts_string;
wxString autobasefn(lagi_wxString(OPT_GET("Path/Automation/Base")->GetString()));
@ -1070,22 +1066,22 @@ void FrameMain::SynchronizeProject(bool fromSubs) {
if (i != 0)
scripts_string += _T("|");
wxString autobase_rel, subsfile_rel;
wxString autobase_rel, assfile_rel;
wxString scriptfn(script->GetFilename());
autobase_rel = MakeRelativePath(scriptfn, autobasefn);
subsfile_rel = MakeRelativePath(scriptfn, AssFile::top->filename);
assfile_rel = MakeRelativePath(scriptfn, ass->filename);
if (autobase_rel.size() <= scriptfn.size() && autobase_rel.size() <= subsfile_rel.size()) {
if (autobase_rel.size() <= scriptfn.size() && autobase_rel.size() <= assfile_rel.size()) {
scriptfn = _T("$") + autobase_rel;
} else if (subsfile_rel.size() <= scriptfn.size() && subsfile_rel.size() <= autobase_rel.size()) {
scriptfn = _T("~") + subsfile_rel;
} else if (assfile_rel.size() <= scriptfn.size() && assfile_rel.size() <= autobase_rel.size()) {
scriptfn = _T("~") + assfile_rel;
} else {
scriptfn = _T("/") + wxFileName(scriptfn).GetFullPath(wxPATH_UNIX);
}
scripts_string += scriptfn;
}
subs->SetScriptInfo(_T("Automation Scripts"), scripts_string);
ass->SetScriptInfo(_T("Automation Scripts"), scripts_string);
#endif
}
}
@ -1347,8 +1343,8 @@ bool FrameMain::LoadList(wxArrayString list) {
/// @brief Sets the descriptions for undo/redo
void FrameMain::SetUndoRedoDesc() {
editMenu->SetHelpString(0,_T("Undo ")+AssFile::top->GetUndoDescription());
editMenu->SetHelpString(1,_T("Redo ")+AssFile::top->GetRedoDescription());
editMenu->SetHelpString(0,_T("Undo ")+ass->GetUndoDescription());
editMenu->SetHelpString(1,_T("Redo ")+ass->GetRedoDescription());
}
/// @brief Check if ASSDraw is available

View file

@ -46,7 +46,7 @@
#include <wx/timer.h>
#endif
class AssFile;
class VideoDisplay;
class VideoSlider;
class VideoZoomSlider;
@ -73,6 +73,7 @@ class FrameMain: public wxFrame {
friend class SubtitlesGrid;
private:
AssFile *ass;
/// DOCME

View file

@ -435,16 +435,16 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
else if (curMenu == editMenu) {
// Undo state
wxMenuItem *item;
wxString undo_text = _("&Undo") + wxString(_T(" ")) + AssFile::top->GetUndoDescription() + wxString(_T("\t")) + Hotkeys.GetText(_T("Undo"));
wxString undo_text = _("&Undo") + wxString(_T(" ")) + ass->GetUndoDescription() + wxString(_T("\t")) + Hotkeys.GetText(_T("Undo"));
item = editMenu->FindItem(Menu_Edit_Undo);
item->SetItemLabel(undo_text);
item->Enable(!AssFile::top->IsUndoStackEmpty());
item->Enable(!ass->IsUndoStackEmpty());
// Redo state
wxString redo_text = _("&Redo") + wxString(_T(" ")) + AssFile::top->GetRedoDescription() + wxString(_T("\t")) + Hotkeys.GetText(_T("Redo"));
wxString redo_text = _("&Redo") + wxString(_T(" ")) + ass->GetRedoDescription() + wxString(_T("\t")) + Hotkeys.GetText(_T("Redo"));
item = editMenu->FindItem(Menu_Edit_Redo);
item->SetItemLabel(redo_text);
item->Enable(!AssFile::top->IsRedoStackEmpty());
item->Enable(!ass->IsRedoStackEmpty());
// Copy/cut/paste
wxArrayInt sels = SubsGrid->GetSelection();
@ -765,7 +765,7 @@ void FrameMain::OnExportSubtitles(wxCommandEvent &) {
}
#endif
DialogExport exporter(this);
DialogExport exporter(this, ass);
exporter.ShowModal();
}
@ -927,7 +927,7 @@ void FrameMain::OnShift(wxCommandEvent&) {
/// @brief Open properties
void FrameMain::OnOpenProperties (wxCommandEvent &) {
VideoContext::Get()->Stop();
DialogProperties Properties(this);
DialogProperties Properties(this, ass);
int res = Properties.ShowModal();
if (res) {
SubsGrid->CommitChanges();
@ -946,7 +946,7 @@ void FrameMain::OnOpenStylesManager(wxCommandEvent&) {
/// @brief Open attachments
void FrameMain::OnOpenAttachments(wxCommandEvent&) {
VideoContext::Get()->Stop();
DialogAttachments attachments(this);
DialogAttachments attachments(this, ass);
attachments.ShowModal();
}
@ -955,7 +955,7 @@ void FrameMain::OnOpenTranslation(wxCommandEvent&) {
VideoContext::Get()->Stop();
int start = SubsGrid->GetFirstSelRow();
if (start == -1) start = 0;
DialogTranslation Trans(this,AssFile::top,SubsGrid,start,true);
DialogTranslation Trans(this,ass,SubsGrid,start,true);
Trans.ShowModal();
}
@ -968,7 +968,7 @@ void FrameMain::OnOpenSpellCheck (wxCommandEvent &) {
/// @brief Open Fonts Collector
void FrameMain::OnOpenFontsCollector (wxCommandEvent &) {
VideoContext::Get()->Stop();
DialogFontsCollector Collector(this);
DialogFontsCollector Collector(this, ass);
Collector.ShowModal();
}
@ -1170,7 +1170,7 @@ void FrameMain::OnUndo(wxCommandEvent&) {
VideoContext::Get()->Stop();
std::vector<int> selected_lines = SubsGrid->GetAbsoluteSelection();
int active_line = SubsGrid->GetDialogueIndex(SubsGrid->GetActiveLine());
AssFile::top->Undo();
ass->Undo();
UpdateTitle();
SubsGrid->UpdateMaps();
SubsGrid->SetSelectionFromAbsolute(selected_lines);
@ -1182,7 +1182,7 @@ void FrameMain::OnRedo(wxCommandEvent&) {
VideoContext::Get()->Stop();
std::vector<int> selected_lines = SubsGrid->GetAbsoluteSelection();
int active_line = SubsGrid->GetDialogueIndex(SubsGrid->GetActiveLine());
AssFile::top->Redo();
ass->Redo();
UpdateTitle();
SubsGrid->UpdateMaps();
SubsGrid->SetSelectionFromAbsolute(selected_lines);
@ -1354,22 +1354,22 @@ void FrameMain::OnSelect (wxCommandEvent &) {
/// @brief Sort subtitles by start time
void FrameMain::OnSortStart (wxCommandEvent &) {
AssFile::top->Sort();
AssFile::top->Commit(_("sort"));
ass->Sort();
ass->Commit(_("sort"));
SubsGrid->UpdateMaps();
SubsGrid->CommitChanges();
}
/// @brief Sort subtitles by end time
void FrameMain::OnSortEnd (wxCommandEvent &) {
AssFile::top->Sort(AssFile::CompEnd);
AssFile::top->Commit(_("sort"));
ass->Sort(AssFile::CompEnd);
ass->Commit(_("sort"));
SubsGrid->UpdateMaps();
SubsGrid->CommitChanges();
}
/// @brief Sort subtitles by style name
void FrameMain::OnSortStyle (wxCommandEvent &) {
AssFile::top->Sort(AssFile::CompStyle);
AssFile::top->Commit(_("sort"));
ass->Sort(AssFile::CompStyle);
ass->Commit(_("sort"));
SubsGrid->UpdateMaps();
SubsGrid->CommitChanges();
}
@ -1385,9 +1385,9 @@ void FrameMain::OnOpenStylingAssistant (wxCommandEvent &) {
void FrameMain::OnAutoSave(wxTimerEvent &) {
// Auto Save
try {
if (AssFile::top->loaded) {
if (ass->loaded) {
// Set path
wxFileName origfile(AssFile::top->filename);
wxFileName origfile(ass->filename);
wxString path = lagi_wxString(OPT_GET("Path/Auto/Save")->GetString());
if (path.IsEmpty()) path = origfile.GetPath();
wxFileName dstpath(path);
@ -1406,7 +1406,7 @@ void FrameMain::OnAutoSave(wxTimerEvent &) {
wxFileName temp = dstpath;
temp.SetName(dstpath.GetName() + ".temp");
AssFile::top->Save(temp.GetFullPath(),false,false);
ass->Save(temp.GetFullPath(),false,false);
wxRenameFile(temp.GetFullPath(), dstpath.GetFullPath());
// Set status bar

View file

@ -100,12 +100,12 @@ END_EVENT_TABLE()
/// @param style
/// @param name
///
SubtitlesGrid::SubtitlesGrid(FrameMain* parentFr, wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
: BaseGrid(parent,id,pos,size,style,name)
SubtitlesGrid::SubtitlesGrid(FrameMain* parentFr, wxWindow *parent, wxWindowID id, AssFile *subs, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
: BaseGrid(parent,id,pos,size,style,name)
, ass(subs)
{
// Vars
byFrame = false;
ass = NULL;
editBox = NULL;
parentFrame = parentFr;
}
@ -789,7 +789,6 @@ void SubtitlesGrid::OnAudioClip(wxCommandEvent &event) {
/// @param _ass
///
void SubtitlesGrid::LoadDefault () {
ass = AssFile::top;
ass->LoadDefault();
UpdateMaps();
@ -815,8 +814,6 @@ void SubtitlesGrid::UpdateMaps() {
line_iter_map.clear();
BaseGrid::ClearMaps();
ass = AssFile::top;
BaseGrid::UpdateMaps();
for (entryIter it = ass->Line.begin(); it != ass->Line.end(); ++it) {
@ -1160,7 +1157,7 @@ void SubtitlesGrid::AdjoinLines(int n1,int n2,bool setStart) {
}
// Commit
AssFile::top->Commit(_("adjoin"));
ass->Commit(_("adjoin"));
CommitChanges();
}

View file

@ -101,7 +101,7 @@ public:
/// DOCME
AssFile *ass;
SubtitlesGrid(FrameMain* parentFrame,wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxPanelNameStr);
SubtitlesGrid(FrameMain* parentFrame,wxWindow *parent, wxWindowID id, AssFile *subs, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxPanelNameStr);
~SubtitlesGrid();
void LoadDefault();