diff options
Diffstat (limited to 'FESgui/src/selectpanel.h')
| -rw-r--r-- | FESgui/src/selectpanel.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/FESgui/src/selectpanel.h b/FESgui/src/selectpanel.h new file mode 100644 index 0000000..a6811bc --- /dev/null +++ b/FESgui/src/selectpanel.h @@ -0,0 +1,53 @@ +#pragma once + +#include "ofMain.h" +#include "ofxGui.h" + +/* a gui panel that receives key and drag events. */ + +class selectPanel : public ofxPanel { + public: + selectPanel(string _name=""){ + name=_name; + ofRegisterKeyEvents(this, defaultEventsPriority); + ofRegisterDragEvents(this, defaultEventsPriority); + } + bool mouseMoved(ofMouseEventArgs & args){ + if (args.x>getPosition().x&& + args.x-getPosition().x<getWidth()&& + args.y>getPosition().y&& + args.y-getPosition().y<getHeight()){ + isSelected=true; + setHeaderBackgroundColor(ofColor(255,128,0)); + } + else { + isSelected=false; + setHeaderBackgroundColor(ofColor(80,80,80)); + } + } + bool keyPressed(ofKeyEventArgs & args){ + if (isSelected){ + ofLog()<<name<<" KEY> "<<args.key; + switch(args.key){ + default: + break; + } + } + } + bool keyReleased(ofKeyEventArgs & args){ + //required in order to call ofRegisterKeyEvents + } + virtual void loadfile(const string & f){}; + bool dragEvent(ofDragInfo & dragInfo){ + if (dragInfo.position.x>getPosition().x&& + dragInfo.position.x-getPosition().x<getWidth()&& + dragInfo.position.y>getPosition().y&& + dragInfo.position.y-getPosition().y<getHeight()){ + ofLog()<<name<<" DRAG> "<<dragInfo.files[0]; + loadfile(dragInfo.files[0]); + } + } +private: + bool isSelected; + string name; +};
\ No newline at end of file |
