void ofxTLKeyframes::mouseDragged(ofMouseEventArgs& args, long millis){

	if(keysAreStretchable){
		//cast the stretch anchor to long so that it can be signed
		float stretchRatio = 1.0*(millis-long(stretchAnchor)) / (1.0*stretchSelectPoint-stretchAnchor);

        for(int k = 0; k < selectedKeyframes.size(); k++){
            setKeyframeTime(selectedKeyframes[k], ofClamp(stretchAnchor + (selectedKeyframes[k]->grabTimeOffset * stretchRatio),
														  0, timeline->getDurationInMilliseconds()));
            selectedKeyframes[k]->screenPosition = screenPositionForKeyframe(selectedKeyframes[k]);
		}
        timeline->flagUserChangedValue();
        keysDidDrag = true;
        updateKeyframeSort();
	}

    if(keysAreDraggable && selectedKeyframes.size() != 0){
        ofVec2f screenpoint(args.x,args.y);
        for(int k = 0; k < selectedKeyframes.size(); k++){
            ofVec2f newScreenPosition;
            setKeyframeTime(selectedKeyframes[k], ofClamp(millis - selectedKeyframes[k]->grabTimeOffset,
														  screenXToMillis(bounds.getMinX()), screenXToMillis(bounds.getMaxX())));
            selectedKeyframes[k]->value = screenYToValue(args.y - selectedKeyframes[k]->grabValueOffset);
            selectedKeyframes[k]->screenPosition = screenPositionForKeyframe(selectedKeyframes[k]);
        }
        if(selectedKeyframe != NULL && timeline->getMovePlayheadOnDrag()){
            timeline->setCurrentTimeMillis(selectedKeyframe->time);
        }
        timeline->flagUserChangedValue();
        keysDidDrag = true;
        updateKeyframeSort();
    }
	createNewOnMouseup = false;
}
void ofxTLCameraTrack::draw3d(){
	
	if(lockCameraToTrack) return;
	
	ofxTLCameraFrame interFrame;
	ofNode n;
	ofPushStyle();

	
	for(int i = 0; i  < keyframes.size(); i++){
		ofxTLCameraFrame* frame = (ofxTLCameraFrame*)keyframes[i];
		n.setPosition(frame->position);
		n.setOrientation(frame->orientation);
		n.draw();
		ofPushStyle();
		ofPopStyle();
	}
	
	unsigned long long startMillis = screenXToMillis(bounds.x);
	unsigned long long endMillis = screenXToMillis(bounds.getMaxX());
	unsigned long long step = (endMillis - startMillis)/100;
	for(unsigned long long millis = startMillis; millis < endMillis; millis += step ){
		setCameraFrameToTime(&interFrame, millis);
		n.setPosition(interFrame.position);
		n.setOrientation(interFrame.orientation);
		ofSetColor(0,0,255);
		ofLine(n.getPosition(), n.getPosition() + n.getLookAtDir()*10);
		ofSetColor(0,255,0);
		ofLine(n.getPosition(), n.getPosition() + n.getUpDir()*10);
		ofSetColor(255,0,0);
		ofLine(n.getPosition(), n.getPosition() + n.getSideDir()*10);
	}

	setCameraFrameToTime(&interFrame, currentTrackTime());
	n.setPosition(interFrame.position);
	n.setOrientation(interFrame.orientation);
	
	ofSetLineWidth(3);
	ofSetColor(0,0,255);
	ofLine(n.getPosition(), n.getPosition() + n.getLookAtDir()*25);
	ofSetColor(0,255,0);
	ofLine(n.getPosition(), n.getPosition() + n.getUpDir()*25);
	ofSetColor(255,0,0);
	ofLine(n.getPosition(), n.getPosition() + n.getSideDir()*25);
	
	ofNoFill();
	ofSetColor(255);
	ofDrawBox(n.getPosition(), 4);
	
	ofPopStyle();
}
void ofxTLVideoDepthAlignmentScrubber::mouseDragged(ofMouseEventArgs& args, long millis){
	if(ready() && bounds.inside(args.x, args.y)){
		selectedPercent = screenXtoNormalizedX(args.x);
		selectedVideoMillis = screenXToMillis(args.x);
		updateSelection();
	}
}
ofxTLKeyframe* ofxTLSubtitleTrack::newKeyframe(){
	ofxTLSubtitle* newTitle = new ofxTLSubtitle();
    newTitle->timeRange.min = newTitle->timeRange.max = screenXToMillis(ofGetMouseX());
    newTitle->startSelected = false;
    newTitle->endSelected   = true; //true so you can drag the range to start with
    
    newTitle->subtitleUnit = subtitles.addSubtitle(newTitle->timeRange.min, newTitle->timeRange.max, "", "");
    return newTitle;
}
Ejemplo n.º 5
0
void ofxTLAudioTrack::mouseMoved(ofMouseEventArgs& args, long millis){
	if (!bounds.inside(args.x, args.y)) return;

	for (vector<AlignMarker>::iterator m = markers.begin(); m != markers.end(); m++) {
		if (m->selected) {
			cout << "ms selected changin from " << m->ms << endl;
			m->ms = screenXToMillis(normalizedXtoScreenX(screenXtoNormalizedX(args.x, zoomBounds)));
			cout << " to: " << m->ms << endl;
		}
	}
}
Ejemplo n.º 6
0
ofxTLKeyframe* ofxTLSwitches::newKeyframe(){
    ofxTLSwitch* switchKey = new ofxTLSwitch();
    //in the case of a click, start at the mouse positiion
    //if this is being restored from XML, the next call to restore will override this with what is in the XML
    switchKey->timeRange.min = switchKey->timeRange.max = screenXToMillis(ofGetMouseX());
    switchKey->startSelected = false;
    switchKey->endSelected   = true; //true so you can drag the range to start with
	
	//for just placing a switch we'll be able to decide the end position
	placingSwitch = switchKey;
	
    return switchKey;
}
Ejemplo n.º 7
0
ofxTLKeyframe* ofxTLNotes::newKeyframe(){
    ofxTLNote* switchKey = new ofxTLNote();
    //in the case of a click, start at the mouse positiion
    //if this is being restored from XML, the next call to restore will override this with what is in the XML
    switchKey->timeRange.min = switchKey->timeRange.max = screenXToMillis(ofGetMouseX());
    switchKey->startSelected = false;
    switchKey->endSelected   = true; //true so you can drag the range to start with
	
	//for just placing a switch we'll be able to decide the end position
	placingSwitch = switchKey;
    
    // add pitch based on mouseY if that's the input device
    if(createNewOnMouseup){
        switchKey->pitch = pitchForScreenY(ofGetMouseY());
    }
	
    return switchKey;
}
Ejemplo n.º 8
0
void ofxTLColorTrack::updatePreviewPalette() {

    if(previewPalette.getWidth() != bounds.width) {
        previewPalette.allocate(bounds.width, 1, OF_IMAGE_COLOR); //someday support alpha would be rad
    }

    if(keyframes.size() == 0 || keyframes.size() == 1) {
        return; //we just draw solid colors in this case
    }

    previewPalette.setUseTexture(false);
    for(int i = 0; i < bounds.width; i++) {
        previewPalette.setColor(i, 0, getColorAtMillis(screenXToMillis(bounds.x+i)));
    }
    previewPalette.setUseTexture(true);
    previewPalette.update();

    shouldRecomputePreviews = false;
}
Ejemplo n.º 9
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);
//	}
//	
}
Ejemplo n.º 10
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);
		}
	}

}