expand on Norm's new track name in display

Audio software developers forum.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Post Reply
Edgar
Forum Crew
Posts: 2042
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10

expand on Norm's new track name in display

Post by Edgar » Wed Jan 18, 2012 10:07 pm

In yesterday's commit of Norm's patch to put the full name of the track in the wave we gained a nice GUI enhancement. Of course, I'm never satisfied so I extended it!
sizeANDcolor.png
sizeANDcolor.png (70.08 KiB) Viewed 7459 times
I can now control both the size and color of the font in the wavetrack display! Here are two examples:
two.png
two.png (4.89 KiB) Viewed 7459 times
The code is pretty simple, here is the patch:

Code: Select all

Index: src/prefs/GUIPrefs.cpp
===================================================================
--- src/prefs/GUIPrefs.cpp	(revision 11419)
+++ src/prefs/GUIPrefs.cpp	(working copy)
@@ -20,6 +20,7 @@
 #include "../Audacity.h"
 
 #include <wx/defs.h>
+#include <wx/clrpicker.h>
 
 #include "../AudacityApp.h"
 #include "../Languages.h"
@@ -128,6 +129,34 @@
       S.TieCheckBox(_("&Show track name in waveform display"),
                     wxT("/GUI/ShowTrackNameInWaveform"),
                     false);
+      S.StartThreeColumn();
+      {
+         int fontSize = gPrefs->Read(wxT("/GUI/FontSizeForNameInWaveform"), (int)8);
+         mFontSizeCtrl = S.TieNumericTextBox(_("Font size for track name in waveform display"), wxT("/GUI/FontSizeForNameInWaveform"), fontSize, 4);
+         mFontSizeCtrl->SetSizeHints(wxSize(50,20));
+         S.AddUnits(_(" Color: "));
+      }
+      wxPoint fontSizeCtrlLocation = mFontSizeCtrl->GetPosition();
+      fontSizeCtrlLocation.x = 320;
+      fontSizeCtrlLocation.y += 200;
+      wxString red;
+      long redValue = 0;
+      if (gPrefs->Read(wxT("/GUI/FontColorRedForNameInWaveform"), &red))
+         red.ToLong(&redValue);
+
+      wxString green;
+      long greenValue = 0;
+      if (gPrefs->Read(wxT("/GUI/FontColorGreenForNameInWaveform"), &green))
+         green.ToLong(&greenValue);
+
+      wxString blue;
+      long blueValue = 0;
+      if (gPrefs->Read(wxT("/GUI/FontColorBlueForNameInWaveform"), &blue))
+         blue.ToLong(&blueValue);
+
+      wxColour fontColor(redValue, greenValue, blueValue);
+      fontColorPickerCtrl = NULL;
+      fontColorPickerCtrl = new wxColourPickerCtrl((wxWindow *)this, wxID_ANY, fontColor, fontSizeCtrlLocation);
    }
    S.EndStatic();
 
@@ -152,6 +181,26 @@
    ShuttleGui S(this, eIsSavingToPrefs);
    PopulateOrExchange(S);
 
+   //validate user's choice of font size
+   long fontSize = 8;
+   mFontSizeCtrl->GetValue().ToLong(&fontSize);
+   if (fontSize < 8) {
+      fontSize = 8;
+      gPrefs->Write(wxT("/GUI/FontSizeForNameInWaveform"), (int)8);
+      wxMessageBox(_("Font size must be no smaller than 8; setting to 8."));
+   }
+   //else if (fontSize > TOO_BIG) {//how big is too big?
+   if (fontColorPickerCtrl) {
+      wxColour fontColor = fontColorPickerCtrl->GetColour();
+      unsigned char red = fontColor.Red();
+      unsigned char green = fontColor.Green();
+      unsigned char blue = fontColor.Blue();
+      //gPrefs->Write(wxT("/GUI/FontColorRedForNameInWaveform"), red);
+      //gPrefs->Write(wxT("/GUI/FontColorGreenForNameInWaveform"), green);
+      //gPrefs->Write(wxT("/GUI/FontColorBlueForNameInWaveform"), blue);
+      delete fontColorPickerCtrl;
+   }
+
    // If language has changed, we want to change it now, not on the next reboot.
    wxString lang = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
    if (lang == wxT(""))
