int Track::GetHeight() const { if (mMinimized) return GetMinimizedHeight(); else return mHeight; }
int Track::GetHeight() const { if (mMinimized) { return GetMinimizedHeight(); } return mHeight; }
int Track::GetHeight(bool vStereo) const { if (mMinimized) { return GetMinimizedHeight(); } if(vStereo && mChannel == Track::MonoChannel) return mHeightv; return mHeight; }
UIHandle::Result TrackPanelResizeHandle::Drag (const TrackPanelMouseEvent &evt, AudacityProject *pProject) { auto pTrack = pProject->GetTracks()->Lock(mpTrack); if ( !pTrack ) return RefreshCode::Cancelled; const wxMouseEvent &event = evt.event; TrackList *const tracks = pProject->GetTracks(); int delta = (event.m_y - mMouseClickY); // On first drag, jump out of minimized mode. Initial height // will be height of minimized track. // // This used to be in HandleResizeClick(), but simply clicking // on a resize border would switch the minimized state. if (pTrack->GetMinimized()) { Track *link = pTrack->GetLink(); pTrack->SetHeight(pTrack->GetHeight()); pTrack->SetMinimized(false); if (link) { link->SetHeight(link->GetHeight()); link->SetMinimized(false); // Initial values must be reset since they weren't based on the // minimized heights. mInitialUpperTrackHeight = link->GetHeight(); mInitialTrackHeight = pTrack->GetHeight(); } } // Common pieces of code for MONO_WAVE_PAN and otherwise. auto doResizeBelow = [&] (Track *prev, bool WXUNUSED(vStereo)) { double proportion = static_cast < double >(mInitialTrackHeight) / (mInitialTrackHeight + mInitialUpperTrackHeight); int newTrackHeight = static_cast < int > (mInitialTrackHeight + delta * proportion); int newUpperTrackHeight = static_cast < int > (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(); pTrack->SetHeight(newTrackHeight); prev->SetHeight(newUpperTrackHeight); }; auto doResizeBetween = [&] (Track *next, bool WXUNUSED(vStereo)) { 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(); newUpperTrackHeight = mInitialUpperTrackHeight + mInitialTrackHeight - next->GetMinimizedHeight(); } if (newUpperTrackHeight < pTrack->GetMinimizedHeight()) { newUpperTrackHeight = pTrack->GetMinimizedHeight(); newTrackHeight = mInitialUpperTrackHeight + mInitialTrackHeight - pTrack->GetMinimizedHeight(); } pTrack->SetHeight(newUpperTrackHeight); next->SetHeight(newTrackHeight); }; auto doResize = [&] { int newTrackHeight = mInitialTrackHeight + delta; if (newTrackHeight < pTrack->GetMinimizedHeight()) newTrackHeight = pTrack->GetMinimizedHeight(); pTrack->SetHeight(newTrackHeight); }; //STM: We may be dragging one or two (stereo) tracks. // If two, resize proportionally if we are dragging the lower track, and // adjust compensatively if we are dragging the upper track. switch( mMode ) { case IsResizingBelowLinkedTracks: { Track *prev = tracks->GetPrev(pTrack.get()); doResizeBelow(prev, false); break; } case IsResizingBetweenLinkedTracks: { Track *next = tracks->GetNext(pTrack.get()); doResizeBetween(next, false); break; } case IsResizing: { doResize(); break; } default: // don't refresh in this case. return RefreshCode::RefreshNone; } return RefreshCode::RefreshAll; }