MCPcopy Create free account
hub / github.com/audacity/audacity / DrawGrid

Method DrawGrid

src/widgets/Ruler.cpp:530–586  ·  view source on GitHub ↗

Draw grid

Source from the content-addressed store, hash-verified

528
529// ********** Draw grid ***************************
530void Ruler::DrawGrid(wxDC& dc,
531 const int gridLineLength,
532 const bool minorGrid, const bool majorGrid, int xOffset, int yOffset)
533 const
534{
535 UpdateCache( dc, nullptr );
536 auto &cache = *mpCache;
537
538 int gridPos;
539 wxPen gridPen;
540
541 if(mbMinor && (minorGrid && (gridLineLength != 0 ))) {
542 gridPen.SetColour(178, 178, 178); // very light grey
543 dc.SetPen(gridPen);
544 for( const auto &label : cache.mMinorLabels ) {
545 gridPos = label.pos;
546 if(mRulerStruct.mOrientation == wxHORIZONTAL) {
547 if((gridPos != 0) && (gridPos != gridLineLength))
548 AColor::Line(dc, gridPos+xOffset, yOffset, gridPos+xOffset, gridLineLength-1+yOffset);
549 }
550 else {
551 if((gridPos != 0) && (gridPos != gridLineLength))
552 AColor::Line(dc, xOffset, gridPos+yOffset, gridLineLength-1+xOffset, gridPos+yOffset);
553 }
554 }
555 }
556
557 if(majorGrid && (gridLineLength != 0 )) {
558 gridPen.SetColour(127, 127, 127); // light grey
559 dc.SetPen(gridPen);
560 for( const auto &label : cache.mMajorLabels ) {
561 gridPos = label.pos;
562 if(mRulerStruct.mOrientation == wxHORIZONTAL) {
563 if((gridPos != 0) && (gridPos != gridLineLength))
564 AColor::Line(dc, gridPos+xOffset, yOffset, gridPos+xOffset, gridLineLength-1+yOffset);
565 }
566 else {
567 if((gridPos != 0) && (gridPos != gridLineLength))
568 AColor::Line(dc, xOffset, gridPos+yOffset, gridLineLength-1+xOffset, gridPos+yOffset);
569 }
570 }
571
572 int zeroPosition = GetZeroPosition();
573 if(zeroPosition > 0) {
574 // Draw 'zero' grid line in black
575 dc.SetPen(*wxBLACK_PEN);
576 if(mRulerStruct.mOrientation == wxHORIZONTAL) {
577 if(zeroPosition != gridLineLength)
578 AColor::Line(dc, zeroPosition+xOffset, yOffset, zeroPosition+xOffset, gridLineLength-1+yOffset);
579 }
580 else {
581 if(zeroPosition != gridLineLength)
582 AColor::Line(dc, xOffset, zeroPosition+yOffset, gridLineLength-1+xOffset, zeroPosition+yOffset);
583 }
584 }
585 }
586}
587

Callers 3

DrawPlotMethod · 0.80
OnPaintMethod · 0.80
OnPaintMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected