Hopefully sensitivity is a bit tidier.
authorCarl Hetherington <cth@carlh.net>
Fri, 19 Jul 2013 23:09:58 +0000 (00:09 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 19 Jul 2013 23:09:58 +0000 (00:09 +0100)
src/wx/audio_panel.cc
src/wx/audio_panel.h
src/wx/film_editor.cc
src/wx/film_editor.h
src/wx/film_editor_panel.h
src/wx/subtitle_panel.cc
src/wx/subtitle_panel.h
src/wx/video_panel.cc
src/wx/video_panel.h

index b4845233f796fb58792ff5cb274ebee667c392d3..cfe34bba5ca8886553857304ecf138e37bb0172e 100644 (file)
@@ -99,9 +99,6 @@ void
 AudioPanel::film_changed (Film::Property property)
 {
        switch (property) {
-       case Film::CONTENT:
-               setup_sensitivity ();
-               break;
        case Film::DCP_AUDIO_CHANNELS:
                _mapping->set_channels (_editor->film()->dcp_audio_channels ());
                break;
@@ -115,6 +112,10 @@ AudioPanel::film_content_changed (shared_ptr<Content> c, int property)
 {
        shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (c);
        shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
+
+       if (_audio_dialog && _editor->selected_audio_content()) {
+               _audio_dialog->set_content (_editor->selected_audio_content ());
+       }
        
        if (property == AudioContentProperty::AUDIO_GAIN) {
                checked_set (_gain, ac ? ac->audio_gain() : 0);
@@ -134,9 +135,6 @@ AudioPanel::film_content_changed (shared_ptr<Content> c, int property)
                                checked_set (_stream, lexical_cast<string> (fc->audio_stream()->id));
                        }
                }
-               setup_sensitivity ();
-       } else if (property == FFmpegContentProperty::AUDIO_STREAM) {
-               setup_sensitivity ();
        }
 }
 
@@ -212,24 +210,6 @@ AudioPanel::show_clicked (wxCommandEvent &)
        _audio_dialog->set_content (ac);
 }
 
-
-void
-AudioPanel::setup_sensitivity ()
-{
-       _show->Enable (_editor->film ());
-       _gain->Enable (_editor->generally_sensitive ());
-       _gain_calculate_button->Enable (_editor->generally_sensitive ());
-       _delay->Enable (_editor->generally_sensitive ());
-}
-
-void
-AudioPanel::content_selection_changed ()
-{
-       if (_audio_dialog && _editor->selected_audio_content()) {
-               _audio_dialog->set_content (_editor->selected_audio_content ());
-       }
-}
-
 void
 AudioPanel::stream_changed (wxCommandEvent &)
 {
index f4a595f3278087d344cf4dd32afaed056c2c1e13..8a6402c9ef27235ffca22f6c966e721c5b4a270d 100644 (file)
@@ -33,9 +33,6 @@ public:
 
        void film_changed (Film::Property);
        void film_content_changed (boost::shared_ptr<Content>, int);
-       void content_selection_changed ();
-
-       void setup_sensitivity ();
        
 private:
        void gain_changed (wxCommandEvent &);
index ea1afd22092d3dcd5cf71939133d0b25c5a3877a..3800774e2268927b4dfbc82df409270afa4eca98 100644 (file)
@@ -257,10 +257,15 @@ FilmEditor::make_content_panel ()
        _content_sizer->Add (_content_notebook, 1, wxEXPAND | wxTOP, 6);
 
        _video_panel = new VideoPanel (this);
+       _panels.push_back (_video_panel);
        _audio_panel = new AudioPanel (this);
+       _panels.push_back (_audio_panel);
        _subtitle_panel = new SubtitlePanel (this);
+       _panels.push_back (_subtitle_panel);
        _timing_panel = new TimingPanel (this);
+       _panels.push_back (_timing_panel);
 }
+
 /** Called when the name widget has been changed */
 void
 FilmEditor::name_changed (wxCommandEvent &)
