30#include <wx/dcmemory.h>
44#define RANGE(array) std::begin(array), std::end(array)
70 for (
const auto line : lines ) {
71 lastExtra = line.extraSpace;
72 total += line.height + lastExtra;
94 (
const TCPLines &lines,
unsigned iItem,
int height )
97 auto pLines = lines.begin();
98 while ( pLines != lines.end() &&
99 0 == (pLines->items & iItem) ) {
100 y -= pLines->height + pLines->extraSpace;
103 if (pLines != lines.end())
104 y -= (pLines->height + pLines->extraSpace );
105 return { y, pLines->height };
112 unsigned height =
Margin * 2;
128 return subRect.y + subRect.height - allowance >= rect.y + limit;
133 const wxRect &rect,
const Track &track )
136 const auto &topLines = trackControl.GetTCPLines();
139 ( context, rect, &track, topLines, bottomLines );
144 const wxRect &rect_,
const Track *pTrack,
145 const std::vector<TCPLine> &topLines,
const std::vector<TCPLine> &bottomLines )
147 const auto rect = wxRect(rect_).Deflate(
Margin);
148 auto dc = &context.
dc;
154 for (
const auto &line : topLines ) {
157 rect.width, line.height
161 line.drawFunction( context, itemRect, pTrack );
162 yy += line.height + line.extraSpace;
166 int yy = rect.height;
167 for (
const auto &line : bottomLines ) {
168 yy -= line.height + line.extraSpace;
169 if ( line.drawFunction ) {
172 rect.width, line.height
174 line.drawFunction( context, itemRect, pTrack );
184 auto dc = &context.
dc;
185 auto pTrack = pChannel
188 bool selected = pTrack ? pTrack->
GetSelected() :
true;
189 bool hit = target && target->
FindTrack().get() == pTrack;
191 bool down = captured && bev.Contains( context.
lastState.GetPosition());
204 dc->Blit(bev.GetLeft(), bev.GetTop(), bev.width, bev.height, &memDC, 2, 2);
211 const auto hovered = rect.Contains( context.
lastState.GetPosition());
212 if(captured && hovered)
221 const wxRect &rect,
const Track *pTrack )
223 const auto dc = &context.
dc;
225 const auto target = context.
target.get();
226 const auto hit = target && target->FindTrack().get() == pTrack;
227 const auto captured = hit && target->IsDragging();
242 pTrack ? pTrack->
GetName() :
_(
"Name"), bev.width);
245 const auto metrics = dc->GetFontMetrics();
248 dc->SetTextBackground( wxTRANSPARENT );
249 dc->DrawText(titleStr, bev.x + 2, bev.y + (bev.height - (metrics.ascent + metrics.descent)) / 2);
254 const auto minimized =
283 const wxRect &rect,
const Track *pTrack )
285 auto dc = &context.
dc;
286 bool syncLockSelected =
290 if (syncLockSelected)
292 wxRect syncLockIconRect = rect;
297 dc->DrawBitmap(syncLockBitmap,
298 syncLockIconRect.x + 3,
299 syncLockIconRect.y + 2,
312 const auto rect = wxRect(rect_).Deflate(
Margin);
315 dest.y = rect.y + results.first;
316 dest.height = results.second;
326 dest.x = rect.x + closeRect.width +
Padding;
327 dest.width = minRect.x - closeRect.width - closeRect.x;
332 const auto rect = wxRect(rect_).Deflate(
Margin);
335 dest.y = rect.y + results.first;
336 dest.height = results.second;
353 const auto rect = wxRect(rect_).Deflate(
Margin);
356 dest.y = rect.y + results.first;
368 const auto rect = wxRect(rect_).Deflate(
Margin);
373 dest.y = rect.y + results.first;
374 dest.height = results.second;
380 dest.x = rect.x + rect.width - dest.width;
385 const auto rect = wxRect(rect_).Deflate(
Margin);
389 dest.y = rect.y + results.first;
390 dest.height = results.second;
std::vector< TrackInfo::TCPLine > TCPLines
TrackInfo::TCPLine TCPLine
static const TCPLines & commonTrackTCPLines()
declares abstract base class Track, TrackList, and iterators over TrackList
static void Bevel2(wxDC &dc, bool up, const wxRect &r, bool bSel=false, bool bHighlight=false)
static void DrawFrame(wxDC &dc, const wxRect &r, wxBitmap &bitmap, int mid)
std::shared_ptr< ChannelType > GetChannel(size_t iChannel)
Retrieve a channel, cast to the given type.
ChannelGroup & GetChannelGroup()
Channel object's lifetime is assumed to be nested in its Track's.
static ChannelView & Get(Channel &channel)
bool GetMinimized() const
static bool IsSyncLockSelected(const Track &track)
wxColour & Colour(int iIndex)
wxImage & Image(int iIndex)
wxBitmap & Bitmap(int iIndex)
static TrackControls & Get(Track &track)
Abstract base class for an object holding data associated with points on a time axis.
bool GetSelected() const
Selectedness is always the same for all channels of a group.
const wxString & GetName() const
Name is always the same for all channels of a group.
Short-lived drawing and event-handling object associated with a TrackPanelCell.
virtual std::shared_ptr< const Track > FindTrack() const =0
virtual bool IsDragging() const
AUDACITY_DLL_API void GetSliderHorizontalBounds(const wxRect &rect, wxRect &dest)
static constexpr auto ToolButtonSize
AUDACITY_DLL_API void GetSyncLockIconRect(const wxRect &rect, wxRect &dest)
static constexpr auto Margin
AUDACITY_DLL_API void GetCloseBoxHorizontalBounds(const wxRect &rect, wxRect &dest)
AUDACITY_DLL_API void CloseTitleDrawFunction(TrackPanelDrawingContext &context, const wxRect &rect, const Track *pTrack)
AUDACITY_DLL_API void GetTrackTitleRect(const wxRect &rect, wxRect &dest)
AUDACITY_DLL_API void GetSyncLockHorizontalBounds(const wxRect &rect, wxRect &dest)
AUDACITY_DLL_API void SyncLockDrawFunction(TrackPanelDrawingContext &context, const wxRect &rect, const Track *pTrack)
AUDACITY_DLL_API void DrawItems(TrackPanelDrawingContext &context, const wxRect &rect, const Track &track)
AUDACITY_DLL_API void GetTrackMenuButtonBounds(const wxRect &rect, wxRect &dest)
AUDACITY_DLL_API void GetCloseBoxRect(const wxRect &rect, wxRect &dest)
AUDACITY_DLL_API void GetTrackTitleHorizontalBounds(const wxRect &rect, wxRect &dest)
TrackInfo::TCPLines TCPLines
AUDACITY_DLL_API unsigned DefaultTrackHeight(const TCPLines &topLines)
AUDACITY_DLL_API void DrawCloseButton(TrackPanelDrawingContext &context, const wxRect &bev, const Channel *pChannel, UIHandle *target)
AUDACITY_DLL_API void GetTrackMenuButtonRect(const wxRect &rect, wxRect &dest)
AUDACITY_DLL_API void GetMinimizeRect(const wxRect &rect, wxRect &dest)
AUDACITY_DLL_API void GetMinimizeHorizontalBounds(const wxRect &rect, wxRect &dest)
AUDACITY_DLL_API const TCPLines & StaticTCPLines()
AUDACITY_DLL_API unsigned MinimumTrackHeight()
AUDACITY_DLL_API bool HideTopItem(const wxRect &rect, const wxRect &subRect, int allowance=0)
AUDACITY_DLL_API wxString TruncateText(wxDC &dc, const wxString &text, const int maxWidth)
AUDACITY_DLL_API void SetTrackInfoFont(wxDC *dc)
std::vector< TCPLine > TCPLines
AUDACITY_DLL_API std::pair< int, int > CalcItemY(const TCPLines &lines, unsigned iItem)
const TrackInfo::TCPLine defaultCommonTrackTCPBottomLines[]
std::pair< int, int > CalcBottomItemY(const TCPLines &lines, unsigned iItem, int height)
TCPLines commonTrackTCPBottomLines
int totalTCPLines(const TCPLines &lines, bool omitLastExtra)
void DrawToolButtonBackground(TrackPanelDrawingContext &context, const wxRect &rect, bool captured)