Esempio n. 1
0
void ofxTLPage::mouseDragged(ofMouseEventArgs& args){
	if(draggingInside){
		bool snapped = false;
		float snapPercent = 0;
		if(snappingEnabled){
			
			refreshSnapPoints();
			
			float closestSnapDistance = snappingTolerance;
			float closestSnapPoint;
			//modify drag X if it should be snapped
			for(int i = 0; i < snapPoints.size(); i++){
				float distanceToPoint = abs(args.x - snapPoints[i]);
				if(distanceToPoint < closestSnapDistance){
					closestSnapPoint = i;
					closestSnapDistance = distanceToPoint; 
				}
			}
			
			if(closestSnapDistance < snappingTolerance){
				args.x = snapPoints[closestSnapPoint] + dragAnchor;
				snapPercent = snapPoints[closestSnapPoint];
				snapped = true;
			}
		}
		
		for(int i = 0; i < headers.size(); i++){
			headers[i]->mouseDragged(args);
			if(!headerHasFocus){
				elements[headers[i]->name]->mouseDragged(args, snapped);
			}
		}
	}
}
Esempio n. 2
0
void ofxTLPage::mousePressed(ofMouseEventArgs& args){
	draggingInside = elementContainerRect.inside(args.x, args.y);
	if(draggingInside){
		if(snappingEnabled){
			refreshSnapPoints();
		}
		headerHasFocus = false;
		for(int i = 0; i < headers.size(); i++){
			headers[i]->mousePressed(args);
			elements[headers[i]->name]->mousePressed(args);
			headerHasFocus |= ( headers[i]->getFooterRect().inside(args.x,args.y) && !elements[headers[i]->name]->getDrawRect().inside(args.x,args.y) );
		}
	}
}
Esempio n. 3
0
void ofxTLPage::mousePressed(ofMouseEventArgs& args, long millis){
	draggingInside = trackContainerRect.inside(args.x, args.y);
	draggingSelectionRectangle = false;
	ofxTLTrack* newFocus = NULL;
	if(draggingInside){
		headerHasFocus = false;
		footerIsDragging = false;

		for(int i = 0; i < headers.size(); i++){
			bool clickIsInHeader = headers[i]->getDrawRect().inside(args.x,args.y);
			bool clickIsInTrack = tracks[headers[i]->name]->getDrawRect().inside(args.x,args.y);
			bool clickIsInFooter = headers[i]->getFooterRect().inside(args.x,args.y);
			bool justMadeSelection = tracks[headers[i]->name]->_mousePressed(args, millis);

			headerHasFocus |= (clickIsInFooter || clickIsInHeader) && !justMadeSelection;
			footerIsDragging |= clickIsInFooter;
			//cout << "ofxTLPage::mousePressed name:"<<headers[i]->name<<": headerHasFocus "<<headerHasFocus<< " justMadeSelection:"<<justMadeSelection<<endl;
			if(headerHasFocus){
				headers[i]->mousePressed(args);
			}
			if(clickIsInTrack || clickIsInHeader || justMadeSelection){
				newFocus = tracks[ headers[i]->name ];
			}
		}

		refreshSnapPoints();

		if(!footerIsDragging && headerHasFocus) {//(headerHasFocus || timeline->getTotalSelectedItems() == 0 || ofGetModifierShiftPressed()) ){
			draggingSelectionRectangle = true;
			selectionRectangleAnchor = ofVec2f(args.x,args.y);
			selectionRectangle = ofRectangle(args.x,args.y,0,0);
		}
	}


	//TODO: explore multi-focus tracks for pasting into many tracks at once
	//paste events get sent to the focus track
	if(newFocus != NULL && newFocus != focusedTrack){
		if(focusedTrack != NULL){
			focusedTrack->lostFocus();
		}
		newFocus->gainedFocus();
		focusedTrack = newFocus; //is set to NULL when the whole timeline loses focus
	}
}