Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

removed and added comments

  • Loading branch information...
commit e2c1013c3856f4dbc6711b7445a05d89e27f1bf2 1 parent 296b657
@obviousjim obviousjim authored
Showing with 19 additions and 220 deletions.
  1. +19 −12 src/ofxTLFlags.cpp
  2. +0 −168 src/ofxTLKeyframer.cpp
  3. +0 −40 src/ofxTLKeyframer.h
View
31 src/ofxTLFlags.cpp
@@ -80,44 +80,48 @@ void ofxTLFlags::draw(){
//main function to get values out of the timeline, operates on the given value range
void ofxTLFlags::mousePressed(ofMouseEventArgs& args){
+ //if we aren't entering text and someone has the shift key held down don't let us go into modal
if(!enteringText && ofGetModifierKeyShift()){
ofxTLBangs::mousePressed(args);
return;
}
- ofxTLFlag* clickedTextField = NULL;
-
- //bool clickedOnTextField = false;
- //look at each element to see if
+ ofxTLFlag* clickedTextField = NULL;
+ //look at each element to see if a text field was clicked
for(int i = 0; i < keyframes.size(); i++){
ofxTLFlag* key = (ofxTLFlag*)keyframes[i];
if(key->display.inside(args.x, args.y)){
- //clickedOnTextField = true;
clickedTextField = key;
break;
}
}
+ //if so, select that text field and key and present modally
+ //so that keyboard input all goes to the text field.
+ //selection model is designed so that you can type into
+ //mulitple fields at once
if(clickedTextField != NULL){
enteringText = true;
timeline->presentedModalContent(this);
if(!ofGetModifierKeyShift()){
timeline->unselectAll();
}
+ //make sure this
if(!isKeyframeSelected(clickedTextField)){
selectedKeyframes.push_back(clickedTextField);
}
return;
}
- else{
- if(enteringText){
- enteringText = false;
- timeline->dismissedModalContent();
- timeline->unselectAll();
- return;
- }
+ //if we didn't click on a text field and we are entering txt
+ //take off the typing mode. Hitting enter will also do this
+ else if(enteringText){
+ enteringText = false;
+ timeline->dismissedModalContent();
+ return;
}
+ //if we get all the way here we didn't click on a text field and we aren't
+ //currently entering text so proceed as normal
ofxTLBangs::mousePressed(args);
}
@@ -130,10 +134,12 @@ void ofxTLFlags::mouseDragged(ofMouseEventArgs& args, bool snapped){
void ofxTLFlags::keyPressed(ofKeyEventArgs& args){
if(enteringText){
+ //enter key submits the values
if(args.key == OF_KEY_RETURN){
enteringText = false;
timeline->dismissedModalContent();
}
+ //otherwise pipe the keypress into all the selected textfields
else {
for(int i = 0; i < selectedKeyframes.size(); i++){
ofxTLFlag* key = (ofxTLFlag*)selectedKeyframes[i];
@@ -141,6 +147,7 @@ void ofxTLFlags::keyPressed(ofKeyEventArgs& args){
}
}
}
+ //normal behavior for nudging and deleting and stuff
else{
ofxTLBangs::keyPressed(args);
}
View
168 src/ofxTLKeyframer.cpp
@@ -55,140 +55,10 @@ ofxTLKeyframer::~ofxTLKeyframer(){
clear();
}
-//void ofxTLKeyframer::setValueRange(ofRange range, float newDefaultValue){
-// valueRange = range;
-// defaultValue = newDefaultValue;
-//}
-//
-////main function to get values out of the timeline, operates on the given value range
-//float ofxTLKeyframer::getValueAtPercent(float percent){
-// return ofMap(sampleAt(percent), 0.0, 1.0, valueRange.min, valueRange.max, false);
-//}
-
-//float ofxTLKeyframer::sampleAt(float percent){
-// percent = ofClamp(percent, 0, 1.0);
-//
-// //edge cases
-// if(keyframes.size() == 0){
-// return ofMap(defaultValue, valueRange.min, valueRange.max, 0, 1.0, true);
-// }
-//
-// if(percent < keyframes[0]->position.x){
-// return keyframes[0]->position.y;
-// }
-//
-// if(percent > keyframes[keyframes.size()-1]->position.x){
-// return keyframes[keyframes.size()-1]->position.y;
-// }
-//
-// for(int i = 1; i < keyframes.size(); i++){
-// if(keyframes[i]->position.x >= percent){
-// float percentBetween = ofxTween::map(percent, keyframes[i-1]->position.x, keyframes[i]->position.x, 0.0, 1.0, false,
-// *keyframes[i-1]->easeFunc->easing, keyframes[i-1]->easeType->type);
-// return keyframes[i-1]->position.y * (1.-percentBetween) + keyframes[i]->position.y*percentBetween;
-// }
-// }
-//
-// ofLog(OF_LOG_ERROR, "ofxTLKeyframer --- Error condition, couldn't find keyframe for percent " + ofToString(percent, 4));
-// return defaultValue;
-//}
-
-
void ofxTLKeyframer::draw(){
//TODO: simple keyframe draw
}
-//void ofxTLKeyframer::draw(){
-//
-// if(bounds.width == 0 || bounds.height == 0){
-//// ofLog(OF_LOG_ERROR, "ofxTLKeyframer --- Error condition, invalid bounds " + ofToString(bounds.width) + " " + ofToString(bounds.height) );
-// return;
-// }
-//
-// ofPushStyle();
-// ofPushMatrix();
-// ofEnableSmoothing();
-//
-// //**** DRAW BORDER. TODO: move to super class
-// ofNoFill();
-// if(hover){
-// ofSetColor(timeline->getColors().highlightColor);
-// }
-// else if(focused){
-// ofSetColor(timeline->getColors().highlightColor);
-// }
-// else{
-// ofSetColor(timeline->getColors().outlineColor);
-// }
-// ofRect(bounds.x, bounds.y, bounds.width, bounds.height);
-//
-//
-// //**** DRAW KEYFRAME LINES
-// ofSetColor(timeline->getColors().highlightColor);
-// ofNoFill();
-// ofBeginShape();
-// if(keyframes.size() == 0 || keyframes.size() == 1){
-// ofVertex(bounds.x, bounds.y + bounds.height - sampleAt(.5)*bounds.height);
-// ofVertex(bounds.x+bounds.width, bounds.y + bounds.height - sampleAt(.5)*bounds.height);
-// }
-// else{
-// for(int p = 0; p <= bounds.width; p++){
-// //TODO: cache this into a poly line to avoid insane sampling.
-// ofVertex(bounds.x + p, bounds.y + bounds.height - sampleAt(ofMap(p, 0, bounds.width, zoomBounds.min, zoomBounds.max, true)) * bounds.height);
-// }
-// }
-// ofEndShape(false);
-//
-// //**** DRAW KEYFRAME DOTS
-// ofSetColor(timeline->getColors().textColor);
-// for(int i = 0; i < keyframes.size(); i++){
-// if(!isKeyframeIsInBounds(keyframes[i])){
-// continue;
-// }
-//
-// ofSetColor(timeline->getColors().textColor);
-// ofVec2f screenpoint = coordForKeyframePoint(keyframes[i]->position);
-//
-// if(isKeyframeSelected( keyframes[i] )){
-// float keysValue = ofMap(keyframes[i]->position.y, 0, 1.0, valueRange.min, valueRange.max, true);
-// string frameString = timeline->getIsFrameBased() ?
-// ofToString(int(keyframes[i]->position.x*timeline->getDurationInFrames())) :
-// timeline->formatTime(keyframes[i]->position.x*timeline->getDurationInSeconds());
-// ofDrawBitmapString(frameString+"|"+ofToString(keysValue, 4), screenpoint.x+5, screenpoint.y+10);
-// ofFill();
-// }
-// else{
-// ofNoFill();
-// }
-//
-// if(keyframes[i] == hoverKeyframe){
-// ofPushStyle();
-// ofFill();
-// ofSetColor(timeline->getColors().highlightColor);
-// ofCircle(screenpoint.x, screenpoint.y, 8);
-// ofPopStyle();
-// }
-//
-// ofCircle(screenpoint.x, screenpoint.y, 4);
-// }
-//
-// //**** DRAW SELECT RECT
-// if(drawingSelectRect){
-// ofFill();
-// ofSetColor(timeline->getColors().keyColor, 30);
-// ofRect(selectRect);
-//
-// ofNoFill();
-// ofSetColor(timeline->getColors().keyColor, 255);
-// ofRect(selectRect);
-//
-// }
-// ofPopMatrix();
-// ofPopStyle();
-//}
-
-
-
void ofxTLKeyframer::load(){
ofxXmlSettings savedkeyframes;
clear();
@@ -269,34 +139,6 @@ string ofxTLKeyframer::getXMLStringForKeyframes(vector<ofxTLKeyframe*>& keys){
void ofxTLKeyframer::mousePressed(ofMouseEventArgs& args){
ofVec2f screenpoint = ofVec2f(args.x, args.y);
-
- //TODO: move to modal click world
- /*
- if(drawingEasingWindow){
- //see if we clicked on an
- drawingEasingWindow = false;
-
- for(int i = 0; i < easingFunctions.size(); i++){
- if(easingFunctions[i]->bounds.inside(screenpoint-easingWindowPosition)){
- for(int k = 0; k < selectedKeyframes.size(); k++){
- selectedKeyframes[k]->easeFunc = easingFunctions[i];
- }
- if(autosave) save();
- return;
- }
- }
-
- for(int i = 0; i < easingTypes.size(); i++){
- if(easingTypes[i]->bounds.inside(screenpoint-easingWindowPosition)){
- for(int k = 0; k < selectedKeyframes.size(); k++){
- selectedKeyframes[k]->easeType = easingTypes[i];
- }
- if(autosave) save();
- return;
- }
- }
- }
- */
keysAreDraggable = !ofGetModifierKeyShift();
@@ -355,18 +197,10 @@ void ofxTLKeyframer::mousePressed(ofMouseEventArgs& args){
}
else if(args.button == 2){
selectedKeySecondaryClick(args);
-// easingWindowPosition = ofVec2f(MIN(screenpoint.x, bounds.width - easingBoxWidth),
-// MIN(screenpoint.y, (timeline->getDrawRect().y + timeline->getDrawRect().height) - (easingBoxHeight*easingFunctions.size() + easingBoxHeight*easingTypes.size())));
-// drawingEasingWindow = true;
}
}
}
-// MODAL CLICK TEST
-// GET SELECTED ITEM
-// CREATE NEW ITEM
-// RIGHT CLICK ITEM
-
void ofxTLKeyframer::updateDragOffsets(ofVec2f screenpoint){
for(int k = 0; k < selectedKeyframes.size(); k++){
selectedKeyframes[k]->grabOffset = screenpoint - coordForKeyframePoint(selectedKeyframes[k]->position);
@@ -600,7 +434,5 @@ ofVec2f ofxTLKeyframer::keyframePointForCoord(ofVec2f coord){
ofxTLKeyframe* ofxTLKeyframer::newKeyframe(ofVec2f point){
ofxTLKeyframe* k = new ofxTLKeyframe();
k->position = point;
-// k->easeFunc = easingFunctions[0];
-// k->easeType = easingTypes[0];
return k;
}
View
40 src/ofxTLKeyframer.h
@@ -40,24 +40,6 @@
#include "ofxTLTrack.h"
#include "ofxXmlSettings.h"
-//
-//typedef struct
-//{
-// int id;
-// ofRectangle bounds;
-// string name;
-// ofxEasing* easing;
-//} EasingFunction;
-//
-//typedef struct
-//{
-// int id;
-// ofRectangle bounds;
-// string name;
-// ofxTween::ofxEasingType type;
-//} EasingType;
-//
-
class ofxTLKeyframe {
public:
ofVec2f position; // x is value, y is time, all 0 - 1.0
@@ -72,11 +54,6 @@ class ofxTLKeyframer : public ofxTLTrack
~ofxTLKeyframer();
virtual void draw();
-// virtual void drawModalContent(); //for pop up window-ish stuff
-
-// virtual void setValueRange(ofRange range, float defaultValue = 0);
-// //main function to get values out of the timeline, operates on the given value range
-// virtual float getValueAtPercent(float percent);
virtual void mousePressed(ofMouseEventArgs& args);
virtual void mouseMoved(ofMouseEventArgs& args);
@@ -104,16 +81,10 @@ class ofxTLKeyframer : public ofxTLTrack
virtual void unselectAll();
protected:
-
-// virtual float sampleAt(float percent);
virtual ofxTLKeyframe* newKeyframe(ofVec2f point);
- //vector<ofVec2f> grabOffsets; //keyframe grab offsets for dragging.
vector<ofxTLKeyframe*> keyframes;
-// ofRange valueRange;
-// float defaultValue;
-
virtual ofxTLKeyframe* keyframeAtScreenpoint(ofVec2f p, int& selectedIndex);
bool isKeyframeIsInBounds(ofxTLKeyframe* key);
bool isKeyframeSelected(ofxTLKeyframe* k);
@@ -143,17 +114,6 @@ class ofxTLKeyframer : public ofxTLTrack
ofVec2f coordForKeyframePoint(ofVec2f keyframePoint);
ofVec2f keyframePointForCoord(ofVec2f coord);
-// //easing dialog stuff
-// ofVec2f easingWindowPosition;
-// bool drawingEasingWindow;
-// vector<EasingFunction*> easingFunctions;
-// vector<EasingType*> easingTypes;
-// float easingBoxWidth;
-// float easingBoxHeight;
-// float easingWindowSeperatorHeight;
-
-// void initializeEasings();
-
bool drawingSelectRect;
ofVec2f selectRectStartPoint;
ofRectangle selectRect;
Please sign in to comment.
Something went wrong with that request. Please try again.