Basic UI.
authorCarl Hetherington <cth@carlh.net>
Mon, 22 Jul 2013 11:25:35 +0000 (12:25 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 22 Jul 2013 11:25:35 +0000 (12:25 +0100)
src/lib/types.h
src/lib/video_content.cc
src/lib/video_content.h
src/wx/film_editor.cc
src/wx/video_panel.cc
src/wx/video_panel.h

index 458a2ecf3a21377b1bc4e3f91cb5186416741360..b1b359810e87219ff7c67777f447e2f52a965848 100644 (file)
@@ -34,6 +34,12 @@ typedef int64_t OutputAudioFrame;
 typedef int    OutputVideoFrame;
 typedef std::vector<boost::shared_ptr<Content> > ContentList;
 
+enum VideoFrameType
+{
+       VIDEO_FRAME_TYPE_2D,
+       VIDEO_FRAME_TYPE_3D_LEFT_RIGHT
+};
+
 /** @struct Crop
  *  @brief A description of the crop of an image or video.
  */
index a157b05993ca4b2532d0dd5fc8168436c2048a69..7eca53c3de8de202aad5c38d5f6c5e934a06e3aa 100644 (file)
@@ -28,8 +28,9 @@
 
 int const VideoContentProperty::VIDEO_SIZE      = 0;
 int const VideoContentProperty::VIDEO_FRAME_RATE = 1;
-int const VideoContentProperty::VIDEO_CROP      = 2;
-int const VideoContentProperty::VIDEO_RATIO     = 3;
+int const VideoContentProperty::VIDEO_FRAME_TYPE = 2;
+int const VideoContentProperty::VIDEO_CROP      = 3;
+int const VideoContentProperty::VIDEO_RATIO     = 4;
 
 using std::string;
 using std::stringstream;
@@ -42,6 +43,7 @@ VideoContent::VideoContent (shared_ptr<const Film> f, Time s, VideoContent::Fram
        : Content (f, s)
        , _video_length (len)
        , _video_frame_rate (0)
+       , _video_frame_type (VIDEO_FRAME_TYPE_2D)
        , _ratio (Ratio::from_id ("185"))
 {
 
@@ -51,6 +53,7 @@ VideoContent::VideoContent (shared_ptr<const Film> f, boost::filesystem::path p)
        : Content (f, p)
        , _video_length (0)
        , _video_frame_rate (0)
+       , _video_frame_type (VIDEO_FRAME_TYPE_2D)
        , _ratio (Ratio::from_id ("185"))
 {
 
@@ -63,6 +66,7 @@ VideoContent::VideoContent (shared_ptr<const Film> f, shared_ptr<const cxml::Nod
        _video_size.width = node->number_child<int> ("VideoWidth");
        _video_size.height = node->number_child<int> ("VideoHeight");
        _video_frame_rate = node->number_child<float> ("VideoFrameRate");
+       _video_frame_type = static_cast<VideoFrameType> (node->number_child<int> ("VideoFrameType"));
        _crop.left = node->number_child<int> ("LeftCrop");
        _crop.right = node->number_child<int> ("RightCrop");
        _crop.top = node->number_child<int> ("TopCrop");
@@ -81,6 +85,7 @@ VideoContent::as_xml (xmlpp::Node* node) const
        node->add_child("VideoWidth")->add_child_text (lexical_cast<string> (_video_size.width));
        node->add_child("VideoHeight")->add_child_text (lexical_cast<string> (_video_size.height));
        node->add_child("VideoFrameRate")->add_child_text (lexical_cast<string> (_video_frame_rate));
+       node->add_child("VideoFrameType")->add_child_text (lexical_cast<string> (static_cast<int> (_video_frame_type)));
        node->add_child("LeftCrop")->add_child_text (boost::lexical_cast<string> (_crop.left));
        node->add_child("RightCrop")->add_child_text (boost::lexical_cast<string> (_crop.right));
        node->add_child("TopCrop")->add_child_text (boost::lexical_cast<string> (_crop.top));
@@ -220,3 +225,14 @@ VideoContent::identifier () const
 
        return s.str ();
 }
+
+void
+VideoContent::set_video_frame_type (VideoFrameType t)
+{
+       {
+               boost::mutex::scoped_lock lm (_mutex);
+               _video_frame_rate = t;
+       }
+
+       signal_changed (VideoContentProperty::VIDEO_FRAME_TYPE);
+}
index 1c85ca09088b5547f386ca1c7bb5c874ab564225..348e2ce8b07723f63340a38e80e9fef9460e79f6 100644 (file)
@@ -30,6 +30,7 @@ class VideoContentProperty
 public:
        static int const VIDEO_SIZE;
        static int const VIDEO_FRAME_RATE;
+       static int const VIDEO_FRAME_TYPE;
        static int const VIDEO_CROP;
        static int const VIDEO_RATIO;
 };
@@ -62,11 +63,18 @@ public:
                return _video_frame_rate;
        }
 
+       void set_video_frame_type (VideoFrameType);
+
        void set_left_crop (int);
        void set_right_crop (int);
        void set_top_crop (int);
        void set_bottom_crop (int);
 
+       VideoFrameType video_frame_type () const {
+               boost::mutex::scoped_lock lm (_mutex);
+               return _video_frame_type;
+       }
+
        Crop crop () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _crop;
@@ -92,6 +100,7 @@ private:
        
        libdcp::Size _video_size;
        float _video_frame_rate;
+       VideoFrameType _video_frame_type;
        Crop _crop;
        Ratio const * _ratio;
 };
index 3800774e2268927b4dfbc82df409270afa4eca98..39935927f2ad498554f48f5f97e12f1f1ae75718 100644 (file)
@@ -488,6 +488,9 @@ FilmEditor::set_film (shared_ptr<Film> f)
 {
        set_general_sensitivity (f != 0);
 
+       wxListEvent ev;
+       content_selection_changed (ev);
+
        if (_film == f) {
                return;
        }
@@ -522,9 +525,6 @@ FilmEditor::set_film (shared_ptr<Film> f)
        if (!_film->content().empty ()) {
                set_selection (_film->content().front ());
        }
-
-       wxListEvent ev;
-       content_selection_changed (ev);
 }
 
 void
@@ -703,6 +703,7 @@ FilmEditor::content_selection_changed (wxListEvent &)
        film_content_changed (s, ContentProperty::LENGTH);
        film_content_changed (s, VideoContentProperty::VIDEO_CROP);
        film_content_changed (s, VideoContentProperty::VIDEO_RATIO);
+       film_content_changed (s, VideoContentProperty::VIDEO_FRAME_TYPE);
        film_content_changed (s, AudioContentProperty::AUDIO_GAIN);
        film_content_changed (s, AudioContentProperty::AUDIO_DELAY);
        film_content_changed (s, AudioContentProperty::AUDIO_MAPPING);
index b72bae035d8bf1088e8d377e47c4445b553a9355..e08edfa5a919a20e1ac22153a6cd07e832abc9f0 100644 (file)
@@ -30,6 +30,7 @@ using std::string;
 using std::pair;
 using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
+using boost::bind;
 
 VideoPanel::VideoPanel (FilmEditor* e)
        : FilmEditorPanel (e, _("Video"))
@@ -38,6 +39,12 @@ VideoPanel::VideoPanel (FilmEditor* e)
        _sizer->Add (grid, 0, wxALL, 8);
 
        int r = 0;
+
+       add_label_to_grid_bag_sizer (grid, this, _("Type"), true, wxGBPosition (r, 0));
+       _frame_type = new wxChoice (this, wxID_ANY);
+       grid->Add (_frame_type, wxGBPosition (r, 1));
+       ++r;
+       
        add_label_to_grid_bag_sizer (grid, this, _("Left crop"), true, wxGBPosition (r, 0));
        _left_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
        grid->Add (_left_crop, wxGBPosition (r, 1));
@@ -93,11 +100,15 @@ VideoPanel::VideoPanel (FilmEditor* e)
                _ratio->Append (std_to_wx ((*i)->nickname ()));
        }
 
