diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-07-27 16:14:41 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-07-27 16:14:41 +0100 |
| commit | ae4f0d9f55489ddc50b3e5f0d713621ee8f50645 (patch) | |
| tree | 05adaa258ecce8029f754a58c847ac3904239400 /src/wx | |
| parent | 3009a585f5222a83213c786e3c564c740f450d18 (diff) | |
| parent | 3006dde72c92356165ef841910368d0dae27ddbe (diff) | |
Merge branch 'master' of ssh://git.carlh.net/home/carl/git/dcpomatic
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/closed_captions_dialog.cc | 19 | ||||
| -rw-r--r-- | src/wx/closed_captions_dialog.h | 2 | ||||
| -rw-r--r-- | src/wx/hints_dialog.cc | 60 | ||||
| -rw-r--r-- | src/wx/hints_dialog.h | 12 |
4 files changed, 75 insertions, 18 deletions
diff --git a/src/wx/closed_captions_dialog.cc b/src/wx/closed_captions_dialog.cc index 1e13f867a..ea7db88f0 100644 --- a/src/wx/closed_captions_dialog.cc +++ b/src/wx/closed_captions_dialog.cc @@ -29,9 +29,6 @@ using std::make_pair; using boost::shared_ptr; using boost::weak_ptr; -int const ClosedCaptionsDialog::_num_lines = 3; -int const ClosedCaptionsDialog::_num_chars_per_line = 30; - ClosedCaptionsDialog::ClosedCaptionsDialog (wxWindow* parent) : wxDialog (parent, wxID_ANY, _("Closed captions"), wxDefaultPosition, wxDefaultSize, #ifdef DCPOMATIC_OSX @@ -45,7 +42,7 @@ ClosedCaptionsDialog::ClosedCaptionsDialog (wxWindow* parent) ) { - _lines.resize (_num_lines); + _lines.resize (CLOSED_CAPTION_LINES); Bind (wxEVT_PAINT, boost::bind (&ClosedCaptionsDialog::paint, this)); } @@ -58,16 +55,16 @@ ClosedCaptionsDialog::paint () dc.SetTextForeground (*wxWHITE); /* Choose a font which fits vertically */ - int const line_height = max (8, dc.GetSize().GetHeight() / _num_lines); + int const line_height = max (8, dc.GetSize().GetHeight() / CLOSED_CAPTION_LINES); wxFont font (*wxNORMAL_FONT); font.SetPixelSize (wxSize (0, line_height * 0.8)); dc.SetFont (font); - for (int i = 0; i < _num_lines; ++i) { - wxString const good = _lines[i].Left (_num_chars_per_line); + for (int i = 0; i < CLOSED_CAPTION_LINES; ++i) { + wxString const good = _lines[i].Left (CLOSED_CAPTION_LENGTH); dc.DrawText (good, 8, line_height * i); - if (_lines[i].Length() > _num_chars_per_line) { - wxString const bad = _lines[i].Right (_lines[i].Length() - _num_chars_per_line); + if (_lines[i].Length() > CLOSED_CAPTION_LENGTH) { + wxString const bad = _lines[i].Right (_lines[i].Length() - CLOSED_CAPTION_LENGTH); wxSize size = dc.GetTextExtent (good); dc.SetTextForeground (*wxRED); dc.DrawText (bad, 8 + size.GetWidth(), line_height * i); @@ -112,7 +109,7 @@ ClosedCaptionsDialog::update (DCPTime time) } } - for (int j = 0; j < _num_lines; ++j) { + for (int j = 0; j < CLOSED_CAPTION_LINES; ++j) { _lines[j] = ""; } @@ -120,7 +117,7 @@ ClosedCaptionsDialog::update (DCPTime time) list<StringText>::const_iterator j = to_show.begin(); int k = 0; - while (j != to_show.end() && k < _num_lines) { + while (j != to_show.end() && k < CLOSED_CAPTION_LINES) { _lines[k] = j->text(); ++j; ++k; diff --git a/src/wx/closed_captions_dialog.h b/src/wx/closed_captions_dialog.h index a599bc703..be5b3664d 100644 --- a/src/wx/closed_captions_dialog.h +++ b/src/wx/closed_captions_dialog.h @@ -38,6 +38,4 @@ private: std::vector<wxString> _lines; boost::weak_ptr<Player> _player; - static int const _num_lines; - static int const _num_chars_per_line; }; diff --git a/src/wx/hints_dialog.cc b/src/wx/hints_dialog.cc index 86a160213..1938e7cc4 100644 --- a/src/wx/hints_dialog.cc +++ b/src/wx/hints_dialog.cc @@ -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. @@ -29,15 +29,24 @@ using std::max; using std::vector; using std::string; +using std::cout; using boost::shared_ptr; using boost::optional; +using boost::bind; using boost::dynamic_pointer_cast; HintsDialog::HintsDialog (wxWindow* parent, boost::weak_ptr<Film> film, bool ok) : wxDialog (parent, wxID_ANY, _("Hints")) , _film (film) + , _hints (new Hints (film)) { wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL); + + _gauge = new wxGauge (this, wxID_ANY, 100); + sizer->Add (_gauge, 0, wxALL | wxEXPAND, DCPOMATIC_SIZER_GAP); + _gauge_message = new wxStaticText (this, wxID_ANY, wxT("")); + sizer->Add (_gauge_message, 0, wxALL | wxEXPAND, DCPOMATIC_SIZER_GAP); + _text = new wxRichTextCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (400, 300), wxRE_READONLY); sizer->Add (_text, 1, wxEXPAND | wxALL, 6); @@ -70,6 +79,11 @@ HintsDialog::HintsDialog (wxWindow* parent, boost::weak_ptr<Film> film, bool ok) _film_content_changed_connection = locked_film->ContentChanged.connect (boost::bind (&HintsDialog::film_changed, this)); } + _hints->Hint.connect (bind (&HintsDialog::hint, this, _1)); + _hints->Progress.connect (bind (&HintsDialog::progress, this, _1)); + _hints->Pulse.connect (bind (&HintsDialog::pulse, this)); + _hints->Finished.connect (bind (&HintsDialog::finished, this)); + film_changed (); } @@ -77,19 +91,30 @@ void HintsDialog::film_changed () { _text->Clear (); + _current.clear (); boost::shared_ptr<Film> film = _film.lock (); if (!film) { return; } - vector<string> hints = get_hints (film); + _gauge->Show (); + _gauge_message->Show (); + Layout (); + _gauge->SetValue (0); + update (); + _hints->start (); +} - if (hints.empty ()) { +void +HintsDialog::update () +{ + _text->Clear (); + if (_current.empty ()) { _text->WriteText (_("There are no hints: everything looks good!")); } else { _text->BeginStandardBullet (N_("standard/circle"), 1, 50); - BOOST_FOREACH (string i, hints) { + BOOST_FOREACH (string i, _current) { _text->WriteText (std_to_wx (i)); _text->Newline (); } @@ -98,7 +123,34 @@ HintsDialog::film_changed () } void +HintsDialog::hint (string text) +{ + _current.push_back (text); + update (); +} + +void HintsDialog::shut_up (wxCommandEvent& ev) { Config::instance()->set_show_hints_before_make_dcp (!ev.IsChecked()); } + +void +HintsDialog::pulse () +{ + _gauge->Pulse (); +} + +void +HintsDialog::finished () +{ + _gauge->Hide (); + _gauge_message->Hide (); + Layout (); +} + +void +HintsDialog::progress (string m) +{ + _gauge_message->SetLabel (std_to_wx(m)); +} diff --git a/src/wx/hints_dialog.h b/src/wx/hints_dialog.h index c02cc8c85..06f979a74 100644 --- a/src/wx/hints_dialog.h +++ b/src/wx/hints_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -24,6 +24,7 @@ class wxRichTextCtrl; class Film; +class Hints; class HintsDialog : public wxDialog { @@ -33,9 +34,18 @@ public: private: void film_changed (); void shut_up (wxCommandEvent& ev); + void update (); + void hint (std::string text); + void pulse (); + void finished (); + void progress (std::string m); boost::weak_ptr<Film> _film; + wxGauge* _gauge; + wxStaticText* _gauge_message; wxRichTextCtrl* _text; + boost::shared_ptr<Hints> _hints; + std::list<std::string> _current; boost::signals2::scoped_connection _film_changed_connection; boost::signals2::scoped_connection _film_content_changed_connection; |
