summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2014-05-03 22:39:59 +0100
committerTim Redfern <tim@eclectronics.org>2014-05-03 22:39:59 +0100
commit9e42612c49059cf014e621e79c28041683430706 (patch)
treecd883e24108c92f396651b3d096a32ce9f8d8e0f
parentb963cf0075bf5786f8112b2572b7a94afb132796 (diff)
windows good; trying to capture mouse
-rw-r--r--le_new/src/ofApp.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/le_new/src/ofApp.cpp b/le_new/src/ofApp.cpp
index 9201dde..f12380e 100644
--- a/le_new/src/ofApp.cpp
+++ b/le_new/src/ofApp.cpp
@@ -74,6 +74,7 @@ void previewWindow::setup(){
setWindowShape(600,800);
setWindowPosition(260, 0);
setWindowTitle("PREVIEW");
+ ofRegisterMouseEvents(this);
}
void previewWindow::setParent(ofApp *p){
parent=p;
@@ -83,7 +84,7 @@ void previewWindow::setBuffer(ofFbo *buffer){
}
void previewWindow::draw(){
- rb->draw(0,0,ofGetWidth(),ofGetHeight()); //why crash?
+ rb->draw(0,0,getWidth(),getHeight()); //why crash?
}
@@ -267,6 +268,7 @@ void ofApp::setup(){
//win2->addListener(guiWin);
//guiWin->setup();
outWin->setParent(this);
+ ofAddListener(outWin->onKeyPressed, this, &ofApp::keyPressedEvent);
//debug=true;
@@ -315,6 +317,11 @@ void ofApp::keyPressed(int key, ofxFenster* win){
else keyPressed(key);
}
void ofApp::keyPressed(int key){
+ if(key == ' '){
+ fullscreenoutput=!fullscreenoutput;
+ outWin->setFullscreen(fullscreenoutput);
+ printf("resolution: %ix%i %s\n",outWin->getWidth(),outWin->getHeight(),fullscreenoutput?"fullscreen":"windowed");
+ }
if(key =='q'){
nmidiMessage(144,127,ofRandom(64)+36);
}
@@ -396,8 +403,7 @@ void ofApp::mouseReleased(int x, int y, int button){
}
-void ofApp::mousePressed(int x, int y, int button) {
-}
+
//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){
@@ -427,19 +433,18 @@ void ofApp::windowEvent(ofResizeEventArgs &args){
printf("window event\n");
}
-void ofApp::mousePressedEvent(ofMouseEventArgs &args) {
- //printf("mouse: %i,%i %i of %ix%i\n",args.x,args.y,args.button,win->getWidth(),win->getHeight());
- //0-2
- switch (args.button) {
+void ofApp::mousePressed( int x, int y, int button ) {
+ printf("mouse: %i,%i %i\n",x,y,button);
+ switch (button) {
case 0:
- xshift=args.x-(prevWin->getWidth()/2);
- yshift=args.y-(prevWin->getHeight()/2);
+ xshift=x-(prevWin->getWidth()/2);
+ yshift=y-(prevWin->getHeight()/2);
break;
case 1:
- scale=pow(pow(args.x-(prevWin->getWidth()/2),2)+pow(args.y-(prevWin->getHeight()/2),2),0.5)/(prevWin->getWidth()*.1);
+ scale=pow(pow(x-(prevWin->getWidth()/2),2)+pow(y-(prevWin->getHeight()/2),2),0.5)/(prevWin->getWidth()*.1);
break;
case 2:
- fscale=(pow(pow(args.x-(prevWin->getWidth()/2),2)+pow(args.y-(prevWin->getHeight()/2),2),0.5)/(prevWin->getWidth()))+0.5;
+ fscale=(pow(pow(x-(prevWin->getWidth()/2),2)+pow(y-(prevWin->getHeight()/2),2),0.5)/(prevWin->getWidth()))+0.5;
break;
}
}