diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-07-22 00:41:03 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-07-22 00:41:03 +0100 |
| commit | dea824f6ff41384a5e17e23de5434cf84eccff29 (patch) | |
| tree | a40207882d506417cb5f456135b9ba4394535d00 /src/wx | |
| parent | 9cbe57dda759fccfa9dec8a0820114d7d8583a36 (diff) | |
Display only required tabs, including subs / ccap.
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/caption_panel.cc | 31 | ||||
| -rw-r--r-- | src/wx/caption_panel.h | 2 | ||||
| -rw-r--r-- | src/wx/content_panel.cc | 115 | ||||
| -rw-r--r-- | src/wx/content_panel.h | 6 | ||||
| -rw-r--r-- | src/wx/content_sub_panel.cc | 3 | ||||
| -rw-r--r-- | src/wx/content_sub_panel.h | 5 |
6 files changed, 140 insertions, 22 deletions
diff --git a/src/wx/caption_panel.cc b/src/wx/caption_panel.cc index 5a3ac39ed..3957c2a45 100644 --- a/src/wx/caption_panel.cc +++ b/src/wx/caption_panel.cc @@ -43,11 +43,11 @@ using std::list; using boost::shared_ptr; using boost::dynamic_pointer_cast; -CaptionPanel::CaptionPanel (ContentPanel* p) - : ContentSubPanel (p, _("Captions")) +CaptionPanel::CaptionPanel (ContentPanel* p, CaptionType t) + : ContentSubPanel (p, std_to_wx(caption_type_to_name(t))) , _caption_view (0) , _fonts_dialog (0) - , _original_type (CAPTION_OPEN) + , _original_type (t) { wxBoxSizer* reference_sizer = new wxBoxSizer (wxVERTICAL); @@ -202,6 +202,11 @@ CaptionPanel::film_content_changed (int property) scs = sc.front (); } + shared_ptr<CaptionContent> caption; + if (scs) { + caption = scs->caption_of_original_type(_original_type); + } + if (property == FFmpegContentProperty::SUBTITLE_STREAMS) { _stream->Clear (); if (fcs) { @@ -218,11 +223,11 @@ CaptionPanel::film_content_changed (int property) } setup_sensitivity (); } else if (property == CaptionContentProperty::USE) { - checked_set (_use, scs ? scs->caption_of_original_type(_original_type)->use() : false); + checked_set (_use, caption ? caption->use() : false); setup_sensitivity (); } else if (property == CaptionContentProperty::TYPE) { - if (scs) { - switch (scs->caption_of_original_type(_original_type)->type()) { + if (caption) { + switch (caption->type()) { case CAPTION_OPEN: _type->SetSelection (0); break; @@ -237,19 +242,19 @@ CaptionPanel::film_content_changed (int property) } setup_sensitivity (); } else if (property == CaptionContentProperty::BURN) { - checked_set (_burn, scs ? scs->caption_of_original_type(_original_type)->burn() : false); + checked_set (_burn, caption ? caption->burn() : false); } else if (property == CaptionContentProperty::X_OFFSET) { - checked_set (_x_offset, scs ? lrint (scs->caption_of_original_type(_original_type)->x_offset() * 100) : 0); + checked_set (_x_offset, caption ? lrint (caption->x_offset() * 100) : 0); } else if (property == CaptionContentProperty::Y_OFFSET) { - checked_set (_y_offset, scs ? lrint (scs->caption_of_original_type(_original_type)->y_offset() * 100) : 0); + checked_set (_y_offset, caption ? lrint (caption->y_offset() * 100) : 0); } else if (property == CaptionContentProperty::X_SCALE) { - checked_set (_x_scale, scs ? lrint (scs->caption_of_original_type(_original_type)->x_scale() * 100) : 100); + checked_set (_x_scale, caption ? lrint (caption->x_scale() * 100) : 100); } else if (property == CaptionContentProperty::Y_SCALE) { - checked_set (_y_scale, scs ? lrint (scs->caption_of_original_type(_original_type)->y_scale() * 100) : 100); + checked_set (_y_scale, caption ? lrint (caption->y_scale() * 100) : 100); } else if (property == CaptionContentProperty::LINE_SPACING) { - checked_set (_line_spacing, scs ? lrint (scs->caption_of_original_type(_original_type)->line_spacing() * 100) : 100); + checked_set (_line_spacing, caption ? lrint (caption->line_spacing() * 100) : 100); } else if (property == CaptionContentProperty::LANGUAGE) { - checked_set (_language, scs ? scs->caption_of_original_type(_original_type)->language() : ""); + checked_set (_language, caption ? caption->language() : ""); } else if (property == DCPContentProperty::REFERENCE_CAPTION) { if (scs) { shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (scs); diff --git a/src/wx/caption_panel.h b/src/wx/caption_panel.h index 8adb85e15..20af29d7e 100644 --- a/src/wx/caption_panel.h +++ b/src/wx/caption_panel.h @@ -28,7 +28,7 @@ class FontsDialog; class CaptionPanel : public ContentSubPanel { public: - explicit CaptionPanel (ContentPanel *); + CaptionPanel (ContentPanel *, CaptionType t); void film_changed (Film::Property); void film_content_changed (int); diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 40501f717..ce9c66a3e 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -52,6 +52,7 @@ using std::list; using std::string; using std::cout; using std::vector; +using std::max; using std::exception; using boost::shared_ptr; using boost::weak_ptr; @@ -63,6 +64,7 @@ using boost::optional; ContentPanel::ContentPanel (wxNotebook* n, boost::shared_ptr<Film> film, FilmViewer* viewer) : _timeline_dialog (0) , _parent (n) + , _last_selected_tab (0) , _film (film) , _film_viewer (viewer) , _generally_sensitive (true) @@ -125,8 +127,10 @@ ContentPanel::ContentPanel (wxNotebook* n, boost::shared_ptr<Film> film, FilmVie _panels.push_back (_video_panel); _audio_panel = new AudioPanel (this); _panels.push_back (_audio_panel); - _caption_panel = new CaptionPanel (this); - _panels.push_back (_caption_panel); + for (int i = 0; i < CAPTION_COUNT; ++i) { + _caption_panel[i] = new CaptionPanel (this, static_cast<CaptionType>(i)); + _panels.push_back (_caption_panel[i]); + } _timing_panel = new TimingPanel (this, _film_viewer); _panels.push_back (_timing_panel); @@ -255,7 +259,7 @@ ContentPanel::selection_changed () } optional<DCPTime> go_to; - BOOST_FOREACH (shared_ptr<Content> i, selected ()) { + BOOST_FOREACH (shared_ptr<Content> i, selected()) { DCPTime p; p = i->position(); if (dynamic_pointer_cast<TextCaptionFileContent>(i) && i->paths_valid()) { @@ -277,7 +281,106 @@ ContentPanel::selection_changed () } if (_timeline_dialog) { - _timeline_dialog->set_selection (selected ()); + _timeline_dialog->set_selection (selected()); + } + + /* Make required tabs visible */ + + if (_notebook->GetPageCount() > 1) { + /* There's more than one tab in the notebook so the current selection could be meaningful + to the user; store it so that we can try to restore it later. + */ + _last_selected_tab = 0; + if (_notebook->GetSelection() != wxNOT_FOUND) { + _last_selected_tab = _notebook->GetPage(_notebook->GetSelection()); + } + } + + bool have_video = false; + bool have_audio = false; + bool have_caption[CAPTION_COUNT] = { false, false }; + BOOST_FOREACH (shared_ptr<Content> i, selected()) { + if (i->video) { + have_video = true; + } + if (i->audio) { + have_audio = true; + } + BOOST_FOREACH (shared_ptr<CaptionContent> j, i->caption) { + have_caption[j->original_type()] = true; + } + } + + bool video_panel = false; + bool audio_panel = false; + bool caption_panel[CAPTION_COUNT] = { false, false }; + for (size_t i = 0; i < _notebook->GetPageCount(); ++i) { + if (_notebook->GetPage(i) == _video_panel) { + video_panel = true; + } else if (_notebook->GetPage(i) == _audio_panel) { + audio_panel = true; + } + for (int j = 0; j < CAPTION_COUNT; ++j) { + if (_notebook->GetPage(i) == _caption_panel[j]) { + caption_panel[j] = true; + } + } + } + + int off = 0; + + if (have_video != video_panel) { + if (video_panel) { + _notebook->RemovePage (off); + } + if (have_video) { + _notebook->InsertPage (off, _video_panel, _video_panel->name()); + } + } + + if (have_video) { + ++off; + } + + if (have_audio != audio_panel) { + if (audio_panel) { + _notebook->RemovePage (off); + } + if (have_audio) { + _notebook->InsertPage (off, _audio_panel, _audio_panel->name()); + } + } + + if (have_audio) { + ++off; + } + + for (int i = 0; i < CAPTION_COUNT; ++i) { + if (have_caption[i] != caption_panel[i]) { + if (caption_panel[i]) { + _notebook->RemovePage (off); + } + if (have_caption[i]) { + _notebook->InsertPage (off, _caption_panel[i], _caption_panel[i]->name()); + } + } + if (have_caption[i]) { + ++off; + } + } + + /* Set up the tab selection */ + + bool done = false; + for (size_t i = 0; i < _notebook->GetPageCount(); ++i) { + if (_notebook->GetPage(i) == _last_selected_tab) { + _notebook->SetSelection (i); + done = true; + } + } + + if (!done) { + _notebook->SetSelection (0); } SelectionChanged (); @@ -447,7 +550,9 @@ ContentPanel::setup_sensitivity () _video_panel->Enable (_generally_sensitive && video_selection.size() > 0); _audio_panel->Enable (_generally_sensitive && audio_selection.size() > 0); - _caption_panel->Enable (_generally_sensitive && selection.size() == 1 && !selection.front()->caption.empty()); + for (int i = 0; i < CAPTION_COUNT; ++i) { + _caption_panel[i]->Enable (_generally_sensitive && selection.size() == 1 && !selection.front()->caption.empty()); + } _timing_panel->Enable (_generally_sensitive); } diff --git a/src/wx/content_panel.h b/src/wx/content_panel.h index e7d9c95b3..3f0fb17a5 100644 --- a/src/wx/content_panel.h +++ b/src/wx/content_panel.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -32,6 +32,7 @@ class wxListEvent; class TimelineDialog; class FilmEditor; class ContentSubPanel; +class CaptionPanel; class AudioPanel; class Film; class FilmViewer; @@ -104,13 +105,14 @@ private: wxButton* _timeline; ContentSubPanel* _video_panel; AudioPanel* _audio_panel; - ContentSubPanel* _caption_panel; + CaptionPanel* _caption_panel[CAPTION_COUNT]; ContentSubPanel* _timing_panel; std::list<ContentSubPanel *> _panels; ContentMenu* _menu; TimelineDialog* _timeline_dialog; wxNotebook* _parent; ContentList _last_selected; + wxWindow* _last_selected_tab; boost::shared_ptr<Film> _film; FilmViewer* _film_viewer; diff --git a/src/wx/content_sub_panel.cc b/src/wx/content_sub_panel.cc index 93296d5b9..a60a65707 100644 --- a/src/wx/content_sub_panel.cc +++ b/src/wx/content_sub_panel.cc @@ -35,8 +35,9 @@ ContentSubPanel::ContentSubPanel (ContentPanel* p, wxString name) : wxScrolledWindow (p->notebook(), wxID_ANY) , _parent (p) , _sizer (new wxBoxSizer (wxVERTICAL)) + , _name (name) { - p->notebook()->AddPage (this, name, false); + p->notebook()->AddPage (this, _name, false); SetScrollRate (-1, 8); SetSizer (_sizer); } diff --git a/src/wx/content_sub_panel.h b/src/wx/content_sub_panel.h index 9afd50d40..8c7854af2 100644 --- a/src/wx/content_sub_panel.h +++ b/src/wx/content_sub_panel.h @@ -40,12 +40,17 @@ public: /** Called when the list of selected Contents changes */ virtual void content_selection_changed () = 0; + wxString name () const { + return _name; + } + protected: void setup_refer_button (wxCheckBox* button, wxStaticText* note, boost::shared_ptr<DCPContent> dcp, bool can_reference, std::string why_not) const; ContentPanel* _parent; wxSizer* _sizer; + wxString _name; }; #endif |
