TrackPanelDrawable implementation
| 1349 | |
| 1350 | // TrackPanelDrawable implementation |
| 1351 | void Draw(TrackPanelDrawingContext &context, |
| 1352 | const wxRect &rect, unsigned iPass) override |
| 1353 | { |
| 1354 | if (iPass == TrackArtist::PassBorders) { |
| 1355 | auto &dc = context.dc; |
| 1356 | dc.SetBrush(*wxTRANSPARENT_BRUSH); |
| 1357 | dc.SetPen(*wxBLACK_PEN); |
| 1358 | |
| 1359 | // border |
| 1360 | dc.DrawRectangle( |
| 1361 | rect.x, rect.y, |
| 1362 | rect.width - kShadowThickness, rect.height - kShadowThickness |
| 1363 | ); |
| 1364 | |
| 1365 | // shadow |
| 1366 | if constexpr (kShadowThickness > 0) |
| 1367 | { |
| 1368 | // Stroke lines along bottom and right, which are slightly short at |
| 1369 | // bottom-left and top-right |
| 1370 | const auto right = rect.GetRight(); |
| 1371 | const auto bottom = rect.GetBottom(); |
| 1372 | |
| 1373 | // bottom |
| 1374 | AColor::Line(dc, rect.x + 2, bottom, right, bottom); |
| 1375 | // right |
| 1376 | AColor::Line(dc, right, rect.y + 2, right, bottom); |
| 1377 | } |
| 1378 | } |
| 1379 | if (iPass == TrackArtist::PassFocus) { |
| 1380 | // Sometimes highlight is not drawn on backing bitmap. I thought |
| 1381 | // it was because FindFocus did not return the TrackPanel on Mac, but |
| 1382 | // when I removed that test, yielding this condition: |
| 1383 | // if (GetFocusedTrack() != NULL) { |
| 1384 | // the highlight was reportedly drawn even when something else |
| 1385 | // was the focus and no highlight should be drawn. -RBD |
| 1386 | const auto artist = TrackArtist::Get(context); |
| 1387 | auto &trackPanel = *artist->parent; |
| 1388 | auto &trackFocus = TrackFocus::Get( *trackPanel.GetProject() ); |
| 1389 | if (trackFocus.Get() == mpTrack.get() && |
| 1390 | wxWindow::FindFocus() == &trackPanel) { |
| 1391 | /// Draw a three-level highlight gradient around the focused track. |
| 1392 | wxRect theRect = rect; |
| 1393 | auto &dc = context.dc; |
| 1394 | dc.SetBrush(*wxTRANSPARENT_BRUSH); |
| 1395 | |
| 1396 | AColor::TrackFocusPen(&dc, 2); |
| 1397 | dc.DrawRectangle(theRect); |
| 1398 | theRect.Deflate(1); |
| 1399 | |
| 1400 | AColor::TrackFocusPen(&dc, 1); |
| 1401 | dc.DrawRectangle(theRect); |
| 1402 | theRect.Deflate(1); |
| 1403 | |
| 1404 | AColor::TrackFocusPen(&dc, 0); |
| 1405 | dc.DrawRectangle(theRect); |
| 1406 | } |
| 1407 | } |
| 1408 | } |