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
Edgar
Forum Crew
Posts: 2043
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 » Mon Jan 23, 2012 10:24 pm

steve wrote:
Edgar wrote:Let me send you a patch via e-mail since we may not attach .patch files here.
You can attach patch files that have the file extension .patch
(we added that a while back, I think in response to your previous complaint :) )
Rad dude! Being the squeaky wheel...
sizeColorFamilyViaFontDialog5.patch
(4.17 KiB) Downloaded 104 times
Ignore the e-mail--it is the same as this.

Code: Select all

Index: src/prefs/GUIPrefs.cpp
===================================================================
--- src/prefs/GUIPrefs.cpp	(revision 11430)
+++ src/prefs/GUIPrefs.cpp	(working copy)
@@ -20,6 +20,7 @@
 #include "../Audacity.h"
 
 #include <wx/defs.h>
+#include <wx/fontdlg.h>
 
 #include "../AudacityApp.h"
 #include "../Languages.h"
@@ -28,6 +29,12 @@
 
 #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"))
 {
@@ -78,6 +85,17 @@
    // ----------------------- End of main section --------------
 }
 
+void GUIPrefs::OnFontDialogButton(wxCommandEvent & e)
+{
+   wxFontDialog fontDialog = new wxFontDialog((wxWindow *)this);
+   fontDialog.ShowModal();
+   wxFontData fontData = fontDialog.GetFontData();
+   gPrefs->Write(wxT("/GUI/NativeFontForNameInWaveform"), fontData.GetChosenFont().GetNativeFontInfoDesc());
+   const wxColor fontColor = fontData.GetColour();
+   wxString fontColorAsString = fontColor.GetAsString(wxC2S_HTML_SYNTAX);
+   gPrefs->Write(wxT("/GUI/FontColorForNameInWaveform"), fontColorAsString);
+}
+
 void GUIPrefs::PopulateOrExchange(ShuttleGui & S)
 {
    S.SetBorder(2);
@@ -128,6 +146,8 @@
       S.TieCheckBox(_("&Show track name in waveform display"),
                     wxT("/GUI/ShowTrackNameInWaveform"),
                     false);
+      S.Id(ID_FONTDIALOG_BUTTON).AddButton(_("System Font Dialog for waveform text..."), 
+                                           wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
    }
    S.EndStatic();
 
Index: src/prefs/GUIPrefs.h
===================================================================
--- src/prefs/GUIPrefs.h	(revision 11430)
+++ src/prefs/GUIPrefs.h	(working copy)
@@ -17,6 +17,8 @@
 
 #include <wx/arrstr.h>
 #include <wx/window.h>
+#include <wx/clrpicker.h>
+#include <wx/textctrl.h>
 
 #include "../ShuttleGui.h"
 
@@ -41,6 +43,10 @@
 
    wxArrayString mRangeCodes;
    wxArrayString mRangeChoices;
+
+   void OnFontDialogButton(wxCommandEvent & e);
+
+   DECLARE_EVENT_TABLE();
 };
 
 #endif
Index: src/TrackArtist.cpp
===================================================================
--- src/TrackArtist.cpp	(revision 11430)
+++ src/TrackArtist.cpp	(working copy)
@@ -160,6 +160,7 @@
 #include <wx/pen.h>
 #include <wx/log.h>
 #include <wx/datetime.h>
+//#include <wx/string.h>
 
 #ifdef USE_MIDI
 #include "NoteTrack.h"
@@ -321,7 +322,10 @@
    dc.DrawRectangle(clip);
 #endif
 
-   wxFont labelFont(8, wxSWISS, wxNORMAL, wxNORMAL);
+   wxFont labelFont(8, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL);
+   wxString fontDescription = gPrefs->Read(wxT("/GUI/NativeFontForNameInWaveform"), wxEmptyString);
+   if (!fontDescription.IsEmpty())
+      labelFont.SetNativeFontInfo(fontDescription);
    dc.SetFont(labelFont);
    gPrefs->Read(wxT("/GUI/ShowTrackNameInWaveform"), &mbShowTrackNameInWaveform, false);
 
