summaryrefslogtreecommitdiff
path: root/FESgui/src/selectpanel.h
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2023-04-17 19:44:00 +0100
committerTim Redfern <tim@getdrop.com>2023-04-17 19:44:00 +0100
commit19be92e0aff674b95bdae72fe7a2e409fd1bf77a (patch)
tree079acfc11ffbff8f11b120649f5cb3a623e354d6 /FESgui/src/selectpanel.h
parent5309ef89393aa56083d1c2238c517c3d576907ec (diff)
add to archive
Diffstat (limited to 'FESgui/src/selectpanel.h')
-rw-r--r--FESgui/src/selectpanel.h53
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