1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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;
};
|