| 436 | } |
| 437 | |
| 438 | void MeterPanel::OnPaint(wxPaintEvent & WXUNUSED(event)) |
| 439 | { |
| 440 | #if defined(__WXMAC__) |
| 441 | auto paintDC = std::make_unique<wxPaintDC>(this); |
| 442 | #else |
| 443 | std::unique_ptr<wxDC> paintDC{ wxAutoBufferedPaintDCFactory(this) }; |
| 444 | #endif |
| 445 | wxDC & destDC = *paintDC; |
| 446 | wxColour clrText = theTheme.Colour( clrTrackPanelText ); |
| 447 | wxColour clrBoxFill = theTheme.Colour( clrMedium ); |
| 448 | |
| 449 | if (mLayoutValid == false || (mStyle == MixerTrackCluster )) |
| 450 | { |
| 451 | // Create a NEW one using current size and select into the DC |
| 452 | mBitmap = std::make_unique<wxBitmap>(); |
| 453 | mBitmap->Create(mWidth, mHeight, destDC); |
| 454 | wxMemoryDC dc; |
| 455 | dc.SelectObject(*mBitmap); |
| 456 | |
| 457 | // Go calculate all of the layout metrics |
| 458 | HandleLayout(dc); |
| 459 | |
| 460 | mBkgndBrush.SetColour( GetBackgroundColour() ); |
| 461 | dc.SetPen(*wxTRANSPARENT_PEN); |
| 462 | dc.SetBrush(mBkgndBrush); |
| 463 | dc.DrawRectangle(0, 0, mWidth, mHeight); |
| 464 | |
| 465 | // MixerTrackCluster style has no icon or L/R labels |
| 466 | if (mStyle != MixerTrackCluster) |
| 467 | { |
| 468 | dc.SetFont(GetFont()); |
| 469 | dc.SetTextForeground( clrText ); |
| 470 | dc.SetTextBackground( clrBoxFill ); |
| 471 | dc.DrawText(mLeftText, mLeftTextPos.x, mLeftTextPos.y); |
| 472 | dc.DrawText(mRightText, mRightTextPos.x, mRightTextPos.y); |
| 473 | } |
| 474 | |
| 475 | // Setup the colors for the 3 sections of the meter bars |
| 476 | wxColor green(117, 215, 112); |
| 477 | wxColor yellow(255, 255, 0); |
| 478 | wxColor red(255, 0, 0); |
| 479 | |
| 480 | // Bug #2473 - (Sort of) Hack to make text on meters more |
| 481 | // visible with darker backgrounds. It would be better to have |
| 482 | // different colors entirely and as part of the theme. |
| 483 | if (GetBackgroundColour().GetLuminance() < 0.25) |
| 484 | { |
| 485 | green = wxColor(117-100, 215-100, 112-100); |
| 486 | yellow = wxColor(255-100, 255-100, 0); |
| 487 | red = wxColor(255-100, 0, 0); |
| 488 | } |
| 489 | else if (GetBackgroundColour().GetLuminance() < 0.50) |
| 490 | { |
| 491 | green = wxColor(117-50, 215-50, 112-50); |
| 492 | yellow = wxColor(255-50, 255-50, 0); |
| 493 | red = wxColor(255-50, 0, 0); |
| 494 | } |
| 495 |
nothing calls this directly
no test coverage detected