mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-03 17:19:43 +02:00
GetVRulerWidth, GetLabelWidth, GetLeftOffset out of TrackPanel.h...
... And some things demoted from ViewInfo to ZoomInfo, related to x coordinates only
This commit is contained in:
parent
baf31dd72e
commit
f87dfd43c1
@ -536,18 +536,20 @@ namespace
|
||||
wxCoord GetPlayHeadX( const AudacityProject *pProject )
|
||||
{
|
||||
const auto &tp = TrackPanel::Get( *pProject );
|
||||
const auto &viewInfo = ViewInfo::Get( *pProject );
|
||||
int width;
|
||||
tp.GetTracksUsableArea(&width, NULL);
|
||||
return tp.GetLeftOffset()
|
||||
return viewInfo.GetLeftOffset()
|
||||
+ width * TracksPrefs::GetPinnedHeadPositionPreference();
|
||||
}
|
||||
|
||||
double GetPlayHeadFraction( const AudacityProject *pProject, wxCoord xx )
|
||||
{
|
||||
const auto &tp = TrackPanel::Get( *pProject );
|
||||
const auto &viewInfo = ViewInfo::Get( *pProject );
|
||||
int width;
|
||||
tp.GetTracksUsableArea(&width, NULL);
|
||||
auto fraction = (xx - tp.GetLeftOffset()) / double(width);
|
||||
auto fraction = (xx - viewInfo.GetLeftOffset()) / double(width);
|
||||
return std::max(0.0, std::min(1.0, fraction));
|
||||
}
|
||||
|
||||
@ -1710,10 +1712,11 @@ void AdornedRulerPanel::UpdateQuickPlayPos(wxCoord &mousePosX, bool shiftDown)
|
||||
{
|
||||
// Keep Quick-Play within usable track area.
|
||||
const auto &tp = TrackPanel::Get( *mProject );
|
||||
const auto &viewInfo = ViewInfo::Get( *mProject );
|
||||
int width;
|
||||
tp.GetTracksUsableArea(&width, NULL);
|
||||
mousePosX = std::max(mousePosX, tp.GetLeftOffset());
|
||||
mousePosX = std::min(mousePosX, tp.GetLeftOffset() + width - 1);
|
||||
mousePosX = std::max(mousePosX, viewInfo.GetLeftOffset());
|
||||
mousePosX = std::min(mousePosX, viewInfo.GetLeftOffset() + width - 1);
|
||||
|
||||
mQuickPlayPosUnsnapped = mQuickPlayPos = Pos2Time(mousePosX);
|
||||
|
||||
|
@ -414,7 +414,7 @@ unsigned operator()
|
||||
// We're converting pixel positions to times,
|
||||
// counting pixels from the left edge of the track.
|
||||
auto &trackPanel = TrackPanel::Get( *pProject );
|
||||
int trackLeftEdge = trackPanel.GetLeftOffset();
|
||||
int trackLeftEdge = viewInfo.GetLeftOffset();
|
||||
|
||||
// Time corresponding to mouse position
|
||||
wxCoord xx;
|
||||
@ -769,7 +769,7 @@ void ProjectWindow::Init()
|
||||
auto hs = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
|
||||
|
||||
// Bottom scrollbar
|
||||
hs->Add(trackPanel.GetLeftOffset() - 1, 0);
|
||||
hs->Add(viewInfo.GetLeftOffset() - 1, 0);
|
||||
hs->Add(mHsbar, 1, wxALIGN_BOTTOM);
|
||||
hs->Add(mVsbar->GetSize().GetWidth(), 0);
|
||||
bs->Add(hs.release(), 0, wxEXPAND | wxALIGN_LEFT);
|
||||
@ -791,7 +791,7 @@ void ProjectWindow::Init()
|
||||
trackPanel.SetFocus();
|
||||
|
||||
FixScrollbars();
|
||||
ruler.SetLeftOffset(trackPanel.GetLeftOffset()); // bevel on AdornedRuler
|
||||
ruler.SetLeftOffset(viewInfo.GetLeftOffset()); // bevel on AdornedRuler
|
||||
|
||||
//
|
||||
// Set the Icon
|
||||
|
@ -349,7 +349,8 @@ wxSize TrackPanel::GetTracksUsableArea() const
|
||||
{
|
||||
auto size = GetSize();
|
||||
return {
|
||||
std::max( 0, size.GetWidth() - ( GetLeftOffset() + kRightMargin ) ),
|
||||
std::max( 0,
|
||||
size.GetWidth() - ( mViewInfo->GetLeftOffset() + kRightMargin ) ),
|
||||
size.GetHeight()
|
||||
};
|
||||
}
|
||||
@ -839,7 +840,8 @@ void TrackPanel::OnMouseEvent(wxMouseEvent & event)
|
||||
|
||||
double TrackPanel::GetMostRecentXPos()
|
||||
{
|
||||
return mViewInfo->PositionToTime(MostRecentXCoord(), GetLabelWidth());
|
||||
return mViewInfo->PositionToTime(
|
||||
MostRecentXCoord(), mViewInfo->GetLabelWidth());
|
||||
}
|
||||
|
||||
void TrackPanel::RefreshTrack(Track *trk, bool refreshbacking)
|
||||
@ -934,7 +936,7 @@ void TrackPanel::DrawTracks(wxDC * dc)
|
||||
return (pt && pt->GetSolo());
|
||||
} );
|
||||
|
||||
mTrackArtist->leftOffset = GetLeftOffset();
|
||||
mTrackArtist->leftOffset = mViewInfo->GetLeftOffset();
|
||||
mTrackArtist->drawEnvelope = envelopeFlag;
|
||||
mTrackArtist->bigPoints = bigPointsFlag;
|
||||
mTrackArtist->drawSliders = sliderFlag;
|
||||
@ -1008,11 +1010,11 @@ void TrackPanel::DrawEverythingElse(TrackPanelDrawingContext &context,
|
||||
trackRect.y = view.GetY() - mViewInfo->vpos + kTopMargin;
|
||||
trackRect.height = view.GetHeight();
|
||||
if (region.Contains(
|
||||
0, trackRect.y, GetLeftOffset(), trackRect.height)) {
|
||||
0, trackRect.y, mViewInfo->GetLeftOffset(), trackRect.height)) {
|
||||
wxRect rect{
|
||||
mViewInfo->GetVRulerOffset(),
|
||||
trackRect.y,
|
||||
GetVRulerWidth() + 1,
|
||||
mViewInfo->GetVRulerWidth() + 1,
|
||||
trackRect.height - kSeparatorThickness
|
||||
};
|
||||
TrackArt::DrawVRuler(context, channel, rect, bSelected);
|
||||
@ -1067,7 +1069,7 @@ void TrackPanel::DrawOutside
|
||||
// Now exclude the resizer below
|
||||
rect.height -= kSeparatorThickness;
|
||||
|
||||
int labelw = GetLabelWidth();
|
||||
int labelw = mViewInfo->GetLabelWidth();
|
||||
int vrul = mViewInfo->GetVRulerOffset();
|
||||
|
||||
TrackInfo::DrawBackground( dc, rect, t->GetSelected(), vrul );
|
||||
@ -1077,7 +1079,7 @@ void TrackPanel::DrawOutside
|
||||
//if (t->IsSyncLockSelected()) {
|
||||
// wxRect tileFill = rect;
|
||||
// tileFill.x = mViewInfo->GetVRulerOffset();
|
||||
// tileFill.width = GetVRulerWidth();
|
||||
// tileFill.width = mViewInfo->GetVRulerWidth();
|
||||
// TrackArt::DrawSyncLockTiles(dc, tileFill);
|
||||
//}
|
||||
|
||||
@ -1268,7 +1270,7 @@ void TrackPanel::UpdateTrackVRuler(const Track *t)
|
||||
|
||||
wxRect rect(mViewInfo->GetVRulerOffset(),
|
||||
kTopMargin,
|
||||
GetVRulerWidth(),
|
||||
mViewInfo->GetVRulerWidth(),
|
||||
0);
|
||||
|
||||
|
||||
@ -1289,7 +1291,8 @@ void TrackPanel::UpdateVRulerSize()
|
||||
|
||||
if (mViewInfo->GetVRulerWidth() != s.GetWidth()) {
|
||||
mViewInfo->SetVRulerWidth( s.GetWidth() );
|
||||
mRuler->SetLeftOffset(GetLeftOffset()); // bevel on AdornedRuler
|
||||
mRuler->SetLeftOffset(
|
||||
mViewInfo->GetLeftOffset()); // bevel on AdornedRuler
|
||||
mRuler->Refresh();
|
||||
}
|
||||
}
|
||||
@ -1313,7 +1316,7 @@ void TrackPanel::ScrollIntoView(double pos)
|
||||
|
||||
void TrackPanel::ScrollIntoView(int x)
|
||||
{
|
||||
ScrollIntoView(mViewInfo->PositionToTime(x, GetLeftOffset()));
|
||||
ScrollIntoView(mViewInfo->PositionToTime(x, mViewInfo->GetLeftOffset()));
|
||||
}
|
||||
|
||||
void TrackPanel::OnTrackMenu(Track *t)
|
||||
@ -1569,7 +1572,8 @@ struct Subgroup final : TrackPanelGroup {
|
||||
explicit Subgroup( TrackPanel &panel ) : mPanel{ panel } {}
|
||||
Subdivision Children( const wxRect &rect ) override
|
||||
{
|
||||
wxCoord yy = -mPanel.GetViewInfo()->vpos;
|
||||
const auto &viewInfo = *mPanel.GetViewInfo();
|
||||
wxCoord yy = -viewInfo.vpos;
|
||||
Refinement refinement;
|
||||
|
||||
auto &tracks = *mPanel.GetTracks();
|
||||
@ -1585,7 +1589,7 @@ struct Subgroup final : TrackPanelGroup {
|
||||
}
|
||||
refinement.emplace_back( yy,
|
||||
std::make_shared< ResizingChannelGroup >(
|
||||
leader->SharedPointer(), mPanel.GetLeftOffset() )
|
||||
leader->SharedPointer(), viewInfo.GetLeftOffset() )
|
||||
);
|
||||
yy += height;
|
||||
}
|
||||
@ -1637,16 +1641,6 @@ wxRect TrackPanel::FindTrackRect( const Track * target )
|
||||
} );
|
||||
}
|
||||
|
||||
int TrackPanel::GetVRulerWidth() const
|
||||
{
|
||||
return mViewInfo->GetVRulerWidth();
|
||||
}
|
||||
|
||||
int TrackPanel::GetLabelWidth() const
|
||||
{
|
||||
return mViewInfo->GetVRulerOffset() + GetVRulerWidth();
|
||||
}
|
||||
|
||||
/// Displays the bounds of the selection in the status bar.
|
||||
void TrackPanel::DisplaySelection()
|
||||
{
|
||||
|
@ -103,8 +103,6 @@ class AUDACITY_DLL_API TrackPanel final
|
||||
void OnProjectSettingsChange(wxCommandEvent &event);
|
||||
void OnTrackFocusChange( wxCommandEvent &event );
|
||||
|
||||
int GetLeftOffset() const { return GetLabelWidth() + 1;}
|
||||
|
||||
wxSize GetTracksUsableArea() const;
|
||||
|
||||
// Width and height, relative to upper left corner at (GetLeftOffset(), 0)
|
||||
@ -173,11 +171,7 @@ protected:
|
||||
// area into cells
|
||||
std::shared_ptr<TrackPanelNode> Root() override;
|
||||
|
||||
int GetVRulerWidth() const;
|
||||
|
||||
public:
|
||||
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.
|
||||
const TrackList * GetTracks() const { return mTracks.get(); }
|
||||
|
@ -21,20 +21,14 @@
|
||||
|
||||
// See big pictorial comment in TrackPanel.cpp for explanation of these numbers
|
||||
enum : int {
|
||||
kLeftInset = 4,
|
||||
kRightInset = kLeftInset,
|
||||
// constants related to y coordinates in the track panel
|
||||
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,
|
||||
@ -106,8 +100,6 @@ public:
|
||||
int GetHeight() const { return mHeight; }
|
||||
void SetHeight( int height ) { mHeight = height; }
|
||||
|
||||
int GetVRulerOffset() const { return kTrackInfoWidth + kLeftMargin; }
|
||||
|
||||
static int UpdateScrollPrefsID();
|
||||
void UpdatePrefs() override;
|
||||
void UpdateSelectedPrefs( int id ) override;
|
||||
|
@ -22,6 +22,20 @@
|
||||
|
||||
class AudacityProject;
|
||||
|
||||
// See big pictorial comment in TrackPanel.cpp for explanation of these numbers
|
||||
enum : int {
|
||||
// Constants related to x coordinates in the track panel
|
||||
kBorderThickness = 1,
|
||||
kShadowThickness = 1,
|
||||
|
||||
kLeftInset = 4,
|
||||
kRightInset = kLeftInset,
|
||||
kLeftMargin = kLeftInset + kBorderThickness,
|
||||
kRightMargin = kRightInset + kShadowThickness + kBorderThickness,
|
||||
|
||||
kTrackInfoWidth = 100 - kLeftMargin,
|
||||
};
|
||||
|
||||
// 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.
|
||||
@ -83,6 +97,9 @@ public:
|
||||
|
||||
int GetVRulerWidth() const { return mVRulerWidth; }
|
||||
void SetVRulerWidth( int width ) { mVRulerWidth = width; }
|
||||
int GetVRulerOffset() const { return kTrackInfoWidth + kLeftMargin; }
|
||||
int GetLabelWidth() const { return GetVRulerOffset() + GetVRulerWidth(); }
|
||||
int GetLeftOffset() const { return GetLabelWidth() + 1;}
|
||||
|
||||
bool ZoomInAvailable() const;
|
||||
bool ZoomOutAvailable() const;
|
||||
|
@ -761,7 +761,7 @@ void GetInfoCommand::ExploreTrackPanel( const CommandContext &context,
|
||||
R.width -= kLeftInset * 2;
|
||||
R.height -= kTopInset;
|
||||
|
||||
int labelw = pTP->GetLabelWidth();
|
||||
int labelw = viewInfo.GetLabelWidth();
|
||||
//int vrul = viewInfo.GetVRulerOffset();
|
||||
bool bIsWave = true;
|
||||
//mTrackInfo.DrawBackground(dc, R, t->GetSelected(), bIsWave, labelw, vrul);
|
||||
@ -780,7 +780,7 @@ void GetInfoCommand::ExploreTrackPanel( const CommandContext &context,
|
||||
wxRect R = trackRect;
|
||||
R.x += viewInfo.GetVRulerOffset();
|
||||
R.y += kTopMargin;
|
||||
R.width = tp.GetVRulerWidth();
|
||||
R.width = viewInfo.GetVRulerWidth();
|
||||
R.height -= (kTopMargin + kBottomMargin);
|
||||
R.SetPosition( R.GetPosition() + P );
|
||||
|
||||
|
@ -2045,7 +2045,7 @@ int LabelTrackView::DialogForLabelName(
|
||||
wxPoint position = trackPanel.FindTrackRect(trackPanel.GetFocusedTrack()).GetBottomLeft();
|
||||
// The start of the text in the text box will be roughly in line with the label's position
|
||||
// if it's a point label, or the start of its region if it's a region label.
|
||||
position.x += trackPanel.GetLabelWidth()
|
||||
position.x += viewInfo.GetLabelWidth()
|
||||
+ std::max(0, static_cast<int>(viewInfo.TimeToPosition(region.t0())))
|
||||
-40;
|
||||
position.y += 2; // just below the bottom of the track
|
||||
|
@ -54,15 +54,16 @@ unsigned EditCursorOverlay::SequenceNumber() const
|
||||
|
||||
std::pair<wxRect, bool> EditCursorOverlay::DoGetRectangle(wxSize size)
|
||||
{
|
||||
const auto &selection = ViewInfo::Get( *mProject ).selectedRegion;
|
||||
const auto &viewInfo = ViewInfo::Get( *mProject );
|
||||
const auto &selection = viewInfo.selectedRegion;
|
||||
if (!selection.isPoint()) {
|
||||
mCursorTime = -1.0;
|
||||
mNewCursorX = -1;
|
||||
}
|
||||
else {
|
||||
mCursorTime = selection.t0();
|
||||
mNewCursorX = ViewInfo::Get( *mProject ).TimeToPosition(
|
||||
mCursorTime, TrackPanel::Get( *mProject ).GetLeftOffset());
|
||||
mNewCursorX = viewInfo.TimeToPosition(
|
||||
mCursorTime, viewInfo.GetLeftOffset());
|
||||
}
|
||||
|
||||
// Excessive height in case of the ruler, but it matters little.
|
||||
|
@ -149,6 +149,7 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event)
|
||||
}
|
||||
|
||||
auto &trackPanel = TrackPanel::Get( *mProject );
|
||||
const auto &viewInfo = ViewInfo::Get( *mProject );
|
||||
int width;
|
||||
trackPanel.GetTracksUsableArea(&width, nullptr);
|
||||
|
||||
@ -158,15 +159,13 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event)
|
||||
const auto &scrubber = Scrubber::Get( *mProject );
|
||||
if (scrubber.HasMark()) {
|
||||
auto position = scrubber.GetScrubStartPosition();
|
||||
const auto offset = trackPanel.GetLeftOffset();
|
||||
if(position >= trackPanel.GetLeftOffset() &&
|
||||
const auto offset = viewInfo.GetLeftOffset();
|
||||
if(position >= viewInfo.GetLeftOffset() &&
|
||||
position < offset + width)
|
||||
mNewIndicatorX = position;
|
||||
}
|
||||
}
|
||||
else {
|
||||
const auto &viewInfo = ViewInfo::Get( *mProject );
|
||||
|
||||
// Calculate the horizontal position of the indicator
|
||||
const double playPos = viewInfo.mRecentStreamTime;
|
||||
|
||||
@ -225,7 +224,8 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event)
|
||||
window.TP_RedrawScrollbars();
|
||||
|
||||
if (onScreen)
|
||||
mNewIndicatorX = viewInfo.TimeToPosition(playPos, trackPanel.GetLeftOffset());
|
||||
mNewIndicatorX =
|
||||
viewInfo.TimeToPosition(playPos, viewInfo.GetLeftOffset());
|
||||
else
|
||||
mNewIndicatorX = -1;
|
||||
|
||||
|
@ -353,10 +353,9 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
|
||||
wxCoord position = xx;
|
||||
if (abs(mScrubStartPosition - position) >= SCRUBBING_PIXEL_TOLERANCE) {
|
||||
auto &viewInfo = ViewInfo::Get( *mProject );
|
||||
auto &trackPanel = TrackPanel::Get( *mProject );
|
||||
auto &ctb = ControlToolBar::Get( *mProject );
|
||||
double maxTime = TrackList::Get( *mProject ).GetEndTime();
|
||||
const int leftOffset = trackPanel.GetLeftOffset();
|
||||
const int leftOffset = viewInfo.GetLeftOffset();
|
||||
double time0 = std::min(maxTime,
|
||||
viewInfo.PositionToTime(mScrubStartPosition, leftOffset)
|
||||
);
|
||||
@ -605,7 +604,7 @@ void Scrubber::ContinueScrubbingPoll()
|
||||
else
|
||||
#endif
|
||||
{
|
||||
const auto origin = trackPanel.GetLeftOffset();
|
||||
const auto origin = viewInfo.GetLeftOffset();
|
||||
auto xx = position.x;
|
||||
if (!seek && !mSmoothScrollingScrub) {
|
||||
// If mouse is out-of-bounds, so that we scrub at maximum speed
|
||||
@ -1007,6 +1006,7 @@ void ScrubbingOverlay::OnTimer(wxCommandEvent &event)
|
||||
}
|
||||
else {
|
||||
TrackPanel &trackPanel = TrackPanel::Get( *mProject );
|
||||
auto &viewInfo = ViewInfo::Get( *mProject );
|
||||
int panelWidth, panelHeight;
|
||||
trackPanel.GetSize(&panelWidth, &panelHeight);
|
||||
|
||||
@ -1021,7 +1021,7 @@ void ScrubbingOverlay::OnTimer(wxCommandEvent &event)
|
||||
scrubber.IsScrollScrubbing()
|
||||
? scrubber.FindScrubSpeed( seeking,
|
||||
ViewInfo::Get( *mProject )
|
||||
.PositionToTime(position.x, trackPanel.GetLeftOffset()))
|
||||
.PositionToTime(position.x, viewInfo.GetLeftOffset()))
|
||||
: maxScrubSpeed;
|
||||
|
||||
const wxChar *format =
|
||||
@ -1073,12 +1073,13 @@ void Scrubber::DoScrub(bool seek)
|
||||
const bool scroll = ShouldScrubPinned();
|
||||
if (!wasScrubbing) {
|
||||
auto &tp = TrackPanel::Get( *mProject );
|
||||
const auto &viewInfo = ViewInfo::Get( *mProject );
|
||||
wxCoord xx = tp.ScreenToClient(::wxGetMouseState().GetPosition()).x;
|
||||
|
||||
// Limit x
|
||||
int width;
|
||||
tp.GetTracksUsableArea(&width, nullptr);
|
||||
const auto offset = tp.GetLeftOffset();
|
||||
const auto offset = viewInfo.GetLeftOffset();
|
||||
xx = (std::max(offset, std::min(offset + width - 1, xx)));
|
||||
|
||||
MarkScrubStart(xx, scroll, seek);
|
||||
|
Loading…
x
Reference in New Issue
Block a user