Move some constants and GetVRulerOffset() out of TrackPanel.h

This commit is contained in:
Paul Licameli 2019-06-17 08:49:58 -04:00
parent 98f322d685
commit 4c5b65d7f6
7 changed files with 50 additions and 44 deletions

View File

@ -84,7 +84,6 @@ audio tracks.
#include "prefs/TracksPrefs.h"
#include "prefs/WaveformSettings.h"
#include "Spectrum.h"
#include "TrackPanel.h"
#include "ViewInfo.h"
#include "widgets/Ruler.h"
#include "AllThemeResources.h"

View File

@ -915,6 +915,14 @@ const TrackInfo::TCPLine defaultWaveTrackTCPLines[] = {
};
TCPLines waveTrackTCPLines{ RANGE(defaultWaveTrackTCPLines) };
#ifdef USE_MIDI
enum : int {
// PRL: was it correct to include the margin?
kMidiCellWidth = ( ( kTrackInfoWidth + kLeftMargin ) / 4) - 2,
kMidiCellHeight = kTrackInfoBtnSize
};
#endif
const TrackInfo::TCPLine defaultNoteTrackTCPLines[] = {
COMMON_ITEMS
#ifdef EXPERIMENTAL_MIDI_OUT
@ -1245,7 +1253,7 @@ void TrackPanel::DrawEverythingElse(TrackPanelDrawingContext &context,
if (region.Contains(
0, trackRect.y, GetLeftOffset(), trackRect.height)) {
wxRect rect{
GetVRulerOffset(),
mViewInfo->GetVRulerOffset(),
trackRect.y,
GetVRulerWidth() + 1,
trackRect.height - kSeparatorThickness
@ -1764,7 +1772,7 @@ void TrackPanel::DrawOutside
rect.height -= kSeparatorThickness;
int labelw = GetLabelWidth();
int vrul = GetVRulerOffset();
int vrul = mViewInfo->GetVRulerOffset();
TrackInfo::DrawBackground( dc, rect, t->GetSelected(), vrul );
@ -1772,7 +1780,7 @@ void TrackPanel::DrawOutside
// Draw sync-lock tiles in ruler area.
//if (t->IsSyncLockSelected()) {
// wxRect tileFill = rect;
// tileFill.x = GetVRulerOffset();
// tileFill.x = mViewInfo->GetVRulerOffset();
// tileFill.width = GetVRulerWidth();
// TrackArt::DrawSyncLockTiles(dc, tileFill);
//}
@ -1962,7 +1970,7 @@ void TrackPanel::UpdateTrackVRuler(const Track *t)
if (!t)
return;
wxRect rect(GetVRulerOffset(),
wxRect rect(mViewInfo->GetVRulerOffset(),
kTopMargin,
GetVRulerWidth(),
0);
@ -2336,6 +2344,11 @@ int TrackPanel::GetVRulerWidth() const
return vrulerSize.x;
}
int TrackPanel::GetLabelWidth() const
{
return mViewInfo->GetVRulerOffset() + GetVRulerWidth();
}
/// Displays the bounds of the selection in the status bar.
void TrackPanel::DisplaySelection()
{

View File

@ -216,38 +216,6 @@ namespace TrackInfo
const int DragThreshold = 3;// Anything over 3 pixels is a drag, else a click.
// See big pictorial comment in TrackPanel for explanation of these numbers
enum : int {
kLeftInset = 4,
kRightInset = kLeftInset,
kTopInset = 4,
kShadowThickness = 1,
kBorderThickness = 1,
kTopMargin = kTopInset + kBorderThickness,
kBottomMargin = kShadowThickness + kBorderThickness,
kLeftMargin = kLeftInset + kBorderThickness,
kRightMargin = kRightInset + kShadowThickness + kBorderThickness,
kSeparatorThickness = kBottomMargin + kTopMargin,
};
enum : int {
kTrackInfoWidth = 100 - kLeftMargin,
kTrackInfoBtnSize = 18, // widely used dimension, usually height
kTrackInfoSliderHeight = 25,
kTrackInfoSliderWidth = 84,
kTrackInfoSliderAllowance = 5,
kTrackInfoSliderExtra = 5,
};
#ifdef USE_MIDI
enum : int {
// PRL: was it correct to include the margin?
kMidiCellWidth = ( ( kTrackInfoWidth + kLeftMargin ) / 4) - 2,
kMidiCellHeight = kTrackInfoBtnSize
};
#endif
class AUDACITY_DLL_API TrackPanel final
: public CellularPanel
, public NonKeystrokeInterceptingWindow
@ -361,11 +329,9 @@ protected:
std::shared_ptr<TrackPanelNode> Root() override;
int GetVRulerWidth() const;
int GetVRulerOffset() const { return kTrackInfoWidth + kLeftMargin; }
public:
int GetLabelWidth() const
{ return GetVRulerOffset() + GetVRulerWidth(); }
int GetLabelWidth() const;
// JKC Nov-2011: These four functions only used from within a dll such as mod-track-panel
// They work around some messy problems with constructors.

View File

@ -28,6 +28,29 @@
class AudacityProject;
// See big pictorial comment in TrackPanel.cpp for explanation of these numbers
enum : int {
kLeftInset = 4,
kRightInset = kLeftInset,
kTopInset = 4,
kShadowThickness = 1,
kBorderThickness = 1,
kTopMargin = kTopInset + kBorderThickness,
kBottomMargin = kShadowThickness + kBorderThickness,
kLeftMargin = kLeftInset + kBorderThickness,
kRightMargin = kRightInset + kShadowThickness + kBorderThickness,
kSeparatorThickness = kBottomMargin + kTopMargin,
};
enum : int {
kTrackInfoWidth = 100 - kLeftMargin,
kTrackInfoBtnSize = 18, // widely used dimension, usually height
kTrackInfoSliderHeight = 25,
kTrackInfoSliderWidth = 84,
kTrackInfoSliderAllowance = 5,
kTrackInfoSliderExtra = 5,
};
// The subset of ViewInfo information (other than selection)
// that is sufficient for purposes of TrackArtist,
// and for computing conversions between track times and pixel positions.
@ -209,6 +232,8 @@ public:
ViewInfo(double start, double screenDuration, double pixelsPerSecond);
int GetVRulerOffset() const { return kTrackInfoWidth + kLeftMargin; }
static int UpdateScrollPrefsID();
void UpdatePrefs() override;
void UpdateSelectedPrefs( int id ) override;

View File

@ -717,11 +717,12 @@ void GetInfoCommand::ExploreTrackPanel( const CommandContext &context,
{
AudacityProject * pProj = &context.project;
auto &tp = TrackPanel::Get( *pProj );
auto &viewInfo = *tp.mViewInfo;
wxRect trackRect = pWin->GetRect();
for ( auto t : TrackList::Get( *pProj ).Any() + IsVisibleTrack{ pProj } ) {
trackRect.y = t->GetY() - tp.mViewInfo->vpos;
trackRect.y = t->GetY() - viewInfo.vpos;
trackRect.height = t->GetHeight();
#if 0
@ -760,7 +761,7 @@ void GetInfoCommand::ExploreTrackPanel( const CommandContext &context,
R.height -= kTopInset;
int labelw = pTP->GetLabelWidth();
int vrul = pTP->GetVRulerOffset();
//int vrul = viewInfo.GetVRulerOffset();
bool bIsWave = true;
//mTrackInfo.DrawBackground(dc, R, t->GetSelected(), bIsWave, labelw, vrul);
@ -776,7 +777,7 @@ void GetInfoCommand::ExploreTrackPanel( const CommandContext &context,
// The VRuler.
{
wxRect R = trackRect;
R.x += tp.GetVRulerOffset();
R.x += viewInfo.GetVRulerOffset();
R.y += kTopMargin;
R.width = tp.GetVRulerWidth();
R.height -= (kTopMargin + kBottomMargin);

View File

@ -20,6 +20,7 @@
#include "../../../../TrackPanel.h" // for TrackInfo
#include "../../../../UndoManager.h"
#include "../../../../NoteTrack.h"
#include "../../../../ViewInfo.h"
VelocitySliderHandle::VelocitySliderHandle
( SliderFn sliderFn, const wxRect &rect,

View File

@ -11,10 +11,11 @@ Paul Licameli split from TrackPanel.cpp
#include "../../Audacity.h"
#include "TrackVRulerControls.h"
#include "../../TrackPanel.h"
#include "../../Track.h"
#include "../../ViewInfo.h"
#include <wx/cursor.h>
#include <wx/dc.h>
#include <wx/translation.h>
TrackVRulerControls::TrackVRulerControls( std::shared_ptr<Track> pTrack )