-       _ratio->Connect          (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,  wxCommandEventHandler (VideoPanel::ratio_changed), 0, this);
+       _frame_type->Append (_("2D"));
+       _frame_type->Append (_("3D left/right"));
+
+       _frame_type->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, bind (&VideoPanel::frame_type_changed, this));
        _left_crop->Connect      (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (VideoPanel::left_crop_changed), 0, this);
        _right_crop->Connect     (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (VideoPanel::right_crop_changed), 0, this);
        _top_crop->Connect       (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (VideoPanel::top_crop_changed), 0, this);
        _bottom_crop->Connect    (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (VideoPanel::bottom_crop_changed), 0, this);
+       _ratio->Connect          (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,  wxCommandEventHandler (VideoPanel::ratio_changed), 0, this);
        _filters_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,   wxCommandEventHandler (VideoPanel::edit_filters_clicked), 0, this);
 }
 
@@ -167,8 +178,10 @@ VideoPanel::film_content_changed (shared_ptr<Content> c, int property)
 {
        shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (c);
        shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
-       
-       if (property == VideoContentProperty::VIDEO_CROP) {
+
+       if (property == VideoContentProperty::VIDEO_FRAME_TYPE) {
+               checked_set (_frame_type, vc->video_frame_type ());
+       } else if (property == VideoContentProperty::VIDEO_CROP) {
                checked_set (_left_crop,   vc ? vc->crop().left : 0);
                checked_set (_right_crop,  vc ? vc->crop().right        : 0);
                checked_set (_top_crop,    vc ? vc->crop().top  : 0);
@@ -308,3 +321,12 @@ VideoPanel::ratio_changed (wxCommandEvent &)
                vc->set_ratio (ratios[n]);
        }
 }
+
+void
+VideoPanel::frame_type_changed ()
+{
+       shared_ptr<VideoContent> vc = _editor->selected_video_content ();
+       if (vc) {
+               vc->set_video_frame_type (static_cast<VideoFrameType> (_frame_type->GetSelection ()));
+       }
+}
index 4cc9cd79ccb62f3c5743dec0174e284528521718..51a593e751921b5f9c372f4efcbb09cfd3525042 100644 (file)
@@ -40,16 +40,18 @@ private:
        void bottom_crop_changed (wxCommandEvent &);
        void edit_filters_clicked (wxCommandEvent &);
        void ratio_changed (wxCommandEvent &);
+       void frame_type_changed ();
 
        void setup_scaling_description ();
-       
-       wxChoice* _ratio;
-       wxStaticText* _ratio_description;
-       wxStaticText* _scaling_description;
+
+       wxChoice* _frame_type;
        wxSpinCtrl* _left_crop;
        wxSpinCtrl* _right_crop;
        wxSpinCtrl* _top_crop;
        wxSpinCtrl* _bottom_crop;
+       wxChoice* _ratio;
+       wxStaticText* _ratio_description;
+       wxStaticText* _scaling_description;
        wxStaticText* _filters;
        wxButton* _filters_button;
 };