1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-17 16:50:26 +02:00

Hide details of screenshot rectangle computations in TrackPanel

(cherry picked from audacity commit 8cbad2022817650f30e737247fa6e6dc25069b81)

Signed-off-by: akleja <storspov@gmail.com>
This commit is contained in:
Paul Licameli 2021-08-06 18:28:36 -04:00 committed by akleja
parent 376f6acb90
commit 3bdb6412e1
3 changed files with 42 additions and 24 deletions

View File

@ -1542,7 +1542,7 @@ wxRect TrackPanel::FindTrackRect( const Track * target )
{
auto leader = *GetTracks()->FindLeader( target );
if (!leader) {
return { 0, 0, 0, 0 };
return {};
}
return CellularPanel::FindRect( [&] ( TrackPanelNode &node ) {
@ -1552,6 +1552,34 @@ wxRect TrackPanel::FindTrackRect( const Track * target )
} );
}
wxRect TrackPanel::FindFocusedTrackRect( const Track * target )
{
auto rect = FindTrackRect(target);
if (rect != wxRect{}) {
// Enlarge horizontally.
// PRL: perhaps it's one pixel too much each side, including some gray
// beyond the yellow?
rect.x = 0;
GetClientSize(&rect.width, nullptr);
// Enlarge vertically, enough to enclose the yellow focus border pixels
// The the outermost ring of gray pixels is included on three sides
// but not the top (should that be fixed?)
// (Note that TrackPanel paints its focus over the "top margin" of the
// 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;
rect.Inflate( 0, dy );
// Note that this rectangle does not coincide with any one of
// the nodes in the subdivision.
}
return rect;
}
TrackPanelCell *TrackPanel::GetFocusedCell()
{
auto pTrack = TrackFocus::Get( *GetProject() ).Get();

View File

@ -135,10 +135,20 @@ protected:
public:
void MakeParentRedrawScrollbars();
// Rectangle includes track control panel, and the vertical ruler, and
// the proper track area of all channels, and the separators between them.
/*!
@return includes track control panel, and the vertical ruler, and
the proper track area of all channels, and the separators between them.
If target is nullptr, returns empty rectangle.
*/
wxRect FindTrackRect( const Track * target );
/*!
@return includes what's in `FindTrackRect(target)` and the focus ring
area around it.
If target is nullptr, returns empty rectangle.
*/
wxRect FindFocusedTrackRect( const Track * target );
protected:
// Get the root object defining a recursive subdivision of the panel's
// area into cells

View File

@ -708,27 +708,7 @@ wxRect ScreenshotCommand::GetTracksRect(TrackPanel * panel){
wxRect ScreenshotCommand::GetTrackRect( AudacityProject * pProj, TrackPanel * panel, int n){
auto FindRectangle = []( TrackPanel &panel, Track &t )
{
// 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 );
// Enlarge horizontally.
// PRL: perhaps it's one pixel too much each side, including some gray
// beyond the yellow?
rect.x = 0;
panel.GetClientSize(&rect.width, nullptr);
// Enlarge vertically, enough to enclose the yellow focus border pixels
// 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 TrackView::GetY() and
// TrackView::GetHeight(), but also over the margin of the next track.)
rect.height += kBottomMargin;
int dy = kTopMargin - 1;
rect.Inflate( 0, dy );
wxRect rect = panel.FindFocusedTrackRect( &t );
// Reposition it relative to parent of panel
rect.SetPosition(