Added graphics support to file attachments (for completion)

Originally committed to SVN as r449.
This commit is contained in:
Rodrigo Braz Monteiro 2006-07-01 05:00:03 +00:00
parent 31a3044bbc
commit 1327e42148
4 changed files with 46 additions and 8 deletions

View File

@ -559,7 +559,8 @@ void AssFile::InsertAttachment (wxString filename) {
}
// Insert
newAttach->group = _T("[Fonts]");
if (filename.Right(4).Lower() == _T(".ttf")) newAttach->group = _T("[Fonts]");
else newAttach->group = _T("[Graphics]");
InsertAttachment(newAttach);
}

View File

@ -87,7 +87,7 @@ Please visit http://aegisub.net to download latest version
- Right-clicking on the header of the subtitles grid will now bring up a popup menu that allows you to disable columns. (AMZ)
- Saving back to SRT directly (that is, via "save", not "export" or "save as") is now allowed, as long as no data will be lost. (AMZ)
- Aegisub now supports file attachments, which are stored decoded (to save memory) and are not part of the undo stack (for the same reason). Previously, they were simply left ignored in the file as unknown lines. (AMZ)
- Implemented an Attached files list, where you can attach new fonts, extract them, or remove them from the script file. (AMZ)
- Implemented an Attached files list, where you can attach new fonts and graphics, extract them, or remove them from the script file. (AMZ)
- The Font Collector can now collect fonts as script attachments. (AMZ)

View File

@ -58,10 +58,11 @@ DialogAttachments::DialogAttachments(wxWindow *parent)
// Buttons sizer
wxSizer *buttonSizer = new wxBoxSizer(wxHORIZONTAL);
buttonSizer->Add(new wxButton(this,BUTTON_ATTACH_FONT,_("&Attach Font")),3,0,0);
buttonSizer->Add(new wxButton(this,BUTTON_EXTRACT,_("E&xtract")),2,0,0);
buttonSizer->Add(new wxButton(this,BUTTON_DELETE,_("&Delete")),2,0,0);
buttonSizer->Add(new wxButton(this,BUTTON_CLOSE,_("&Close")),2,wxLEFT,5);
buttonSizer->Add(new wxButton(this,BUTTON_ATTACH_FONT,_("Attach &Font")),1,0,0);
buttonSizer->Add(new wxButton(this,BUTTON_ATTACH_GRAPHICS,_("Attach &Graphics")),1,0,0);
buttonSizer->Add(new wxButton(this,BUTTON_EXTRACT,_("E&xtract")),1,0,0);
buttonSizer->Add(new wxButton(this,BUTTON_DELETE,_("&Delete")),1,0,0);
buttonSizer->Add(new wxButton(this,BUTTON_CLOSE,_("&Close")),1,wxLEFT,5);
// Main sizer
wxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
@ -109,6 +110,7 @@ DialogAttachments::~DialogAttachments() {
// Event table
BEGIN_EVENT_TABLE(DialogAttachments,wxDialog)
EVT_BUTTON(BUTTON_ATTACH_FONT,DialogAttachments::OnAttachFont)
EVT_BUTTON(BUTTON_ATTACH_GRAPHICS,DialogAttachments::OnAttachGraphics)
EVT_BUTTON(BUTTON_EXTRACT,DialogAttachments::OnExtract)
EVT_BUTTON(BUTTON_DELETE,DialogAttachments::OnDelete)
EVT_BUTTON(BUTTON_CLOSE,DialogAttachments::OnClose)
@ -118,12 +120,12 @@ END_EVENT_TABLE()
///////////////
// Attach font
void DialogAttachments::OnAttachFont(wxCommandEvent &event) {
// Pick file
// Pick files
wxArrayString filenames;
wxArrayString paths;
{
wxFileDialog diag (this,_("Choose file to be attached"), Options.AsText(_T("Fonts Collector Destination")), _T(""), _T("Font Files (*.ttf)|*.ttf"), wxOPEN | wxFILE_MUST_EXIST | wxMULTIPLE);
diag.ShowModal();
if (diag.ShowModal() == wxID_CANCEL) return;
diag.GetFilenames(filenames);
diag.GetPaths(paths);
}
@ -148,6 +150,39 @@ void DialogAttachments::OnAttachFont(wxCommandEvent &event) {
}
///////////////////
// Attach graphics
void DialogAttachments::OnAttachGraphics(wxCommandEvent &event) {
// Pick files
wxArrayString filenames;
wxArrayString paths;
{
wxFileDialog diag (this,_("Choose file to be attached"), _T(""), _T(""), _T("Graphic Files (*.bmp,*.gif,*.jpg,*.ico,*.wmf)|*.bmp;*.gif;*.jpg;*.ico;*.wmf"), wxOPEN | wxFILE_MUST_EXIST | wxMULTIPLE);
if (diag.ShowModal() == wxID_CANCEL) return;
diag.GetFilenames(filenames);
diag.GetPaths(paths);
}
// Create attachments
for (size_t i=0;i<filenames.Count();i++) {
//wxFileName file(filenames[i]);
AssAttachment *newAttach = new AssAttachment(filenames[i]);
try {
newAttach->Import(paths[i]);
}
catch (...) {
delete newAttach;
return;
}
newAttach->group = _T("[Graphics]");
AssFile::top->InsertAttachment(newAttach);
}
// Update
UpdateList();
}
///////////
// Extract
void DialogAttachments::OnExtract(wxCommandEvent &event) {

View File

@ -54,6 +54,7 @@ private:
wxListView *listView;
void OnAttachFont(wxCommandEvent &event);
void OnAttachGraphics(wxCommandEvent &event);
void OnExtract(wxCommandEvent &event);
void OnDelete(wxCommandEvent &event);
void OnClose(wxCommandEvent &event);
@ -72,6 +73,7 @@ public:
// IDs
enum {
BUTTON_ATTACH_FONT = 1300,
BUTTON_ATTACH_GRAPHICS,
BUTTON_EXTRACT,
BUTTON_DELETE,
BUTTON_CLOSE