Pass a project context to AssExportFilter::GetConfigDialogWindow so that export filters don't have to use things like AssFile::top and VideoContext::Get
Originally committed to SVN as r5629.
This commit is contained in:
parent
9ce579e187
commit
df100fb5a5
9 changed files with 41 additions and 34 deletions
|
@ -46,8 +46,8 @@
|
|||
|
||||
class AssFile;
|
||||
class AssExportFilter;
|
||||
class DialogExport;
|
||||
class AssExporter;
|
||||
|
||||
namespace agi { struct Context; }
|
||||
|
||||
/// DOCME
|
||||
typedef std::list<AssExportFilter*> FilterList;
|
||||
|
@ -111,9 +111,12 @@ public:
|
|||
virtual void ProcessSubs(AssFile *subs, wxWindow *parent_window=0)=0;
|
||||
|
||||
/// Draw setup controls
|
||||
virtual wxWindow *GetConfigDialogWindow(wxWindow *parent) { return 0; }
|
||||
/// @param parent Parent window to add controls to
|
||||
/// @param c Project context
|
||||
virtual wxWindow *GetConfigDialogWindow(wxWindow *parent, agi::Context *c) { return 0; }
|
||||
|
||||
/// Load settings to use from the configuration dialog
|
||||
/// @param is_default If true use default settings instead
|
||||
virtual void LoadSettings(bool is_default) { }
|
||||
/// @param c Project context
|
||||
virtual void LoadSettings(bool is_default, agi::Context *c) { }
|
||||
};
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "ass_export_filter.h"
|
||||
#include "ass_exporter.h"
|
||||
#include "ass_file.h"
|
||||
#include "include/aegisub/context.h"
|
||||
|
||||
static inline std::list<AssExportFilter*>::const_iterator filter_list_begin() {
|
||||
return AssExportFilterChain::GetFilterList()->begin();
|
||||
|
@ -48,8 +49,8 @@ static inline std::list<AssExportFilter*>::const_iterator filter_list_end() {
|
|||
return AssExportFilterChain::GetFilterList()->end();
|
||||
}
|
||||
|
||||
AssExporter::AssExporter(AssFile *subs)
|
||||
: original_subs(subs)
|
||||
AssExporter::AssExporter(agi::Context *c)
|
||||
: c(c)
|
||||
, is_default(true)
|
||||
{
|
||||
}
|
||||
|
@ -63,7 +64,7 @@ void AssExporter::DrawSettings(wxWindow *parent, wxSizer *target_sizer) {
|
|||
// Make sure to construct static box sizer first, so it won't overlap
|
||||
// the controls on wxMac.
|
||||
wxSizer *box = new wxStaticBoxSizer(wxVERTICAL, parent, (*cur)->GetName());
|
||||
wxWindow *window = (*cur)->GetConfigDialogWindow(parent);
|
||||
wxWindow *window = (*cur)->GetConfigDialogWindow(parent, c);
|
||||
if (window) {
|
||||
box->Add(window, 0, wxEXPAND, 0);
|
||||
target_sizer->Add(box, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
|
||||
|
@ -99,10 +100,10 @@ wxArrayString AssExporter::GetAllFilterNames() {
|
|||
}
|
||||
|
||||
AssFile *AssExporter::ExportTransform(wxWindow *export_dialog, bool copy) {
|
||||
AssFile *subs = copy ? new AssFile(*original_subs) : original_subs;
|
||||
AssFile *subs = copy ? new AssFile(*c->ass) : c->ass;
|
||||
|
||||
for (filter_iterator cur = filters.begin(); cur != filters.end(); cur++) {
|
||||
(*cur)->LoadSettings(is_default);
|
||||
(*cur)->LoadSettings(is_default, c);
|
||||
(*cur)->ProcessSubs(subs, export_dialog);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
|
||||
class AssExportFilter;
|
||||
class AssFile;
|
||||
namespace agi { struct Context; }
|
||||
|
||||
typedef std::list<AssExportFilter*> FilterList;
|
||||
|
||||
|
@ -62,15 +63,15 @@ class AssExporter {
|
|||
/// Filters which will be applied to the subtitles
|
||||
FilterList filters;
|
||||
|
||||
/// Input subtitle file
|
||||
AssFile *original_subs;
|
||||
/// Input context
|
||||
agi::Context *c;
|
||||
|
||||
/// Have the config windows been created, or should filters simply use
|
||||
/// their default settings
|
||||
bool is_default;
|
||||
|
||||
public:
|
||||
AssExporter(AssFile *subs);
|
||||
AssExporter(agi::Context *c);
|
||||
~AssExporter();
|
||||
|
||||
/// Get the names of all registered export filters
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
|
||||
#include "ass_attachment.h"
|
||||
#include "ass_dialogue.h"
|
||||
#include "ass_exporter.h"
|
||||
#include "ass_file.h"
|
||||
#include "ass_override.h"
|
||||
#include "ass_style.h"
|
||||
|
@ -224,12 +223,6 @@ void AssFile::SaveMemory(std::vector<char> &dst,const wxString encoding) {
|
|||
}
|
||||
}
|
||||
|
||||
void AssFile::Export(wxString _filename) {
|
||||
AssExporter exporter(this);
|
||||
exporter.AddAutoFilters();
|
||||
exporter.Export(_filename,"UTF-8");
|
||||
}
|
||||
|
||||
bool AssFile::CanSave() {
|
||||
// ASS format?
|
||||
wxString ext = filename.Lower().Right(4);
|
||||
|
|
|
@ -132,9 +132,6 @@ public:
|
|||
/// @brief Save to a memory buffer. Used for subtitle providers which support it
|
||||
/// @param[out] dst Destination vector
|
||||
void SaveMemory(std::vector<char> &dst,const wxString encoding="");
|
||||
/// @brief Saves exported copy, with effects applied
|
||||
/// @param file Path to save to; file name is never set to this
|
||||
void Export(wxString file);
|
||||
/// Add file name to the MRU list
|
||||
void AddToRecent(wxString file);
|
||||
/// Can the file be saved in its current format?
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
DialogExport::DialogExport(agi::Context *c)
|
||||
: wxDialog(c->parent, -1, _("Export"), wxDefaultPosition, wxSize(200, 100), wxCAPTION | wxCLOSE_BOX, "Export")
|
||||
, c(c)
|
||||
, exporter(new AssExporter(c->ass))
|
||||
, exporter(new AssExporter(c))
|
||||
{
|
||||
wxArrayString filters = exporter->GetAllFilterNames();
|
||||
filter_list = new wxCheckListBox(this, -1, wxDefaultPosition, wxSize(200, 100), filters);
|
||||
|
|
|
@ -52,11 +52,13 @@
|
|||
#include "ass_file.h"
|
||||
#include "ass_override.h"
|
||||
#include "export_framerate.h"
|
||||
#include "include/aegisub/context.h"
|
||||
#include "utils.h"
|
||||
#include "video_context.h"
|
||||
|
||||
AssTransformFramerateFilter::AssTransformFramerateFilter()
|
||||
: AssExportFilter(_("Transform Framerate"), _("Transform subtitle times, including those in override tags, from an input framerate to an output framerate.\n\nThis is useful for converting regular time subtitles to VFRaC time subtitles for hardsubbing.\nIt can also be used to convert subtitles to a different speed video, such as NTSC to PAL speedup."), 1000)
|
||||
, c(0)
|
||||
, Input(0)
|
||||
, Output(0)
|
||||
{
|
||||
|
@ -66,10 +68,10 @@ void AssTransformFramerateFilter::ProcessSubs(AssFile *subs, wxWindow *) {
|
|||
TransformFrameRate(subs);
|
||||
}
|
||||
|
||||
wxWindow *AssTransformFramerateFilter::GetConfigDialogWindow(wxWindow *parent) {
|
||||
wxWindow *AssTransformFramerateFilter::GetConfigDialogWindow(wxWindow *parent, agi::Context *c) {
|
||||
wxWindow *base = new wxPanel(parent, -1);
|
||||
|
||||
LoadSettings(true);
|
||||
LoadSettings(true, c);
|
||||
|
||||
// Input sizer
|
||||
wxSizer *InputSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
@ -130,13 +132,15 @@ wxWindow *AssTransformFramerateFilter::GetConfigDialogWindow(wxWindow *parent) {
|
|||
}
|
||||
|
||||
void AssTransformFramerateFilter::OnFpsFromVideo(wxCommandEvent &) {
|
||||
InputFramerate->SetValue(wxString::Format("%g", VideoContext::Get()->FPS().FPS()));
|
||||
InputFramerate->SetValue(wxString::Format("%g", c->videoController->FPS().FPS()));
|
||||
}
|
||||
|
||||
void AssTransformFramerateFilter::LoadSettings(bool IsDefault) {
|
||||
if (IsDefault) {
|
||||
Input = &VideoContext::Get()->VFR_Input;
|
||||
Output = &VideoContext::Get()->VFR_Output;
|
||||
void AssTransformFramerateFilter::LoadSettings(bool is_default, agi::Context *c) {
|
||||
this->c = c;
|
||||
|
||||
if (is_default) {
|
||||
Input = &c->videoController->VFR_Input;
|
||||
Output = &c->videoController->VFR_Output;
|
||||
}
|
||||
else {
|
||||
double temp;
|
||||
|
@ -148,7 +152,7 @@ void AssTransformFramerateFilter::LoadSettings(bool IsDefault) {
|
|||
t2 = temp;
|
||||
Output = &t2;
|
||||
}
|
||||
else Output = &VideoContext::Get()->VFR_Output;
|
||||
else Output = &c->videoController->VFR_Output;
|
||||
|
||||
if (Reverse->IsChecked()) {
|
||||
std::swap(Input, Output);
|
||||
|
|
|
@ -47,6 +47,7 @@ class wxTextCtrl;
|
|||
/// @class AssTransformFramerateFilter
|
||||
/// @brief Transform subtitle times, including those in override tags, from an input framerate to an output framerate
|
||||
class AssTransformFramerateFilter : public AssExportFilter {
|
||||
agi::Context *c;
|
||||
AssDialogue *line;
|
||||
int newStart;
|
||||
int newEnd;
|
||||
|
@ -92,6 +93,6 @@ public:
|
|||
/// Constructor
|
||||
AssTransformFramerateFilter();
|
||||
void ProcessSubs(AssFile *subs, wxWindow *);
|
||||
wxWindow *GetConfigDialogWindow(wxWindow *parent);
|
||||
void LoadSettings(bool IsDefault);
|
||||
wxWindow *GetConfigDialogWindow(wxWindow *parent, agi::Context *c);
|
||||
void LoadSettings(bool is_default, agi::Context *c);
|
||||
};
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "ass_exporter.h"
|
||||
#include "ass_file.h"
|
||||
#include "compat.h"
|
||||
#include "include/aegisub/context.h"
|
||||
#include "include/aegisub/subtitles_provider.h"
|
||||
#include "video_provider_manager.h"
|
||||
|
||||
|
@ -86,7 +87,13 @@ std::tr1::shared_ptr<AegiVideoFrame> ThreadedFrameSource::ProcFrame(int frameNum
|
|||
// other lines will probably not be viewed before the file changes
|
||||
// again), and if it's a different frame, export the entire file.
|
||||
if (singleFrame == -1) {
|
||||
AssExporter exporter(subs.get());
|
||||
// This will crash if any of the export filters try to use
|
||||
// anything but the subtitles, but that wouldn't be safe to
|
||||
// do anyway
|
||||
agi::Context c = { 0 };
|
||||
c.ass = subs.get();
|
||||
|
||||
AssExporter exporter(&c);
|
||||
exporter.AddAutoFilters();
|
||||
exporter.ExportTransform();
|
||||
|
||||
|
|
Loading…
Reference in a new issue