Index: src/prefs/GUIPrefs.h
===================================================================
--- src/prefs/GUIPrefs.h	(revision 11419)
+++ src/prefs/GUIPrefs.h	(working copy)
@@ -17,6 +17,7 @@
 
 #include <wx/arrstr.h>
 #include <wx/window.h>
+#include <wx/clrpicker.h>
 
 #include "../ShuttleGui.h"
 
@@ -41,6 +42,8 @@
 
    wxArrayString mRangeCodes;
    wxArrayString mRangeChoices;
+   wxTextCtrl * mFontSizeCtrl;
+   wxColourPickerCtrl * fontColorPickerCtrl;
 };
 
 #endif
Index: src/TrackArtist.cpp
===================================================================
--- src/TrackArtist.cpp	(revision 11419)
+++ src/TrackArtist.cpp	(working copy)
@@ -321,7 +321,10 @@
    dc.DrawRectangle(clip);
 #endif
 
-   wxFont labelFont(8, wxSWISS, wxNORMAL, wxNORMAL);
+   
+   int fontSize = gPrefs->Read(wxT("/GUI/FontSizeForNameInWaveform"), (int)8);
+
+   wxFont labelFont(fontSize, wxSWISS, wxNORMAL, wxNORMAL);
    dc.SetFont(labelFont);
    gPrefs->Read(wxT("/GUI/ShowTrackNameInWaveform"), &mbShowTrackNameInWaveform, false);
 
@@ -403,8 +406,29 @@
       case WaveTrack::WaveformDisplay:
          DrawWaveform(wt, dc, r, viewInfo,
                       drawEnvelope, drawSamples, drawSliders, false, muted);
