summaryrefslogtreecommitdiff
path: root/gui/src/ofApp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src/ofApp.cpp')
-rw-r--r--gui/src/ofApp.cpp85
1 files changed, 47 insertions, 38 deletions
diff --git a/gui/src/ofApp.cpp b/gui/src/ofApp.cpp
index 797f729..4f73e90 100644
--- a/gui/src/ofApp.cpp
+++ b/gui/src/ofApp.cpp
@@ -33,7 +33,11 @@ void ofApp::setup(){
dmxIntensity=255;
- next_update=ofGetElapsedTimef()+5.0f;
+ next_update=ofGetElapsedTimef()+0.1f;
+
+ sets.push_back(chainImageSet());
+ sets.push_back(chainImageSet());
+ selected_set=0;
}
//--------------------------------------------------------------
@@ -48,9 +52,9 @@ void ofApp::update(){
void ofApp::updateOutput(ofEventArgs & args){
- images.update();
- images2.update();
-
+ for (int i=0;i<sets.size();i++){
+ sets[i].update();
+ }
}
@@ -58,15 +62,19 @@ void ofApp::updateOutput(ofEventArgs & args){
//--------------------------------------------------------------
void ofApp::draw(){
ofBackground(0,0,0);
- images.drawGui(0,0);
- images2.drawGui(0,200);
+
+ for (int i=0;i<sets.size();i++){
+ sets[i].drawGui(0,i*200,i==selected_set);
+ }
+
}
void ofApp::drawOutput(ofEventArgs & args){
ofBackground(0,0,0);
- images.drawOutput();
- images2.drawOutput();
+for (int i=0;i<sets.size();i++){
+ sets[i].drawOutput();
+ }
if (dmx.isConnected()&&ofGetElapsedTimef()>next_update){
//if (dmx.isConnected()&&()){
@@ -130,14 +138,14 @@ void ofApp::newMidiMessage(ofxMidiMessage& msg) {
//from .9 to 1.1 but reaching numbers very near 1
float signed_value=(float)msg.value-64;
if (signed_value<0){
- images.decayFactor=1.0 + (pow(4.0f,abs(signed_value)/8)/pow(4,8));
+ sets[0].decayFactor=1.0 + (pow(4.0f,abs(signed_value)/8)/pow(4,8));
}
else {
- images.decayFactor=1.0 - (pow(4.0f,(signed_value)/8)/pow(4,8));
+ sets[0].decayFactor=1.0 - (pow(4.0f,(signed_value)/8)/pow(4,8));
}
- images2.decayFactor=images.decayFactor;
+ sets[1].decayFactor=sets[0].decayFactor;
- printf("Val %i, decay: %f \n",msg.value,images.decayFactor);
+ printf("Val %i, decay: %f \n",msg.value,sets[0].decayFactor);
}
if (msg.channel==1&&msg.control==65+offet){
@@ -161,14 +169,14 @@ void ofApp::newMidiMessage(ofxMidiMessage& msg) {
}
if (msg.channel==1&&msg.control==65+offet){
//top button 1
- images.additive=(msg.value==127);
+ sets[0].additive=(msg.value==127);
}
if (msg.channel==1&&msg.control==73+offet){
//bottom button 1
}
if (msg.channel==1&&msg.control==81+offet){
//fader 1
- images.intensity=((float)msg.value)/127.0f;
+ sets[0].intensity=((float)msg.value)/127.0f;
}
//column 6 for image set 1
@@ -180,14 +188,14 @@ void ofApp::newMidiMessage(ofxMidiMessage& msg) {
}
if (msg.channel==1&&msg.control==65+offet){
//top button 1
- images.additive=(msg.value==127);
+ sets[0].additive=(msg.value==127);
}
if (msg.channel==1&&msg.control==73+offet){
//bottom button 1
}
if (msg.channel==1&&msg.control==81+offet){
//fader 1
- images2.intensity=((float)msg.value)/127.0f;
+ sets[1].intensity=((float)msg.value)/127.0f;
}
//column 1 for more controls
@@ -195,10 +203,11 @@ void ofApp::newMidiMessage(ofxMidiMessage& msg) {
if (msg.channel==1&&msg.control==1+offet){
//pot 1
- images.fitFactor=1.0f+(((float)msg.value-64)/64.0f);
- images2.fitFactor=1.0f+(((float)msg.value-64)/64.0f);
+ for (int i=0;i<sets.size();i++){
+ sets[i].fitFactor=1.0f+(((float)msg.value-64)/64.0f);
+ };
- printf("Val %i, fitfactor: %f \n",msg.value,images.fitFactor);
+ printf("Val %i, fitfactor: %f \n",msg.value,sets[0].fitFactor);
}
if (msg.channel==1&&msg.control==65+offet){
//top button 1
@@ -215,10 +224,18 @@ void ofApp::newMidiMessage(ofxMidiMessage& msg) {
}
//--------------------------------------------------------------
-void ofApp::keyPressed(ofKeyEventArgs &keyargs){
- images.keyPressed(keyargs);
+void ofApp::keyPressed(ofKeyEventArgs &args){
+ sets[selected_set].keyPressed(args);
-
+
+ if(args.key == '-'){
+ selected_set-=1;
+ if (selected_set<0) selected_set=sets.size()-1;
+ }
+ if(args.key == '='){
+ selected_set+=1;
+ if (selected_set==sets.size()) selected_set=0;
+ }
}
void ofApp::outputKeyPressed(ofKeyEventArgs &args){
@@ -240,26 +257,17 @@ void ofApp::mouseMoved(int x, int y ){
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
- if (y<ofGetHeight()/2){
- images.mouseDragged(x,y,button);
- }
- else images2.mouseDragged(x,y,button);
+ sets[selected_set].mouseDragged(x,y,button);
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
- if (y<ofGetHeight()/2){
- images.mousePressed(x,y,button);
- }
- else images2.mousePressed(x,y,button);
+ sets[selected_set].mousePressed(x,y,button);
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
- if (y<ofGetHeight()/2){
- images.mouseReleased(x,y,button);
- }
- else images2.mouseReleased(x,y,button);
+ sets[selected_set].mouseReleased(x,y,button);
}
//--------------------------------------------------------------
@@ -279,8 +287,9 @@ void ofApp::windowResized(int w, int h){
void ofApp::outputWindowResized(ofResizeEventArgs &resizeargs){
//printf("Output window: %i,%i \n",resizeargs.width,resizeargs.height);
- images.outputSize=ofPoint(resizeargs.width,resizeargs.height);
- images2.outputSize=ofPoint(resizeargs.width,resizeargs.height);
+ for (int i=0;i<sets.size();i++){
+ sets[i].outputSize=ofPoint(resizeargs.width,resizeargs.height);
+ }
}
//--------------------------------------------------------------
@@ -299,9 +308,9 @@ void ofApp::dragEvent(ofDragInfo dragInfo){
filenames=filenames+*f;
if (dragInfo.position.y<200){
- images.add(*f,dragInfo.position);
+ sets[0].add(*f,dragInfo.position);
}
- else images2.add(*f,dragInfo.position);
+ else sets[1].add(*f,dragInfo.position);
}