From 2a043c0b35752819fb7a616786ce0fb10dd33a26 Mon Sep 17 00:00:00 2001 From: James Crook Date: Wed, 26 Apr 2017 22:32:09 +0100 Subject: [PATCH] Add settable ruler colouring. --- src/FreqWindow.cpp | 2 ++ src/effects/Compressor.cpp | 5 +++++ src/widgets/Ruler.cpp | 18 +++++++++--------- src/widgets/Ruler.h | 5 +++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/FreqWindow.cpp b/src/FreqWindow.cpp index 3fd61e06f..9bc82700d 100644 --- a/src/FreqWindow.cpp +++ b/src/FreqWindow.cpp @@ -285,6 +285,7 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, int w; vRuler->ruler.GetMaxSize(&w, NULL); vRuler->SetMinSize(wxSize(w, 150)); // height needed for wxGTK + vRuler->SetTickColour( theTheme.Colour( clrGraphLabels )); S.AddSpace(wxDefaultCoord, 1); S.Prop(1); @@ -354,6 +355,7 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, int h; hRuler->ruler.GetMaxSize(NULL, &h); hRuler->SetMinSize(wxSize(wxDefaultCoord, h)); + hRuler->SetTickColour( theTheme.Colour( clrGraphLabels )); S.AddSpace(1, wxDefaultCoord); S.Prop(1); diff --git a/src/effects/Compressor.cpp b/src/effects/Compressor.cpp index 958564896..a5e9307e9 100644 --- a/src/effects/Compressor.cpp +++ b/src/effects/Compressor.cpp @@ -42,6 +42,8 @@ #include "../widgets/Ruler.h" #include "../WaveTrack.h" +#include "../Theme.h" +#include "../AllThemeResources.h" enum { @@ -685,6 +687,9 @@ void EffectCompressorPanel::OnPaint(wxPaintEvent & WXUNUSED(evt)) vRuler.SetBounds(0, 0, w, height - h); hRuler.SetBounds(w, height - h, width, height); + vRuler.SetTickColour( theTheme.Colour( clrGraphLabels )); + hRuler.SetTickColour( theTheme.Colour( clrGraphLabels )); + #if defined(__WXMSW__) dc.Clear(); #endif diff --git a/src/widgets/Ruler.cpp b/src/widgets/Ruler.cpp index bac05d15a..d4ea922ec 100644 --- a/src/widgets/Ruler.cpp +++ b/src/widgets/Ruler.cpp @@ -100,7 +100,7 @@ using std::max; #define PLAY_REGION_RECT_HEIGHT 3 #define PLAY_REGION_GLOBAL_OFFSET_Y 7 -wxColour Ruler::mTickColour{ 153, 153, 153 }; +//wxColour Ruler::mTickColour{ 153, 153, 153 }; // // Ruler @@ -126,6 +126,7 @@ Ruler::Ruler() mBottom = -1; mbTicksOnly = true; mbTicksAtExtremes = false; + mTickColour = wxColour( 153, 153, 153 ); mPen.SetColour(mTickColour); // Note: the font size is now adjusted automatically whenever @@ -1340,7 +1341,7 @@ void Ruler::Draw(wxDC& dc, const TimeTrack* timetrack) } } - mMajorLabels[i].Draw(*mDC, mTwoTone); + mMajorLabels[i].Draw(*mDC, mTwoTone, mTickColour); } if(mbMinor == true) { @@ -1368,7 +1369,7 @@ void Ruler::Draw(wxDC& dc, const TimeTrack* timetrack) mRight, mTop + pos); } } - mMinorLabels[i].Draw(*mDC, mTwoTone); + mMinorLabels[i].Draw(*mDC, mTwoTone, mTickColour); } } @@ -1400,7 +1401,7 @@ void Ruler::Draw(wxDC& dc, const TimeTrack* timetrack) mRight, mTop + pos); } } - mMinorMinorLabels[i].Draw(*mDC, mTwoTone); + mMinorMinorLabels[i].Draw(*mDC, mTwoTone, mTickColour); } } } @@ -1532,14 +1533,14 @@ void Ruler::SetCustomMinorLabels(wxArrayString *label, size_t numLabel, int star //Remember: DELETE majorlabels.... } -void Ruler::Label::Draw(wxDC&dc, bool twoTone) const +void Ruler::Label::Draw(wxDC&dc, bool twoTone, wxColour c) const { if (text != wxT("")) { bool altColor = twoTone && value < 0.0; #ifdef EXPERIMENTAL_THEMING // TODO: handle color distinction - dc.SetTextForeground(mTickColour); + dc.SetTextForeground(c); #else dc.SetTextForeground(altColor ? *wxBLUE : *wxBLACK); #endif @@ -3095,16 +3096,15 @@ void AdornedRulerPanel::ShowContextMenu( MenuChoice choice, const wxPoint *pPosi void AdornedRulerPanel::DoDrawBackground(wxDC * dc) { // Draw AdornedRulerPanel border - AColor::MediumTrackInfo( dc, false ); + AColor::UseThemeColour( dc, clrTrackInfo ); dc->DrawRectangle( mInner ); if (mShowScrubbing) { // Let's distinguish the scrubbing area by using the same gray as for // selected track control panel. - AColor::MediumTrackInfo(dc, true); + AColor::UseThemeColour(dc, clrScrubRuler ); dc->DrawRectangle(mScrubZone); } - } void AdornedRulerPanel::DoDrawEdge(wxDC *dc) diff --git a/src/widgets/Ruler.h b/src/widgets/Ruler.h index 753f8e372..93e5a4b71 100644 --- a/src/widgets/Ruler.h +++ b/src/widgets/Ruler.h @@ -171,7 +171,7 @@ public: wxRect mRect; private: - static wxColour mTickColour; + wxColour mTickColour; wxPen mPen; int mMaxWidth, mMaxHeight; @@ -204,7 +204,7 @@ private: int lx, ly; wxString text; - void Draw(wxDC &dc, bool twoTone) const; + void Draw(wxDC &dc, bool twoTone, wxColour c) const; }; int mNumMajor; @@ -258,6 +258,7 @@ class AUDACITY_DLL_API RulerPanel final : public wxPanelWrapper { void OnErase(wxEraseEvent &evt); void OnPaint(wxPaintEvent &evt); void OnSize(wxSizeEvent &evt); + void SetTickColour( wxColour & c){ ruler.SetTickColour( c );} // We don't need or want to accept focus. bool AcceptsFocus() const { return false; }