1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-02-07 04:01:54 +01:00

Move drawing code for margins and separators

This commit is contained in:
Paul Licameli
2018-11-03 00:34:49 -04:00
parent b881a6e918
commit 1ca079b503
5 changed files with 86 additions and 135 deletions

View File

@@ -11,12 +11,18 @@ Paul Licameli split from TrackPanel.cpp
#include "Audacity.h"
#include "TrackPanelResizerCell.h"
#include "AColor.h"
#include "Track.h"
#include "TrackArtist.h"
#include "TrackPanelDrawingContext.h"
#include "TrackPanelResizeHandle.h"
#include "TrackPanelMouseEvent.h"
#include "HitTestResult.h"
#include "ViewInfo.h"
#include "tracks/ui/TrackView.h"
#include <wx/dc.h>
#include <wx/mousestate.h>
TrackPanelResizerCell::TrackPanelResizerCell(
@@ -46,3 +52,63 @@ std::shared_ptr<Track> TrackPanelResizerCell::DoFindTrack()
return pView->FindTrack();
return {};
}
void TrackPanelResizerCell::Draw(
TrackPanelDrawingContext &context,
const wxRect &rect, unsigned iPass )
{
if ( iPass == TrackArtist::PassMargins ) {
auto pTrack = FindTrack();
if ( pTrack ) {
auto dc = &context.dc;
const bool last =
pTrack.get() == *TrackList::Channels( pTrack.get() ).rbegin();
if ( last ) {
// Fill in separator area below a track
AColor::TrackPanelBackground( dc, false );
dc->DrawRectangle( rect );
}
else {
// Area between channels of a group
// Paint the channel separator over (what would be) the lower border
// of this channel, down to and including the upper border of the
// next channel
ADCChanger cleanup{ dc };
// Paint the left part of the background
const auto artist = TrackArtist::Get( context );
auto labelw = artist->pZoomInfo->GetLabelWidth();
AColor::MediumTrackInfo( dc, pTrack->GetSelected() );
dc->DrawRectangle(
rect.GetX(), rect.GetY(), labelw, rect.GetHeight() );
// Stroke the left border
dc->SetPen(*wxBLACK_PEN);
{
const auto left = rect.GetLeft();
AColor::Line( *dc, left, rect.GetTop(), left, rect.GetBottom() );
}
AColor::TrackPanelBackground(dc, false);
wxRect rec{ rect };
rec.width -= labelw - rec.x;
rec.x = labelw;
dc->DrawRectangle( wxRect( rec ).Inflate( 0, -kBorderThickness ) );
// These lines stroke over what is otherwise "border" of each
// channel
dc->SetBrush(*wxTRANSPARENT_BRUSH);
dc->SetPen(*wxBLACK_PEN);
const auto left = rec.GetLeft();
const auto right = rec.GetRight();
const auto top = rec.GetTop();
const auto bottom = rec.GetBottom();
AColor::Line( *dc, left, top, right, top );
AColor::Line( *dc, left, bottom, right, bottom );
}
}
}
}