mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-11 09:31:13 +02:00
Simplify the track rectangle calculations in TrackArtist
This commit is contained in:
parent
49dd6002d3
commit
8d02134d6a
@ -78,6 +78,7 @@ audio tracks.
|
|||||||
#include "prefs/TracksPrefs.h"
|
#include "prefs/TracksPrefs.h"
|
||||||
#include "prefs/WaveformSettings.h"
|
#include "prefs/WaveformSettings.h"
|
||||||
#include "Spectrum.h"
|
#include "Spectrum.h"
|
||||||
|
#include "TrackPanel.h"
|
||||||
#include "ViewInfo.h"
|
#include "ViewInfo.h"
|
||||||
#include "widgets/Ruler.h"
|
#include "widgets/Ruler.h"
|
||||||
#include "Theme.h"
|
#include "Theme.h"
|
||||||
@ -165,11 +166,6 @@ int TrackArtist::GetBottom(NoteTrack *t, const wxRect &rect)
|
|||||||
|
|
||||||
TrackArtist::TrackArtist()
|
TrackArtist::TrackArtist()
|
||||||
{
|
{
|
||||||
mMarginLeft = 0;
|
|
||||||
mMarginTop = 0;
|
|
||||||
mMarginRight = 0;
|
|
||||||
mMarginBottom = 0;
|
|
||||||
|
|
||||||
mdBrange = ENV_DB_RANGE;
|
mdBrange = ENV_DB_RANGE;
|
||||||
mShowClipping = false;
|
mShowClipping = false;
|
||||||
mSampleDisplay = 1;// Stem plots by default.
|
mSampleDisplay = 1;// Stem plots by default.
|
||||||
@ -230,27 +226,20 @@ void TrackArtist::SetColours( int iColorIndex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackArtist::SetMargins(int left, int top, int right, int bottom)
|
|
||||||
{
|
|
||||||
mMarginLeft = left;
|
|
||||||
mMarginTop = top;
|
|
||||||
mMarginRight = right;
|
|
||||||
mMarginBottom = bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackArtist::DrawTracks(TrackPanelDrawingContext &context,
|
void TrackArtist::DrawTracks(TrackPanelDrawingContext &context,
|
||||||
const TrackList * tracks,
|
const TrackList * tracks,
|
||||||
const wxRegion & reg,
|
const wxRegion & reg,
|
||||||
const wxRect & rect,
|
const wxRect & clip, int leftOffset,
|
||||||
const wxRect & clip,
|
|
||||||
const SelectedRegion &selectedRegion,
|
const SelectedRegion &selectedRegion,
|
||||||
const ZoomInfo &zoomInfo,
|
const ZoomInfo &zoomInfo,
|
||||||
bool drawEnvelope,
|
bool drawEnvelope,
|
||||||
bool bigPoints,
|
bool bigPoints,
|
||||||
bool drawSliders)
|
bool drawSliders)
|
||||||
{
|
{
|
||||||
// Copy the horizontal extent of rect; will later change only the vertical.
|
// Fix the horizontal extent; will later change only the vertical extent.
|
||||||
wxRect teamRect = rect;
|
wxRect teamRect{
|
||||||
|
clip.x + leftOffset, 0, clip.width - (leftOffset + kRightMargin), 0
|
||||||
|
};
|
||||||
|
|
||||||
bool hasSolo = false;
|
bool hasSolo = false;
|
||||||
for (const Track *t : *tracks) {
|
for (const Track *t : *tracks) {
|
||||||
@ -262,19 +251,6 @@ void TrackArtist::DrawTracks(TrackPanelDrawingContext &context,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DEBUG_CLIENT_AREA)
|
|
||||||
// Change the +0 to +1 or +2 to see the bounding box
|
|
||||||
mMarginLeft = 1+0; mMarginTop = 5+0; mMarginRight = 6+0; mMarginBottom = 2+0;
|
|
||||||
|
|
||||||
// This just shows what the passed in rectangles enclose
|
|
||||||
dc.SetPen(wxColour(*wxGREEN));
|
|
||||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
|
||||||
dc.DrawRectangle(rect);
|
|
||||||
dc.SetPen(wxColour(*wxBLUE));
|
|
||||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
|
||||||
dc.DrawRectangle(clip);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gPrefs->Read(wxT("/GUI/ShowTrackNameInWaveform"), &mbShowTrackNameInWaveform, false);
|
gPrefs->Read(wxT("/GUI/ShowTrackNameInWaveform"), &mbShowTrackNameInWaveform, false);
|
||||||
|
|
||||||
for(auto leader : tracks->Leaders()) {
|
for(auto leader : tracks->Leaders()) {
|
||||||
@ -293,15 +269,6 @@ void TrackArtist::DrawTracks(TrackPanelDrawingContext &context,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
for (auto t : group) {
|
for (auto t : group) {
|
||||||
#if defined(DEBUG_CLIENT_AREA)
|
|
||||||
// Filled rectangle to show the interior of the client area
|
|
||||||
wxRect zr = trackRect;
|
|
||||||
zr.x+=1; zr.y+=5; zr.width-=7; zr.height-=7;
|
|
||||||
dc.SetPen(*wxCYAN_PEN);
|
|
||||||
dc.SetBrush(*wxRED_BRUSH);
|
|
||||||
dc.DrawRectangle(zr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// For various reasons, the code will break if we display one
|
// For various reasons, the code will break if we display one
|
||||||
// of a stereo pair of tracks but not the other - for example,
|
// of a stereo pair of tracks but not the other - for example,
|
||||||
// if you try to edit the envelope of one track when its linked
|
// if you try to edit the envelope of one track when its linked
|
||||||
@ -313,10 +280,10 @@ void TrackArtist::DrawTracks(TrackPanelDrawingContext &context,
|
|||||||
if (teamRect.Intersects(clip) && reg.Contains(teamRect)) {
|
if (teamRect.Intersects(clip) && reg.Contains(teamRect)) {
|
||||||
t = t->SubstitutePendingChangedTrack().get();
|
t = t->SubstitutePendingChangedTrack().get();
|
||||||
wxRect trackRect {
|
wxRect trackRect {
|
||||||
rect.x + mMarginLeft,
|
teamRect.x,
|
||||||
t->GetY() - zoomInfo.vpos + mMarginTop,
|
t->GetY() - zoomInfo.vpos + kTopMargin,
|
||||||
rect.width - (mMarginLeft + mMarginRight),
|
teamRect.width,
|
||||||
t->GetHeight() - (mMarginTop + mMarginBottom)
|
t->GetHeight() - (kTopMargin + kBottomMargin)
|
||||||
};
|
};
|
||||||
DrawTrack(context, t, trackRect,
|
DrawTrack(context, t, trackRect,
|
||||||
selectedRegion, zoomInfo,
|
selectedRegion, zoomInfo,
|
||||||
|
@ -57,7 +57,7 @@ class AUDACITY_DLL_API TrackArtist {
|
|||||||
void DrawTracks(TrackPanelDrawingContext &context,
|
void DrawTracks(TrackPanelDrawingContext &context,
|
||||||
const TrackList *tracks,
|
const TrackList *tracks,
|
||||||
const wxRegion & reg,
|
const wxRegion & reg,
|
||||||
const wxRect & rect, const wxRect & clip,
|
const wxRect &clip, int leftOffset,
|
||||||
const SelectedRegion &selectedRegion, const ZoomInfo &zoomInfo,
|
const SelectedRegion &selectedRegion, const ZoomInfo &zoomInfo,
|
||||||
bool drawEnvelope, bool bigPoints, bool drawSliders);
|
bool drawEnvelope, bool bigPoints, bool drawSliders);
|
||||||
|
|
||||||
@ -73,8 +73,6 @@ class AUDACITY_DLL_API TrackArtist {
|
|||||||
|
|
||||||
void UpdateVRuler(const Track *t, const wxRect & rect);
|
void UpdateVRuler(const Track *t, const wxRect & rect);
|
||||||
|
|
||||||
void SetMargins(int left, int top, int right, int bottom);
|
|
||||||
|
|
||||||
void UpdatePrefs();
|
void UpdatePrefs();
|
||||||
|
|
||||||
void SetBackgroundBrushes(wxBrush unselectedBrushIn, wxBrush selectedBrushIn,
|
void SetBackgroundBrushes(wxBrush unselectedBrushIn, wxBrush selectedBrushIn,
|
||||||
@ -182,11 +180,6 @@ class AUDACITY_DLL_API TrackArtist {
|
|||||||
int mSampleDisplay;
|
int mSampleDisplay;
|
||||||
bool mbShowTrackNameInWaveform; // "/GUI/ShowTrackNameInWaveform"
|
bool mbShowTrackNameInWaveform; // "/GUI/ShowTrackNameInWaveform"
|
||||||
|
|
||||||
int mMarginLeft;
|
|
||||||
int mMarginTop;
|
|
||||||
int mMarginRight;
|
|
||||||
int mMarginBottom;
|
|
||||||
|
|
||||||
wxBrush blankBrush;
|
wxBrush blankBrush;
|
||||||
wxBrush unselectedBrush;
|
wxBrush unselectedBrush;
|
||||||
wxBrush selectedBrush;
|
wxBrush selectedBrush;
|
||||||
|
@ -242,8 +242,6 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
|
|||||||
|
|
||||||
mTrackArtist = std::make_unique<TrackArtist>();
|
mTrackArtist = std::make_unique<TrackArtist>();
|
||||||
|
|
||||||
mTrackArtist->SetMargins(1, kTopMargin, kRightMargin, kBottomMargin);
|
|
||||||
|
|
||||||
mTimeCount = 0;
|
mTimeCount = 0;
|
||||||
mTimer.parent = this;
|
mTimer.parent = this;
|
||||||
// Timer is started after the window is visible
|
// Timer is started after the window is visible
|
||||||
@ -1053,13 +1051,6 @@ void TrackPanel::DrawTracks(wxDC * dc)
|
|||||||
|
|
||||||
const wxRect clip = GetRect();
|
const wxRect clip = GetRect();
|
||||||
|
|
||||||
wxRect panelRect = clip;
|
|
||||||
panelRect.y = -mViewInfo->vpos;
|
|
||||||
|
|
||||||
wxRect tracksRect = panelRect;
|
|
||||||
tracksRect.x += GetLabelWidth();
|
|
||||||
tracksRect.width -= GetLabelWidth();
|
|
||||||
|
|
||||||
ToolsToolBar *pTtb = mListener->TP_GetToolsToolBar();
|
ToolsToolBar *pTtb = mListener->TP_GetToolsToolBar();
|
||||||
bool bMultiToolDown = pTtb->IsDown(multiTool);
|
bool bMultiToolDown = pTtb->IsDown(multiTool);
|
||||||
bool envelopeFlag = pTtb->IsDown(envelopeTool) || bMultiToolDown;
|
bool envelopeFlag = pTtb->IsDown(envelopeTool) || bMultiToolDown;
|
||||||
@ -1070,7 +1061,7 @@ void TrackPanel::DrawTracks(wxDC * dc)
|
|||||||
|
|
||||||
// The track artist actually draws the stuff inside each track
|
// The track artist actually draws the stuff inside each track
|
||||||
mTrackArtist->DrawTracks(context, GetTracks(),
|
mTrackArtist->DrawTracks(context, GetTracks(),
|
||||||
region, tracksRect, clip,
|
region, clip, GetLeftOffset(),
|
||||||
mViewInfo->selectedRegion, *mViewInfo,
|
mViewInfo->selectedRegion, *mViewInfo,
|
||||||
envelopeFlag, bigPointsFlag, sliderFlag);
|
envelopeFlag, bigPointsFlag, sliderFlag);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user