-         if (mbShowTrackNameInWaveform && wt->GetChannel() != Track::RightChannel)    // so left or mono only
+
+         if (mbShowTrackNameInWaveform && wt->GetChannel() != Track::RightChannel) {    // so left or mono only
+            const wxColour& originalForegroundTextColor = dc.GetTextForeground();
+            wxString red;
+            long redValue = 0;
+            if (gPrefs->Read(wxT("/GUI/FontColorRedForNameInWaveform"), &red))
+               red.ToLong(&redValue);
+
+            wxString green;
+            long greenValue = 0;
+            if (gPrefs->Read(wxT("/GUI/FontColorGreenForNameInWaveform"), &green))
+               green.ToLong(&greenValue);
+
+            wxString blue;
+            long blueValue = 0;
+            if (gPrefs->Read(wxT("/GUI/FontColorBlueForNameInWaveform"), &blue))
+               blue.ToLong(&blueValue);
+
+            wxColour newForegroundColor(redValue, greenValue, blueValue);
+            dc.SetTextForeground(newForegroundColor);
             dc.DrawText (wt->GetName(), r.x+10, r.y);  // move right 10 pixels to avoid overwriting <- symbol
+            dc.SetTextForeground(originalForegroundTextColor);
+         }
          break;
       case WaveTrack::WaveformDBDisplay:
          DrawWaveform(wt, dc, r, viewInfo,

There are some problems--we do not have a color picker in ShuttleGUI so we must manage the wxColourPickerCtrl separately. For some reason the picker does not return the picked color (just black) after the panel is destroyed so for now I am resorting to editing the config file directly:

Code: Select all

[GUI]
[...]
ShowTrackNameInWaveform=1
FontSizeForNameInWaveform=14
FontColorRedForNameInWaveform=240
FontColorGreenForNameInWaveform=0
FontColorBlueForNameInWaveform=240
-Edgar
running Audacity personally customized 2.0.6 daily in a professional audio studio
occasionally using current Audacity alpha for testing and support situations
64-bit Windows Pro 10

waxcylinder
Forum Staff
Posts: 14585
Joined: Tue Jul 31, 2007 11:03 am
Operating System: Windows 10

Re: expand on Norm's new track name in display

Post by waxcylinder » Thu Jan 19, 2012 9:43 am

Edgar wrote:In yesterday's commit of Norm's patch to put the full name of the track in the wave we gained a nice GUI enhancement. Of course, I'm never satisfied so I extended it!
Why am I not surprised Ed? :D

WC
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * FAQ * * * * * Tutorials * * * * * Audacity Manual * * * * *

billw58
Forum Staff
Posts: 5566
Joined: Wed Aug 12, 2009 2:10 am
Operating System: macOS 10.15 Catalina or later

Re: expand on Norm's new track name in display

Post by billw58 » Thu Jan 19, 2012 4:48 pm

Somebody please review and commit Ed's patch - I can hardly read the track name in the waveform display.

-- Bill
Screen Shot 2012-01-19 at 11.39.25 AM.png
Example of name in waveform on 27" iMac
Screen Shot 2012-01-19 at 11.39.25 AM.png (12.06 KiB) Viewed 7445 times

Edgar
Forum Crew
Posts: 2042
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10

Re: expand on Norm's new track name in display

Post by Edgar » Thu Jan 19, 2012 4:52 pm

new patch with working color storage in prefs

Code: Select all

Index: src/prefs/GUIPrefs.cpp
===================================================================
--- src/prefs/GUIPrefs.cpp	(revision 11419)
+++ src/prefs/GUIPrefs.cpp	(working copy)
@@ -20,6 +20,7 @@
 #include "../Audacity.h"
 
 #include <wx/defs.h>
+#include <wx/clrpicker.h>
 
 #include "../AudacityApp.h"
 #include "../Languages.h"
@@ -31,6 +32,7 @@
 GUIPrefs::GUIPrefs(wxWindow * parent)
 :  PrefsPanel(parent, _("Interface"))
 {
+   fontColorPickerCtrl = NULL;
    Populate();
 }
 
@@ -128,6 +130,43 @@
       S.TieCheckBox(_("&Show track name in waveform display"),
                     wxT("/GUI/ShowTrackNameInWaveform"),
                     false);
+      S.StartThreeColumn();
+      {
+         int fontSize = gPrefs->Read(wxT("/GUI/FontSizeForNameInWaveform"), (int)8);
+         mFontSizeCtrl = S.TieNumericTextBox(_("Font size for track name in waveform display"), wxT("/GUI/FontSizeForNameInWaveform"), fontSize, 4);
+         mFontSizeCtrl->SetSizeHints(wxSize(50,20));
+         S.AddUnits(_(" Color: "));
+      }
+      wxPoint fontSizeCtrlLocation = mFontSizeCtrl->GetPosition();
+      fontSizeCtrlLocation.x = 320;
+      fontSizeCtrlLocation.y += 200;
+      wxString red;
+      long redValue = 0;
+      if (gPrefs->Read(wxT("/GUI/FontColorRedForNameInWaveform"), &red))
+         red.ToLong(&redValue);
+
+      wxString green;
+      long greenValue = 0;
+      if (gPrefs->Read(wxT("/GUI/FontColorGreenForNameInWaveform"), &green))
+         green.ToLong(&greenValue);
+
+      wxString blue;
+      long blueValue = 0;
+      if (gPrefs->Read(wxT("/GUI/FontColorBlueForNameInWaveform"), &blue))
+         blue.ToLong(&blueValue);
+
+      wxColour fontColor(redValue, greenValue, blueValue);
+      if (!fontColorPickerCtrl)
+         fontColorPickerCtrl = new wxColourPickerCtrl((wxWindow *)this, wxID_ANY, fontColor, fontSizeCtrlLocation);
+      else {
+         wxColour fontColor = fontColorPickerCtrl->GetColour();
+         unsigned char red = fontColor.Red();
+         unsigned char green = fontColor.Green();
+         unsigned char blue = fontColor.Blue();
+         gPrefs->Write(wxT("/GUI/FontColorRedForNameInWaveform"), red);
+         gPrefs->Write(wxT("/GUI/FontColorGreenForNameInWaveform"), green);
+         gPrefs->Write(wxT("/GUI/FontColorBlueForNameInWaveform"), blue);
+      }
    }
    S.EndStatic();
 
@@ -152,6 +191,17 @@
    ShuttleGui S(this, eIsSavingToPrefs);
    PopulateOrExchange(S);
 
