The current stumbling block is that I have not figured out how to store a system font in Prefs--mañana. The following patch has all the old patch stuff commented out. Doing it this way is far less code and removes the problem of the color picker's location; the font dialog is launched via a button for which we have ShuttleGUI access.
Code: Select all
Index: src/AudacityApp.h
===================================================================
--- src/AudacityApp.h (revision 11419)
+++ src/AudacityApp.h (working copy)
@@ -24,6 +24,7 @@
#include <wx/snglinst.h>
#include <wx/log.h>
#include <wx/timer.h>
+#include <wx/font.h>
#include "widgets/FileHistory.h"
#include "ondemand/ODTaskThread.h"
@@ -193,6 +194,8 @@
Importer *mImporter;
wxLogWindow *mLogger;
+ wxFont mWaveformFont;
+ wxColor mWaveformFontColor;
#if defined(__WXGTK__)
/** brief This flag is set true when in a keyboard event handler.
Index: src/prefs/GUIPrefs.cpp
===================================================================
--- src/prefs/GUIPrefs.cpp (revision 11419)
+++ src/prefs/GUIPrefs.cpp (working copy)
@@ -20,6 +20,10 @@
#include "../Audacity.h"
#include <wx/defs.h>
+#include <wx/clrpicker.h>
+#include <wx/textctrl.h>
+#include <wx/msgdlg.h>
+#include <wx/fontdlg.h>
#include "../AudacityApp.h"
#include "../Languages.h"
@@ -28,9 +32,16 @@
#include "GUIPrefs.h"
+#define ID_FONTDIALOG_BUTTON 7777
+
+BEGIN_EVENT_TABLE(GUIPrefs, PrefsPanel)
+ EVT_BUTTON(ID_FONTDIALOG_BUTTON, GUIPrefs::OnFontDialogButton)
+END_EVENT_TABLE()
+
GUIPrefs::GUIPrefs(wxWindow * parent)
: PrefsPanel(parent, _("Interface"))
{
+ //mFontColorPickerCtrl = NULL;
Populate();
}
@@ -63,6 +74,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");
@@ -78,6 +105,15 @@
// ----------------------- End of main section --------------
}
+void GUIPrefs::OnFontDialogButton(wxCommandEvent & e)
+{
+ wxFontDialog fontDialog = new wxFontDialog((wxWindow *)this);
+ fontDialog.ShowModal();
+ wxFontData fontData = fontDialog.GetFontData();
+ wxGetApp().mWaveformFont = fontData.GetChosenFont();
+ wxGetApp().mWaveformFontColor = fontData.GetColour();
+}
+
void GUIPrefs::PopulateOrExchange(ShuttleGui & S)
{
S.SetBorder(2);
@@ -128,6 +164,68 @@
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();
+//#ifdef __WXMSW__
+// fontSizeCtrlLocation.x = 320;
+// fontSizeCtrlLocation.y += 200;
+//#endif
+//#ifdef __WXGTK__
+// fontSizeCtrlLocation.x = 425;
+// fontSizeCtrlLocation.y += 260;
+//#endif
+//#ifdef __WXMAC__
+// //don't really know what the correct values are
+// fontSizeCtrlLocation.x = 320;
+// fontSizeCtrlLocation.y += 200;
+//#endif
+// 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 (!mFontColorPickerCtrl)
+// mFontColorPickerCtrl = new wxColourPickerCtrl((wxWindow *)this, wxID_ANY, fontColor, fontSizeCtrlLocation);
+// else {
+// wxColour fontColor = mFontColorPickerCtrl->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.Id(ID_FONTDIALOG_BUTTON).AddButton(_("System Font Dialog for waveform text..."), wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
}
S.EndStatic();
@@ -152,6 +250,19 @@
ShuttleGui S(this, eIsSavingToPrefs);
PopulateOrExchange(S);
+ //validate user's choice of font size
+ //if (mFontSizeCtrl) {
+ // 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 (mFontColorPickerCtrl) delete mFontColorPickerCtrl;
+
// 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,10 @@
#include <wx/arrstr.h>
#include <wx/window.h>
+#include <wx/clrpicker.h>
+#include <wx/textctrl.h>
+#include <wx/msgdlg.h>
+#include <wx/fontdlg.h>
#include "../ShuttleGui.h"
@@ -41,6 +45,15 @@
wxArrayString mRangeCodes;
wxArrayString mRangeChoices;
+
+ //wxArrayString mFontFamilyCodes;
+ //wxArrayString mFontFamilyChoices;
+ //wxTextCtrl * mFontSizeCtrl;
+ //wxColourPickerCtrl * mFontColorPickerCtrl;
+
+ void OnFontDialogButton(wxCommandEvent & e);
+
+ DECLARE_EVENT_TABLE();
};
#endif
Index: src/TrackArtist.cpp
===================================================================
--- src/TrackArtist.cpp (revision 11419)
+++ src/TrackArtist.cpp (working copy)
@@ -321,8 +321,30 @@
dc.DrawRectangle(clip);
#endif
- wxFont labelFont(8, wxSWISS, wxNORMAL, wxNORMAL);
- dc.SetFont(labelFont);
+
+ //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);
+ dc.SetFont(wxGetApp().mWaveformFont);
gPrefs->Read(wxT("/GUI/ShowTrackNameInWaveform"), &mbShowTrackNameInWaveform, false);
t = iter.StartWith(start);
@@ -403,8 +425,30 @@
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.SetTextForeground(wxGetApp().mWaveformFontColor);
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,