| 57 | } |
| 58 | |
| 59 | void Canvas::Render() |
| 60 | { |
| 61 | ofPushMatrix(); |
| 62 | ofTranslate(mX, mY); |
| 63 | ofPushStyle(); |
| 64 | ofSetLineWidth(.5f); |
| 65 | float w, h; |
| 66 | GetDimensions(w, h); |
| 67 | ofNoFill(); |
| 68 | ofRect(0, 0, mWidth, mHeight, 0); |
| 69 | ofRect(0, 0, GetWidth(), GetHeight(), 0); |
| 70 | |
| 71 | ofPushStyle(); |
| 72 | ofFill(); |
| 73 | const float rowHeight = GetHeight() / GetNumVisibleRows(); |
| 74 | for (int i = 0; i < GetNumVisibleRows(); ++i) |
| 75 | { |
| 76 | int row = mRowOffset + i; |
| 77 | if (row >= 0 && row < mRowColors.size()) |
| 78 | ofSetColorGradient(mRowColors[row], ofColor::lerp(mRowColors[row], ofColor::clear, .1f), ofVec2f(0, i * rowHeight + rowHeight * 0.0f), ofVec2f(0, i * rowHeight + rowHeight)); |
| 79 | ofRect(0, i * rowHeight, GetWidth(), rowHeight, 0); |
| 80 | } |
| 81 | ofPopStyle(); |
| 82 | |
| 83 | for (int i = 0; i < GetNumCols(); ++i) |
| 84 | { |
| 85 | float pos = ofMap(float(i) / GetNumCols(), mViewStart / mLength, mViewEnd / mLength, 0, 1) * GetWidth(); |
| 86 | if (pos >= 0 && pos < GetWidth()) |
| 87 | { |
| 88 | ofPushStyle(); |
| 89 | if (mMajorColumnInterval != -1 && i % mMajorColumnInterval == 0) |
| 90 | ofSetColor(255, 255, 255); |
| 91 | ofLine(pos, 0, pos, GetHeight()); |
| 92 | ofPopStyle(); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | for (int i = 0; i < mElements.size(); ++i) |
| 97 | { |
| 98 | //ofMap(GetStart() + offset,mCanvas->mStart/mCanvas->GetLength(),mCanvas->mEnd/mCanvas->GetLength(),0,1,clamp) |
| 99 | bool visibleOnCanvas = mElements[i]->mRow >= mRowOffset && mElements[i]->mRow < mRowOffset + GetNumVisibleRows() && |
| 100 | mElements[i]->GetStart() <= mViewEnd / GetLength() && mElements[i]->GetEnd() >= mViewStart / GetLength(); |
| 101 | if (visibleOnCanvas) |
| 102 | { |
| 103 | ofVec2f offset(0, 0); |
| 104 | if (mClick && mClickedElement != nullptr && mElements[i]->GetHighlighted() && mDragEnd == kHighlightEnd_None) |
| 105 | offset = (ofVec2f(TheSynth->GetRawMouseX(), TheSynth->GetRawMouseY()) - mClickedElementStartMousePos) / gDrawScale; |
| 106 | mElements[i]->Draw(offset); |
| 107 | } |
| 108 | |
| 109 | if (!visibleOnCanvas) |
| 110 | mElements[i]->DrawOffscreen(); |
| 111 | } |
| 112 | |
| 113 | if (mDragSelecting) |
| 114 | { |
| 115 | ofPushStyle(); |
| 116 | ofSetColor(255, 255, 255); |
nothing calls this directly
no test coverage detected