+   //validate user's choice of font size
+   long fontSize = 8;
+   mFontSizeCtrl->GetValue().ToLong(&fontSize);
+   if (fontSize < 8) {
+      fontSize = 8;
+      gPrefs->Write(wxT("/GUI/FontSizeForNameInWaveform"), (int)8);
+      wxMessageBox(_("Font size must be no smaller than 8; setting to 8."));
+   }
+   //else if (fontSize > TOO_BIG) {//how big is too big?
+   if (fontColorPickerCtrl) delete fontColorPickerCtrl;
+
    // If language has changed, we want to change it now, not on the next reboot.
    wxString lang = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
    if (lang == wxT(""))
Index: src/prefs/GUIPrefs.h
===================================================================
--- src/prefs/GUIPrefs.h	(revision 11419)
+++ src/prefs/GUIPrefs.h	(working copy)
@@ -17,6 +17,7 @@
 
 #include <wx/arrstr.h>
 #include <wx/window.h>
+#include <wx/clrpicker.h>
 
 #include "../ShuttleGui.h"
 
@@ -41,6 +42,8 @@
 
    wxArrayString mRangeCodes;
    wxArrayString mRangeChoices;
+   wxTextCtrl * mFontSizeCtrl;
+   wxColourPickerCtrl * fontColorPickerCtrl;
 };
 
 #endif
Index: src/TrackArtist.cpp
===================================================================
--- src/TrackArtist.cpp	(revision 11419)
+++ src/TrackArtist.cpp	(working copy)
@@ -321,7 +321,10 @@
    dc.DrawRectangle(clip);
 #endif
 
-   wxFont labelFont(8, wxSWISS, wxNORMAL, wxNORMAL);
+   
+   int fontSize = gPrefs->Read(wxT("/GUI/FontSizeForNameInWaveform"), (int)8);
+
+   wxFont labelFont(fontSize, wxSWISS, wxNORMAL, wxNORMAL);
    dc.SetFont(labelFont);
    gPrefs->Read(wxT("/GUI/ShowTrackNameInWaveform"), &mbShowTrackNameInWaveform, false);
 
@@ -403,8 +406,29 @@
       case WaveTrack::WaveformDisplay:
          DrawWaveform(wt, dc, r, viewInfo,
                       drawEnvelope, drawSamples, drawSliders, false, muted);