@@ -332,10 +337,9 @@ FilmEditor::film_changed (Film::Property p)
 
        stringstream s;
 
-       _video_panel->film_changed (p);
-       _audio_panel->film_changed (p);
-       _subtitle_panel->film_changed (p);
-       _timing_panel->film_changed (p);
+       for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
+               (*i)->film_changed (p);
+       }
                
        switch (p) {
        case Film::NONE:
@@ -415,25 +419,13 @@ FilmEditor::film_content_changed (weak_ptr<Content> weak_content, int property)
        }
 
        shared_ptr<Content> content = weak_content.lock ();
-       if (content != selected_content ()) {
+       if (!content || content != selected_content ()) {
                return;
        }
-       
-       shared_ptr<VideoContent> video_content;
-       shared_ptr<AudioContent> audio_content;
-       shared_ptr<SubtitleContent> subtitle_content;
-       shared_ptr<FFmpegContent> ffmpeg_content;
-       if (content) {
-               video_content = dynamic_pointer_cast<VideoContent> (content);
-               audio_content = dynamic_pointer_cast<AudioContent> (content);
-               subtitle_content = dynamic_pointer_cast<SubtitleContent> (content);
-               ffmpeg_content = dynamic_pointer_cast<FFmpegContent> (content);
-       }
-
-       _video_panel->film_content_changed    (content, property);
-       _audio_panel->film_content_changed    (content, property);
-       _subtitle_panel->film_content_changed (content, property);
-       _timing_panel->film_content_changed   (content, property);
+
+       for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
+               (*i)->film_content_changed (content, property);
+       }
 
        if (property == FFmpegContentProperty::AUDIO_STREAM) {
                setup_dcp_name ();
@@ -458,7 +450,6 @@ FilmEditor::setup_container ()
        }
        
        setup_dcp_name ();
-       _video_panel->setup_scaling_description ();
 }      
 
 /** Called when the container widget has been changed */
@@ -495,7 +486,7 @@ FilmEditor::dcp_content_type_changed (wxCommandEvent &)
 void
 FilmEditor::set_film (shared_ptr<Film> f)
 {
-       set_things_sensitive (f != 0);
+       set_general_sensitivity (f != 0);
 
        if (_film == f) {
                return;
@@ -536,28 +527,33 @@ FilmEditor::set_film (shared_ptr<Film> f)
        content_selection_changed (ev);
 }
 
-/** Updates the sensitivity of lots of widgets to a given value.
- *  @param s true to make sensitive, false to make insensitive.
- */
 void
-FilmEditor::set_things_sensitive (bool s)
+FilmEditor::set_general_sensitivity (bool s)
 {
        _generally_sensitive = s;
-       
+
+       /* Stuff in the Content / DCP tabs */
        _name->Enable (s);
        _use_dci_name->Enable (s);
        _edit_dci_button->Enable (s);
        _content->Enable (s);
+       _content_add->Enable (s);
+       _content_remove->Enable (s);
+       _content_timeline->Enable (s);
        _dcp_content_type->Enable (s);
        _dcp_frame_rate->Enable (s);
        _dcp_audio_channels->Enable (s);
        _j2k_bandwidth->Enable (s);
        _container->Enable (s);
-
-       _subtitle_panel->setup_control_sensitivity ();
-       _audio_panel->setup_sensitivity ();
-       setup_content_sensitivity ();
        _best_dcp_frame_rate->Enable (s && _film && _film->best_dcp_video_frame_rate () != _film->dcp_video_frame_rate ());
+       _sequence_video->Enable (s);
+       _dcp_resolution->Enable (s);
+       _scaler->Enable (s);
+
+       /* Set the panels in the content notebook */
+       for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
+               (*i)->Enable (s);
+       }
 }
 
 /** Called when the scaler widget has been changed */
