Fix small DCP standard choice (#2475).
[dcpomatic.git] / src / wx / audio_dialog.cc
index f4b4b2577c67b97f85e702f55f584f030ee54cfc..4cd308ab1cebf852b93d782064f69a5e11d42f02 100644 (file)
@@ -18,6 +18,7 @@
 
 */
 
+
 #include "audio_dialog.h"
 #include "audio_plot.h"
 #include "check_box.h"
 #include "lib/audio_content.h"
 #include "lib/film.h"
 #include "lib/job_manager.h"
+#include "lib/maths_util.h"
 #include <libxml++/libxml++.h>
 #include <boost/filesystem.hpp>
 #include <iostream>
 
+
 using std::cout;
 using std::list;
 using std::make_shared;
@@ -48,11 +51,12 @@ using namespace dcpomatic;
 using namespace boost::placeholders;
 #endif
 
+
 /** @param parent Parent window.
  *  @param film Film we are using.
  *  @param content Content to analyse, or 0 to analyse all of the film's audio.
  */
-AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film, weak_ptr<FilmViewer> viewer, shared_ptr<Content> content)
+AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film, FilmViewer& viewer, shared_ptr<Content> content)
        : wxDialog (
                parent,
                wxID_ANY,
@@ -69,7 +73,6 @@ AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film, weak_ptr<Film
 #endif
                )
        , _film (film)
-       , _viewer (viewer)
        , _content (content)
        , _channels (film->audio_channels ())
        , _plot (nullptr)
@@ -111,7 +114,7 @@ AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film, weak_ptr<Film
                _channel_checkbox[i] = new CheckBox (this, std_to_wx(audio_channel_name(i)));
                _channel_checkbox[i]->SetForegroundColour(wxColour(_plot->colour(i)));
                right->Add (_channel_checkbox[i], 0, wxEXPAND | wxALL, 3);
-               _channel_checkbox[i]->Bind (wxEVT_CHECKBOX, boost::bind (&AudioDialog::channel_clicked, this, _1));
+               _channel_checkbox[i]->bind(&AudioDialog::channel_clicked, this, _1);
        }
 
        show_or_hide_channel_checkboxes ();
@@ -130,7 +133,7 @@ AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film, weak_ptr<Film
        for (int i = 0; i < AudioPoint::COUNT; ++i) {
                _type_checkbox[i] = new CheckBox (this, types[i]);
                right->Add (_type_checkbox[i], 0, wxEXPAND | wxALL, 3);
-               _type_checkbox[i]->Bind (wxEVT_CHECKBOX, boost::bind (&AudioDialog::type_clicked, this, _1));
+               _type_checkbox[i]->bind(&AudioDialog::type_clicked, this, _1);
        }
 
        {
@@ -161,7 +164,11 @@ AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film, weak_ptr<Film
        _film_connection = film->Change.connect (boost::bind(&AudioDialog::film_change, this, _1, _2));
        _film_content_connection = film->ContentChange.connect(boost::bind(&AudioDialog::content_change, this, _1, _3));
        DCPOMATIC_ASSERT (film->directory());
-       SetTitle(wxString::Format(_("DCP-o-matic audio - %s"), std_to_wx(film->directory().get().string())));
+       if (content) {
+               SetTitle(wxString::Format(_("DCP-o-matic audio - %s"), std_to_wx(content->path(0).string())));
+       } else {
+               SetTitle(wxString::Format(_("DCP-o-matic audio - %s"), std_to_wx(film->directory().get().string())));
+       }
 
        if (content) {
                _playlist = make_shared<Playlist>();
@@ -392,10 +399,13 @@ AudioDialog::setup_statistics ()
                        )
                );
 
+       wxColour const peaking = *wxRED;
+       wxColour const not_peaking = gui_is_dark() ? *wxWHITE : *wxBLACK;
+
        if (peak_dB > -3) {
-               _sample_peak->SetForegroundColour (wxColour (255, 0, 0));
+               _sample_peak->SetForegroundColour(peaking);
        } else {
-               _sample_peak->SetForegroundColour (wxColour (0, 0, 0));
+               _sample_peak->SetForegroundColour(not_peaking);
        }
 
        if (_analysis->overall_true_peak()) {
@@ -405,9 +415,9 @@ AudioDialog::setup_statistics ()
                _true_peak->SetLabel (wxString::Format (_("True peak is %.2fdB"), peak_dB));
 
                if (peak_dB > -3) {
-                       _true_peak->SetForegroundColour (wxColour (255, 0, 0));
+                       _true_peak->SetForegroundColour(peaking);
                } else {
-                       _true_peak->SetForegroundColour (wxColour (0, 0, 0));
+                       _true_peak->SetForegroundColour(not_peaking);
                }
        }