#include "lib/filter.h"
#include "lib/ffmpeg_content.h"
#include "lib/image_content.h"
+#include "lib/scope_guard.h"
#include "lib/video_content.h"
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
_ignore_video->Enable(static_cast<bool>(_content->video));
_ignore_video->SetValue(_content->video ? !content->video->use() : false);
+
+ auto fcs = dynamic_pointer_cast<FFmpegContent>(content);
+ _filters_allowed = static_cast<bool>(fcs);
+ if (fcs) {
+ _filters_list = fcs->filters();
+ }
setup_filters ();
bool const single_frame_image_content = dynamic_pointer_cast<const ImageContent>(_content) && _content->number_of_paths() == 1;
void
ContentAdvancedDialog::setup_filters ()
{
- auto fcs = dynamic_pointer_cast<FFmpegContent>(_content);
- if (!fcs) {
+ if (!_filters_allowed) {
checked_set (_filters, _("None"));
_filters->Enable (false);
_filters_button->Enable (false);
return;
}
- auto p = Filter::ffmpeg_string (fcs->filters());
+ auto p = Filter::ffmpeg_string(_filters_list);
if (p.empty()) {
checked_set (_filters, _("None"));
} else {
void
ContentAdvancedDialog::edit_filters ()
{
- auto fcs = dynamic_pointer_cast<FFmpegContent>(_content);
- if (!fcs) {
+ if (!_filters_allowed) {
return;
}
- auto d = new FilterDialog (this, fcs->filters());
- d->ActiveChanged.connect (bind(&ContentAdvancedDialog::filters_changed, this, _1));
- d->ShowModal ();
- d->Destroy ();
+ auto dialog = new FilterDialog(this, _filters_list);
+ ScopeGuard sg = [dialog]() { dialog->Destroy(); };
+
+ dialog->ActiveChanged.connect(bind(&ContentAdvancedDialog::filters_changed, this, _1));
+ dialog->ShowModal();
}
void
ContentAdvancedDialog::filters_changed (vector<Filter const *> filters)
{
- auto fcs = dynamic_pointer_cast<FFmpegContent>(_content);
- if (!fcs) {
- return;
- }
-
- fcs->set_filters (filters);
+ _filters_list = filters;
setup_filters ();
}
ContentAdvancedDialog (wxWindow* parent, std::shared_ptr<Content> content);
bool ignore_video() const;
+ std::vector<Filter const*> filters() {
+ return _filters_list;
+ }
private:
void edit_filters ();
void burnt_subtitle_language_changed ();
std::shared_ptr<Content> _content;
+ bool _filters_allowed = false;
+ std::vector<Filter const*> _filters_list;
wxStaticText* _filters;
wxButton* _filters_button;