mirror of
https://github.com/cookiengineer/audacity
synced 2025-04-29 23:29:41 +02:00
Rewrite GetInfoCommand::ExploreTrackPanel...
... implemented simply and more correctly (though not efficiently), hiding details about the method of rectangle subdivision, and allowing for multiple sub-views. This function can be exercised by choosing Boxes in the Track Info item of Extra > Scriptables II This commit leaves one fewer call to each of TrackView::GetY() and TrackView::GetHeight() (cherry picked from audacity commit 1880c14f112e3f38214f8517e6b9f8c6359a0171) Signed-off-by: akleja <storspov@gmail.com>
This commit is contained in:
parent
3bdb6412e1
commit
88fe1ee084
@ -1580,6 +1580,18 @@ wxRect TrackPanel::FindFocusedTrackRect( const Track * target )
|
||||
return rect;
|
||||
}
|
||||
|
||||
std::vector<wxRect> TrackPanel::FindRulerRects( const Track *target )
|
||||
{
|
||||
std::vector<wxRect> results;
|
||||
if (target)
|
||||
VisitCells( [&]( const wxRect &rect, TrackPanelCell &visited ) {
|
||||
if (auto pRuler = dynamic_cast<const TrackVRulerControls*>(&visited);
|
||||
pRuler && pRuler->FindTrack().get() == target)
|
||||
results.push_back(rect);
|
||||
} );
|
||||
return results;
|
||||
}
|
||||
|
||||
TrackPanelCell *TrackPanel::GetFocusedCell()
|
||||
{
|
||||
auto pTrack = TrackFocus::Get( *GetProject() ).Get();
|
||||
@ -1603,27 +1615,3 @@ void TrackPanel::OnTrackFocusChange( wxCommandEvent &event )
|
||||
Refresh( false );
|
||||
}
|
||||
}
|
||||
|
||||
IsVisibleTrack::IsVisibleTrack(AudacityProject *project)
|
||||
: mPanelRect {
|
||||
wxPoint{ 0, ViewInfo::Get( *project ).vpos },
|
||||
wxSize{
|
||||
ViewInfo::Get( *project ).GetTracksUsableWidth(),
|
||||
ViewInfo::Get( *project ).GetHeight()
|
||||
}
|
||||
}
|
||||
{}
|
||||
|
||||
bool IsVisibleTrack::operator () (const Track *pTrack) const
|
||||
{
|
||||
// Need to return true if this track or a later channel intersects
|
||||
// the view
|
||||
return
|
||||
TrackList::Channels(pTrack).StartingWith(pTrack).any_of(
|
||||
[this]( const Track *pT ) {
|
||||
auto &view = TrackView::Get( *pT );
|
||||
wxRect r(0, view.GetY(), 1, view.GetHeight());
|
||||
return r.Intersects(mPanelRect);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -149,6 +149,13 @@ public:
|
||||
*/
|
||||
wxRect FindFocusedTrackRect( const Track * target );
|
||||
|
||||
/*!
|
||||
@return extents of the vertical rulers of one channel, top to bottom.
|
||||
(There may be multiple sub-views, each with a ruler.)
|
||||
If target is nullptr, returns an empty vector.
|
||||
*/
|
||||
std::vector<wxRect> FindRulerRects( const Track * target );
|
||||
|
||||
protected:
|
||||
// Get the root object defining a recursive subdivision of the panel's
|
||||
// area into cells
|
||||
|
@ -694,80 +694,20 @@ void GetInfoCommand::ExploreAdornments( const CommandContext &context,
|
||||
}
|
||||
|
||||
void GetInfoCommand::ExploreTrackPanel( const CommandContext &context,
|
||||
wxPoint P, wxWindow * pWin, int WXUNUSED(Id), int depth )
|
||||
wxPoint P, int depth )
|
||||
{
|
||||
AudacityProject * pProj = &context.project;
|
||||
auto &tp = TrackPanel::Get( *pProj );
|
||||
auto &viewInfo = ViewInfo::Get( *pProj );
|
||||
|
||||
wxRect trackRect = pWin->GetRect();
|
||||
|
||||
for ( auto t : TrackList::Get( *pProj ).Any() + IsVisibleTrack{ pProj } ) {
|
||||
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.
|
||||
wxRect rect = trackRect;
|
||||
Track *l = t->GetLink();
|
||||
|
||||
if (t->GetLinked()) {
|
||||
rect.height += l->GetHeight();
|
||||
}
|
||||
|
||||
switch (t->GetKind()) {
|
||||
case Track::Wave:
|
||||
{
|
||||
break;
|
||||
}
|
||||
#ifdef USE_MIDI
|
||||
case Track::Note:
|
||||
{
|
||||
break;
|
||||
}
|
||||
#endif // USE_MIDI
|
||||
case Track::Label:
|
||||
break;
|
||||
case Track::Time:
|
||||
break;
|
||||
}
|
||||
{
|
||||
// Start with whole track rect
|
||||
wxRect R = trackRect;
|
||||
|
||||
// Now exclude left, right, and top insets
|
||||
R.x += kLeftInset;
|
||||
R.y += kTopInset;
|
||||
R.width -= kLeftInset * 2;
|
||||
R.height -= kTopInset;
|
||||
|
||||
int labelw = viewInfo.GetLabelWidth();
|
||||
//int vrul = viewInfo.GetVRulerOffset();
|
||||
bool bIsWave = true;
|
||||
//mTrackInfo.DrawBackground(dc, R, t->GetSelected(), bIsWave, labelw, vrul);
|
||||
|
||||
|
||||
for (Overlay * pOverlay : pTP->mOverlays) {
|
||||
auto R2(pOverlay->GetRectangle(trackRect.GetSize()).first);
|
||||
context.Status( wxString::Format(" [ %2i, %3i, %3i, %3i, %3i, \"%s\" ],",
|
||||
depth, R2.GetLeft(), R2.GetTop(), R2.GetRight(), R2.GetBottom(), "Otherthing" ));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// The VRuler.
|
||||
{
|
||||
wxRect R = trackRect;
|
||||
R.x += viewInfo.GetVRulerOffset();
|
||||
R.y += kTopMargin;
|
||||
R.width = viewInfo.GetVRulerWidth();
|
||||
R.height -= (kTopMargin + kBottomMargin);
|
||||
wxRect panelRect{ {}, tp.GetSize() };
|
||||
for ( auto t : TrackList::Get( *pProj ).Any() ) {
|
||||
auto rulers = tp.FindRulerRects(t);
|
||||
for (auto &R : rulers) {
|
||||
if (!R.Intersects(panelRect))
|
||||
continue;
|
||||
R.SetPosition( R.GetPosition() + P );
|
||||
|
||||
context.StartStruct();
|
||||
context.AddItem( depth, "depth" );
|
||||
context.AddItem( "VRuler", "label" );
|
||||
context.AddItem( "VRuler", "label" );
|
||||
context.StartField("box");
|
||||
context.StartArray();
|
||||
context.AddItem( R.GetLeft() );
|
||||
@ -790,7 +730,7 @@ void GetInfoCommand::ExploreWindows( const CommandContext &context,
|
||||
if( pWin->GetName() == "Track Panel" )
|
||||
{
|
||||
wxRect R = pWin->GetScreenRect();
|
||||
ExploreTrackPanel( context, R.GetPosition()-P, pWin, Id, depth );
|
||||
ExploreTrackPanel( context, R.GetPosition()-P, depth );
|
||||
return;
|
||||
}
|
||||
wxWindowList list = pWin->GetChildren();
|
||||
|
@ -58,7 +58,7 @@ private:
|
||||
|
||||
void ExploreMenu( const CommandContext &context, wxMenu * pMenu, int Id, int depth );
|
||||
void ExploreTrackPanel( const CommandContext & context,
|
||||
wxPoint P, wxWindow * pWin, int Id, int depth );
|
||||
wxPoint P, int depth );
|
||||
void ExploreAdornments( const CommandContext & context,
|
||||
wxPoint P, wxWindow * pWin, int Id, int depth );
|
||||
void ExploreWindows( const CommandContext & context,
|
||||
|
Loading…
x
Reference in New Issue
Block a user