mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-18 09:00:52 +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;
|
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()
|
UIHandlePtr CellularPanel::Target()
|
||||||
{
|
{
|
||||||
auto &state = *mState;
|
auto &state = *mState;
|
||||||
|
@ -97,6 +97,12 @@ public:
|
|||||||
// is not specified which rectangle is returned.
|
// is not specified which rectangle is returned.
|
||||||
wxRect FindRect(const TrackPanelCell &cell);
|
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();
|
UIHandlePtr Target();
|
||||||
|
|
||||||
std::shared_ptr<TrackPanelCell> LastCell() const;
|
std::shared_ptr<TrackPanelCell> LastCell() const;
|
||||||
|
@ -3079,7 +3079,8 @@ int LabelTrack::DialogForLabelName(
|
|||||||
auto trackPanel = project.GetTrackPanel();
|
auto trackPanel = project.GetTrackPanel();
|
||||||
auto &viewInfo = project.GetViewInfo();
|
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
|
// 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.
|
// if it's a point label, or the start of its region if it's a region label.
|
||||||
position.x += trackPanel->GetLabelWidth()
|
position.x += trackPanel->GetLabelWidth()
|
||||||
|
@ -275,7 +275,8 @@ TrackPanel::~TrackPanel()
|
|||||||
|
|
||||||
LWSlider *TrackPanel::GainSlider( const WaveTrack *wt )
|
LWSlider *TrackPanel::GainSlider( const WaveTrack *wt )
|
||||||
{
|
{
|
||||||
auto rect = FindTrackRect( wt, true );
|
auto pControls = wt->GetTrackControl();
|
||||||
|
auto rect = FindRect( *pControls );
|
||||||
wxRect sliderRect;
|
wxRect sliderRect;
|
||||||
TrackInfo::GetGainRect( rect.GetTopLeft(), sliderRect );
|
TrackInfo::GetGainRect( rect.GetTopLeft(), sliderRect );
|
||||||
return TrackInfo::GainSlider(sliderRect, wt, false, this);
|
return TrackInfo::GainSlider(sliderRect, wt, false, this);
|
||||||
@ -283,7 +284,8 @@ LWSlider *TrackPanel::GainSlider( const WaveTrack *wt )
|
|||||||
|
|
||||||
LWSlider *TrackPanel::PanSlider( const WaveTrack *wt )
|
LWSlider *TrackPanel::PanSlider( const WaveTrack *wt )
|
||||||
{
|
{
|
||||||
auto rect = FindTrackRect( wt, true );
|
auto pControls = wt->GetTrackControl();
|
||||||
|
auto rect = FindRect( *pControls );
|
||||||
wxRect sliderRect;
|
wxRect sliderRect;
|
||||||
TrackInfo::GetPanRect( rect.GetTopLeft(), sliderRect );
|
TrackInfo::GetPanRect( rect.GetTopLeft(), sliderRect );
|
||||||
return TrackInfo::PanSlider(sliderRect, wt, false, this);
|
return TrackInfo::PanSlider(sliderRect, wt, false, this);
|
||||||
@ -292,7 +294,8 @@ LWSlider *TrackPanel::PanSlider( const WaveTrack *wt )
|
|||||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||||
LWSlider *TrackPanel::VelocitySlider( const NoteTrack *nt )
|
LWSlider *TrackPanel::VelocitySlider( const NoteTrack *nt )
|
||||||
{
|
{
|
||||||
auto rect = FindTrackRect( nt, true );
|
auto pControls = nt->GetTrackControl();
|
||||||
|
auto rect = FindRect( *pControls );
|
||||||
wxRect sliderRect;
|
wxRect sliderRect;
|
||||||
TrackInfo::GetVelocityRect( rect.GetTopLeft(), sliderRect );
|
TrackInfo::GetVelocityRect( rect.GetTopLeft(), sliderRect );
|
||||||
return TrackInfo::VelocitySlider(sliderRect, nt, false, this);
|
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),
|
// This finds the rectangle of a given track (including all channels),
|
||||||
// either that of the label 'adornment' or the track itself
|
// either that of the label 'adornment' or the track itself
|
||||||
// The given track is assumed to be the first channel
|
// 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 };
|
return { 0, 0, 0, 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
// PRL: I think the following very old comment misused the term "race
|
return CellularPanel::FindRect( [&] ( TrackPanelNode &node ) {
|
||||||
// condition" for a bug that happened with only a single thread. I think the
|
if (auto pGroup = dynamic_cast<const LabeledChannelGroup*>( &node ))
|
||||||
// real problem referred to, was that this function could be reached, via
|
return pGroup->mpTrack.get() == leader;
|
||||||
// TrackPanelAx callbacks, during low-level operations while the TrackList
|
return false;
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int TrackPanel::GetVRulerWidth() const
|
int TrackPanel::GetVRulerWidth() const
|
||||||
|
@ -341,10 +341,9 @@ public:
|
|||||||
|
|
||||||
void MakeParentRedrawScrollbars();
|
void MakeParentRedrawScrollbars();
|
||||||
|
|
||||||
// If label, rectangle includes track control panel only.
|
// Rectangle includes track control panel, and the vertical ruler, and
|
||||||
// If !label, rectangle includes all of that, and the vertical ruler, and
|
// the proper track area of all channels, and the separators between them.
|
||||||
// the proper track area.
|
wxRect FindTrackRect( const Track * target );
|
||||||
wxRect FindTrackRect( const Track * target, bool label );
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void MakeParentModifyState(bool bWantsAutoSave); // if true, writes auto-save file. Should set only if you really want the state change restored after
|
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;
|
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
|
// Inflate the screen reader's rectangle so it overpaints Audacity's own
|
||||||
// yellow focus rectangle.
|
// yellow focus rectangle.
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
|
@ -746,7 +746,7 @@ wxRect ScreenshotCommand::GetTrackRect( AudacityProject * pProj, TrackPanel * pa
|
|||||||
// This rectangle omits the focus ring about the track, and
|
// This rectangle omits the focus ring about the track, and
|
||||||
// also within that, a narrow black border with a "shadow" below and
|
// also within that, a narrow black border with a "shadow" below and
|
||||||
// to the right
|
// to the right
|
||||||
wxRect rect = panel.FindTrackRect( &t, false );
|
wxRect rect = panel.FindTrackRect( &t );
|
||||||
|
|
||||||
// Enlarge horizontally.
|
// Enlarge horizontally.
|
||||||
// PRL: perhaps it's one pixel too much each side, including some gray
|
// PRL: perhaps it's one pixel too much each side, including some gray
|
||||||
|
Loading…
x
Reference in New Issue
Block a user