@@ -403,8 +407,21 @@
       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 fontColorAsString;
+            if (gPrefs->Read(wxT("/GUI/FontColorForNameInWaveform"), &fontColorAsString)) {
+               wxColour newForegroundColorFromPrefs(fontColorAsString);
+               dc.SetTextForeground(newForegroundColorFromPrefs);
+            }
+            else {
+               wxColour newForegroundColor(0, 0, 0);
+               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,
Some times pasting a patch into a code block has issues if the patch has blank lines at the end (I suspect).
-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: 2043
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 » Mon Jan 23, 2012 10:41 pm

In my most recent patch (#5) there are two spurious lines left over in GUIPrefs.h; lines 20 & 21:

Code: Select all

#include <wx/clrpicker.h>
#include <wx/textctrl.h>
they may be removed as they are leftovers from the earlier version.
-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: 81627
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 » Mon Jan 23, 2012 11:39 pm

Edgar wrote:Some times pasting a patch into a code block has issues if the patch has blank lines at the end (I suspect).
Quite possibly. There are sometimes problems with Firefox getting the spaces wrong when copying from the code block.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

steve
Site Admin
Posts: 81627
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 » Mon Jan 23, 2012 11:50 pm

The patch applies OK but I'm still getting this same error:

Code: Select all

/usr/include/wx-2.8/wx/fontdlg.h: In copy constructor ‘wxFontDialog::wxFontDialog(const wxFontDialog&)’:
/usr/include/wx-2.8/wx/fontdlg.h:61: error: ‘wxFontDialogBase::wxFontDialogBase(const wxFontDialogBase&)’ is private
/usr/include/wx-2.8/wx/gtk/fontdlg.h:19: error: within this context
prefs/GUIPrefs.cpp: In member function ‘void GUIPrefs::OnFontDialogButton(wxCommandEvent&)’:
prefs/GUIPrefs.cpp:90: note: synthesized method ‘wxFontDialog::wxFontDialog(const wxFontDialog&)’ first required here 
make[1]: *** [prefs/GUIPrefs.o] Error 1
make[1]: Leaving directory `/home/steve/sourcecode/audacity/src'
make: *** [audacity] Error 2
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Edgar
Forum Crew
Posts: 2043
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 » Tue Jan 24, 2012 12:42 am

steve wrote:The patch applies OK but I'm still getting this same error
I think that is a a problem with your wxWidgets build. Are you building it from scratch or using a build from a repository? I recommend building it yourself from source.

Do you have the wxWidgets sample code installed and built? Try the program built in:
wxWidgets-2.8.12samplesfont
use the menu item Select > Select Font...--it should pop up a font dialog.


I have not built on Linux (in a VM) in many months because SVN HEAD would not build after late May. Since the recent patches may have dealt with this I suppose I could try again. It would take some time as I no longer have VM (thus any Linux) installed and that is a tedious chore!
-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: 81627
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 » Tue Jan 24, 2012 9:38 pm

I'm using 2.8.12 from the wxWidgets repository for Debian.

Code: Select all

deb http://apt.wxwidgets.org/ squeeze-wx main
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

steve
Site Admin
Posts: 81627
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 » Tue Jan 24, 2012 10:48 pm

Edgar wrote:Do you have the wxWidgets sample code installed and built?
I didn't but I do now.
Edgar wrote:Try the program built in:
wxWidgets-2.8.12samplesfont
use the menu item Select > Select Font...--it should pop up a font dialog.
OK, done that:
font-choose.png
font-choose.png (65.85 KiB) Viewed 1933 times
but still got the problem with sizeColorFamilyViaFontDialog5.patch
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Edgar
Forum Crew
Posts: 2043
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 » Wed Jan 25, 2012 12:25 am

At least we know that the dialog works now for you.

Oh, yeah, make sure to do a "clean" (is that "make clean" on Linux ??) before starting this...

Have a look at the headers listed at the top of GUIPrefs (.h & .cpp both) and add any of these which are not there now:

Code: Select all

#include "wx/choicdlg.h"//discard 4th
#include "wx/fontdlg.h"//should already be there--must keep
#include "wx/fontenum.h"//probably the culprit
#include "wx/fontmap.h"//might need
#include "wx/encconv.h"//discard 3rd
#include "wx/splitter.h"//discard 2nd
#include "wx/textfile.h"//discard 1st
If it compiles and runs, start discarding (one at a time--test compile after each discard) #1-4 as they are not likely to be needed. You can also try dumping fontmap & fontenum too.

I see this:

Code: Select all

#ifdef __WXMAC__
    #undef wxFontDialog
    #include "wx/mac/fontdlg.h"
#endif
which I did not know about but it will not effect you or me.
-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: 2043
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 » Wed Jan 25, 2012 12:41 am

Steve, on Windows these are set up by default:

// wxFontMapper class
#define wxUSE_FONTMAP 1
#define wxUSE_FONTPICKERCTRL 1 // wxFontPickerCtrl
// Use font picker dialog
//
// Default is 1
//
// Recommended setting: 1 (used in the library itself)
#define wxUSE_FONTDLG 1

These may need to be configured for Linux (maybe in a makefile??).
-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: 81627
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 » Wed Jan 25, 2012 6:11 pm

Edgar wrote:Have a look at the headers listed at the top of GUIPrefs (.h & .cpp both) and add any of these which are not there now:
Tried that, but no difference, still the same error.
Edgar wrote:// wxFontMapper class
#define wxUSE_FONTMAP 1
#define wxUSE_FONTPICKERCTRL 1 // wxFontPickerCtrl
// Use font picker dialog
//
// Default is 1
//
// Recommended setting: 1 (used in the library itself)
#define wxUSE_FONTDLG 1

These may need to be configured for Linux (maybe in a makefile??).
Sorry, that's over my head.

This is the contents of Makefile for the "font" example program (in case it's of any use to you):

Code: Select all

# =========================================================================
#     This makefile was generated by
#     Bakefile 0.2.9 (http://www.bakefile.org)
#     Do not modify, all changes will be overwritten!
# =========================================================================



# -------------------------------------------------------------------------
# These are configurable options:
# -------------------------------------------------------------------------

# C++ compiler 
CXX = g++

# Standard flags for C++ 
CXXFLAGS ?= 

# Standard preprocessor flags (common for CC and CXX) 
CPPFLAGS ?= 

# Standard linker flags 
LDFLAGS ?= 

# Location and arguments of wx-config script 
WX_CONFIG ?= wx-config

# C++ flags to use with wxWidgets code 
WX_CXXFLAGS ?= `$(WX_CONFIG) --cxxflags`



# -------------------------------------------------------------------------
# Do not modify the rest of this file!
# -------------------------------------------------------------------------

### Variables: ###

CPPDEPS = [email protected] -MF`echo [email protected] | sed -e 's,.o$$,.d,'` -MD -MP
FONT_CXXFLAGS =  -I.  $(WX_CXXFLAGS) $(CPPFLAGS) $(CXXFLAGS)
FONT_OBJECTS =  
	font_font.o

### Conditionally set variables: ###



### Targets: ###

all: font

install: 

uninstall: 

clean: 
	rm -f ./*.o
	rm -f ./*.d
	rm -f font

font: $(FONT_OBJECTS)
	$(CXX) -o [email protected] $(FONT_OBJECTS)   `$(WX_CONFIG) --libs core,base` $(LDFLAGS)

font_font.o: ./font.cpp
	$(CXX) -c -o [email protected] $(FONT_CXXFLAGS) $(CPPDEPS) $<

.PHONY: all install uninstall clean


# Dependencies tracking:
-include ./*.d

Post Reply