From d9c2cf78e6c5e465e7f76020f78f7ed1e71c3bc0 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 10 Jan 2019 20:36:10 +0000 Subject: [PATCH] Add File->Close to main DCP-o-matic (#1180). --- ChangeLog | 4 ++++ src/tools/dcpomatic.cc | 20 ++++++++++++++++---- src/wx/content_panel.cc | 6 ++++++ src/wx/controls.cc | 5 ++++- src/wx/dcp_panel.cc | 9 +++++++++ src/wx/film_editor.cc | 13 ++++++++----- 6 files changed, 47 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7aa6e0f33..d13331d6c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2019-01-10 Carl Hetherington + + * Add File->Close to main DCP-o-matic (bound to Cmd-W on Mac) (#1180). + 2019-01-09 Carl Hetherington * Hopefully improve layout on high-resolution (>2K) displays (#1303). diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index b337ff102..a70d243d9 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -211,7 +211,8 @@ enum { ID_file_duplicate_and_open, ID_file_history, /* Allow spare IDs after _history for the recent files list */ - ID_edit_copy = 100, + ID_file_close = 100, + ID_edit_copy, ID_edit_paste, ID_content_scale_to_fit_width, ID_content_scale_to_fit_height, @@ -295,6 +296,7 @@ public: Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_save_as_template, this), ID_file_save_as_template); Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_duplicate, this), ID_file_duplicate); Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_duplicate_and_open, this), ID_file_duplicate_and_open); + Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_close, this), ID_file_close); Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_history, this, _1), ID_file_history, ID_file_history + HISTORY_SIZE); Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_exit, this), wxID_EXIT); Bind (wxEVT_MENU, boost::bind (&DOMFrame::edit_copy, this), ID_edit_copy); @@ -374,7 +376,7 @@ public: accel[4].Set (wxACCEL_NORMAL, WXK_LEFT, ID_back_frame); accel[5].Set (wxACCEL_NORMAL, WXK_RIGHT, ID_forward_frame); #ifdef __WXOSX__ - accel[6].Set (wxACCEL_CTRL, static_cast('W'), wxID_EXIT); + accel[6].Set (wxACCEL_CTRL, static_cast('W'), ID_file_close); #endif Bind (wxEVT_MENU, boost::bind (&ContentPanel::add_file_clicked, _film_editor->content_panel()), ID_add_file); Bind (wxEVT_MENU, boost::bind (&DOMFrame::remove_clicked, this, _1), ID_remove); @@ -450,10 +452,12 @@ public: _video_waveform_dialog = 0; } set_menu_sensitivity (); - if (_film->directory()) { + if (_film && _film->directory()) { Config::instance()->add_to_history (_film->directory().get()); } - _film->Change.connect (boost::bind (&DOMFrame::film_change, this, _1)); + if (_film) { + _film->Change.connect (boost::bind (&DOMFrame::film_change, this, _1)); + } } shared_ptr film () const { @@ -584,6 +588,11 @@ private: d->Destroy (); } + void file_close () + { + set_film (shared_ptr()); + } + void file_history (wxCommandEvent& event) { vector history = Config::instance()->history (); @@ -1180,6 +1189,9 @@ private: _history_position = _file_menu->GetMenuItems().GetCount(); + _file_menu->AppendSeparator (); + add_item (_file_menu, _("&Close"), ID_file_close, NEEDS_FILM); + #ifndef __WXOSX__ _file_menu->AppendSeparator (); #endif diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 4587b8cc3..318a344f2 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -667,6 +667,12 @@ ContentPanel::film_content_changed (int property) void ContentPanel::setup () { + if (!_film) { + _content->DeleteAllItems (); + setup_sensitivity (); + return; + } + ContentList content = _film->content (); Content* selected_content = 0; diff --git a/src/wx/controls.cc b/src/wx/controls.cc index ef93b8597..5e68baaa0 100644 --- a/src/wx/controls.cc +++ b/src/wx/controls.cc @@ -371,7 +371,10 @@ Controls::set_film (shared_ptr film) } _film = film; - _film_change_connection = _film->Change.connect (boost::bind(&Controls::film_change, this, _1, _2)); + + if (_film) { + _film_change_connection = _film->Change.connect (boost::bind(&Controls::film_change, this, _1, _2)); + } setup_sensitivity (); diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index a01db9be3..5ebd0989d 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -565,6 +565,13 @@ DCPPanel::set_film (shared_ptr film) _film = film; + if (!_film) { + /* Really should all the film_changed below but this might be enough */ + checked_set (_dcp_name, wxT("")); + set_general_sensitivity (false); + return; + } + film_changed (Film::NAME); film_changed (Film::USE_ISDCF_NAME); film_changed (Film::CONTENT); @@ -628,6 +635,8 @@ DCPPanel::setup_sensitivity () _resolution->Enable (_generally_sensitive && _film && !_film->references_dcp_video()); _three_d->Enable (_generally_sensitive && _film && !_film->references_dcp_video()); _standard->Enable (_generally_sensitive && _film && !_film->references_dcp_video() && !_film->references_dcp_audio()); + _reencode_j2k->Enable (_generally_sensitive && _film); + _show_audio->Enable (_generally_sensitive && _film); } void diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 59b44cd8c..a017175f5 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -125,18 +125,21 @@ FilmEditor::set_film (shared_ptr film) _content_panel->set_film (_film); _dcp_panel->set_film (_film); - if (_film) { - _film->Change.connect (bind (&FilmEditor::film_change, this, _1, _2)); - _film->ContentChange.connect (bind (&FilmEditor::film_content_change, this, _1, _3)); + if (!_film) { + FileChanged (""); + return; } - if (_film && _film->directory()) { + _film->Change.connect (bind (&FilmEditor::film_change, this, _1, _2)); + _film->ContentChange.connect (bind (&FilmEditor::film_content_change, this, _1, _3)); + + if (_film->directory()) { FileChanged (_film->directory().get()); } else { FileChanged (""); } - if (!_film->content().empty ()) { + if (!_film->content().empty()) { _content_panel->set_selection (_film->content().front ()); } } -- 2.30.2