summaryrefslogtreecommitdiff
path: root/pluginchooser/src/pluginpanel.h
diff options
context:
space:
mode:
Diffstat (limited to 'pluginchooser/src/pluginpanel.h')
-rw-r--r--pluginchooser/src/pluginpanel.h99
1 files changed, 99 insertions, 0 deletions
diff --git a/pluginchooser/src/pluginpanel.h b/pluginchooser/src/pluginpanel.h
new file mode 100644
index 0000000..21b9251
--- /dev/null
+++ b/pluginchooser/src/pluginpanel.h
@@ -0,0 +1,99 @@
+#pragma once
+
+#include "ofMain.h"
+#include "ofxGui.h"
+#include "ofxAChaoslib.h"
+
+class loader {
+public:
+ loader(string _n,AChaosBase *_plugin,vector<string> _params={}){
+ name=_n;
+ plugin=_plugin;
+ params=_params;
+ }
+ string name;
+ AChaosBase *plugin;
+ vector<string> params;
+};
+
+class pluginPanel : public ofxPanel {
+ public:
+ pluginPanel(){
+ ofRegisterKeyEvents(this, defaultEventsPriority);
+ plugins={
+ loader("baker",&baker),
+ loader("clifford",&clifford,{"a","b","c","d"}),
+ };
+ index=0;
+ update();
+ }
+ bool mouseMoved(ofMouseEventArgs & args){
+ if (args.x>getPosition().x&&
+ args.x-getPosition().x<getWidth()&&
+ args.y>getPosition().y&&
+ args.y-getPosition().y<getHeight()){
+ if (!isSelected){
+ isSelected=true;
+ //setBorderColor(
+ setHeaderBackgroundColor(ofColor(255,128,0));
+ //ofLog()<<"IN> "<<args.x<<","<<args.y;
+ }
+ }
+ else {
+ if (isSelected){
+ isSelected=false;
+ setHeaderBackgroundColor(ofColor(80,80,80));
+ //ofLog()<<"OUT> "<<args.x<<","<<args.y;
+ }
+ }
+ }
+ bool keyPressed(ofKeyEventArgs & args){
+ if (isSelected){
+ //ofLog()<<"plugin KEY> "<<args.key;
+ switch(args.key){
+ if (plugins.size()){
+ case 57356:{ //left
+ index-=1;
+ if (index<0){
+ index=plugins.size()-1;
+ }
+ update();
+ break;
+ }
+ case 57358:{ //right
+ index+=1;
+ if (index==plugins.size()){
+ index=0;
+ }
+ update();
+ break;
+ }
+ default:
+ break ;
+ }
+ }
+ }
+ }
+ bool keyReleased(ofKeyEventArgs & args){
+ //required in order to call ofRegisterKeyEvents
+ }
+ void update(){
+ ofLog()<<"selected "<<plugins[index].name;
+ clear();
+ add(label.setup(plugins[index].name));
+ add(active.set("use",false));
+ add(amount.set("amount", 0.0f, -0.1f, 0.1f));
+ for (int i=0;i<plugins[index].params.size();i++){
+ add(new ofParameter<float>().set((plugins[index].params[i], 0.0, -1.0, 1.0)));
+ }
+ }
+private:
+ int index;
+ bool isSelected;
+ ofxLabel label;
+ vector <loader> plugins;
+ ofParameter<bool> active;
+ ofParameter<float> amount;
+ AChaosBaker baker;
+ AChaosClifford clifford;
+}; \ No newline at end of file