-         if (mbShowTrackNameInWaveform && wt->GetChannel() != Track::RightChannel)    // so left or mono only
+
+         if (mbShowTrackNameInWaveform && wt->GetChannel() != Track::RightChannel) {    // so left or mono only
+            const wxColour& originalForegroundTextColor = dc.GetTextForeground();
+            wxString red;
+            long redValue = 0;
+            if (gPrefs->Read(wxT("/GUI/FontColorRedForNameInWaveform"), &red))
+               red.ToLong(&redValue);
+
+            wxString green;
+            long greenValue = 0;
+            if (gPrefs->Read(wxT("/GUI/FontColorGreenForNameInWaveform"), &green))
+               green.ToLong(&greenValue);
+
+            wxString blue;
+            long blueValue = 0;
+            if (gPrefs->Read(wxT("/GUI/FontColorBlueForNameInWaveform"), &blue))
+               blue.ToLong(&blueValue);
+
+            wxColour newForegroundColor(redValue, greenValue, blueValue);
+            dc.SetTextForeground(newForegroundColor);
             dc.DrawText (wt->GetName(), r.x+10, r.y);  // move right 10 pixels to avoid overwriting <- symbol
+            dc.SetTextForeground(originalForegroundTextColor);
+         }
          break;
       case WaveTrack::WaveformDBDisplay:
          DrawWaveform(wt, dc, r, viewInfo,
-Edgar
running Audacity personally customized 2.0.6 daily in a professional audio studio
occasionally using current Audacity alpha for testing and support situations
64-bit Windows Pro 10

Edgar
Forum Crew
Posts: 2042
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10

Re: expand on Norm's new track name in display

Post by Edgar » Thu Jan 19, 2012 5:00 pm

billw58 wrote:Somebody please review and commit Ed's patch
Sorry Bill, I doubt you can get any traction on this asking here. I do not post on -QA (nor -devel) but that is probably the best place to ask. I do not understand how/why Norm's enhancement got committed in the face of the feature freeze and with no QA discussion.
-Edgar
running Audacity personally customized 2.0.6 daily in a professional audio studio
occasionally using current Audacity alpha for testing and support situations
64-bit Windows Pro 10

steve
Site Admin
Posts: 80752
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: expand on Norm's new track name in display

Post by steve » Fri Jan 20, 2012 3:18 pm

Edgar wrote: I do not understand how/why Norm's enhancement got committed in the face of the feature freeze and with no QA discussion.
I agree that was irregular, but not entirely unwelcome.
Improved support for long track names has been on the feature requests page for a long time and this is in my opinion a good step in the right direction.
I get the impression that Martyn pushed to get this through and persuaded the other active developers that it was 100% safe.

The inability to see the full track name could perhaps be seen as a bug (possibly part of bug 75 - ".. <snip>..The fundamental problem is how to both display the full name without having to edit it..") in which case it is allowed even in a feature freeze.

Also, all of the P1s and P2s are now officially clear, so hopefully we are looking at the release of 2.0 and an end to the current freeze.
billw58 wrote: I can hardly read the track name in the waveform display.
It is particularly difficult to read when the track is collapsed. As I wrote to -devel:
While Norm's fix is a very welcome additional feature, it is difficult to read on some monitors when the track is collapsed, putting the text against a blue "disruptive pattern" background. In fact, for this reason I think that it would still be useful if the track name was visible as a Tool Tip,
to which Gale replied:
I agree with Steve, not least, can all VI screen readers read that text in the waveform on all platforms? Otherwise, it would be an extra step for VI users to open the menu to find the name - they need to know what track they are on more than sighted users do.

How do other editors manage the colour changes according to whether there is a waveform where the name is? Could the name change to white when it has a waveform behind it? Is black the best colour? Some kind of yellow might possibly work for all cases? Yes, after 2.0.
So I think that improvements to "name in track" are on the cards, but just having "name in track" is a start and a reminder that it needs improving.
Edgar wrote:There are some problems--we do not have a color picker in ShuttleGUI so we must manage the wxColourPickerCtrl separately. For some reason the picker does not return the picked color (just black) after the panel is destroyed so for now I am resorting to editing the config file directly:
Would it be possible to have a simpler colour selection option? Say 4 colours in the Preference dialogue itself to choose from?
If so, what colours would be best? I'd suggest black, white, yellow and one other.
A less user friendly option might be for a text box for the Hex colour value.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Edgar
Forum Crew
Posts: 2042
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10

Re: expand on Norm's new track name in display

Post by Edgar » Fri Jan 20, 2012 4:07 pm

steve wrote:
Edgar wrote:There are some problems--we do not have a color picker in ShuttleGUI so we must manage the wxColourPickerCtrl separately. For some reason the picker does not return the picked color (just black) after the panel is destroyed so for now I am resorting to editing the config file directly:
Would it be possible to have a simpler colour selection option? Say 4 colours in the Preference dialogue itself to choose from?
If so, what colours would be best? I'd suggest black, white, yellow and one other.
A less user friendly option might be for a text box for the Hex colour value.
simpler colour selection option? Say 4 colours in the Preference dialogue itself to choose from
That was my first thought (since we do not have a color picker in ShuttleGUI) but the extra code involved was messy and I could not settle on a reasonable selection of colors <grin>!
a text box for the Hex colour value
I also tried that but thought it way too geeky for the general public. It also added a lot of messy code.

In the first patch I could not figure out how to deal with the wxWidgets color picker but I figured that all out eventually for the second patch. Have you tried in on Linux?

My goal would be to lobby James to add the wxWidgets color picker to ShuttleGUI because locating the widget might not work well the way I have it hard-coded right now. Before committing the hard-coded location version the GUI would need testing on all 3 platforms at various screen resolutions.
-Edgar
running Audacity personally customized 2.0.6 daily in a professional audio studio
occasionally using current Audacity alpha for testing and support situations
64-bit Windows Pro 10

steve
Site Admin
Posts: 80752
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: expand on Norm's new track name in display

Post by steve » Fri Jan 20, 2012 4:23 pm

I've not tried it yet, but adding the colour picker may well have more widespread use post 2.0 if they bring back theme support.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Edgar
Forum Crew
Posts: 2042
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10

Re: expand on Norm's new track name in display

Post by Edgar » Fri Jan 20, 2012 9:43 pm

steve wrote:adding the colour picker may well have more widespread use post 2.0 if they bring back theme support.
The current code for theme support-based color is quite "interesting" and IMVHO should be scrapped. Given that this text is far outside the bounds of that theme stuff it would not get colored anyway. AFAIR, font size is not a part of that themeing but I only looked at it once and that was a long time ago.
-Edgar
running Audacity personally customized 2.0.6 daily in a professional audio studio
occasionally using current Audacity alpha for testing and support situations
64-bit Windows Pro 10

Edgar
Forum Crew
Posts: 2042
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10

Re: expand on Norm's new track name in display

Post by Edgar » Sun Jan 22, 2012 8:41 pm

I found a tiny bug in the previous patch (a S.StartThreeColumn(); did not have a closing S.EndMultiColumn(); -- which does not seem to affect anything but is now fixed).

Also, having been snowbound now for a week and having way too much time on my hands...
sizeColor&Family.png
sizeColor&Family.png (39.88 KiB) Viewed 7381 times
This might be the final patch on this; it adds font family to the mix (I prefer Roman or teletype to Swiss) as a Preference setting:
[edit: added needed header #includes]

Code: Select all

Index: src/prefs/GUIPrefs.cpp
===================================================================
--- src/prefs/GUIPrefs.cpp	(revision 11419)
+++ src/prefs/GUIPrefs.cpp	(working copy)
@@ -20,6 +20,9 @@
 #include "../Audacity.h"
 
 #include <wx/defs.h>
+#include <wx/clrpicker.h>
+#include <wx/textctrl.h>
+#include <wx/msgdlg.h>
 
 #include "../AudacityApp.h"
 #include "../Languages.h"
@@ -31,6 +34,7 @@
 GUIPrefs::GUIPrefs(wxWindow * parent)
 :  PrefsPanel(parent, _("Interface"))
 {
+   fontColorPickerCtrl = NULL;
    Populate();
 }
 
@@ -63,6 +67,22 @@
    mRangeChoices.Add(_("-120 dB (approximate limit of human hearing)"));
    mRangeChoices.Add(_("-145 dB (PCM range of 24 bit samples)"));
 
+   mFontFamilyCodes.Add(wxT("wxFONTFAMILY_DEFAULT"));
+   mFontFamilyCodes.Add(wxT("wxFONTFAMILY_DECORATIVE"));
+   mFontFamilyCodes.Add(wxT("wxFONTFAMILY_ROMAN"));
+   mFontFamilyCodes.Add(wxT("wxFONTFAMILY_SCRIPT"));
+   mFontFamilyCodes.Add(wxT("wxFONTFAMILY_SWISS"));
+   mFontFamilyCodes.Add(wxT("wxFONTFAMILY_MODERN"));
+   mFontFamilyCodes.Add(wxT("wxFONTFAMILY_TELETYPE"));
+
+   mFontFamilyChoices.Add(_("Default"));
+   mFontFamilyChoices.Add(_("Decorative"));
+   mFontFamilyChoices.Add(_("Roman"));
+   mFontFamilyChoices.Add(_("Script"));
+   mFontFamilyChoices.Add(_("Swiss"));
+   mFontFamilyChoices.Add(_("Modern"));
+   mFontFamilyChoices.Add(_("Teletype"));
+
 #if 0
    // only for testing...
    mLangCodes.Add("kg");   mLangNames.Add("Klingon");
@@ -128,6 +148,55 @@
       S.TieCheckBox(_("&Show track name in waveform display"),
                     wxT("/GUI/ShowTrackNameInWaveform"),
                     false);
+      S.StartThreeColumn();
+      {
+         int fontSize = gPrefs->Read(wxT("/GUI/FontSizeForNameInWaveform"), (int)8);
+         mFontSizeCtrl = S.TieNumericTextBox(_("Font size for track name in waveform display"), wxT("/GUI/FontSizeForNameInWaveform"), fontSize, 4);
+         mFontSizeCtrl->SetSizeHints(wxSize(50,20));
+         S.AddUnits(_(" Color: "));
+         wxPoint fontSizeCtrlLocation = mFontSizeCtrl->GetPosition();
+         fontSizeCtrlLocation.x = 320;
+         fontSizeCtrlLocation.y += 200;
+         wxString red;
+         long redValue = 0;
+         if (gPrefs->Read(wxT("/GUI/FontColorRedForNameInWaveform"), &red))
+            red.ToLong(&redValue);
+
+         wxString green;
+         long greenValue = 0;
+         if (gPrefs->Read(wxT("/GUI/FontColorGreenForNameInWaveform"), &green))
+            green.ToLong(&greenValue);
+
+         wxString blue;
+         long blueValue = 0;
+         if (gPrefs->Read(wxT("/GUI/FontColorBlueForNameInWaveform"), &blue))
+            blue.ToLong(&blueValue);
+
+         wxColour fontColor(redValue, greenValue, blueValue);
+         if (!fontColorPickerCtrl)
+            fontColorPickerCtrl = new wxColourPickerCtrl((wxWindow *)this, wxID_ANY, fontColor, fontSizeCtrlLocation);
+         else {
+            wxColour fontColor = fontColorPickerCtrl->GetColour();
+            unsigned char red = fontColor.Red();
+            unsigned char green = fontColor.Green();
+            unsigned char blue = fontColor.Blue();
+            gPrefs->Write(wxT("/GUI/FontColorRedForNameInWaveform"), red);
+            gPrefs->Write(wxT("/GUI/FontColorGreenForNameInWaveform"), green);
+            gPrefs->Write(wxT("/GUI/FontColorBlueForNameInWaveform"), blue);
+         }
+      }
+      S.EndMultiColumn();
+
+      S.StartMultiColumn(2);
+      {
+         S.TieChoice(_("Font family for track name in waveform display"),
+                     wxT("/GUI/FontFamilyForNameInWaveform"),
+                     wxT("Swiss"),
+                     mFontFamilyChoices,
+                     mFontFamilyCodes);
+         S.SetSizeHints(mFontFamilyChoices);
+      }
+      S.EndMultiColumn();
    }
    S.EndStatic();
 
@@ -152,6 +221,17 @@
    ShuttleGui S(this, eIsSavingToPrefs);
    PopulateOrExchange(S);
 
+   //validate user's choice of font size
+   long fontSize = 8;
+   mFontSizeCtrl->GetValue().ToLong(&fontSize);
+   if (fontSize < 8) {
+      fontSize = 8;
+      gPrefs->Write(wxT("/GUI/FontSizeForNameInWaveform"), (int)8);
+      wxMessageBox(_("Font size must be no smaller than 8; setting to 8."));
+   }
+   //else if (fontSize > TOO_BIG) {//how big is too big?
+   if (fontColorPickerCtrl) delete fontColorPickerCtrl;
+
    // If language has changed, we want to change it now, not on the next reboot.
    wxString lang = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
    if (lang == wxT(""))
Index: src/prefs/GUIPrefs.h
===================================================================
--- src/prefs/GUIPrefs.h	(revision 11419)
+++ src/prefs/GUIPrefs.h	(working copy)
@@ -17,6 +17,9 @@
 
 #include <wx/arrstr.h>
 #include <wx/window.h>
+#include <wx/clrpicker.h>
+#include <wx/textctrl.h>
+#include <wx/msgdlg.h>
 
 #include "../ShuttleGui.h"
 
@@ -41,6 +44,11 @@
 
    wxArrayString mRangeCodes;
    wxArrayString mRangeChoices;
+
+   wxArrayString mFontFamilyCodes;
+   wxArrayString mFontFamilyChoices;
+   wxTextCtrl * mFontSizeCtrl;
+   wxColourPickerCtrl * fontColorPickerCtrl;
 };
 
 #endif