@@ -600,7 +596,7 @@ FilmEditor::edit_dci_button_clicked (wxCommandEvent &)
 void
 FilmEditor::active_jobs_changed (bool a)
 {
-       set_things_sensitive (!a);
+       set_general_sensitivity (!a);
 }
 
 void
@@ -700,8 +696,9 @@ FilmEditor::content_selection_changed (wxListEvent &)
        setup_content_sensitivity ();
        shared_ptr<Content> s = selected_content ();
 
-       _audio_panel->content_selection_changed ();
-       
+       /* All other sensitivity in content panels should be triggered by
+          one of these.
+       */
        film_content_changed (s, ContentProperty::START);
        film_content_changed (s, ContentProperty::LENGTH);
        film_content_changed (s, VideoContentProperty::VIDEO_CROP);
@@ -718,6 +715,7 @@ FilmEditor::content_selection_changed (wxListEvent &)
        film_content_changed (s, SubtitleContentProperty::SUBTITLE_SCALE);
 }
 
+/** Set up broad sensitivity based on the type of content that is selected */
 void
 FilmEditor::setup_content_sensitivity ()
 {
@@ -811,6 +809,10 @@ FilmEditor::set_selection (weak_ptr<Content> wc)
 void
 FilmEditor::sequence_video_changed (wxCommandEvent &)
 {
+       if (!_film) {
+               return;
+       }
+       
        _film->set_sequence_video (_sequence_video->GetValue ());
 }
 
index 751ed0890790ce72d32a7ed4647d219df00ced3d..66913643eb49fe8d48c6d7c6a1340c3bee0e82d0 100644 (file)
@@ -36,10 +36,7 @@ class Film;
 class TimelineDialog;
 class Ratio;
 class Timecode;
-class TimingPanel;
-class SubtitlePanel;
-class AudioPanel;
-class VideoPanel;
+class FilmEditorPanel;
 
 /** @class FilmEditor
  *  @brief A wx widget to edit a film's metadata, and perform various functions.
@@ -69,10 +66,6 @@ public:
        boost::shared_ptr<AudioContent> selected_audio_content ();
        boost::shared_ptr<SubtitleContent> selected_subtitle_content ();
        
-       bool generally_sensitive () const {
-               return _generally_sensitive;
-       }
-
 private:
        void make_dcp_panel ();
        void make_content_panel ();
@@ -101,7 +94,7 @@ private:
        void film_changed (Film::Property);
        void film_content_changed (boost::weak_ptr<Content>, int);
 
-       void set_things_sensitive (bool);
+       void set_general_sensitivity (bool);
        void setup_dcp_name ();
        void setup_content ();
        void setup_container ();
@@ -109,10 +102,11 @@ private:
        
        void active_jobs_changed (bool);
 
-       VideoPanel* _video_panel;
-       AudioPanel* _audio_panel;
-       SubtitlePanel* _subtitle_panel;
-       TimingPanel* _timing_panel;
+       FilmEditorPanel* _video_panel;
+       FilmEditorPanel* _audio_panel;
+       FilmEditorPanel* _subtitle_panel;
+       FilmEditorPanel* _timing_panel;
+       std::list<FilmEditorPanel *> _panels;
 
        wxNotebook* _main_notebook;
        wxNotebook* _content_notebook;
index 8bfe94f8d688ffedb00f7724955debf161333786..8acb3efb6d8ef651f6f516deeb695a5deba63a4a 100644 (file)
@@ -34,7 +34,6 @@ public:
 
        virtual void film_changed (Film::Property) {}
        virtual void film_content_changed (boost::shared_ptr<Content>, int) = 0;
-       virtual void content_selection_changed () {}
 
 protected:
        FilmEditor* _editor;
index e410120221fb5b887f8314cf840fd173135d6058..2cc5197ce2a8d9e197e5521e17a47a17952d71ba 100644 (file)
@@ -76,11 +76,11 @@ SubtitlePanel::film_changed (Film::Property property)
 {
        switch (property) {
        case Film::CONTENT:
-               setup_control_sensitivity ();
+               setup_sensitivity ();
                break;
        case Film::WITH_SUBTITLES:
                checked_set (_with_subtitles, _editor->film()->with_subtitles ());
-               setup_control_sensitivity ();
+               setup_sensitivity ();
                break;
        default:
                break;
@@ -107,7 +107,7 @@ SubtitlePanel::film_content_changed (shared_ptr<Content> c, int property)
                                _stream->SetSelection (wxNOT_FOUND);
                        }
                }
-               setup_control_sensitivity ();
+               setup_sensitivity ();
        } else if (property == SubtitleContentProperty::SUBTITLE_OFFSET) {
                checked_set (_offset, sc ? (sc->subtitle_offset() * 100) : 0);
        } else if (property == SubtitleContentProperty::SUBTITLE_SCALE) {
@@ -127,20 +127,16 @@ SubtitlePanel::with_subtitles_toggled (wxCommandEvent &)
 }
 
 void
-SubtitlePanel::setup_control_sensitivity ()
+SubtitlePanel::setup_sensitivity ()
 {
        bool h = false;
-       if (_editor->generally_sensitive() && _editor->film()) {
-               h = _editor->film()->has_subtitles ();
-       }
-       
-       _with_subtitles->Enable (h);
-
        bool j = false;
        if (_editor->film()) {
+               h = _editor->film()->has_subtitles ();
                j = _editor->film()->with_subtitles ();
        }
        
+       _with_subtitles->Enable (h);
        _offset->Enable (j);
        _scale->Enable (j);
        _stream->Enable (j);
index ec684d7ad888e37e82ff80169b482a166bcee72b..c2891f86da247a614184e3c07ebda2e40425e28e 100644 (file)
@@ -30,13 +30,14 @@ public:
        void film_changed (Film::Property);
        void film_content_changed (boost::shared_ptr<Content>, int);
 
-       void setup_control_sensitivity ();
        
 private:
        void with_subtitles_toggled (wxCommandEvent &);
        void offset_changed (wxCommandEvent &);
        void scale_changed (wxCommandEvent &);
        void stream_changed (wxCommandEvent &);
+
+       void setup_sensitivity ();
        
        wxCheckBox* _with_subtitles;
        wxSpinCtrl* _offset;
index 09fa8dbe6668319e42b536b08d6cdb8a8ddb72c1..47e32c5e812b03fcee4454d7536f5c2207c36bea 100644 (file)
@@ -150,6 +150,18 @@ VideoPanel::bottom_crop_changed (wxCommandEvent &)
        c->set_bottom_crop (_bottom_crop->GetValue ());
 }
 
+void
+VideoPanel::film_changed (Film::Property property)
+{
+       switch (property) {
+       case Film::CONTAINER:
+               setup_scaling_description ();
+               break;
+       default:
+               break;
+       }
+}
+
 void
 VideoPanel::film_content_changed (shared_ptr<Content> c, int property)
 {
index a373f091e6f4a71e64efcbe4020af736b166cfd1..4cc9cd79ccb62f3c5743dec0174e284528521718 100644 (file)
@@ -17,6 +17,7 @@
 
 */
 
+#include "lib/film.h"
 #include "film_editor_panel.h"
 
 class wxChoice;
@@ -29,10 +30,9 @@ class VideoPanel : public FilmEditorPanel
 public:
        VideoPanel (FilmEditor *);
 
+       void film_changed (Film::Property);
        void film_content_changed (boost::shared_ptr<Content>, int);
 
-       void setup_scaling_description ();
-       
 private:
        void left_crop_changed (wxCommandEvent &);
        void right_crop_changed (wxCommandEvent &);
@@ -41,6 +41,8 @@ private:
        void edit_filters_clicked (wxCommandEvent &);
        void ratio_changed (wxCommandEvent &);
 
+       void setup_scaling_description ();
+       
        wxChoice* _ratio;
        wxStaticText* _ratio_description;
        wxStaticText* _scaling_description;