Re: [Audacity-devel] spectrum display with log frequency axis
A free multi-track audio editor and recorder
Brought to you by:
aosiniao
From: Andreas M. <And...@gm...> - 2007-11-17 01:37:04
|
Martyn Shaw wrote: > A few comments on the ruler (which I know is a hard piece of code to > get right): > ... > The new RealLogFormat has a similar problem to we have with Spectrum; > the digits tend to spill over the allocated area when many digits are > used. Would you consider using 'k' for 1000 so they don't? > > And do you you have a good idea to stop the digits spilling over when > zoomed in with the Spectrum display? That would be good too. > I've got it now. It was pretty hard to get it (hopefully) right. I have it implemented the rulers dynamically sized, refresh works also now. It's quite a problem to remember all of my changes. I still try: 1) track.cpp: Track::Track(DirManager * projDirManager) : mDirManager(projDirManager), vrulerSize(36,0) 2) track.h: class AUDACITY_DLL_API Track: public XMLTagHandler { ... public: wxSize vrulerSize; 3) trackartist.cpp: t->vrulerSize = vruler->mRect.GetSize(); } ... int TrackArtist::GetWaveYPos(float value, int height, bool dB, float dBr) 4) trackartist.h: Ruler *GetVRuler() {return vruler;} int GetVRulerWidth() const; private: ... 5) trackpanel.cpp: TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id, ... mAutoScrolling(false), vrulerSize(36,0) ... UpdateVRulerRect(); } trackRect.y += t->GetHeight(); } /// Draw a three-level highlight gradient around the focused track. void TrackPanel::HighlightFocusedTrack(wxDC * dc, const wxRect r) { ... void TrackPanel::DrawOutside(Track * t, wxDC * dc, const wxRect rec, const int labelw, const int vrul, const wxRect trackRect, int index) { wxRect r = rec; DrawOutsideOfTrack(t, dc, r); r.x += kLeftInset; r.y += kTopInset; r.width -= kLeftInset * 2; r.height -= kTopInset; mLastDrawnTrackRect = r; dc->SetTextForeground(theTheme.Colour( clrTrackPanelText )); bool bIsWave = (t->GetKind() == Track::Wave); mTrackInfo.DrawBackground(dc, r, t->GetSelected(), bIsWave, labelw, vrul); ... void TrackPanel::UpdateVRulerRect() { TrackListIterator iter(mTracks); Track *t = iter.First(); if (t) { wxSize s=t->vrulerSize; while (t) { if (s.x < t->vrulerSize.x) s.x = t->vrulerSize.x; if (s.y < t->vrulerSize.y) s.y = t->vrulerSize.y; t = iter.Next(); } if (vrulerSize != s) { vrulerSize = s; Refresh(); mRuler->SetLeftOffset(GetLeftOffset()-1); // bevel on AdornedRuler mRuler->Refresh(); } } } ... int TrackPanel::GetVRulerWidth() const { //return 36; return vrulerSize.x; } int TrackInfo::GetTitleWidth() const { return 100; TrackPanel *parent=(TrackPanel*)pParent; if (parent) return 100;//+parent->vrulerSize.x; return 100; } void TrackInfo::DrawBackground(wxDC * dc, const wxRect r, bool bSelected, bool bHasMuteSolo, const int labelw, const int vrul) { // fill in label wxRect fill = r; fill.width = labelw-4; AColor::MediumTrackInfo(dc, bSelected); dc->DrawRectangle(fill); if( bHasMuteSolo ) { fill=wxRect( r.x+1, r.y+17, vrul-6, 32); AColor::BevelTrackInfo( *dc, true, fill ); fill=wxRect( r.x+1, r.y+67, fill.width, r.height-87); AColor::BevelTrackInfo( *dc, true, fill ); } else { fill=wxRect( r.x+1, r.y+17, vrul-6, r.height-37); AColor::BevelTrackInfo( *dc, true, fill ); } } 6) trackpanel.h: class TrackInfo { public: TrackInfo(wxWindow * pParentIn); ~TrackInfo(); int GetTitleWidth() const; ... void DrawBackground(wxDC * dc, const wxRect r, bool bSelected, bool bHasMuteSolo, const int labelw, const int vrul); ... class TrackPanel:public wxPanel { ... public: void UpdateVRulerRect(); private: int GetVRulerWidth() const; public: wxSize vrulerSize; > When zooming in on 'Spectrum', more digits get used so that you know > where you are. On 'Spectrum log(f)' you soon lose any indication of > the frequency you are at. Neither are ideal. Any good ideas to fix > both? (I think I just repeated myself!) > That's my next quest! But probably not any more this night. ;-) Cheers, Andreas |