Index: src/TrackArtist.cpp
===================================================================
--- src/TrackArtist.cpp	(revision 11419)
+++ src/TrackArtist.cpp	(working copy)
@@ -321,7 +321,28 @@
    dc.DrawRectangle(clip);
 #endif
 
-   wxFont labelFont(8, wxSWISS, wxNORMAL, wxNORMAL);
+   
+   int fontSize = gPrefs->Read(wxT("/GUI/FontSizeForNameInWaveform"), (int)8);
+   wxString fontFamilyStr = gPrefs->Read(wxT("/GUI/FontFamilyForNameInWaveform"), wxT("wxFONTFAMILY_SWISS"));
+   int fontFamily = wxFONTFAMILY_SWISS;
+   if (fontFamilyStr.IsSameAs(wxT("wxFONTFAMILY_DEFAULT")))
+         fontFamily = wxFONTFAMILY_DEFAULT;
+   else if (fontFamilyStr.IsSameAs(wxT("wxFONTFAMILY_DECORATIVE")))
+         fontFamily = wxFONTFAMILY_DECORATIVE;
+   else if (fontFamilyStr.IsSameAs(wxT("wxFONTFAMILY_ROMAN")))
+         fontFamily = wxFONTFAMILY_ROMAN;
+   else if (fontFamilyStr.IsSameAs(wxT("wxFONTFAMILY_SCRIPT")))
+         fontFamily = wxFONTFAMILY_SCRIPT;
+   else if (fontFamilyStr.IsSameAs(wxT("wxFONTFAMILY_SWISS")))
+         fontFamily = wxFONTFAMILY_SWISS;
+   else if (fontFamilyStr.IsSameAs(wxT("wxFONTFAMILY_MODERN")))
+         fontFamily = wxFONTFAMILY_MODERN;
+   else if (fontFamilyStr.IsSameAs(wxT("wxFONTFAMILY_TELETYPE")))
+         fontFamily = wxFONTFAMILY_TELETYPE;
+   else
+         fontFamily = wxFONTFAMILY_SWISS;
+
+   wxFont labelFont(fontSize, fontFamily, wxNORMAL, wxNORMAL);
    dc.SetFont(labelFont);
    gPrefs->Read(wxT("/GUI/ShowTrackNameInWaveform"), &mbShowTrackNameInWaveform, false);
 
