Content button sensitivity.
authorCarl Hetherington <cth@carlh.net>
Sun, 31 Mar 2013 15:16:20 +0000 (16:16 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 31 Mar 2013 15:16:20 +0000 (16:16 +0100)
src/wx/film_editor.cc
src/wx/film_editor.h

index f9a91f8fac9d18d5a77bccd1e9d8743e3bf28af9..100d3a93d75630b8be7084c1314ebaa319d7cacf 100644 (file)
@@ -203,6 +203,7 @@ FilmEditor::connect_to_widgets ()
        _edit_dci_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::edit_dci_button_clicked), 0, this);
        _format->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::format_changed), 0, this);
        _trust_content_header->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::trust_content_header_changed), 0, this);
+       _content->Connect (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler (FilmEditor::content_item_selected), 0, this);
        _content_add->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::content_add_clicked), 0, this);
        _content_remove->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::content_add_clicked), 0, this);
        _content_earlier->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::content_add_clicked), 0, this);
@@ -842,10 +843,6 @@ FilmEditor::set_things_sensitive (bool s)
        _content->Enable (s);
        _trust_content_header->Enable (s);
        _content->Enable (s);
-       _content_add->Enable (s);
-       _content_remove->Enable (s);
-       _content_earlier->Enable (s);
-       _content_later->Enable (s);
        _left_crop->Enable (s);
        _right_crop->Enable (s);
        _top_crop->Enable (s);
@@ -867,6 +864,7 @@ FilmEditor::set_things_sensitive (bool s)
 
        setup_subtitle_control_sensitivity ();
        setup_show_audio_sensitivity ();
+       setup_content_button_sensitivity ();
 }
 
 /** Called when the `Edit filters' button has been clicked */
@@ -1202,3 +1200,20 @@ FilmEditor::content_later_clicked (wxCommandEvent &)
 {
 
 }
+
+void
+FilmEditor::content_item_selected (wxListEvent &)
+{
+        setup_content_button_sensitivity ();
+}
+
+void
+FilmEditor::setup_content_button_sensitivity ()
+{
+        _content_add->Enable (_generally_sensitive);
+
+       bool const have_selection = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED) != -1;
+        _content_remove->Enable (have_selection && _generally_sensitive);
+        _content_earlier->Enable (have_selection && _generally_sensitive);
+        _content_later->Enable (have_selection && _generally_sensitive);
+}
index 52854b894436a1cc1ed876f45ced463f09c9a3bb..4048cd587b78c8123757dbc49f1a796c26419089 100644 (file)
@@ -30,6 +30,7 @@
 
 class wxNotebook;
 class wxListCtrl;
+class wxListEvent;
 class Film;
 class AudioDialog;
 
@@ -62,6 +63,7 @@ private:
        void top_crop_changed (wxCommandEvent &);
        void bottom_crop_changed (wxCommandEvent &);
        void trust_content_header_changed (wxCommandEvent &);
+       void content_item_selected (wxListEvent &);
        void content_add_clicked (wxCommandEvent &);
        void content_remove_clicked (wxCommandEvent &);
        void content_earlier_clicked (wxCommandEvent &);
@@ -100,6 +102,7 @@ private:
        void setup_dcp_name ();
        void setup_show_audio_sensitivity ();
        void setup_content ();
+       void setup_content_button_sensitivity ();
        
        void active_jobs_changed (bool);