summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-09-30 09:33:33 +0100
committerCarl Hetherington <cth@carlh.net>2014-09-30 20:38:12 +0100
commita4d8e5d24beddb719180e75f1047ae317bef85a4 (patch)
tree9884019a61aabfc0658d16e29cfd6a4b4a21c485 /src/wx
parent391d85619ac19a2a93696ddc35c222eb9bb5d9d6 (diff)
Basic video fade support.
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/content_widget.h10
-rw-r--r--src/wx/timecode.cc57
-rw-r--r--src/wx/timecode.h62
-rw-r--r--src/wx/timing_panel.cc10
-rw-r--r--src/wx/timing_panel.h13
-rw-r--r--src/wx/video_panel.cc119
-rw-r--r--src/wx/video_panel.h7
7 files changed, 169 insertions, 109 deletions
diff --git a/src/wx/content_widget.h b/src/wx/content_widget.h
index bbe160399..b4d06286e 100644
--- a/src/wx/content_widget.h
+++ b/src/wx/content_widget.h
@@ -103,11 +103,12 @@ public:
}
/** Add this widget to a wxGridBagSizer */
- void add (wxGridBagSizer* sizer, wxGBPosition position)
+ void add (wxGridBagSizer* sizer, wxGBPosition position, wxGBSpan span = wxDefaultSpan)
{
_sizer = sizer;
_position = position;
- _sizer->Add (_wrapped, _position);
+ _span = span;
+ _sizer->Add (_wrapped, _position, _span);
}
/** Update the view from the model */
@@ -151,7 +152,7 @@ private:
_sizer->Detach (_button);
_button->Hide ();
- _sizer->Add (_wrapped, _position);
+ _sizer->Add (_wrapped, _position, _span);
_wrapped->Show ();
_sizer->Layout ();
}
@@ -165,7 +166,7 @@ private:
_wrapped->Hide ();
_sizer->Detach (_wrapped);
_button->Show ();
- _sizer->Add (_button, _position);
+ _sizer->Add (_button, _position, _span);
_sizer->Layout ();
}
@@ -187,6 +188,7 @@ private:
T* _wrapped;
wxGridBagSizer* _sizer;
wxGBPosition _position;
+ wxGBSpan _span;
wxButton* _button;
List _content;
int _property;
diff --git a/src/wx/timecode.cc b/src/wx/timecode.cc
index 07cb0be65..bd0a182c2 100644
--- a/src/wx/timecode.cc
+++ b/src/wx/timecode.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,16 +17,16 @@
*/
-#include <boost/lexical_cast.hpp>
#include "lib/util.h"
#include "timecode.h"
#include "wx_util.h"
+#include <boost/lexical_cast.hpp>
using std::string;
using std::cout;
using boost::lexical_cast;
-Timecode::Timecode (wxWindow* parent)
+TimecodeBase::TimecodeBase (wxWindow* parent)
: wxPanel (parent)
{
wxClientDC dc (parent);
@@ -69,11 +69,11 @@ Timecode::Timecode (wxWindow* parent)
_fixed = add_label_to_sizer (_sizer, this, wxT ("42"), false);
- _hours->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&Timecode::changed, this));
- _minutes->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&Timecode::changed, this));
- _seconds->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&Timecode::changed, this));
- _frames->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&Timecode::changed, this));
- _set_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&Timecode::set_clicked, this));
+ _hours->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&TimecodeBase::changed, this));
+ _minutes->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&TimecodeBase::changed, this));
+ _seconds->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&TimecodeBase::changed, this));
+ _frames->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&TimecodeBase::changed, this));
+ _set_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&TimecodeBase::set_clicked, this));
_set_button->Enable (false);
@@ -83,40 +83,7 @@ Timecode::Timecode (wxWindow* parent)
}
void
-Timecode::set (DCPTime t, int fps)
-{
- int h;
- int m;
- int s;
- int f;
- t.split (fps, h, m, s, f);
-
- checked_set (_hours, lexical_cast<string> (h));
- checked_set (_minutes, lexical_cast<string> (m));
- checked_set (_seconds, lexical_cast<string> (s));
- checked_set (_frames, lexical_cast<string> (f));
-
- _fixed->SetLabel (std_to_wx (t.timecode (fps)));
-}
-
-DCPTime
-Timecode::get (int fps) const
-{
- DCPTime t;
- string const h = wx_to_std (_hours->GetValue ());
- t += DCPTime::from_seconds (lexical_cast<int> (h.empty() ? "0" : h) * 3600);
- string const m = wx_to_std (_minutes->GetValue());
- t += DCPTime::from_seconds (lexical_cast<int> (m.empty() ? "0" : m) * 60);
- string const s = wx_to_std (_seconds->GetValue());
- t += DCPTime::from_seconds (lexical_cast<int> (s.empty() ? "0" : s));
- string const f = wx_to_std (_frames->GetValue());
- t += DCPTime::from_seconds (lexical_cast<double> (f.empty() ? "0" : f) / fps);
-
- return t;
-}
-
-void
-Timecode::clear ()
+TimecodeBase::clear ()
{
checked_set (_hours, "");
checked_set (_minutes, "");
@@ -126,20 +93,20 @@ Timecode::clear ()
}
void
-Timecode::changed ()
+TimecodeBase::changed ()
{
_set_button->Enable (true);
}
void
-Timecode::set_clicked ()
+TimecodeBase::set_clicked ()
{
Changed ();
_set_button->Enable (false);
}
void
-Timecode::set_editable (bool e)
+TimecodeBase::set_editable (bool e)
{
_editable->Show (e);
_fixed->Show (!e);
diff --git a/src/wx/timecode.h b/src/wx/timecode.h
index 72b00ddeb..7a34b80fe 100644
--- a/src/wx/timecode.h
+++ b/src/wx/timecode.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,24 +17,27 @@
*/
-#include <boost/signals2.hpp>
-#include <wx/wx.h>
+#ifndef DCPOMATIC_WX_TIMECODE_H
+#define DCPOMATIC_WX_TIMECODE_H
+
+#include "wx_util.h"
#include "lib/types.h"
+#include <wx/wx.h>
+#include <boost/signals2.hpp>
+#include <boost/lexical_cast.hpp>
-class Timecode : public wxPanel
+class TimecodeBase : public wxPanel
{
public:
- Timecode (wxWindow *);
+ TimecodeBase (wxWindow *);
- void set (DCPTime, int);
- DCPTime get (int) const;
void clear ();
void set_editable (bool);
boost::signals2::signal<void ()> Changed;
-private:
+protected:
void changed ();
void set_clicked ();
@@ -48,3 +51,46 @@ private:
wxStaticText* _fixed;
};
+template <class T>
+class Timecode : public TimecodeBase
+{
+public:
+ Timecode (wxWindow* parent)
+ : TimecodeBase (parent)
+ {
+
+ }
+
+ void set (T t, int fps)
+ {
+ int h;
+ int m;
+ int s;
+ int f;
+ t.split (fps, h, m, s, f);
+
+ checked_set (_hours, boost::lexical_cast<std::string> (h));
+ checked_set (_minutes, boost::lexical_cast<std::string> (m));
+ checked_set (_seconds, boost::lexical_cast<std::string> (s));
+ checked_set (_frames, boost::lexical_cast<std::string> (f));
+
+ _fixed->SetLabel (std_to_wx (t.timecode (fps)));
+ }
+
+ T get (int fps) const
+ {
+ T t;
+ std::string const h = wx_to_std (_hours->GetValue ());
+ t += T::from_seconds (boost::lexical_cast<int> (h.empty() ? "0" : h) * 3600);
+ std::string const m = wx_to_std (_minutes->GetValue());
+ t += T::from_seconds (boost::lexical_cast<int> (m.empty() ? "0" : m) * 60);
+ std::string const s = wx_to_std (_seconds->GetValue());
+ t += T::from_seconds (boost::lexical_cast<int> (s.empty() ? "0" : s));
+ std::string const f = wx_to_std (_frames->GetValue());
+ t += T::from_seconds (boost::lexical_cast<double> (f.empty() ? "0" : f) / fps);
+
+ return t;
+ }
+};
+
+#endif
diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc
index 27d5b9cd3..0f86a3f3f 100644
--- a/src/wx/timing_panel.cc
+++ b/src/wx/timing_panel.cc
@@ -40,19 +40,19 @@ TimingPanel::TimingPanel (ContentPanel* p)
_sizer->Add (grid, 0, wxALL, 8);
add_label_to_sizer (grid, this, _("Position"), true);
- _position = new Timecode (this);
+ _position = new Timecode<DCPTime> (this);
grid->Add (_position);
add_label_to_sizer (grid, this, _("Full length"), true);
- _full_length = new Timecode (this);
+ _full_length = new Timecode<DCPTime> (this);
grid->Add (_full_length);
add_label_to_sizer (grid, this, _("Trim from start"), true);
- _trim_start = new Timecode (this);
+ _trim_start = new Timecode<DCPTime> (this);
grid->Add (_trim_start);
add_label_to_sizer (grid, this, _("Trim from end"), true);
- _trim_end = new Timecode (this);
+ _trim_end = new Timecode<DCPTime> (this);
grid->Add (_trim_end);
add_label_to_sizer (grid, this, _("Play length"), true);
- _play_length = new Timecode (this);
+ _play_length = new Timecode<DCPTime> (this);
grid->Add (_play_length);
{
diff --git a/src/wx/timing_panel.h b/src/wx/timing_panel.h
index b531db551..00b7f84e7 100644
--- a/src/wx/timing_panel.h
+++ b/src/wx/timing_panel.h
@@ -18,8 +18,7 @@
*/
#include "content_sub_panel.h"
-
-class Timecode;
+#include "timecode.h"
class TimingPanel : public ContentSubPanel
{
@@ -38,11 +37,11 @@ private:
void video_frame_rate_changed ();
void set_video_frame_rate ();
- Timecode* _position;
- Timecode* _full_length;
- Timecode* _trim_start;
- Timecode* _trim_end;
- Timecode* _play_length;
+ Timecode<DCPTime>* _position;
+ Timecode<DCPTime>* _full_length;
+ Timecode<DCPTime>* _trim_start;
+ Timecode<DCPTime>* _trim_end;
+ Timecode<DCPTime>* _play_length;
wxTextCtrl* _video_frame_rate;
wxButton* _set_video_frame_rate;
};
diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc
index a5d197c2a..a8510cbba 100644
--- a/src/wx/video_panel.cc
+++ b/src/wx/video_panel.cc
@@ -37,6 +37,7 @@ using std::string;
using std::pair;
using std::cout;
using std::list;
+using std::set;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
using boost::bind;
@@ -82,7 +83,7 @@ VideoPanel::VideoPanel (ContentPanel* p)
&caster<int, VideoFrameType>,
&caster<VideoFrameType, int>
);
- _frame_type->add (grid, wxGBPosition (r, 1));
+ _frame_type->add (grid, wxGBPosition (r, 1), wxGBSpan (1, 2));
++r;
add_label_to_grid_bag_sizer (grid, this, _("Left crop"), true, wxGBPosition (r, 0));
@@ -94,9 +95,8 @@ VideoPanel::VideoPanel (ContentPanel* p)
boost::mem_fn (&VideoContent::set_left_crop)
);
_left_crop->add (grid, wxGBPosition (r, 1));
- ++r;
- add_label_to_grid_bag_sizer (grid, this, _("Right crop"), true, wxGBPosition (r, 0));
+ add_label_to_grid_bag_sizer (grid, this, _("Right crop"), true, wxGBPosition (r, 2));
_right_crop = new ContentSpinCtrl<VideoContent> (
this,
new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1)),
@@ -104,7 +104,8 @@ VideoPanel::VideoPanel (ContentPanel* p)
boost::mem_fn (&VideoContent::right_crop),
boost::mem_fn (&VideoContent::set_right_crop)
);
- _right_crop->add (grid, wxGBPosition (r, 1));
+ _right_crop->add (grid, wxGBPosition (r, 3));
+
++r;
add_label_to_grid_bag_sizer (grid, this, _("Top crop"), true, wxGBPosition (r, 0));
@@ -115,10 +116,9 @@ VideoPanel::VideoPanel (ContentPanel* p)
boost::mem_fn (&VideoContent::top_crop),
boost::mem_fn (&VideoContent::set_top_crop)
);
- _top_crop->add (grid, wxGBPosition (r,1 ));
- ++r;
+ _top_crop->add (grid, wxGBPosition (r, 1));
- add_label_to_grid_bag_sizer (grid, this, _("Bottom crop"), true, wxGBPosition (r, 0));
+ add_label_to_grid_bag_sizer (grid, this, _("Bottom crop"), true, wxGBPosition (r, 2));
_bottom_crop = new ContentSpinCtrl<VideoContent> (
this,
new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1)),
@@ -126,9 +126,20 @@ VideoPanel::VideoPanel (ContentPanel* p)
boost::mem_fn (&VideoContent::bottom_crop),
boost::mem_fn (&VideoContent::set_bottom_crop)
);
- _bottom_crop->add (grid, wxGBPosition (r, 1));
+ _bottom_crop->add (grid, wxGBPosition (r, 3));
+
++r;
+ add_label_to_grid_bag_sizer (grid, this, _("Fade in"), true, wxGBPosition (r, 0));
+ _fade_in = new Timecode<ContentTime> (this);
+ grid->Add (_fade_in, wxGBPosition (r, 1), wxGBSpan (1, 3));
+ ++r;
+
+ add_label_to_grid_bag_sizer (grid, this, _("Fade out"), true, wxGBPosition (r, 0));
+ _fade_out = new Timecode<ContentTime> (this);
+ grid->Add (_fade_out, wxGBPosition (r, 1), wxGBSpan (1, 3));
+ ++r;
+
add_label_to_grid_bag_sizer (grid, this, _("Scale to"), true, wxGBPosition (r, 0));
_scale = new ContentChoice<VideoContent, VideoContentScale> (
this,
@@ -139,44 +150,29 @@ VideoPanel::VideoPanel (ContentPanel* p)
&index_to_scale,
&scale_to_index
);
- _scale->add (grid, wxGBPosition (r, 1));
+ _scale->add (grid, wxGBPosition (r, 1), wxGBSpan (1, 2));
++r;
- {
- add_label_to_grid_bag_sizer (grid, this, _("Filters"), true, wxGBPosition (r, 0));
- wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
-
- wxClientDC dc (this);
- wxSize size = dc.GetTextExtent (wxT ("A quite long name"));
- size.SetHeight (-1);
-
- _filters = new wxStaticText (this, wxID_ANY, _("None"), wxDefaultPosition, size);
- s->Add (_filters, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
- _filters_button = new wxButton (this, wxID_ANY, _("Edit..."));
- s->Add (_filters_button, 0, wxALIGN_CENTER_VERTICAL);
- grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
- }
+ wxClientDC dc (this);
+ wxSize size = dc.GetTextExtent (wxT ("A quite long name"));
+ size.SetHeight (-1);
+
+ add_label_to_grid_bag_sizer (grid, this, _("Filters"), true, wxGBPosition (r, 0));
+ _filters = new wxStaticText (this, wxID_ANY, _("None"), wxDefaultPosition, size);
+ grid->Add (_filters, wxGBPosition (r, 1), wxGBSpan (1, 2), wxALIGN_CENTER_VERTICAL);
+ _filters_button = new wxButton (this, wxID_ANY, _("Edit..."));
+ grid->Add (_filters_button, wxGBPosition (r, 3), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
++r;
- {
- add_label_to_grid_bag_sizer (grid, this, _("Colour conversion"), true, wxGBPosition (r, 0));
- wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
-
- wxClientDC dc (this);
- wxSize size = dc.GetTextExtent (wxT ("A quite long name"));
- size.SetHeight (-1);
-
- _colour_conversion = new wxStaticText (this, wxID_ANY, wxT (""), wxDefaultPosition, size);
-
- s->Add (_colour_conversion, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
- _colour_conversion_button = new wxButton (this, wxID_ANY, _("Edit..."));
- s->Add (_colour_conversion_button, 0, wxALIGN_CENTER_VERTICAL);
- grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
- }
+ add_label_to_grid_bag_sizer (grid, this, _("Colour conversion"), true, wxGBPosition (r, 0));
+ _colour_conversion = new wxStaticText (this, wxID_ANY, wxT (""), wxDefaultPosition, size);
+ grid->Add (_colour_conversion, wxGBPosition (r, 1), wxGBSpan (1, 2), wxALIGN_CENTER_VERTICAL);
+ _colour_conversion_button = new wxButton (this, wxID_ANY, _("Edit..."));
+ grid->Add (_colour_conversion_button, wxGBPosition (r, 3), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
++r;
_description = new wxStaticText (this, wxID_ANY, wxT ("\n \n \n \n \n"), wxDefaultPosition, wxDefaultSize);
- grid->Add (_description, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 6);
+ grid->Add (_description, wxGBPosition (r, 0), wxGBSpan (1, 4), wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 6);
wxFont font = _description->GetFont();
font.SetStyle(wxFONTSTYLE_ITALIC);
font.SetPointSize(font.GetPointSize() - 1);
@@ -201,6 +197,9 @@ VideoPanel::VideoPanel (ContentPanel* p)
_frame_type->wrapped()->Append (_("3D left only"));
_frame_type->wrapped()->Append (_("3D right only"));
+ _fade_in->Changed.connect (boost::bind (&VideoPanel::fade_in_changed, this));
+ _fade_out->Changed.connect (boost::bind (&VideoPanel::fade_out_changed, this));
+
_filters_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&VideoPanel::edit_filters_clicked, this));
_colour_conversion_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&VideoPanel::edit_colour_conversion_clicked, this));
}
@@ -251,6 +250,28 @@ VideoPanel::film_content_changed (int property)
_filters->SetLabel (std_to_wx (p));
}
}
+ } else if (property == VideoContentProperty::VIDEO_FADE_IN) {
+ set<ContentTime> check;
+ for (VideoContentList::const_iterator i = vc.begin (); i != vc.end(); ++i) {
+ check.insert ((*i)->fade_in ());
+ }
+
+ if (check.size() == 1) {
+ _fade_in->set (vc.front()->fade_in (), vc.front()->video_frame_rate ());
+ } else {
+ _fade_in->clear ();
+ }
+ } else if (property == VideoContentProperty::VIDEO_FADE_OUT) {
+ set<ContentTime> check;
+ for (VideoContentList::const_iterator i = vc.begin (); i != vc.end(); ++i) {
+ check.insert ((*i)->fade_out ());
+ }
+
+ if (check.size() == 1) {
+ _fade_out->set (vc.front()->fade_out (), vc.front()->video_frame_rate ());
+ } else {
+ _fade_out->clear ();
+ }
}
}
@@ -381,5 +402,25 @@ VideoPanel::content_selection_changed ()
film_content_changed (VideoContentProperty::VIDEO_CROP);
film_content_changed (VideoContentProperty::VIDEO_FRAME_RATE);
film_content_changed (VideoContentProperty::COLOUR_CONVERSION);
+ film_content_changed (VideoContentProperty::VIDEO_FADE_IN);
+ film_content_changed (VideoContentProperty::VIDEO_FADE_OUT);
film_content_changed (FFmpegContentProperty::FILTERS);
}
+
+void
+VideoPanel::fade_in_changed ()
+{
+ VideoContentList vc = _parent->selected_video ();
+ for (VideoContentList::const_iterator i = vc.begin(); i != vc.end(); ++i) {
+ (*i)->set_fade_in (_fade_in->get (_parent->film()->video_frame_rate ()));
+ }
+}
+
+void
+VideoPanel::fade_out_changed ()
+{
+ VideoContentList vc = _parent->selected_video ();
+ for (VideoContentList::const_iterator i = vc.begin(); i != vc.end(); ++i) {
+ (*i)->set_fade_out (_fade_out->get (_parent->film()->video_frame_rate ()));
+ }
+}
diff --git a/src/wx/video_panel.h b/src/wx/video_panel.h
index e17541cd3..aa0c6ed53 100644
--- a/src/wx/video_panel.h
+++ b/src/wx/video_panel.h
@@ -21,9 +21,10 @@
* @brief VideoPanel class.
*/
-#include "lib/film.h"
#include "content_sub_panel.h"
#include "content_widget.h"
+#include "timecode.h"
+#include "lib/film.h"
class wxChoice;
class wxStaticText;
@@ -45,6 +46,8 @@ public:
private:
void edit_filters_clicked ();
void edit_colour_conversion_clicked ();
+ void fade_in_changed ();
+ void fade_out_changed ();
void setup_description ();
@@ -53,6 +56,8 @@ private:
ContentSpinCtrl<VideoContent>* _right_crop;
ContentSpinCtrl<VideoContent>* _top_crop;
ContentSpinCtrl<VideoContent>* _bottom_crop;
+ Timecode<ContentTime>* _fade_in;
+ Timecode<ContentTime>* _fade_out;
ContentChoice<VideoContent, VideoContentScale>* _scale;
wxStaticText* _description;
wxStaticText* _filters;