void ofxTLCameraTrack::draw(){
	//draw your keyframes into bounds
	ofPushStyle();

	if(lockCameraToTrack){
		ofSetColor(timeline->getColors().keyColor, 40*(sin(ofGetElapsedTimef()*5)*.5+.5)+25);
		ofFill();
		ofRect(bounds);
	}
	ofSetColor(timeline->getColors().keyColor);
	ofNoFill();


	//	for(int i = 0; i < track.getSamples().size(); i++){
	for(int i = 0; i < keyframes.size(); i++){
		if(!isKeyframeIsInBounds(keyframes[i])){
			continue;
		}
		
		ofxTLCameraFrame* sample =(ofxTLCameraFrame*)keyframes[i];
		float screenX = millisToScreenX(keyframes[i]->time);
		float screenY = bounds.y;
		ofPoint screenPoint = ofPoint(screenX,screenY);
		
		//        if(keyframes[i] == selectedKeyframe){
		if(isKeyframeSelected(sample)){
			if(sample->easeInSelected){
				ofSetColor(timeline->getColors().highlightColor);
				draweEase(sample->easeIn, screenPoint, true);
				ofSetColor(timeline->getColors().keyColor);
				draweEase(sample->easeOut, screenPoint, false);
			}
			else {
				ofSetColor(timeline->getColors().keyColor);
				draweEase(sample->easeIn, screenPoint, true);
				ofSetColor(timeline->getColors().highlightColor);
				draweEase(sample->easeOut,screenPoint, false);
			}
		}
		else{
			ofSetColor(timeline->getColors().keyColor);
			draweEase(sample->easeIn,  screenPoint, true);
			draweEase(sample->easeOut, screenPoint, false);
		}
	}

	ofFill();
	ofSetColor(timeline->getColors().highlightColor);
	for(int i = 0; i < selectedKeyframes.size(); i++){
		float screenX = millisToScreenX( selectedKeyframes[i]->time );
		float screenY = bounds.y+bounds.height/2;
		ofCircle(screenX, screenY, 4);
	}

	ofPopStyle();

}
Example #2
0
//TODO: find a way to make this not happen every frame
void ofxTLTicker::updateBPMPoints(){
	
	bpmScreenPoints.clear();

	double currentPoint = 0;
	double oneMeasure = 1.0/(bpm/60.);
	double halfMeasure = oneMeasure/2;
	double quarterMeasure = halfMeasure/2;

	bool showMeasure = false;
	bool showHalfMeasure = false;
	bool showQuarterMeasure = false;
	showMeasure = screenXForTime(oneMeasure) - screenXForTime(0) > 20;
	if(showMeasure){
		showHalfMeasure = screenXForTime(halfMeasure) - screenXForTime(0) > 20;
		if (showHalfMeasure) {
			showQuarterMeasure = screenXForTime(halfMeasure) - screenXForTime(0) > 20;
		}
	}

	int currentMeasure = 0;        
	while(currentPoint < timeline->getDurationInSeconds()){
		ofxTLBPMPoint measures[4];
		int numMeasures = 0;
		if(showMeasure){
			measures[0].millis = currentPoint * 1000;
			measures[0].screenX = millisToScreenX(measures[0].millis);
			measures[0].weight = 4;
			numMeasures = 1;
		}
		if(showHalfMeasure){
			measures[1].millis = (currentPoint+halfMeasure) * 1000;
			measures[1].screenX = millisToScreenX(measures[1].millis);
			measures[1].weight = 2;
			numMeasures = 2;
		}
		if(showQuarterMeasure){
			measures[2].millis = (currentPoint+quarterMeasure) * 1000;
			measures[2].screenX = millisToScreenX(measures[2].millis);
			measures[2].weight = 1;
			measures[3].millis = (currentPoint+halfMeasure+quarterMeasure) * 1000;
			measures[3].screenX = millisToScreenX(measures[3].millis);
			measures[3].weight = 1;
			numMeasures = 4;
		}
		
		for(int m = 0; m < numMeasures; m++){
			if( isOnScreen(measures[m].screenX) ){
				bpmScreenPoints.push_back( measures[m] );
			}
		}

		currentMeasure++;
		currentPoint = currentMeasure*oneMeasure;
	}

}
Example #3
0
void ofxTLTrack::_draw(){
	ofPushStyle();
	
	if(focused){
		ofFill();
		ofSetColor(timeline->getColors().highlightColor, 50);
		ofRect(bounds.x, bounds.y, bounds.width, bounds.height);
	}
	
	ofNoFill();
	if(hover){
		ofSetColor(timeline->getColors().textColor);
	}
	else{
		ofSetColor(timeline->getColors().outlineColor);
	}	
	ofRect(bounds.x, bounds.y, bounds.width, bounds.height);
	ofPopStyle();

	ofPushStyle();
    draw();
	ofPopStyle();
	
	if(isPlaying){
		float playheadScreenX = millisToScreenX(currentTrackTime());
		if(isOnScreen(playheadScreenX)){
			ofPushStyle();
			ofSetColor(timeline->getColors().keyColor);
			ofLine(playheadScreenX, bounds.getMinY(), playheadScreenX, bounds.getMaxY());
			ofPopStyle();
		}			
	}
	viewIsDirty = false;
}
bool ofxTLVideoDepthAlignmentScrubber::mousePressed(ofMouseEventArgs& args, long millis){
	cout << "mouse pressed in depth align. active? " << isActive() << endl;
	if(!isActive()){
		return false;
	}
	vector<VideoDepthPair>& alignedFrames = getPairs();
	for(int i = 0; i < alignedFrames.size(); i++){

//		long videoMillis;
//		if(depthSequence->doFramesHaveTimestamps()){
////			videoMillis = videoSequence->getPlayer()->getTotalNumFrames() * alignedFrames[i].videoMillis / (videoSequence->getPlayer()->getDuration()*1000.0);
//            float videoPercent = alignedFrames[i].videoMillis / (videoSequence->getPlayer()->getDuration()*1000.0);
//			videoMillis = videoPercent * videoSequence->getPlayer()->getTotalNumFrames();			
//		}
//		else{
//			videoMillis = alignedFrames[i].videoMillis;
//		}
		int screenX = millisToScreenX( alignedFrames[i].videoMillis );
		cout << "clicked on x " << screenX << " for vidoe millis " << alignedFrames[i].videoMillis << " mouse x is " << args.x << endl;
		if(abs(args.x - screenX) < 5){
			cout << " selecting pair " << endl;
			selectedPairIndex = i;
			return false;
		}
	}
	
	selectedPairIndex = -1;
	return false;
}
Example #5
0
void ofxTLFlags::draw(){
	
	if(bounds.height < 2){
		return;
	}
	
	ofPushStyle();
	
    ofxTLBangs::draw();
    
	ofFill();
	ofSetLineWidth(5);
	for(int i = keyframes.size()-1; i >= 0; i--){
        ofxTLFlag* key = (ofxTLFlag*)keyframes[i];
		if(isKeyframeIsInBounds(key)){
			int screenX = millisToScreenX(key->time);
			
			ofSetColor(timeline->getColors().backgroundColor);		
			int textHeight = bounds.y + 10 + ( (20*i) % int(MAX(bounds.height-15, 15)));
			key->display = ofRectangle(MIN(screenX+3, bounds.getMaxX() - key->textField.bounds.width),
									   textHeight-10, 100, 15);
			ofRect(key->display);
			
			ofSetColor(timeline->getColors().textColor);
			
			key->textField.bounds.x = key->display.x;
			key->textField.bounds.y = key->display.y;
			key->textField.draw();
		}
	}
	ofPopStyle();
}
Example #6
0
void ofxTLFlags::draw(){
	
	if(bounds.height < 2){
		return;
	}
	
	ofPushStyle();
	
    ofxTLBangs::draw();
    
	ofFill();
	ofSetLineWidth(5);
	for(int i = keyframes.size()-1; i >= 0; i--){
        ofxTLFlag* key = (ofxTLFlag*)keyframes[i];
		int screenX = millisToScreenX(key->time);
		ofSetColor(timeline->getColors().backgroundColor);		
		int textHeight = bounds.y + 10 + ( (20*i) % int(bounds.height) );
		key->display = ofRectangle(screenX+2.5, textHeight-10, 100, 15);
		ofRect(key->display);
        
		ofSetColor(timeline->getColors().textColor);		
        key->textField.bounds.x = screenX;
        key->textField.bounds.y = key->display.y;//-10 accounts for textfield's offset
        key->textField.draw(); 
	}
	ofPopStyle();
}
bool ofxTLCameraTrack::mousePressed(ofMouseEventArgs& args, long millis){
	//for the general behavior call the super class
	//or you can do your own thing. Return true if the click caused an item to
	//become selectd
	bool ret = ofxTLKeyframes::mousePressed(args, millis);
	createNewOnMouseup = false;
	if(selectedKeyframe != NULL){
		ofxTLCameraFrame* sample = (ofxTLCameraFrame*)selectedKeyframe;
		sample->easeInSelected = args.x < millisToScreenX(sample->time);
	}
	return ret;

}
Example #8
0
//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();
}
void ofxTLVideoDepthAlignmentScrubber::draw(){
	
	if(!ready()){
		ofPushStyle();
		ofSetColor(255, 100, 0, 30);
		ofRect(bounds);
		ofPopStyle();
		return;
	}
		
	ofPushStyle();
	vector<VideoDepthPair>& alignedFrames = getPairs();
	for(int i = 0; i < alignedFrames.size(); i++){
//		long vid;
//		if(depthSequence->doFramesHaveTimestamps()){
//			float videoPercent = alignedFrames[i].videoMillis / (videoSequence->getPlayer()->getDuration()*1000.0);
//			videoFrame = videoPercent * videoSequence->getPlayer()->getTotalNumFrames();
//		}
//		else{
//			videoFrame = alignedFrames[i].videoMillis;
//		}
//        
		int screenX = millisToScreenX( alignedFrames[i].videoMillis );
		if(i == selectedPairIndex){
			ofSetColor(timeline->getColors().textColor);
		}
		else{
			ofSetColor(timeline->getColors().keyColor);
		}
		
		ofLine(screenX, bounds.y, 
               screenX, bounds.y+bounds.height);
		ofDrawBitmapString("video: " + ofToString(ofxTimecode::timecodeForMillis(alignedFrames[i].videoMillis)), ofPoint(screenX+10, bounds.y+15));
		ofDrawBitmapString("depth: " + ofToString(ofxTimecode::timecodeForMillis(alignedFrames[i].depthMillis)), ofPoint(screenX+10, bounds.y+35));
	}
	
	ofSetColor(0, 125, 255);
	int selectedScreenX = normalizedXtoScreenX(selectedPercent);
	ofLine(selectedScreenX, bounds.y, selectedScreenX, bounds.y+bounds.height);
	ofDrawBitmapString("sel.video: " + ofToString(selectedVideoMillis), ofPoint(selectedScreenX+10, bounds.y+55));
	ofDrawBitmapString("sel.depth: " + ofToString(selectedDepthMillis), ofPoint(selectedScreenX+10, bounds.y+75));
	
	ofPopStyle();
}
Example #10
0
void ofxTLBangs::draw(){
        
    if(bounds.height < 2){
        return;
    }
    
    ofPushStyle();
    ofFill();
	
	//float currentPercent = powf(MIN(ofGetElapsedTimef() - lastBangTime, .5), 2);
	float currentPercent = powf(ofMap(ofGetElapsedTimef() - lastBangTime, 0, .5, 1.0, 0,true), 2);
	if(currentPercent > 0){
		ofSetColor(timeline->getColors().disabledColor, 100*(currentPercent));
		ofFill();
		ofRect(bounds.x, bounds.y, bounds.width, bounds.height);
	}
	
    for(int i = keyframes.size()-1; i >= 0; i--){
		if(!isKeyframeIsInBounds(keyframes[i])){
			continue;
		}
        //int screenX = normalizedXtoScreenX(keyframes[i]->position.x);
        int screenX = millisToScreenX(keyframes[i]->time);
        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);
        }
        
        ofLine(screenX, bounds.y, screenX, bounds.y+bounds.height);
    }
    ofPopStyle();

}
void ofxTLFileSelectFlags::draw()
{
    
    if(bounds.height < 2){
        return;
    }
    
    ofPushStyle();
    
    ofxTLBangs::draw();
    
    ofFill();
    ofSetLineWidth(5);
    for(int i = keyframes.size()-1; i >= 0; i--){
        ofxTLFileSelectFlag* key = (ofxTLFileSelectFlag*)keyframes[i];
        if(isKeyframeIsInBounds(key)){
            int screenX = millisToScreenX(key->time);
            int textHeight = bounds.y + 10 + ( (20*i) % int(MAX(bounds.height-15, 15)));
            
//            ofSetColor(timeline->getColors().backgroundColor);
//            key->display = ofRectangle(MIN(screenX+3, bounds.getMaxX() - key->textField.bounds.width),
//                                       textHeight-10, 180, 30);
//            ofRect(key->display);
//            
//            ofSetColor(timeline->getColors().textColor);
            
            int x = MIN(screenX+3, bounds.getMaxX());// - key->textField.bounds.width);
            int y = textHeight - 10;

            //key->textField.draw();
            
            
            //DatGUI
            
            key->flagButton->setPosition(x,y);
            key->flagButton->draw();
        }
    }
    ofPopStyle();
}
void ofxTLSwitches::draw(){
    
    ofPushStyle();
	ofFill();
	
	//draw a little wobble if its on
	//if(isOnAtMillis(timeline->getCurrentTimeMillis())){
	//play solo change
	if(isOn()){
		ofSetColor(timeline->getColors().disabledColor, 20+(1-powf(sin(ofGetElapsedTimef()*5)*.5+.5,2))*20);
		ofRect(bounds);
	}

    for(int i = 0; i < keyframes.size(); i++){
        ofxTLSwitch* switchKey = (ofxTLSwitch*)keyframes[i];
        float startScreenX = millisToScreenX(switchKey->timeRange.min);
        float endScreenX = millisToScreenX(switchKey->timeRange.max);
		switchKey->display = ofRectangle(startScreenX, bounds.y, endScreenX-startScreenX, bounds.height);

        //draw handles

        ofSetLineWidth(2);
        bool keyIsSelected = isKeyframeSelected(switchKey);
        if(keyIsSelected || switchKey->startSelected){
	        ofSetColor(timeline->getColors().textColor);
        }
        else{
	        ofSetColor(timeline->getColors().keyColor);    
        }        

        ofLine(switchKey->display.x, bounds.y, 
               switchKey->display.x, bounds.y+bounds.height);

        if(keyIsSelected || switchKey->endSelected){
	        ofSetColor(timeline->getColors().textColor);                
        }
        else{
	        ofSetColor(timeline->getColors().keyColor);    
        }        
        ofLine(switchKey->display.x+switchKey->display.width, bounds.y, 
               switchKey->display.x+switchKey->display.width, bounds.y+bounds.height);

        //draw region
        if(keyIsSelected){
        	ofSetColor(timeline->getColors().textColor, 100);    
        }
        else{
        	ofSetColor(timeline->getColors().keyColor, 100);
        }
        //set overlay colors, this will override the colors above
        if(hoverKeyframe == switchKey){
            if(startHover){
                ofPushStyle();
                if(switchKey->startSelected){
                    ofSetColor(timeline->getColors().highlightColor);
                }
                else{
                    ofSetColor(timeline->getColors().keyColor);
                }
                ofRect(switchKey->display.x-2, bounds.y, 4, bounds.height);
                ofPopStyle();
            }
            else if(endHover){
				ofPushStyle();
                if(switchKey->endSelected){
                    ofSetColor(timeline->getColors().highlightColor);
                }
                else{
                    ofSetColor(timeline->getColors().keyColor);
                }
                ofRect(switchKey->display.x+switchKey->display.width-2, bounds.y, 4.0, bounds.height);
                ofPopStyle();
            }
            else {
                if(keyIsSelected){
	                ofSetColor(timeline->getColors().highlightColor);                    
                }else {
	                ofSetColor(timeline->getColors().keyColor);    
                }
            }
        }
        ofRect(switchKey->display);
    }
    ofPopStyle();
}
Example #13
0
void ofxTLColorTrack::draw() {

    if(bounds.height == 0) {
        return;
    }

    if(viewIsDirty || shouldRecomputePreviews) {
        updatePreviewPalette();
    }

    if(keyframes.size() == 0) {
        ofPushStyle();
        ofSetColor(defaultColor);
        ofFill();
        ofRect(bounds);
        ofPopStyle();
    }
    else if(keyframes.size() == 1) {
        ofPushStyle();
        ofxTLColorSample* s = (ofxTLColorSample*)keyframes[0];
        ofSetColor(s->color);
        ofFill();
        ofRect(bounds);
        ofPopStyle();
    }
    else {
        previewPalette.draw(bounds);
    }

    for(int i = 0; i < keyframes.size(); i++) {

        if(!isKeyframeIsInBounds(keyframes[i])) {
            continue;
        }

        float screenX = millisToScreenX(keyframes[i]->time);

        ofPoint a = ofPoint(screenX-10,bounds.y);
        ofPoint b = ofPoint(screenX+10,bounds.y);
        ofPoint c = ofPoint(screenX,bounds.y+10);

        ofPushStyle();
        ofFill();
        ofxTLColorSample* s = (ofxTLColorSample*)keyframes[i];
        ofSetColor(s->color);
        ofTriangle(a,b,c);
        ofNoFill();
        ofSetColor(s->color.getInverted());
        ofSetLineWidth(1);
        ofTriangle(a,b,c);

        if(keyframes[i] == hoverKeyframe) {
            ofSetColor(timeline->getColors().highlightColor);
            ofSetLineWidth(3);
        }
        else if(isKeyframeSelected(keyframes[i])) {
            ofSetColor(timeline->getColors().textColor);
            ofSetLineWidth(2);
        }
        else {
            ofSetColor(s->color.getInverted());
        }
        ofLine(c, ofVec2f(screenX, bounds.getMaxY()));
        ofPopStyle();
    }
}
Example #14
0
void ofxTLBeatTicker::draw(){
	if (!isSetup || disabled)
		return;

	ofPushStyle();

	int textH, textW;
	string text;

	if(viewIsDirty){
		refreshTickMarks();
	}

	drawBPMGrid = true;
	tickerMarks.setStrokeColor( ofColor(0, 0, 240) );
	tickerMarks.setStrokeWidth(1);
	tickerMarks.draw(bounds.x, bounds.y);

	if(drawBPMGrid){
		if(viewIsDirty){
			updateBPMPoints();
		}
		ofPushStyle();

		ofSetColor(0, 0, 0, 200);
		ofSetLineWidth(1);

		int siz = bpmScreenPoints.size();
		int howmany;
		if (siz > 20)
			howmany = siz / 15;
		else if (siz > 12)
			howmany = 4;
		else howmany = 4;
		for(int i = 0; i < bpmScreenPoints.size(); i++) {
			if (isOnScreen(bpmScreenPoints[i].screenX)) {
				int bi = floor(bpmScreenPoints[i].beat);
				//if ((bi) % 4 == 1) { // draw bpms indices
				if ((bi) % howmany == 1) { // draw bpms indices
#if DRAW_FXCKING_GRID
						ofLine(bpmScreenPoints[i].screenX, getBottomEdge(), bpmScreenPoints[i].screenX, totalDrawRect.y+totalDrawRect.height);
#endif
						text = tostr(bi);
						textW = timeline->getFont().stringWidth(text);
						timeline->getFont().drawString(text, bpmScreenPoints[i].screenX - textW/2, getBottomEdge()-20);
				}
			}
		}
		ofPopStyle();
	}

	textH = timeline->getFont().getLineHeight();
	textW = 3;


	//draw current frame
	int currentFrameX;
	if (timeline->getIsFrameBased()) {
		//text = ofToString(timeline->getCurrentFrame());
		text = tostr(timeline->millisecToBeat(hoverTime));
		currentFrameX = screenXForIndex(timeline->getCurrentFrame());
	} else{
		//text = timeline->formatTime(timeline->getCurrentTime());
		text = tostr(timeline->millisecToBeat(hoverTime));
		currentFrameX = screenXForTime(timeline->getCurrentTime());
		//currenttimeline->normalizedXtoScreenX(timeline->beatToNormalizedX(currentPoint), zoomBounds); //;timeline->millisToScreenX(timeline->beatToMillisec(measures[0].beat));
	}
	currentFrameX = ofClamp(currentFrameX, bounds.getMinX(), bounds.getMaxX());

	//draw playhead line
	ofSetLineWidth(1);
	ofLine(currentFrameX, totalDrawRect.y, currentFrameX, totalDrawRect.y+totalDrawRect.height);
	//text = tostr(timeline->millisecToBeat(hoverTime)+1 - startBeat);
	unsigned long startBeat = timeline->normalizedXToBeat(zoomBounds.min);// * timeline->getDurationInMilliseconds();
	text = tostr( timeline->normalizedXToBeat( screenXtoNormalizedX( millisToScreenX(hoverTime), zoomBounds) ) + 1);
	//cout << "ofxTLBeatTicker: hoverTime: " << hoverTime << " text:"<< text << endl;
	float screenX = ofClamp(millisToScreenX(hoverTime), bounds.getMinX(), bounds.getMaxX());
	timeline->getFont().drawString(text, screenX, bounds.y+textH+25);
	ofPopStyle();

}
Example #15
0
void ofxTLAudioTrack::draw(){
	
	if(!soundLoaded || player.getBuffer().size() == 0){
		ofPushStyle();
		ofSetColor(timeline->getColors().disabledColor);
		ofRectangle(bounds);
		ofPopStyle();
		return;
	}
		
	if(shouldRecomputePreview || viewIsDirty){
		recomputePreview();
	}

	//cout << "ofxTLAudioTrack::draw" << endl;

    ofSetColor(255, 255, 255, 205);
    ofFill();
    ofRect(bounds);
    ofPushStyle();
    //ofSetColor(timeline->getColors().keyColor);
    ofSetColor(0, 0 , 0, 255);
    ofNoFill();
    
    for(int i = 0; i < previews.size(); i++){
        ofPushMatrix();
        ofTranslate( normalizedXtoScreenX(computedZoomBounds.min, zoomBounds)  - normalizedXtoScreenX(zoomBounds.min, zoomBounds), 0, 0);
        ofScale(computedZoomBounds.span()/zoomBounds.span(), 1, 1);
        previews[i].draw();
        ofPopMatrix();
    }
    ofPopStyle();
	
	if(getIsPlaying() || timeline->getIsPlaying()){
		ofPushStyle();
		
		//will refresh fft bins for other calls too
		vector<float>& bins = getFFTSpectrum(defaultFFTBins);
		float binWidth = bounds.width / bins.size();
		//find max
		float averagebin = 0 ;
		for(int i = 0; i < bins.size(); i++){
			maxBinReceived = MAX(maxBinReceived, bins[i]);
			averagebin += bins[i];
		}
		averagebin /= bins.size();
		
		ofFill();
		ofSetColor(timeline->getColors().disabledColor, 120);
		for(int i = 0; i < bins.size(); i++){
			float height = bounds.height * bins[i]/maxBinReceived;
			float y = bounds.y + bounds.height - height;
			ofRect(bounds.x + i*binWidth, y, binWidth, height);
		}
		
		ofPopStyle();
	}

	// playhead 
	ofPushStyle();
	ofSetColor(0, 0, 0, 255);
	float x = normalizedXtoScreenX( oldpos, zoomBounds);
	ofLine(x, bounds.y, x, bounds.y + bounds.height);
	ofSetLineWidth(3);
	ofPopStyle();

	/*
	float pos = player.getPosition();
	if (pos) {
		ofxTLZoomer2D *zoom = (ofxTLZoomer2D*)timeline->getZoomer();
		ofRange z = zoom->getViewRange();
		ofRange oldz = z;
		float c = z.center(); 
		float d = pos - c;

		z.min = ofClamp(z.min + d, 0, 1); z.max = ofClamp(z.max + d, 0, 1);
		if (z.min == .0 && z.span() < oldz.span())
			z.max = oldz.max - oldz.min;
		if (z.max == 1. && z.span() < oldz.span())
			z.min = z.max - oldz.max + oldz.min;
	}*/




	// draw markers:
	for (vector<AlignMarker>::iterator m = markers.begin(); m != markers.end(); m++) {
		float xn = screenXtoNormalizedX(millisToScreenX(m->ms));
		if (zoomBounds.contains(xn)) {
			float x = timeline->normalizedXtoScreenX(xn, zoomBounds);
			if (m->selected)
				ofSetColor(255, 0, 0, 255);
			else 
				ofSetColor(0, 0, 0, 255);
			ofLine(x, bounds.y, x, bounds.y+bounds.height);
			m->rect = ofRectangle(x - 5, bounds.y + bounds.height - 12, 10, 10);
			ofSetColor(10, 0, 200, 100);
			ofFill();
			ofRect(m->rect);

			//cout << "m:" << m->ms << endl;
			ofSetColor(0, 0, 0, 255);
			timeline->getFont().drawString(ofToString(m->ms), x+1, bounds.y + 30);
		}
	}
	
}
Example #16
0
void ofxTLNotes::draw(){
    
    ofPushStyle();
	ofFill();
    
    // Draw Row BGs
	ofFill();
	float rowHeight = bounds.height / (valueRange.span()+1);
	
	for (int i = 0; i <= valueRange.span(); i++) {
		// alternate row colors
		if(i%2 == 1) {
			ofSetColor(255, 255, 255, 50);
		} else {
			ofSetColor(255, 255, 255, 25);
		}
		
        // set row color for active notes
        int whichRow = ofMap(i, 0, valueRange.span(), valueRange.max, valueRange.min);
        if(pitchIsOn(whichRow)){
            ofSetColor(0, 0, 0, 100);
        }
		ofRect(bounds.x, bounds.y + i * rowHeight, bounds.width, rowHeight);
	}
    
    for(int i = 0; i < keyframes.size(); i++){
        // Calculate Note Bounds
        ofxTLNote* switchKey = (ofxTLNote*)keyframes[i];
        float startScreenX = MAX(millisToScreenX(switchKey->timeRange.min), 0);
        float endScreenX = MIN(millisToScreenX(switchKey->timeRange.max), bounds.getMaxX());
		if(startScreenX == endScreenX){
			continue;
		}
        int whichRow = ofMap(switchKey->pitch, valueRange.max, valueRange.min, 0, valueRange.span());
		switchKey->display = ofRectangle(startScreenX, bounds.y + whichRow * rowHeight, endScreenX-startScreenX, rowHeight);
            
        // Drawing The Handles
        ofSetLineWidth(2);
        bool keyIsSelected = isKeyframeSelected(switchKey);
        if(keyIsSelected || switchKey->startSelected){
	        ofSetColor(timeline->getColors().textColor);
        }
        else{
	        ofSetColor(timeline->getColors().keyColor);
        }
        // Do Left Line
        ofLine(switchKey->display.x, switchKey->display.y,
               switchKey->display.x, switchKey->display.y + switchKey->display.height);
        
        if(keyIsSelected || switchKey->endSelected){
	        ofSetColor(timeline->getColors().textColor);
        }
        else{
	        ofSetColor(timeline->getColors().keyColor);
        }
        // Do Right Line
        ofLine(switchKey->display.x+switchKey->display.width,  switchKey->display.y,
               switchKey->display.x+switchKey->display.width, switchKey->display.y + switchKey->display.height);
        
        //draw region
        if(keyIsSelected){
        	ofSetColor(timeline->getColors().textColor, 100);
        }
        else{
        	ofSetColor(timeline->getColors().keyColor, 100);
        }
        //set overlay colors, this will override the colors above
        if(hoverKeyframe == switchKey){
            if(startHover){
                ofPushStyle();
                if(switchKey->startSelected){
                    ofSetColor(timeline->getColors().highlightColor);
                }
                else{
                    ofSetColor(timeline->getColors().keyColor);
                }
                ofRect(switchKey->display.x-2, bounds.y, 4, bounds.height);
                ofPopStyle();
            }
            else if(endHover){
				ofPushStyle();
                if(switchKey->endSelected){
                    ofSetColor(timeline->getColors().highlightColor);
                }
                else{
                    ofSetColor(timeline->getColors().keyColor);
                }
                ofRect(switchKey->display.x+switchKey->display.width-2, bounds.y, 4.0, bounds.height);
                ofPopStyle();
            }
            else {
                if(keyIsSelected){
	                ofSetColor(timeline->getColors().highlightColor);
                }else {
	                ofSetColor(timeline->getColors().keyColor);
                }
            }
        }
        ofRect(switchKey->display);
    }
    ofPopStyle();
}
Example #17
0
void ofxTLColorTrack::drawModalContent() {
    if(drawingColorWindow) {

        //this happens when a new keyframe is added
        //we need to wait until the draw cycle for the new
        //key to be in the array so we can determine it's
        //surrounding samples
        if(setNextAndPreviousOnUpdate) {
            setNextAndPreviousSamples();
            setNextAndPreviousOnUpdate = false;
        }

        if(selectedKeyframe == NULL) {
            ofLogError("ofxTLColorTrack::drawModalContent") << "The selected keyframe is null" << endl;
            drawingColorWindow = false;
            timeline->dismissedModalContent();
            return;
        }

        if(!colorPallete.bAllocated()) {
            ofLogError("ofxTLColorTrack::drawModalContent") << "The color palette is not allocated" << endl;
            timeline->dismissedModalContent();
            drawingColorWindow = false;
        }
        ofPushStyle();
        ofFill();
        ofSetColor(255);

        ofxTLColorSample* selectedSample = (ofxTLColorSample*)selectedKeyframe;
        colorWindow = ofRectangle( millisToScreenX(selectedKeyframe->time), bounds.y+bounds.height, 200, 200);
        if(colorWindow.getMaxY()+25 > timeline->getBottomLeft().y) {
            colorWindow.y = bounds.y - 25 - colorWindow.height;
        }
        if(colorWindow.getMaxX() > ofGetWidth()) {
            colorWindow.x -= colorWindow.width;
        }
        colorPallete.draw(colorWindow);

        ofVec2f selectionPoint = colorWindow.getMin() + selectedSample->samplePoint * ofVec2f(colorWindow.width,colorWindow.height);
        ofSetColor(selectedSample->color.getInverted());
        ofLine(selectionPoint - ofVec2f(8,0), selectionPoint + ofVec2f(8,0));
        ofLine(selectionPoint - ofVec2f(0,8), selectionPoint + ofVec2f(0,8));

        ofPushStyle();
        ofNoFill();
        if(previousSample != NULL) {
            ofVec2f previousSamplePoint = colorWindow.getMin() + previousSample->samplePoint * ofVec2f(colorWindow.width,colorWindow.height);
            ofSetColor(previousSample->color.getInverted(), 150);
            ofCircle(previousSamplePoint, 3);
            ofLine(previousSamplePoint,selectionPoint);
        }
        if(nextSample != NULL) {
            ofVec2f nextSamplePoint = colorWindow.getMin() + nextSample->samplePoint * ofVec2f(colorWindow.width,colorWindow.height);
            ofSetColor(nextSample->color.getInverted(), 150);

            //draw a little triangle pointer
            ofVec2f direction = (nextSamplePoint - selectionPoint).normalized();
            ofVec2f backStep = nextSamplePoint-direction*5;
            ofTriangle(nextSamplePoint,
                       backStep + direction.getRotated(90)*3,
                       backStep - direction.getRotated(90)*3);
            ofLine(nextSamplePoint,selectionPoint);
        }
        ofPopStyle();

        previousColorRect = ofRectangle(colorWindow.x, colorWindow.getMaxY(), colorWindow.width/2, 25);
        newColorRect = ofRectangle(colorWindow.x+colorWindow.width/2, colorWindow.getMaxY(), colorWindow.width/2, 25);

        ofSetColor(colorAtClickTime);
        ofRect(previousColorRect);
        ofSetColor(selectedSample->color);
        ofRect(newColorRect);
        ofSetColor(timeline->getColors().keyColor);
        ofNoFill();
        ofSetLineWidth(2);
        ofRect(colorWindow);
        ofPopStyle();
    }
}
Example #18
0
void ofxTLTicker::refreshTickMarks(){
	tickerMarks.clear();

    unsigned long startMillis = zoomBounds.min * timeline->getDurationInMilliseconds();
    unsigned long endMillis = zoomBounds.max * timeline->getDurationInMilliseconds();
    unsigned long durationInview = endMillis-startMillis;
    float millisPerPixel = durationInview / bounds.width;
	
	//expand to days
	bool showMillis;
	bool showSeconds;
	bool showMinutes;
	int step = 4;
	//find the scale of time being shown
	if(millisPerPixel > 1000*60 * step){ //each pixel is more than a minute
		showMillis = false;
		showSeconds = false;
		showMinutes = false;
	}
	else if(millisPerPixel > 1000 * step){ //each pixel is more than a second
		showMillis = false;
		showSeconds = false;
		showMinutes = true;
	}
	else if(millisPerPixel > step){ //each pixel is more than a millisecond
		showMillis = false;
		showSeconds = true;
		showMinutes = true;
	}
	else{ //each pixel is less than a millsecond
		showMillis = true;
		showSeconds = true;
		showMinutes = true;
	}
	
	unsigned long lastMillis = screenXToMillis(bounds.x);
	int lastSecond = lastMillis/1000;
	int lastMinute = lastSecond/60;
	int lastHour = lastMinute/60;
	for(int i = bounds.getMinX()+step; i < bounds.getMaxX(); i+=step){
		int height = 0;
		unsigned long currentMillis = screenXToMillis(i);
		int currentSecond = currentMillis/1000;
		int currentMinute = currentSecond/60;
		int currentHour = currentMinute/60;
		float x;
		if(showMillis && currentMillis > lastMillis){
			height = bounds.height*.25;
			lastMillis = currentMillis;
			x = millisToScreenX(currentMillis);
		}

		if(showSeconds && currentSecond > lastSecond){
			height = bounds.height*.5;
			lastSecond = currentSecond;
			x = millisToScreenX(lastSecond*1000);
		}
				
		if(showMinutes && currentMinute > lastMinute){
			height = bounds.height*.75;
			lastMinute = currentMinute;
			x = millisToScreenX(lastMinute*1000*60);
		}
		
		if(currentHour > lastHour){
			height = bounds.height;
			lastHour = currentHour;
			x = millisToScreenX(lastMinute*1000*60*60);
		}
		
		if(height != 0){
			tickerMarks.moveTo(x, bounds.height - height);
			tickerMarks.lineTo(x, bounds.height);
		}
	}
	
//	//draw ticker marks
//	ofSetLineWidth(1);
//	float heightMultiplier = .75;
//	for(float i = startTime; i <= endTime; i += secondsPerPixel*5){
//		//float x = ofMap(i, curStartFrame, curEndFrame, totalDrawRect.x, totalDrawRect.x+totalDrawRect.width, true);
//		float x = screenXForTime(i);
//		ofLine(x, bounds.y+bounds.height*heightMultiplier, x, bounds.y+bounds.height);
//	}
//    
//	//draw regular increments
//	int bigTickStep;
//	if(durationInview < 1){ //draw big tick every 100 millis
//		bigTickStep = .1;
//	}
//	else if(durationInview < 60){ // draw big tick every second
//		bigTickStep = 1;
//	}
//	else {
//		bigTickStep = 60;
//	}
//	ofSetLineWidth(3);
//	heightMultiplier = .5;
//	for(float i = startTime-fmod(startTime, bigTickStep); i <= endTime; i+=bigTickStep){
//		float x = screenXForTime(i);
//		ofLine(x, bounds.y+bounds.height*heightMultiplier, x, bounds.y+bounds.height);
//	}
//	
}
Example #19
0
void ofxTLTicker::refreshTickMarks(){
	tickerMarks.clear();

    unsigned long startMillis = zoomBounds.min * timeline->getDurationInMilliseconds();
    unsigned long endMillis = zoomBounds.max * timeline->getDurationInMilliseconds();
    unsigned long durationInview = endMillis-startMillis;
    float millisPerPixel = durationInview / bounds.width;
	
	//expand to days
	bool showMillis;
	bool showSeconds;
	bool showMinutes;
	int step = 4;
	//find the scale of time being shown
	if(millisPerPixel > 1000*60 * step){ //each pixel is more than a minute
		showMillis = false;
		showSeconds = false;
		showMinutes = false;
	}
	else if(millisPerPixel > 1000 * step){ //each pixel is more than a second
		showMillis = false;
		showSeconds = false;
		showMinutes = true;
	}
	else if(millisPerPixel > step){ //each pixel is more than a millisecond
		showMillis = false;
		showSeconds = true;
		showMinutes = true;
	}
	else{ //each pixel is less than a millsecond
		showMillis = true;
		showSeconds = true;
		showMinutes = true;
	}
	
	unsigned long lastMillis = screenXToMillis(bounds.x);
	int lastSecond = lastMillis/1000;
	int lastMinute = lastSecond/60;
	int lastHour = lastMinute/60;
	for(int i = bounds.getMinX()+step; i < bounds.getMaxX(); i+=step){
		int height = 0;
		unsigned long currentMillis = screenXToMillis(i);
		int currentSecond = currentMillis/1000;
		int currentMinute = currentSecond/60;
		int currentHour = currentMinute/60;
		float x;
		if(showMillis && currentMillis > lastMillis){
			height = bounds.height*.25;
			lastMillis = currentMillis;
			x = millisToScreenX(currentMillis);
		}

		if(showSeconds && currentSecond > lastSecond){
			height = bounds.height*.5;
			lastSecond = currentSecond;
			x = millisToScreenX(lastSecond*1000);
		}
				
		if(showMinutes && currentMinute > lastMinute){
			height = bounds.height*.75;
			lastMinute = currentMinute;
			x = millisToScreenX(lastMinute*1000*60);
		}
		
		if(currentHour > lastHour){
			height = bounds.height;
			lastHour = currentHour;
			x = millisToScreenX(lastMinute*1000*60*60);
		}
		
		if(height != 0){
			tickerMarks.moveTo(x, bounds.height - height);
			tickerMarks.lineTo(x, bounds.height);
		}
	}

}
Example #20
0
void ofxTLTicker::draw(){
	
	ofPushStyle();
	
	int textH, textW;
	string text;

    //draw tickers with time
    float startTime = zoomBounds.min * timeline->getDurationInSeconds();
    float endTime = zoomBounds.max * timeline->getDurationInSeconds();
    float durationInview = endTime-startTime;
    float secondsPerPixel = durationInview / bounds.width;
    
	if(viewIsDirty){
		refreshTickMarks();
	}
	
	tickerMarks.setStrokeColor( ofColor(200, 180, 40) );
	tickerMarks.setStrokeWidth(1);
	tickerMarks.draw(bounds.x, bounds.y);
		
    if(drawBPMGrid){
		if(viewIsDirty){
	        updateBPMPoints();
		}
        ofPushStyle();
        ofSetColor(255, 255, 255, 50);
        for(int i = 0; i < bpmScreenPoints.size(); i++){
            ofSetLineWidth(bpmScreenPoints[i].weight);
            ofLine(bpmScreenPoints[i].screenX, getBottomEdge(), bpmScreenPoints[i].screenX, totalDrawRect.y+totalDrawRect.height);
        }
        ofPopStyle();
    }

	textH = timeline->getFont().getLineHeight();
	textW = 3;

	//highlite current mouse position
	if(hover){
		//draw background rect
		ofSetColor(timeline->getColors().backgroundColor);
        float screenX = millisToScreenX(hoverTime);
		text = timeline->formatTime(hoverTime);
		textW = timeline->getFont().stringWidth(text)+3;
        if(bounds.height > 2){
            int previewTimecodeX = ofClamp(screenX+5, bounds.x, bounds.x+bounds.width-textW-5);
            ofFill();
            ofRect(previewTimecodeX-5, bounds.y+textH, textW, textH);		
            //draw playhead line
            ofSetColor(timeline->getColors().textColor);
            timeline->getFont().drawString(text, previewTimecodeX, bounds.y+textH*2);
        }
		
		ofSetColor(timeline->getColors().highlightColor);
		ofSetLineWidth(1);

        ofLine(screenX, totalDrawRect.y, screenX, totalDrawRect.y+totalDrawRect.height);
	}
	
	//draw current frame
    //TIMECODE
    int currentFrameX;
    if (timeline->getIsFrameBased()) {
        text = ofToString(timeline->getCurrentFrame());
        currentFrameX = screenXForIndex(timeline->getCurrentFrame());
    }
    else{
        text = timeline->formatTime(timeline->getCurrentTime());
        currentFrameX = screenXForTime(timeline->getCurrentTime());
    }
    
    if(bounds.height > 2){
        int timeCodeX = ofClamp(currentFrameX+5, bounds.x, bounds.x+bounds.width-textW-5);
        ofSetColor(timeline->getColors().backgroundColor);
        ofFill();
        ofRect(timeCodeX-5, bounds.y, textW, textH);
        ofSetColor(timeline->getColors().textColor);
        timeline->getFont().drawString(text, timeCodeX, bounds.y+textH);
    }
	
    if(timeline->getIsPlaying()){
        ofSetColor(timeline->getColors().keyColor);
    }
    else{
        ofSetColor(timeline->getColors().outlineColor);
    }
	
	//draw playhead line
	ofSetLineWidth(1);
	ofLine(currentFrameX, totalDrawRect.y, currentFrameX, totalDrawRect.y+totalDrawRect.height);
	//draw bounds 
	ofNoFill();
	ofSetColor(200, 180, 40);
	ofRect(bounds);
		
	ofPopStyle();
}
ofVec2f ofxTLKeyframes::screenPositionForKeyframe(ofxTLKeyframe* keyframe){
    return ofVec2f(millisToScreenX(keyframe->time), 
                   valueToScreenY(keyframe->value));
}