@@ -403,8 +424,29 @@
       case WaveTrack::WaveformDisplay:
          DrawWaveform(wt, dc, r, viewInfo,
                       drawEnvelope, drawSamples, drawSliders, false, muted);
-         if (mbShowTrackNameInWaveform && wt->GetChannel() != Track::RightChannel)    // so left or mono only
+
+         if (mbShowTrackNameInWaveform && wt->GetChannel() != Track::RightChannel) {    // so left or mono only
+            const wxColour& originalForegroundTextColor = dc.GetTextForeground();
+            wxString red;
+            long redValue = 0;
+            if (gPrefs->Read(wxT("/GUI/FontColorRedForNameInWaveform"), &red))
+               red.ToLong(&redValue);
+
+            wxString green;
+            long greenValue = 0;
+            if (gPrefs->Read(wxT("/GUI/FontColorGreenForNameInWaveform"), &green))
+               green.ToLong(&greenValue);
+
+            wxString blue;
+            long blueValue = 0;
+            if (gPrefs->Read(wxT("/GUI/FontColorBlueForNameInWaveform"), &blue))
+               blue.ToLong(&blueValue);
+
+            wxColour newForegroundColor(redValue, greenValue, blueValue);
+            dc.SetTextForeground(newForegroundColor);
             dc.DrawText (wt->GetName(), r.x+10, r.y);  // move right 10 pixels to avoid overwriting <- symbol
+            dc.SetTextForeground(originalForegroundTextColor);
+         }
          break;
       case WaveTrack::WaveformDBDisplay:
          DrawWaveform(wt, dc, r, viewInfo,

-Edgar
running Audacity personally customized 2.0.6 daily in a professional audio studio
occasionally using current Audacity alpha for testing and support situations
64-bit Windows Pro 10

Post Reply