mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-01 08:09:41 +02:00
Move Y position, height, and minimized state into TrackView...
... and eliminate some unnecessary calls to SubstitutePendingChangedTrack, because the track and the substitute store Y and height in their shared TrackView object. Also make GetMinimizedHeight() virtual to avoid inclusion of TrackPanel.h in TrackView.cpp.
This commit is contained in:
parent
3797a5227a
commit
66e32ca35d
@ -126,11 +126,6 @@ LabelTrack::LabelTrack(const std::shared_ptr<DirManager> &projDirManager):
|
||||
SetDefaultName(_("Label Track"));
|
||||
SetName(GetDefaultName());
|
||||
|
||||
// Label tracks are narrow
|
||||
// Default is to allow two rows so that NEW users get the
|
||||
// idea that labels can 'stack' when they would overlap.
|
||||
SetHeight(73);
|
||||
|
||||
ResetFont();
|
||||
CreateCustomGlyphs();
|
||||
|
||||
|
@ -37,7 +37,6 @@
|
||||
|
||||
#include "InconsistencyException.h"
|
||||
|
||||
#include "TrackPanel.h" // For TrackInfo
|
||||
#include "AllThemeResources.h"
|
||||
|
||||
#ifdef SONIFY
|
||||
@ -123,8 +122,6 @@ NoteTrack::NoteTrack(const std::shared_ptr<DirManager> &projDirManager)
|
||||
SetDefaultName(_("Note Track"));
|
||||
SetName(GetDefaultName());
|
||||
|
||||
SetHeight( TrackInfo::DefaultNoteTrackHeight() );
|
||||
|
||||
mSeq = NULL;
|
||||
mSerializationLength = 0;
|
||||
|
||||
|
@ -32,6 +32,8 @@
|
||||
|
||||
#include "TrackPanelDrawingContext.h"
|
||||
|
||||
#include "tracks/ui/TrackView.h"
|
||||
|
||||
// Globals, so that we remember settings from session to session
|
||||
wxPrintData &gPrintData()
|
||||
{
|
||||
@ -98,7 +100,7 @@ bool AudacityPrintout::OnPrintPage(int WXUNUSED(page))
|
||||
r.x = 0;
|
||||
r.y = y;
|
||||
r.width = width;
|
||||
r.height = (int)(n->GetHeight() * scale);
|
||||
r.height = (int)(TrackView::Get( *n ).GetHeight() * scale);
|
||||
|
||||
TrackPanelDrawingContext context{
|
||||
*dc, {}, {}, &artist
|
||||
|
@ -42,6 +42,7 @@ It forwards the actual work of doing the commands to the ScreenshotCommand.
|
||||
#include "ProjectWindow.h"
|
||||
#include "Prefs.h"
|
||||
#include "toolbars/ToolManager.h"
|
||||
#include "tracks/ui/TrackView.h"
|
||||
|
||||
#include "ViewInfo.h"
|
||||
#include "WaveTrack.h"
|
||||
@ -719,15 +720,17 @@ void ScreenFrame::SizeTracks(int h)
|
||||
auto nChannels = channels.size();
|
||||
auto height = nChannels == 1 ? 2 * h : h;
|
||||
for (auto channel : channels)
|
||||
channel->SetHeight(height);
|
||||
TrackView::Get( *channel ).SetHeight(height);
|
||||
}
|
||||
ProjectWindow::Get( mContext.project ).RedrawProject();
|
||||
}
|
||||
|
||||
void ScreenFrame::OnShortTracks(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
for (auto t : TrackList::Get( mContext.project ).Any<WaveTrack>())
|
||||
t->SetHeight(t->GetMinimizedHeight());
|
||||
for (auto t : TrackList::Get( mContext.project ).Any<WaveTrack>()) {
|
||||
auto &view = TrackView::Get( *t );
|
||||
view.SetHeight( view.GetMinimizedHeight() );
|
||||
}
|
||||
|
||||
ProjectWindow::Get( mContext.project ).RedrawProject();
|
||||
}
|
||||
|
@ -56,8 +56,6 @@ TimeTrack::TimeTrack(const std::shared_ptr<DirManager> &projDirManager, const Zo
|
||||
Track(projDirManager)
|
||||
, mZoomInfo(zoomInfo)
|
||||
{
|
||||
mHeight = 100;
|
||||
|
||||
mEnvelope = std::make_unique<BoundedEnvelope>(true, TIMETRACK_MIN, TIMETRACK_MAX, 1.0);
|
||||
|
||||
SetRangeLower( 0.9 );
|
||||
@ -312,7 +310,8 @@ void TimeTrack::Draw
|
||||
//
|
||||
// LL: It's because the ruler only Invalidate()s when the NEW value is different
|
||||
// than the current value.
|
||||
mRuler->SetFlip(GetHeight() > 75 ? true : true); // MB: so why don't we just call Invalidate()? :)
|
||||
mRuler->SetFlip( true );
|
||||
//mRuler->SetFlip(GetHeight() > 75 ? true : true); // MB: so why don't we just call Invalidate()? :)
|
||||
mRuler->SetTickColour( theTheme.Colour( clrTrackPanelText ));
|
||||
mRuler->Draw(dc, GetEnvelope());
|
||||
|
||||
|
101
src/Track.cpp
101
src/Track.cpp
@ -41,8 +41,6 @@ and TimeTrack.
|
||||
|
||||
#include "InconsistencyException.h"
|
||||
|
||||
#include "TrackPanel.h" // for TrackInfo
|
||||
|
||||
#include "tracks/ui/TrackView.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
@ -57,8 +55,6 @@ Track::Track(const std::shared_ptr<DirManager> &projDirManager)
|
||||
mSelected = false;
|
||||
mLinked = false;
|
||||
|
||||
mY = 0;
|
||||
mHeight = DefaultHeight;
|
||||
mIndex = 0;
|
||||
|
||||
mOffset = 0.0;
|
||||
@ -69,7 +65,6 @@ Track::Track(const std::shared_ptr<DirManager> &projDirManager)
|
||||
Track::Track(const Track &orig)
|
||||
: vrulerSize( orig.vrulerSize )
|
||||
{
|
||||
mY = 0;
|
||||
mIndex = 0;
|
||||
Init(orig);
|
||||
mOffset = orig.mOffset;
|
||||
@ -87,7 +82,6 @@ void Track::Init(const Track &orig)
|
||||
|
||||
mSelected = orig.mSelected;
|
||||
mLinked = orig.mLinked;
|
||||
mHeight = orig.mHeight;
|
||||
mChannel = orig.mChannel;
|
||||
}
|
||||
|
||||
@ -146,16 +140,6 @@ void Track::SetOwner
|
||||
mNode = node;
|
||||
}
|
||||
|
||||
int Track::GetMinimizedHeight() const
|
||||
{
|
||||
auto height = TrackInfo::MinimumTrackHeight();
|
||||
auto channels = TrackList::Channels(this->SubstituteOriginalTrack().get());
|
||||
auto nChannels = channels.size();
|
||||
auto begin = channels.begin();
|
||||
auto index = std::distance(begin, std::find(begin, channels.end(), this));
|
||||
return (height * (index + 1) / nChannels) - (height * index / nChannels);
|
||||
}
|
||||
|
||||
int Track::GetIndex() const
|
||||
{
|
||||
return mIndex;
|
||||
@ -166,67 +150,6 @@ void Track::SetIndex(int index)
|
||||
mIndex = index;
|
||||
}
|
||||
|
||||
int Track::GetY() const
|
||||
{
|
||||
return mY;
|
||||
}
|
||||
|
||||
void Track::SetY(int y)
|
||||
{
|
||||
auto pList = mList.lock();
|
||||
if (pList && !pList->mPendingUpdates.empty()) {
|
||||
auto orig = pList->FindById( GetId() );
|
||||
if (orig && orig != this) {
|
||||
// delegate, and rely on the update to copy back
|
||||
orig->SetY(y);
|
||||
pList->UpdatePendingTracks();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
DoSetY(y);
|
||||
}
|
||||
|
||||
void Track::DoSetY(int y)
|
||||
{
|
||||
mY = y;
|
||||
}
|
||||
|
||||
#include "tracks/ui/TrackView.h"
|
||||
int Track::GetHeight() const
|
||||
{
|
||||
if ( TrackView::Get( *this ).GetMinimized() ) {
|
||||
return GetMinimizedHeight();
|
||||
}
|
||||
|
||||
return mHeight;
|
||||
}
|
||||
|
||||
void Track::SetHeight(int h)
|
||||
{
|
||||
auto pList = mList.lock();
|
||||
if (pList && !pList->mPendingUpdates.empty()) {
|
||||
auto orig = pList->FindById( GetId() );
|
||||
if (orig && orig != this) {
|
||||
// delegate, and rely on RecalcPositions to copy back
|
||||
orig->SetHeight(h);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
DoSetHeight(h);
|
||||
|
||||
if (pList) {
|
||||
pList->RecalcPositions(mNode);
|
||||
pList->ResizingEvent(mNode);
|
||||
}
|
||||
}
|
||||
|
||||
void Track::DoSetHeight(int h)
|
||||
{
|
||||
mHeight = h;
|
||||
}
|
||||
|
||||
void Track::SetLinked(bool l)
|
||||
{
|
||||
auto pList = mList.lock();
|
||||
@ -615,15 +538,17 @@ void TrackList::RecalcPositions(TrackNodePointer node)
|
||||
if ( !isNull( prev ) ) {
|
||||
t = prev.first->get();
|
||||
i = t->GetIndex() + 1;
|
||||
y = t->GetY() + t->GetHeight();
|
||||
auto &view = TrackView::Get( *t );
|
||||
y = view.GetY() + view.GetHeight();
|
||||
}
|
||||
|
||||
const auto theEnd = end();
|
||||
for (auto n = Find( node.first->get() ); n != theEnd; ++n) {
|
||||
t = *n;
|
||||
auto &view = TrackView::Get( *t );
|
||||
t->SetIndex(i++);
|
||||
t->DoSetY(y);
|
||||
y += t->GetHeight();
|
||||
view.SetY(y);
|
||||
y += view.GetHeight();
|
||||
}
|
||||
|
||||
UpdatePendingTracks();
|
||||
@ -921,7 +846,9 @@ Track *TrackList::GetPrev(Track * t, bool linked) const
|
||||
/// For stereo track combined height of both channels.
|
||||
int TrackList::GetGroupHeight(const Track * t) const
|
||||
{
|
||||
return Channels(t).sum( &Track::GetHeight );
|
||||
const auto GetHeight = []( const Track *track )
|
||||
{ return TrackView::Get( *track ).GetHeight(); };
|
||||
return Channels(t).sum( GetHeight );
|
||||
}
|
||||
|
||||
bool TrackList::CanMoveUp(Track * t) const
|
||||
@ -1049,7 +976,8 @@ int TrackList::GetHeight() const
|
||||
|
||||
if (!empty()) {
|
||||
auto track = getPrev( getEnd() ).first->get();
|
||||
height = track->GetY() + track->GetHeight();
|
||||
auto &view = TrackView::Get( *track );
|
||||
height = view.GetY() + view.GetHeight();
|
||||
}
|
||||
|
||||
return height;
|
||||
@ -1128,8 +1056,6 @@ void TrackList::UpdatePendingTracks()
|
||||
if (pendingTrack && src) {
|
||||
if (updater)
|
||||
updater( *pendingTrack, *src );
|
||||
pendingTrack->DoSetY(src->GetY());
|
||||
pendingTrack->DoSetHeight(src->GetActualHeight());
|
||||
pendingTrack->DoSetLinked(src->GetLinked());
|
||||
}
|
||||
++pUpdater;
|
||||
@ -1272,8 +1198,9 @@ void Track::WriteCommonXMLAttributes(
|
||||
xmlFile.WriteAttr(wxT("name"), GetName());
|
||||
xmlFile.WriteAttr(wxT("isSelected"), this->GetSelected());
|
||||
}
|
||||
xmlFile.WriteAttr(wxT("height"), this->GetActualHeight());
|
||||
xmlFile.WriteAttr(wxT("minimized"), TrackView::Get( *this ).GetMinimized());
|
||||
auto &view = TrackView::Get( *this );
|
||||
xmlFile.WriteAttr(wxT("height"), view.GetActualHeight());
|
||||
xmlFile.WriteAttr(wxT("minimized"), view.GetMinimized());
|
||||
}
|
||||
|
||||
// Return true iff the attribute is recognized.
|
||||
@ -1288,7 +1215,7 @@ bool Track::HandleCommonXMLAttribute(const wxChar *attr, const wxChar *value)
|
||||
}
|
||||
else if (!wxStrcmp(attr, wxT("height")) &&
|
||||
XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) {
|
||||
SetHeight(nValue);
|
||||
TrackView::Get( *this ).SetHeight(nValue);
|
||||
return true;
|
||||
}
|
||||
else if (!wxStrcmp(attr, wxT("minimized")) &&
|
||||
|
23
src/Track.h
23
src/Track.h
@ -196,8 +196,6 @@ class AUDACITY_DLL_API Track /* not final */
|
||||
std::weak_ptr<TrackList> mList;
|
||||
TrackNodePointer mNode{};
|
||||
int mIndex;
|
||||
int mY;
|
||||
int mHeight;
|
||||
wxString mName;
|
||||
wxString mDefaultName;
|
||||
|
||||
@ -275,28 +273,9 @@ class AUDACITY_DLL_API Track /* not final */
|
||||
|
||||
// Return another, associated TrackPanelCell object that implements the
|
||||
|
||||
// This just returns a constant and can be overriden by subclasses
|
||||
// to specify a different height for the case that the track is minimized.
|
||||
virtual int GetMinimizedHeight() const;
|
||||
int GetActualHeight() const { return mHeight; }
|
||||
|
||||
int GetIndex() const;
|
||||
void SetIndex(int index);
|
||||
|
||||
int GetY() const;
|
||||
private:
|
||||
// Always maintain a strictly contiguous layout of tracks.
|
||||
// So client code is not permitted to modify this attribute directly.
|
||||
void SetY(int y);
|
||||
// No need yet to make this virtual
|
||||
void DoSetY(int y);
|
||||
public:
|
||||
|
||||
int GetHeight() const;
|
||||
void SetHeight(int h);
|
||||
protected:
|
||||
virtual void DoSetHeight(int h);
|
||||
|
||||
public:
|
||||
static void FinishCopy (const Track *n, Track *dest);
|
||||
|
||||
@ -333,8 +312,6 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
enum : unsigned { DefaultHeight = 150 };
|
||||
|
||||
Track(const std::shared_ptr<DirManager> &projDirManager);
|
||||
Track(const Track &orig);
|
||||
|
||||
|
@ -88,6 +88,7 @@ audio tracks.
|
||||
#include "widgets/Ruler.h"
|
||||
#include "AllThemeResources.h"
|
||||
#include "TrackPanelDrawingContext.h"
|
||||
#include "tracks/ui/TrackView.h"
|
||||
|
||||
|
||||
#undef PROFILE_WAVEFORM
|
||||
@ -222,12 +223,12 @@ void TrackArt::DrawTracks(TrackPanelDrawingContext &context,
|
||||
|
||||
for(auto leader : tracks->Leaders()) {
|
||||
auto group = TrackList::Channels( leader );
|
||||
leader = leader->SubstitutePendingChangedTrack().get();
|
||||
auto &view1 = TrackView::Get( *leader );
|
||||
|
||||
teamRect.y = leader->GetY() - zoomInfo.vpos;
|
||||
teamRect.y = view1.GetY() - zoomInfo.vpos;
|
||||
teamRect.height = group.sum( [&] (const Track *channel) {
|
||||
channel = channel->SubstitutePendingChangedTrack().get();
|
||||
return channel->GetHeight();
|
||||
auto &view = TrackView::Get( *channel );
|
||||
return view.GetHeight();
|
||||
});
|
||||
|
||||
if (teamRect.GetBottom() < clip.GetTop())
|
||||
@ -245,13 +246,17 @@ void TrackArt::DrawTracks(TrackPanelDrawingContext &context,
|
||||
// If so, we draw both. Otherwise, we can safely draw neither.
|
||||
|
||||
if (teamRect.Intersects(clip) && reg.Contains(teamRect)) {
|
||||
t = t->SubstitutePendingChangedTrack().get();
|
||||
auto &view = TrackView::Get( *t );
|
||||
wxRect trackRect {
|
||||
teamRect.x,
|
||||
t->GetY() - zoomInfo.vpos + kTopMargin,
|
||||
view.GetY() - zoomInfo.vpos + kTopMargin,
|
||||
teamRect.width,
|
||||
t->GetHeight() - (kTopMargin + kBottomMargin)
|
||||
view.GetHeight() - (kTopMargin + kBottomMargin)
|
||||
};
|
||||
// Find any pending changed track contents (such as during a
|
||||
// recording that is not yet committed to the undo history), and
|
||||
// draw those instead
|
||||
t = t->SubstitutePendingChangedTrack().get();
|
||||
DrawTrack( context, t, trackRect );
|
||||
}
|
||||
}
|
||||
@ -276,12 +281,12 @@ void TrackArt::DrawTrackNames(TrackPanelDrawingContext &context,
|
||||
|
||||
for(auto leader : tracks->Leaders()) {
|
||||
auto group = TrackList::Channels( leader );
|
||||
leader = leader->SubstitutePendingChangedTrack().get();
|
||||
auto &view = TrackView::Get( *leader );
|
||||
|
||||
teamRect.y = leader->GetY() - zoomInfo.vpos;
|
||||
teamRect.y = view.GetY() - zoomInfo.vpos;
|
||||
teamRect.height = group.sum( [&] (const Track *channel) {
|
||||
channel = channel->SubstitutePendingChangedTrack().get();
|
||||
return channel->GetHeight();
|
||||
auto &channelView = TrackView::Get( *channel );
|
||||
return view.GetHeight();
|
||||
});
|
||||
|
||||
if (teamRect.GetBottom() < clip.GetTop())
|
||||
@ -294,7 +299,7 @@ void TrackArt::DrawTrackNames(TrackPanelDrawingContext &context,
|
||||
t = t->SubstitutePendingChangedTrack().get();
|
||||
wxRect trackRect {
|
||||
teamRect.x,
|
||||
t->GetY() - zoomInfo.vpos + kTopMargin,
|
||||
TrackView::Get( *t ).GetY() - zoomInfo.vpos + kTopMargin,
|
||||
teamRect.width,
|
||||
teamRect.height
|
||||
};
|
||||
|
@ -117,7 +117,7 @@ is time to refresh some aspect of the screen.
|
||||
\class TrackPanel
|
||||
|
||||
This is a diagram of TrackPanel's division of one (non-stereo) track rectangle.
|
||||
Total height equals Track::GetHeight()'s value. Total width is the wxWindow's
|
||||
Total height equals TrackView::GetHeight()'s value. Total width is the wxWindow's
|
||||
width. Each charater that is not . represents one pixel.
|
||||
|
||||
Inset space of this track, and top inset of the next track, are used to draw the
|
||||
@ -1095,14 +1095,17 @@ void TrackPanel::RefreshTrack(Track *trk, bool refreshbacking)
|
||||
return;
|
||||
|
||||
trk = *GetTracks()->FindLeader(trk);
|
||||
auto &view = TrackView::Get( *trk );
|
||||
const auto GetHeight = []( const Track *track )
|
||||
{ return TrackView::Get( *track ).GetHeight(); };
|
||||
auto height =
|
||||
TrackList::Channels(trk).sum( &Track::GetHeight )
|
||||
TrackList::Channels(trk).sum( GetHeight )
|
||||
- kTopInset - kShadowThickness;
|
||||
|
||||
// subtract insets and shadows from the rectangle, but not border
|
||||
// This matters because some separators do paint over the border
|
||||
wxRect rect(kLeftInset,
|
||||
-mViewInfo->vpos + trk->GetY() + kTopInset,
|
||||
-mViewInfo->vpos + view.GetY() + kTopInset,
|
||||
GetRect().GetWidth() - kLeftInset - kRightInset - kShadowThickness,
|
||||
height);
|
||||
|
||||
@ -1224,11 +1227,11 @@ void TrackPanel::DrawEverythingElse(TrackPanelDrawingContext &context,
|
||||
bool first = true;
|
||||
for (auto channel : channels) {
|
||||
focused = focused || mAx->IsFocused(channel);
|
||||
channel = channel->SubstitutePendingChangedTrack().get();
|
||||
auto &view = TrackView::Get( *channel );
|
||||
if (first)
|
||||
first = false,
|
||||
teamRect.y = channel->GetY() - mViewInfo->vpos + kTopMargin;
|
||||
teamRect.height += channel->GetHeight();
|
||||
teamRect.y = view.GetY() - mViewInfo->vpos + kTopMargin;
|
||||
teamRect.height += view.GetHeight();
|
||||
}
|
||||
|
||||
if (focused) {
|
||||
@ -1248,10 +1251,11 @@ void TrackPanel::DrawEverythingElse(TrackPanelDrawingContext &context,
|
||||
#endif
|
||||
|
||||
for (auto channel : channels) {
|
||||
auto &view = TrackView::Get( *channel );
|
||||
bool bSelected = channel->GetSelected();
|
||||
channel = channel->SubstitutePendingChangedTrack().get();
|
||||
trackRect.y = channel->GetY() - mViewInfo->vpos + kTopMargin;
|
||||
trackRect.height = channel->GetHeight();
|
||||
trackRect.y = view.GetY() - mViewInfo->vpos + kTopMargin;
|
||||
trackRect.height = view.GetHeight();
|
||||
if (region.Contains(
|
||||
0, trackRect.y, GetLeftOffset(), trackRect.height)) {
|
||||
wxRect rect{
|
||||
@ -1794,10 +1798,10 @@ void TrackPanel::DrawOutside
|
||||
// omit last (perhaps, only) channel
|
||||
--channels.second;
|
||||
for (auto channel : channels) {
|
||||
auto &view = TrackView::Get( *channel );
|
||||
// draw the sash below this channel
|
||||
channel = channel->SubstitutePendingChangedTrack().get();
|
||||
auto yy =
|
||||
channel->GetY() - mViewInfo->vpos + channel->GetHeight()
|
||||
view.GetY() - mViewInfo->vpos + view.GetHeight()
|
||||
- kBottomMargin;
|
||||
wxRect sashRect{
|
||||
vrul, yy, rect.GetRight() - vrul, kSeparatorThickness
|
||||
@ -1980,7 +1984,8 @@ void TrackPanel::UpdateTrackVRuler(const Track *t)
|
||||
|
||||
|
||||
for (auto channel : TrackList::Channels(t)) {
|
||||
rect.height = channel->GetHeight() - (kTopMargin + kBottomMargin);
|
||||
auto &view = TrackView::Get( *channel );
|
||||
rect.height = view.GetHeight() - (kTopMargin + kBottomMargin);
|
||||
mTrackArtist->UpdateVRuler(channel, rect);
|
||||
}
|
||||
}
|
||||
@ -2048,7 +2053,9 @@ void TrackPanel::EnsureVisible(Track * t)
|
||||
trackTop += trackHeight;
|
||||
|
||||
auto channels = TrackList::Channels(it);
|
||||
trackHeight = channels.sum( &Track::GetHeight );
|
||||
const auto GetHeight = []( const Track *track )
|
||||
{ return TrackView::Get( *track ).GetHeight(); };
|
||||
trackHeight = channels.sum( GetHeight );
|
||||
|
||||
//We have found the track we want to ensure is visible.
|
||||
if (channels.contains(t)) {
|
||||
@ -2082,7 +2089,7 @@ void TrackPanel::VerticalScroll( float fracPosition){
|
||||
int trackHeight = 0;
|
||||
|
||||
auto tracks = GetTracks();
|
||||
auto GetHeight =
|
||||
const auto GetHeight =
|
||||
[&]( const Track *t ){ return tracks->GetGroupHeight(t); };
|
||||
|
||||
auto range = tracks->Leaders();
|
||||
@ -2223,9 +2230,8 @@ struct ChannelGroup final : TrackPanelGroup {
|
||||
std::make_shared< VRulerAndChannel >(
|
||||
channel->SharedPointer(), mLeftOffset ) );
|
||||
if ( channel != pLast ) {
|
||||
const auto substitute =
|
||||
channel->SubstitutePendingChangedTrack();
|
||||
yy += substitute->GetHeight();
|
||||
auto &view = TrackView::Get( *channel );
|
||||
yy += view.GetHeight();
|
||||
refinement.emplace_back(
|
||||
yy - kSeparatorThickness,
|
||||
TrackView::Get( *channel ).GetResizer() );
|
||||
@ -2289,9 +2295,8 @@ struct Subgroup final : TrackPanelGroup {
|
||||
for ( const auto leader : tracks.Leaders() ) {
|
||||
wxCoord height = 0;
|
||||
for ( auto channel : TrackList::Channels( leader ) ) {
|
||||
auto substitute =
|
||||
channel->SubstitutePendingChangedTrack();
|
||||
height += substitute->GetHeight();
|
||||
auto &view = TrackView::Get( *channel );
|
||||
height += view.GetHeight();
|
||||
}
|
||||
refinement.emplace_back( yy,
|
||||
std::make_shared< ResizingChannelGroup >(
|
||||
@ -2785,7 +2790,7 @@ unsigned DefaultTrackHeight( const TCPLines &topLines )
|
||||
kTopMargin + kBottomMargin +
|
||||
totalTCPLines( topLines, true ) +
|
||||
totalTCPLines( commonTrackTCPBottomLines, false ) + 1;
|
||||
return (unsigned) std::max( needed, (int) Track::DefaultHeight );
|
||||
return (unsigned) std::max( needed, (int) TrackView::DefaultHeight );
|
||||
}
|
||||
}
|
||||
|
||||
@ -2953,7 +2958,8 @@ bool IsVisibleTrack::operator () (const Track *pTrack) const
|
||||
return
|
||||
TrackList::Channels(pTrack).StartingWith(pTrack).any_of(
|
||||
[this]( const Track *pT ) {
|
||||
wxRect r(0, pT->GetY(), 1, pT->GetHeight());
|
||||
auto &view = TrackView::Get( *pT );
|
||||
wxRect r(0, view.GetY(), 1, view.GetHeight());
|
||||
return r.Intersects(mPanelRect);
|
||||
}
|
||||
);
|
||||
|
@ -67,15 +67,17 @@ TrackPanelResizeHandle::TrackPanelResizeHandle
|
||||
//STM: Determine whether we should rescale one or two tracks
|
||||
auto channels = TrackList::Channels(track.get());
|
||||
auto last = *channels.rbegin();
|
||||
mInitialTrackHeight = last->GetHeight();
|
||||
mInitialActualHeight = last->GetActualHeight();
|
||||
mInitialMinimized = TrackView::Get( *last ).GetMinimized();
|
||||
auto &lastView = TrackView::Get( *last );
|
||||
mInitialTrackHeight = lastView.GetHeight();
|
||||
mInitialActualHeight = lastView.GetActualHeight();
|
||||
mInitialMinimized = lastView.GetMinimized();
|
||||
|
||||
if (channels.size() > 1) {
|
||||
auto first = *channels.begin();
|
||||
auto &firstView = TrackView::Get( *first );
|
||||
|
||||
mInitialUpperTrackHeight = first->GetHeight();
|
||||
mInitialUpperActualHeight = first->GetActualHeight();
|
||||
mInitialUpperTrackHeight = firstView.GetHeight();
|
||||
mInitialUpperActualHeight = firstView.GetActualHeight();
|
||||
|
||||
if (track.get() == *channels.rbegin())
|
||||
// capturedTrack is the lowest track
|
||||
@ -96,6 +98,8 @@ UIHandle::Result TrackPanelResizeHandle::Drag
|
||||
if ( !pTrack )
|
||||
return RefreshCode::Cancelled;
|
||||
|
||||
auto &view = TrackView::Get( *pTrack );
|
||||
|
||||
const wxMouseEvent &event = evt.event;
|
||||
|
||||
int delta = (event.m_y - mMouseClickY);
|
||||
@ -109,15 +113,17 @@ UIHandle::Result TrackPanelResizeHandle::Drag
|
||||
if (data.GetMinimized()) {
|
||||
auto channels = TrackList::Channels( pTrack.get() );
|
||||
for (auto channel : channels) {
|
||||
channel->SetHeight(channel->GetHeight());
|
||||
TrackView::Get( *channel ).SetMinimized( false );
|
||||
auto &channelView = TrackView::Get( *channel );
|
||||
channelView.SetHeight(channelView.GetHeight());
|
||||
channelView.SetMinimized( false );
|
||||
}
|
||||
|
||||
if (channels.size() > 1) {
|
||||
// Initial values must be reset since they weren't based on the
|
||||
// minimized heights.
|
||||
mInitialUpperTrackHeight = (*channels.begin())->GetHeight();
|
||||
mInitialTrackHeight = (*channels.rbegin())->GetHeight();
|
||||
auto &channelView = TrackView::Get( **channels.begin() );
|
||||
mInitialUpperTrackHeight = channelView.GetHeight();
|
||||
mInitialTrackHeight = channelView.GetHeight();
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,6 +131,8 @@ UIHandle::Result TrackPanelResizeHandle::Drag
|
||||
auto doResizeBelow = [&] (Track *prev, bool WXUNUSED(vStereo)) {
|
||||
// TODO: more-than-two-channels
|
||||
|
||||
auto &prevView = TrackView::Get( *prev );
|
||||
|
||||
double proportion = static_cast < double >(mInitialTrackHeight)
|
||||
/ (mInitialTrackHeight + mInitialUpperTrackHeight);
|
||||
|
||||
@ -135,42 +143,43 @@ UIHandle::Result TrackPanelResizeHandle::Drag
|
||||
(mInitialUpperTrackHeight + delta * (1.0 - proportion));
|
||||
|
||||
//make sure neither track is smaller than its minimum height
|
||||
if (newTrackHeight < pTrack->GetMinimizedHeight())
|
||||
newTrackHeight = pTrack->GetMinimizedHeight();
|
||||
if (newUpperTrackHeight < prev->GetMinimizedHeight())
|
||||
newUpperTrackHeight = prev->GetMinimizedHeight();
|
||||
if (newTrackHeight < view.GetMinimizedHeight())
|
||||
newTrackHeight = view.GetMinimizedHeight();
|
||||
if (newUpperTrackHeight < prevView.GetMinimizedHeight())
|
||||
newUpperTrackHeight = prevView.GetMinimizedHeight();
|
||||
|
||||
pTrack->SetHeight(newTrackHeight);
|
||||
prev->SetHeight(newUpperTrackHeight);
|
||||
view.SetHeight(newTrackHeight);
|
||||
prevView.SetHeight(newUpperTrackHeight);
|
||||
};
|
||||
|
||||
auto doResizeBetween = [&] (Track *next, bool WXUNUSED(vStereo)) {
|
||||
// TODO: more-than-two-channels
|
||||
|
||||
auto &nextView = TrackView::Get( *next );
|
||||
int newUpperTrackHeight = mInitialUpperTrackHeight + delta;
|
||||
int newTrackHeight = mInitialTrackHeight - delta;
|
||||
|
||||
// make sure neither track is smaller than its minimum height
|
||||
if (newTrackHeight < next->GetMinimizedHeight()) {
|
||||
newTrackHeight = next->GetMinimizedHeight();
|
||||
if (newTrackHeight < nextView.GetMinimizedHeight()) {
|
||||
newTrackHeight = nextView.GetMinimizedHeight();
|
||||
newUpperTrackHeight =
|
||||
mInitialUpperTrackHeight + mInitialTrackHeight - next->GetMinimizedHeight();
|
||||
mInitialUpperTrackHeight + mInitialTrackHeight - nextView.GetMinimizedHeight();
|
||||
}
|
||||
if (newUpperTrackHeight < pTrack->GetMinimizedHeight()) {
|
||||
newUpperTrackHeight = pTrack->GetMinimizedHeight();
|
||||
if (newUpperTrackHeight < view.GetMinimizedHeight()) {
|
||||
newUpperTrackHeight = view.GetMinimizedHeight();
|
||||
newTrackHeight =
|
||||
mInitialUpperTrackHeight + mInitialTrackHeight - pTrack->GetMinimizedHeight();
|
||||
mInitialUpperTrackHeight + mInitialTrackHeight - view.GetMinimizedHeight();
|
||||
}
|
||||
|
||||
pTrack->SetHeight(newUpperTrackHeight);
|
||||
next->SetHeight(newTrackHeight);
|
||||
view.SetHeight(newUpperTrackHeight);
|
||||
nextView.SetHeight(newTrackHeight);
|
||||
};
|
||||
|
||||
auto doResize = [&] {
|
||||
int newTrackHeight = mInitialTrackHeight + delta;
|
||||
if (newTrackHeight < pTrack->GetMinimizedHeight())
|
||||
newTrackHeight = pTrack->GetMinimizedHeight();
|
||||
pTrack->SetHeight(newTrackHeight);
|
||||
if (newTrackHeight < view.GetMinimizedHeight())
|
||||
newTrackHeight = view.GetMinimizedHeight();
|
||||
view.SetHeight(newTrackHeight);
|
||||
};
|
||||
|
||||
//STM: We may be dragging one or two (stereo) tracks.
|
||||
@ -235,26 +244,31 @@ UIHandle::Result TrackPanelResizeHandle::Cancel(AudacityProject *pProject)
|
||||
switch (mMode) {
|
||||
case IsResizing:
|
||||
{
|
||||
pTrack->SetHeight(mInitialActualHeight);
|
||||
TrackView::Get( *pTrack ).SetMinimized( mInitialMinimized );
|
||||
auto &view = TrackView::Get( *pTrack );
|
||||
view.SetHeight(mInitialActualHeight);
|
||||
view.SetMinimized( mInitialMinimized );
|
||||
}
|
||||
break;
|
||||
case IsResizingBetweenLinkedTracks:
|
||||
{
|
||||
Track *const next = * ++ tracks.Find(pTrack.get());
|
||||
pTrack->SetHeight(mInitialUpperActualHeight);
|
||||
TrackView::Get( *pTrack ).SetMinimized( mInitialMinimized );
|
||||
next->SetHeight(mInitialActualHeight);
|
||||
TrackView::Get( *next ).SetMinimized( mInitialMinimized );
|
||||
auto
|
||||
&view = TrackView::Get( *pTrack ), &nextView = TrackView::Get( *next );
|
||||
view.SetHeight(mInitialUpperActualHeight);
|
||||
view.SetMinimized( mInitialMinimized );
|
||||
nextView.SetHeight(mInitialActualHeight);
|
||||
nextView.SetMinimized( mInitialMinimized );
|
||||
}
|
||||
break;
|
||||
case IsResizingBelowLinkedTracks:
|
||||
{
|
||||
Track *const prev = * -- tracks.Find(pTrack.get());
|
||||
pTrack->SetHeight(mInitialActualHeight);
|
||||
TrackView::Get( *pTrack ).SetMinimized( mInitialMinimized );
|
||||
prev->SetHeight(mInitialUpperActualHeight);
|
||||
TrackView::Get( *prev ).SetMinimized( mInitialMinimized );
|
||||
auto
|
||||
&view = TrackView::Get( *pTrack ), &prevView = TrackView::Get( *prev );
|
||||
view.SetHeight(mInitialActualHeight);
|
||||
view.SetMinimized( mInitialMinimized );
|
||||
prevView.SetHeight(mInitialUpperActualHeight);
|
||||
prevView.SetMinimized(mInitialMinimized);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -62,8 +62,6 @@ Track classes.
|
||||
|
||||
#include "InconsistencyException.h"
|
||||
|
||||
#include "TrackPanel.h" // for TrackInfo
|
||||
|
||||
using std::max;
|
||||
|
||||
static ProjectFileIORegistry::Entry registerFactory{
|
||||
@ -127,8 +125,6 @@ WaveTrack::WaveTrack(const std::shared_ptr<DirManager> &projDirManager, sampleFo
|
||||
mLastScaleType = -1;
|
||||
mLastdBRange = -1;
|
||||
mAutoSaveIdent = 0;
|
||||
|
||||
SetHeight( TrackInfo::DefaultWaveTrackHeight() );
|
||||
}
|
||||
|
||||
WaveTrack::WaveTrack(const WaveTrack &orig):
|
||||
|
@ -43,6 +43,7 @@ This class now lists
|
||||
#include "../prefs/PrefsDialog.h"
|
||||
#include "../Shuttle.h"
|
||||
#include "../PluginManager.h"
|
||||
#include "../tracks/ui/TrackView.h"
|
||||
#include "../ShuttleGui.h"
|
||||
|
||||
#include <wx/frame.h>
|
||||
@ -496,7 +497,7 @@ bool GetInfoCommand::SendTracks(const CommandContext & context)
|
||||
context.AddBool( (trk == fTrack), "focused");
|
||||
context.AddBool( trk->GetSelected(), "selected" );
|
||||
//JKC: Possibly add later...
|
||||
//context.AddItem( trk->GetHeight(), "height" );
|
||||
//context.AddItem( GetTrackView::Get( *trk ).GetHeight(), "height" );
|
||||
trk->TypeSwitch( [&] (const WaveTrack* t ) {
|
||||
float vzmin, vzmax;
|
||||
t->GetDisplayBounds(&vzmin, &vzmax);
|
||||
@ -722,8 +723,9 @@ void GetInfoCommand::ExploreTrackPanel( const CommandContext &context,
|
||||
wxRect trackRect = pWin->GetRect();
|
||||
|
||||
for ( auto t : TrackList::Get( *pProj ).Any() + IsVisibleTrack{ pProj } ) {
|
||||
trackRect.y = t->GetY() - viewInfo.vpos;
|
||||
trackRect.height = t->GetHeight();
|
||||
auto &view = TrackView::Get( *t );
|
||||
trackRect.y = view.GetY() - viewInfo.vpos;
|
||||
trackRect.height = view.GetHeight();
|
||||
|
||||
#if 0
|
||||
// Work in progress on getting the TCP button positions and sizes.
|
||||
|
@ -770,8 +770,8 @@ wxRect ScreenshotCommand::GetTrackRect( AudacityProject * pProj, TrackPanel * pa
|
||||
// Omit the outermost ring of gray pixels
|
||||
|
||||
// (Note that TrackPanel paints its focus over the "top margin" of the
|
||||
// rectangle allotted to the track, according to Track::GetY() and
|
||||
// Track::GetHeight(), but also over the margin of the next track.)
|
||||
// rectangle allotted to the track, according to TrackView::GetY() and
|
||||
// TrackView::GetHeight(), but also over the margin of the next track.)
|
||||
|
||||
rect.height += kBottomMargin;
|
||||
int dy = kTopMargin - 1;
|
||||
|
@ -43,6 +43,7 @@ SetTrackAudioCommand and SetTrackVisualsCommand.
|
||||
#include "../prefs/SpectrogramSettings.h"
|
||||
#include "../Shuttle.h"
|
||||
#include "../ShuttleGui.h"
|
||||
#include "../tracks/ui/TrackView.h"
|
||||
#include "CommandContext.h"
|
||||
|
||||
SetTrackBase::SetTrackBase(){
|
||||
@ -348,7 +349,7 @@ bool SetTrackVisualsCommand::ApplyInner(const CommandContext & context, Track *
|
||||
wt->SetWaveColorIndex( mColour );
|
||||
|
||||
if( t && bHasHeight )
|
||||
t->SetHeight( mHeight );
|
||||
TrackView::Get( *t ).SetHeight( mHeight );
|
||||
|
||||
if( wt && bHasDisplayType )
|
||||
wt->SetDisplay(
|
||||
|
@ -203,15 +203,17 @@ void DoZoomFitV(AudacityProject &project)
|
||||
height -= 28;
|
||||
|
||||
// The height of minimized and non-audio tracks cannot be apportioned
|
||||
const auto GetHeight = []( const Track *track )
|
||||
{ return TrackView::Get( *track ).GetHeight(); };
|
||||
height -=
|
||||
tracks.Any().sum( &Track::GetHeight ) - range.sum( &Track::GetHeight );
|
||||
tracks.Any().sum( GetHeight ) - range.sum( GetHeight );
|
||||
|
||||
// Give each resized track the average of the remaining height
|
||||
height = height / count;
|
||||
height = std::max( (int)TrackInfo::MinimumTrackHeight(), height );
|
||||
|
||||
for (auto t : range)
|
||||
t->SetHeight(height);
|
||||
TrackView::Get( *t ).SetHeight(height);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,15 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "../../../HitTestResult.h"
|
||||
#include "../../../TrackPanelMouseEvent.h"
|
||||
|
||||
LabelTrackView::LabelTrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackView{ pTrack }
|
||||
{
|
||||
// Label tracks are narrow
|
||||
// Default is to allow two rows so that NEW users get the
|
||||
// idea that labels can 'stack' when they would overlap.
|
||||
DoSetHeight(73);
|
||||
}
|
||||
|
||||
LabelTrackView::~LabelTrackView()
|
||||
{
|
||||
}
|
||||
|
@ -27,8 +27,7 @@ class LabelTrackView final : public CommonTrackView
|
||||
|
||||
public:
|
||||
explicit
|
||||
LabelTrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackView{ pTrack } {}
|
||||
LabelTrackView( const std::shared_ptr<Track> &pTrack );
|
||||
~LabelTrackView() override;
|
||||
|
||||
static LabelTrackView &Get( LabelTrack& );
|
||||
|
@ -23,6 +23,13 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "../../../../TrackPanelMouseEvent.h"
|
||||
#include "../../../ui/SelectHandle.h"
|
||||
#include "StretchHandle.h"
|
||||
#include "../../../../TrackPanel.h"
|
||||
|
||||
NoteTrackView::NoteTrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackView{ pTrack }
|
||||
{
|
||||
DoSetHeight( TrackInfo::DefaultNoteTrackHeight() );
|
||||
}
|
||||
|
||||
NoteTrackView::~NoteTrackView()
|
||||
{
|
||||
|
@ -20,8 +20,7 @@ class NoteTrackView final : public CommonTrackView
|
||||
|
||||
public:
|
||||
explicit
|
||||
NoteTrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackView{ pTrack } {}
|
||||
NoteTrackView( const std::shared_ptr<Track> &pTrack );
|
||||
~NoteTrackView() override;
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||
|
@ -871,13 +871,16 @@ void WaveTrackMenuTable::OnMergeStereo(wxCommandEvent &)
|
||||
partner->SetPan( 0.0f );
|
||||
|
||||
// Set NEW track heights and minimized state
|
||||
TrackView::Get( *pTrack ).SetMinimized(false);
|
||||
TrackView::Get( *partner ).SetMinimized(false);
|
||||
int AverageHeight = (pTrack->GetHeight() + partner->GetHeight()) / 2;
|
||||
pTrack->SetHeight(AverageHeight);
|
||||
partner->SetHeight(AverageHeight);
|
||||
TrackView::Get( *pTrack ).SetMinimized(bBothMinimizedp);
|
||||
TrackView::Get( *partner ).SetMinimized(bBothMinimizedp);
|
||||
auto
|
||||
&view = TrackView::Get( *pTrack ),
|
||||
&partnerView = TrackView::Get( *partner );
|
||||
view.SetMinimized(false);
|
||||
partnerView.SetMinimized(false);
|
||||
int AverageHeight = (view.GetHeight() + partnerView.GetHeight()) / 2;
|
||||
view.SetHeight(AverageHeight);
|
||||
partnerView.SetHeight(AverageHeight);
|
||||
view.SetMinimized(bBothMinimizedp);
|
||||
partnerView.SetMinimized(bBothMinimizedp);
|
||||
|
||||
//On Demand - join the queues together.
|
||||
if (ODManager::IsInstanceCreated())
|
||||
@ -913,6 +916,7 @@ void WaveTrackMenuTable::SplitStereo(bool stereo)
|
||||
for (auto channel : channels) {
|
||||
// Keep original stereo track name.
|
||||
channel->SetName(pTrack->GetName());
|
||||
auto &view = TrackView::Get( *channel );
|
||||
if (stereo)
|
||||
channel->SetPanFromChannelType();
|
||||
|
||||
@ -920,9 +924,9 @@ void WaveTrackMenuTable::SplitStereo(bool stereo)
|
||||
if (ODManager::IsInstanceCreated())
|
||||
ODManager::Instance()->MakeWaveTrackIndependent(channel);
|
||||
//make sure no channel is smaller than its minimum height
|
||||
if (channel->GetHeight() < channel->GetMinimizedHeight())
|
||||
channel->SetHeight(channel->GetMinimizedHeight());
|
||||
totalHeight += channel->GetHeight();
|
||||
if (view.GetHeight() < view.GetMinimizedHeight())
|
||||
view.SetHeight(view.GetMinimizedHeight());
|
||||
totalHeight += view.GetHeight();
|
||||
++nChannels;
|
||||
}
|
||||
|
||||
@ -931,7 +935,7 @@ void WaveTrackMenuTable::SplitStereo(bool stereo)
|
||||
|
||||
for (auto channel : channels)
|
||||
// Make tracks the same height
|
||||
channel->SetHeight( averageHeight );
|
||||
TrackView::Get( *channel ).SetHeight( averageHeight );
|
||||
}
|
||||
|
||||
/// Swap the left and right channels of a stero track...
|
||||
|
@ -9,6 +9,9 @@ Paul Licameli split from TrackPanel.cpp
|
||||
**********************************************************************/
|
||||
|
||||
#include "WaveTrackView.h"
|
||||
|
||||
#include "../../../../Experimental.h"
|
||||
|
||||
#include "../../../../WaveTrack.h"
|
||||
|
||||
#include "WaveTrackControls.h"
|
||||
@ -17,6 +20,7 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "WaveTrackVRulerControls.h"
|
||||
#include "../../../../HitTestResult.h"
|
||||
#include "../../../../prefs/SpectrogramSettings.h"
|
||||
#include "../../../../TrackPanel.h"
|
||||
#include "../../../../TrackPanelMouseEvent.h"
|
||||
|
||||
#include "CutlineHandle.h"
|
||||
@ -26,6 +30,12 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "../../../ui/TimeShiftHandle.h"
|
||||
#include "../../../../ProjectSettings.h"
|
||||
|
||||
WaveTrackView::WaveTrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackView{ pTrack }
|
||||
{
|
||||
DoSetHeight( TrackInfo::DefaultWaveTrackHeight() );
|
||||
}
|
||||
|
||||
WaveTrackView::~WaveTrackView()
|
||||
{
|
||||
}
|
||||
|
@ -24,8 +24,7 @@ class WaveTrackView final : public CommonTrackView
|
||||
|
||||
public:
|
||||
explicit
|
||||
WaveTrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackView{ pTrack } {}
|
||||
WaveTrackView( const std::shared_ptr<Track> &pTrack );
|
||||
~WaveTrackView() override;
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||
|
@ -20,6 +20,12 @@ Paul Licameli split from TrackPanel.cpp
|
||||
|
||||
#include "../../ui/EnvelopeHandle.h"
|
||||
|
||||
TimeTrackView::TimeTrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackView{ pTrack }
|
||||
{
|
||||
DoSetHeight( 100 );
|
||||
}
|
||||
|
||||
TimeTrackView::~TimeTrackView()
|
||||
{
|
||||
}
|
||||
|
@ -22,8 +22,7 @@ class TimeTrackView final : public CommonTrackView
|
||||
|
||||
public:
|
||||
explicit
|
||||
TimeTrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackView{ pTrack } {}
|
||||
TimeTrackView( const std::shared_ptr<Track> &pTrack );
|
||||
~TimeTrackView() override;
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||
|
@ -13,9 +13,11 @@ Paul Licameli split from class TrackView
|
||||
#include "BackgroundCell.h"
|
||||
#include "TimeShiftHandle.h"
|
||||
#include "TrackControls.h"
|
||||
#include "TrackPanel.h" // for TrackInfo
|
||||
#include "ZoomHandle.h"
|
||||
#include "../ui/SelectHandle.h"
|
||||
#include "../../ProjectSettings.h"
|
||||
#include "../../Track.h"
|
||||
#include "../../TrackPanelMouseEvent.h"
|
||||
|
||||
std::vector<UIHandlePtr> CommonTrackView::HitTest
|
||||
@ -76,3 +78,15 @@ std::shared_ptr<TrackPanelCell> CommonTrackView::ContextMenuDelegate()
|
||||
{
|
||||
return TrackControls::Get( *FindTrack() ).shared_from_this();
|
||||
}
|
||||
|
||||
int CommonTrackView::GetMinimizedHeight() const
|
||||
{
|
||||
auto height = TrackInfo::MinimumTrackHeight();
|
||||
const auto pTrack = FindTrack();
|
||||
auto channels = TrackList::Channels(pTrack->SubstituteOriginalTrack().get());
|
||||
auto nChannels = channels.size();
|
||||
auto begin = channels.begin();
|
||||
auto index =
|
||||
std::distance(begin, std::find(begin, channels.end(), pTrack.get()));
|
||||
return (height * (index + 1) / nChannels) - (height * index / nChannels);
|
||||
}
|
||||
|
@ -31,6 +31,8 @@ public:
|
||||
(const TrackPanelMouseState &, const AudacityProject *pProject)
|
||||
final override;
|
||||
|
||||
virtual int GetMinimizedHeight() const override;
|
||||
|
||||
protected:
|
||||
// Rather override this for subclasses:
|
||||
virtual std::vector<UIHandlePtr> DetailedHitTest
|
||||
|
@ -21,6 +21,10 @@ TrackView::~TrackView()
|
||||
void TrackView::Copy( const TrackView &other )
|
||||
{
|
||||
mMinimized = other.mMinimized;
|
||||
|
||||
// Let mY remain 0 -- TrackList::RecalcPositions corrects it later
|
||||
mY = 0;
|
||||
mHeight = other.mHeight;
|
||||
}
|
||||
|
||||
TrackView &TrackView::Get( Track &track )
|
||||
@ -101,3 +105,27 @@ std::shared_ptr<const TrackPanelCell> TrackView::GetResizer() const
|
||||
{
|
||||
return const_cast<TrackView*>(this)->GetResizer();
|
||||
}
|
||||
|
||||
void TrackView::DoSetY(int y)
|
||||
{
|
||||
mY = y;
|
||||
}
|
||||
|
||||
int TrackView::GetHeight() const
|
||||
{
|
||||
if ( GetMinimized() )
|
||||
return GetMinimizedHeight();
|
||||
|
||||
return mHeight;
|
||||
}
|
||||
|
||||
void TrackView::SetHeight(int h)
|
||||
{
|
||||
DoSetHeight(h);
|
||||
FindTrack()->AdjustPositions();
|
||||
}
|
||||
|
||||
void TrackView::DoSetHeight(int h)
|
||||
{
|
||||
mHeight = h;
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ class TrackView /* not final */ : public CommonTrackCell
|
||||
TrackView &operator=( const TrackView& ) = delete;
|
||||
|
||||
public:
|
||||
enum : unsigned { DefaultHeight = 150 };
|
||||
|
||||
explicit
|
||||
TrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackCell{ pTrack } {}
|
||||
@ -39,6 +41,14 @@ public:
|
||||
bool GetMinimized() const { return mMinimized; }
|
||||
void SetMinimized( bool minimized );
|
||||
|
||||
int GetY() const { return mY; }
|
||||
int GetActualHeight() const { return mHeight; }
|
||||
virtual int GetMinimizedHeight() const = 0;
|
||||
int GetHeight() const;
|
||||
|
||||
void SetY(int y) { DoSetY( y ); }
|
||||
void SetHeight(int height);
|
||||
|
||||
// Return another, associated TrackPanelCell object that implements the
|
||||
// mouse actions for the vertical ruler
|
||||
std::shared_ptr<TrackVRulerControls> GetVRulerControls();
|
||||
@ -53,6 +63,11 @@ public:
|
||||
protected:
|
||||
virtual void DoSetMinimized( bool isMinimized );
|
||||
|
||||
// No need yet to make this virtual
|
||||
void DoSetY(int y);
|
||||
|
||||
virtual void DoSetHeight(int h);
|
||||
|
||||
// Private factory to make appropriate object; class TrackView handles
|
||||
// memory management thereafter
|
||||
virtual std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() = 0;
|
||||
@ -62,6 +77,8 @@ protected:
|
||||
|
||||
private:
|
||||
bool mMinimized{ false };
|
||||
int mY{ 0 };
|
||||
int mHeight{ DefaultHeight };
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user