void ofxTLKeyframes::draw(){ if(bounds.width == 0 || bounds.height < 2){ return; } if(shouldRecomputePreviews || viewIsDirty){ recomputePreviews(); } ofPushStyle(); //draw current value indicator as a big transparent rectangle ofSetColor(timeline->getColors().disabledColor, 30); float currentPercent = sampleAtTime(timeline->getCurrentTimeMillis()); ofFill(); ofRect(bounds.x, bounds.getMaxY(), bounds.width, -bounds.height*currentPercent); //***** DRAW KEYFRAME LINES ofSetColor(timeline->getColors().keyColor); ofNoFill(); preview.draw(); //**** DRAW KEYFRAME DOTS //**** HOVER FRAME if(hoverKeyframe != NULL){ ofPushStyle(); ofFill(); ofSetColor(timeline->getColors().highlightColor); ofVec2f hoverKeyPoint = screenPositionForKeyframe( hoverKeyframe ); ofCircle(hoverKeyPoint.x, hoverKeyPoint.y, 6); ofPopStyle(); } //**** ALL CACHED VISIBLE KEYS ofSetColor(timeline->getColors().textColor); ofNoFill(); for(int i = 0; i < keyPoints.size(); i++){ ofRect(keyPoints[i].x-1, keyPoints[i].y-1, 3, 3); } //**** SELECTED KEYS ofSetColor(timeline->getColors().textColor); ofFill(); for(int i = 0; i < selectedKeyframes.size(); i++){ if(isKeyframeIsInBounds(selectedKeyframes[i])){ ofVec2f screenpoint = screenPositionForKeyframe(selectedKeyframes[i]); float keysValue = ofMap(selectedKeyframes[i]->value, 0, 1.0, valueRange.min, valueRange.max, true); if(keysAreDraggable){ string frameString = timeline->formatTime(selectedKeyframes[i]->time); timeline->getFont().drawString(ofToString(keysValue, 4), screenpoint.x+5, screenpoint.y-5); } ofCircle(screenpoint.x, screenpoint.y, 4); } } ofPopStyle(); }
//draw your keyframes into bounds void ofxTLLFO::draw(){ //we draw keys our own way //ofxTLKeyframes::draw(); if(bounds.width == 0 || bounds.height < 2){ return; } if(shouldRecomputePreviews || viewIsDirty){ recomputePreviews(); } ofSetColor(timeline->getColors().disabledColor, 30); float currentPercent = sampleAtTime(currentTrackTime()); ofFill(); ofRect(bounds.x, bounds.getMaxY(), bounds.width, -bounds.height*currentPercent); ofPushStyle(); ofSetColor(timeline->getColors().keyColor); preview.draw(); for(int i = 0; i < keyframes.size(); i++){ //make sure it's on screen if(isKeyframeIsInBounds(keyframes[i])){ //we know the type because we created it in newKeyframe() //so we can safely cast ofxTLLFOKey* lfoKey = (ofxTLLFOKey*)keyframes[i]; if(isKeyframeSelected(keyframes[i])){ ofSetLineWidth(2); ofSetColor(timeline->getColors().textColor); } else if(keyframes[i] == hoverKeyframe){ ofSetLineWidth(4); ofSetColor(timeline->getColors().highlightColor); } else{ ofSetLineWidth(4); ofSetColor(timeline->getColors().keyColor); } float screenX = millisToScreenX(keyframes[i]->time); ofLine(screenX, bounds.y, screenX, bounds.y+bounds.height); } } ofPopStyle(); }