mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-05 14:18:53 +02:00
Remove one duplicate definition of track panel area subdivision
This commit is contained in:
commit
e86d508067
@ -1043,6 +1043,21 @@ wxRect CellularPanel::FindRect( const TrackPanelCell &cell )
|
||||
return result;
|
||||
}
|
||||
|
||||
wxRect CellularPanel::FindRect(
|
||||
const std::function< bool( TrackPanelNode& ) > &pred)
|
||||
{
|
||||
wxRect result;
|
||||
|
||||
struct Stop{};
|
||||
try { VisitPreorder( [&]( const wxRect &rect, TrackPanelNode &visited ) {
|
||||
if ( pred( visited ) )
|
||||
result = rect, throw Stop{};
|
||||
} ); }
|
||||
catch ( const Stop& ) {}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
UIHandlePtr CellularPanel::Target()
|
||||
{
|
||||
auto &state = *mState;
|
||||
|
@ -97,6 +97,12 @@ public:
|
||||
// is not specified which rectangle is returned.
|
||||
wxRect FindRect(const TrackPanelCell &cell);
|
||||
|
||||
// Search the tree of subdivisions of the panel area for a node (group or
|
||||
// cell) satisfying the predicate. If more than one sub-area is associated
|
||||
// with some node satisfying the predicate, it is not specified which
|
||||
// rectangle is returned.
|
||||
wxRect FindRect(const std::function< bool( TrackPanelNode& ) > &pred);
|
||||
|
||||
UIHandlePtr Target();
|
||||
|
||||
std::shared_ptr<TrackPanelCell> LastCell() const;
|
||||
|
@ -3079,7 +3079,8 @@ int LabelTrack::DialogForLabelName(
|
||||
auto trackPanel = project.GetTrackPanel();
|
||||
auto &viewInfo = project.GetViewInfo();
|
||||
|
||||
wxPoint position = trackPanel->FindTrackRect(trackPanel->GetFocusedTrack(), false).GetBottomLeft();
|
||||
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()
|
||||
|
@ -275,7 +275,8 @@ TrackPanel::~TrackPanel()
|
||||
|
||||
LWSlider *TrackPanel::GainSlider( const WaveTrack *wt )
|
||||
{
|
||||
auto rect = FindTrackRect( wt, true );
|
||||
auto pControls = wt->GetTrackControl();
|
||||
auto rect = FindRect( *pControls );
|
||||
wxRect sliderRect;
|
||||
TrackInfo::GetGainRect( rect.GetTopLeft(), sliderRect );
|
||||
return TrackInfo::GainSlider(sliderRect, wt, false, this);
|
||||
@ -283,7 +284,8 @@ LWSlider *TrackPanel::GainSlider( const WaveTrack *wt )
|
||||
|
||||
LWSlider *TrackPanel::PanSlider( const WaveTrack *wt )
|
||||
{
|
||||
auto rect = FindTrackRect( wt, true );
|
||||
auto pControls = wt->GetTrackControl();
|
||||
auto rect = FindRect( *pControls );
|
||||
wxRect sliderRect;
|
||||
TrackInfo::GetPanRect( rect.GetTopLeft(), sliderRect );
|
||||
return TrackInfo::PanSlider(sliderRect, wt, false, this);
|
||||
@ -292,7 +294,8 @@ LWSlider *TrackPanel::PanSlider( const WaveTrack *wt )
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
LWSlider *TrackPanel::VelocitySlider( const NoteTrack *nt )
|
||||
{
|
||||
auto rect = FindTrackRect( nt, true );
|
||||
auto pControls = nt->GetTrackControl();
|
||||
auto rect = FindRect( *pControls );
|
||||
wxRect sliderRect;
|
||||
TrackInfo::GetVelocityRect( rect.GetTopLeft(), sliderRect );
|
||||
return TrackInfo::VelocitySlider(sliderRect, nt, false, this);
|
||||
@ -2166,46 +2169,18 @@ std::shared_ptr<TrackPanelNode> TrackPanel::Root()
|
||||
// This finds the rectangle of a given track (including all channels),
|
||||
// either that of the label 'adornment' or the track itself
|
||||
// The given track is assumed to be the first channel
|
||||
wxRect TrackPanel::FindTrackRect( const Track * target, bool label )
|
||||
wxRect TrackPanel::FindTrackRect( const Track * target )
|
||||
{
|
||||
if (!target) {
|
||||
auto leader = *GetTracks()->FindLeader( target );
|
||||
if (!leader) {
|
||||
return { 0, 0, 0, 0 };
|
||||
}
|
||||
|
||||
// PRL: I think the following very old comment misused the term "race
|
||||
// condition" for a bug that happened with only a single thread. I think the
|
||||
// real problem referred to, was that this function could be reached, via
|
||||
// TrackPanelAx callbacks, during low-level operations while the TrackList
|
||||
// was not in a consistent state.
|
||||
// Now the problem is fixed by delaying the handling of events generated
|
||||
// by TrackList. And besides that, we use Channels() instead of looking
|
||||
// directly at the links.
|
||||
|
||||
// Old comment:
|
||||
// The check for a null linked track is necessary because there's
|
||||
// a possible race condition between the time the 2 linked tracks
|
||||
// are added and when wxAccessible methods are called. This is
|
||||
// most evident when using Jaws.
|
||||
auto height = TrackList::Channels( target ).sum( &Track::GetHeight );
|
||||
|
||||
wxRect rect{
|
||||
0,
|
||||
target->GetY() - mViewInfo->vpos,
|
||||
GetSize().GetWidth(),
|
||||
height
|
||||
};
|
||||
|
||||
|
||||
rect.x += kLeftMargin;
|
||||
if (label)
|
||||
rect.width = GetVRulerOffset() - kLeftMargin;
|
||||
else
|
||||
rect.width -= (kLeftMargin + kRightMargin);
|
||||
|
||||
rect.y += kTopMargin;
|
||||
rect.height -= (kTopMargin + kBottomMargin);
|
||||
|
||||
return rect;
|
||||
return CellularPanel::FindRect( [&] ( TrackPanelNode &node ) {
|
||||
if (auto pGroup = dynamic_cast<const LabeledChannelGroup*>( &node ))
|
||||
return pGroup->mpTrack.get() == leader;
|
||||
return false;
|
||||
} );
|
||||
}
|
||||
|
||||
int TrackPanel::GetVRulerWidth() const
|
||||
|
@ -341,10 +341,9 @@ public:
|
||||
|
||||
void MakeParentRedrawScrollbars();
|
||||
|
||||
// If label, rectangle includes track control panel only.
|
||||
// If !label, rectangle includes all of that, and the vertical ruler, and
|
||||
// the proper track area.
|
||||
wxRect FindTrackRect( const Track * target, bool label );
|
||||
// Rectangle includes track control panel, and the vertical ruler, and
|
||||
// the proper track area of all channels, and the separators between them.
|
||||
wxRect FindTrackRect( const Track * target );
|
||||
|
||||
protected:
|
||||
void MakeParentModifyState(bool bWantsAutoSave); // if true, writes auto-save file. Should set only if you really want the state change restored after
|
||||
|
@ -306,7 +306,7 @@ wxAccStatus TrackPanelAx::GetLocation( wxRect& rect, int elementId )
|
||||
return wxACC_FAIL;
|
||||
}
|
||||
|
||||
rect = mTrackPanel->FindTrackRect( t.get(), false );
|
||||
rect = mTrackPanel->FindTrackRect( t.get() );
|
||||
// Inflate the screen reader's rectangle so it overpaints Audacity's own
|
||||
// yellow focus rectangle.
|
||||
#ifdef __WXMAC__
|
||||
|
@ -746,7 +746,7 @@ wxRect ScreenshotCommand::GetTrackRect( AudacityProject * pProj, TrackPanel * pa
|
||||
// This rectangle omits the focus ring about the track, and
|
||||
// also within that, a narrow black border with a "shadow" below and
|
||||
// to the right
|
||||
wxRect rect = panel.FindTrackRect( &t, false );
|
||||
wxRect rect = panel.FindTrackRect( &t );
|
||||
|
||||
// Enlarge horizontally.
|
||||
// PRL: perhaps it's one pixel too much each side, including some gray
|
||||
|
Loading…
x
Reference in New Issue
Block a user