Fix colouring of audio plot in dark mode.
authorCarl Hetherington <cth@carlh.net>
Sun, 16 Oct 2022 20:22:22 +0000 (22:22 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 18 Oct 2022 18:37:00 +0000 (20:37 +0200)
src/wx/audio_dialog.cc
src/wx/audio_plot.cc

index a4f1dd514884621b4431b388fb2a628cae38a7fc..e433f45fdbc7742c55f5262020db9305c90103ec 100644 (file)
@@ -399,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()) {
@@ -412,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);
                }
        }
 
index 59df0425b69824a6dc104d833da643c7a65a35f2..cac939ac0a19de4bdf6018e81f90187f41cf6c51 100644 (file)
@@ -72,7 +72,11 @@ AudioPlot::AudioPlot(wxWindow* parent, FilmViewer& viewer)
                _type_visible[i] = false;
        }
 
-       _colours.push_back (wxColour (  0,   0,   0));
+       if (gui_is_dark()) {
+               _colours.push_back(wxColour(255, 255, 255));
+       } else {
+               _colours.push_back(wxColour(0, 0, 0));
+       }
        _colours.push_back (wxColour (255,   0,   0));
        _colours.push_back (wxColour (  0, 255,   0));
        _colours.push_back (wxColour (139,   0, 204));
@@ -165,14 +169,14 @@ AudioPlot::paint ()
        gc->SetAntialiasMode (wxANTIALIAS_DEFAULT);
 
        if (!_analysis || _analysis->channels() == 0) {
-               gc->SetFont (gc->CreateFont (*wxNORMAL_FONT));
+               gc->SetFont(gc->CreateFont(*wxNORMAL_FONT, gui_is_dark() ? *wxWHITE : *wxBLACK));
                gc->DrawText (_message, 32, 32);
                delete gc;
                return;
        }
 
        auto h_grid = gc->CreatePath ();
-       gc->SetFont (gc->CreateFont (*wxSMALL_FONT));
+       gc->SetFont(gc->CreateFont(*wxSMALL_FONT, gui_is_dark() ? *wxWHITE : *wxBLACK));
        wxDouble db_label_height;
        wxDouble db_label_descent;
        wxDouble db_label_leading;
@@ -195,7 +199,9 @@ AudioPlot::paint ()
                gc->DrawText (std_to_wx (String::compose ("%1dB", i)), 0, y - (db_label_height / 2));
        }
 
-       gc->SetPen (wxPen (wxColour (200, 200, 200)));
+       wxColour const grid_colour = gui_is_dark() ? wxColour(80, 80, 80) : wxColour(200, 200, 200);
+
+       gc->SetPen(wxPen(grid_colour));
        gc->StrokePath (h_grid);
 
        /* Draw an x axis with marks */
@@ -205,8 +211,6 @@ AudioPlot::paint ()
        DCPOMATIC_ASSERT (_analysis->samples_per_point() != 0.0);
        double const pps = _analysis->sample_rate() * metrics.x_scale / _analysis->samples_per_point();
 
-       gc->SetPen (*wxThePenList->FindOrCreatePen (wxColour (0, 0, 0), 1, wxPENSTYLE_SOLID));
-
        double const mark_interval = calculate_mark_interval (rint (128 / pps));
 
        auto t = DCPTime::from_seconds (mark_interval);
@@ -234,7 +238,7 @@ AudioPlot::paint ()
                t += DCPTime::from_seconds (mark_interval);
        }
 
-       gc->SetPen (wxPen (wxColour (200, 200, 200)));
+       gc->SetPen(wxPen(grid_colour));
        gc->StrokePath (v_grid);
 
        if (_type_visible[AudioPoint::PEAK]) {
@@ -265,7 +269,7 @@ AudioPlot::paint ()
        axes.MoveToPoint (metrics.db_label_width, 0);
        axes.AddLineToPoint (metrics.db_label_width, metrics.height - metrics.y_origin);
        axes.AddLineToPoint (metrics.db_label_width + data_width, metrics.height - metrics.y_origin);
-       gc->SetPen (wxPen (wxColour (0, 0, 0)));
+       gc->SetPen(wxPen(grid_colour));
        gc->StrokePath (axes);
 
        if (_cursor) {