added activation button to bricks

This commit is contained in:
2022-06-25 15:45:26 +02:00
parent f37f8d1fa0
commit 8a27d0199a
3 changed files with 74 additions and 11 deletions

View File

@@ -1,2 +1,2 @@
//globals
uptime = 116632721
uptime = 116633391

View File

@@ -23,6 +23,8 @@ int renderSize = 500; //px
String[] saveData;
int w, h;
boolean spawnPlaying = true;
boolean videoRecord;
String[] params;

View File

@@ -26,10 +26,33 @@ public class SecondApplet extends PApplet {
.plugTo(this, "CP5_listActions")
.addItems(l)
.setType(ControlP5.LIST);
cp5.addToggle("rec")
.setPosition(100, height-50)
.setSize(20, 20)
Toggle rec = cp5.addToggle("record")
.setPosition(100, height-105)
.setSize(15, 15)
.plugTo(this, "CP5_recordAction");
rec.getCaptionLabel().getStyle().setMargin(-17, 0, 0, 20);
Toggle auto = cp5.addToggle("spawn playing")
.setPosition(100, height-85)
.setSize(15, 15)
.plugTo(this, "CP5_spawnPlayingAction")
.setValue(false);
auto.getCaptionLabel().getStyle().setMargin(-17, 0, 0, 20);
Toggle pauseAll = cp5.addToggle("pause all")
.setPosition(100, height-65)
.setSize(15, 15)
.plugTo(this, "CP5_pauseAllAction");
pauseAll.getCaptionLabel().getStyle().setMargin(-17, 0, 0, 20);
/*
Toggle saveParams = cp5.addToggle("save parameters")
.setPosition(100, height-45)
.setSize(15, 15)
.plugTo(this, "CP5_saveParamsAction");
saveParams.getCaptionLabel().getStyle().setMargin(-17,0,0,20);
*/
binX = width-55;
binY = height-85;
@@ -40,6 +63,16 @@ public class SecondApplet extends PApplet {
recording = !recording;
}
void CP5_spawnPlayingAction() {
spawnPlaying = !spawnPlaying;
}
void CP5_pauseAllAction() {
//pauseAll = !pauseAll;
}
int totalBrickHeight;
public void draw() {
background(68, 68, 68);
@@ -81,6 +114,10 @@ public class SecondApplet extends PApplet {
shader.pos = shaderList.size()-1;
bricks.add(new Brick(shaderList.size()-1, shaderList.get(shaderList.size()-1).params, shader.name));
refreshSurface(0);
if (!spawnPlaying) bricks.get(shaderList.size()-1).pauseAllSliders();
println("Added " + shader + " to fxList at spot. List length: " + shaderList.size());
}
@@ -124,8 +161,14 @@ public class SecondApplet extends PApplet {
}
void applyShader() {
for (int i = 0; i < shaderList.size(); i++) {
shaderList.get(i).getValuesFromGUI();
shaderList.get(i).apply();
try {
if (bricks.get(i).active) {
shaderList.get(i).getValuesFromGUI();
shaderList.get(i).apply();
}
}
catch(Exception e) {
}
if (i > maxFx) break;
}
}
@@ -135,7 +178,7 @@ public class SecondApplet extends PApplet {
class Brick {
ArrayList<Slider> slider = new ArrayList<Slider>();
ArrayList<Param> params = new ArrayList<Param>();
boolean dragging, dragHovering, hovering, hoveringLineAbove, hoveringLineBelow;
boolean active, dragging, dragHovering, hovering, hoveringLineAbove, hoveringLineBelow;
color brickBGcol;
int pos;
int h, y;
@@ -145,6 +188,7 @@ public class SecondApplet extends PApplet {
name = name_;
pos = pos_;
params = params_;
active = true;
y = totalBrickHeight;
h = 20 + params.size() * 20;
for (int i = 0; i < params.size(); i++) {
@@ -173,6 +217,11 @@ public class SecondApplet extends PApplet {
slider.get(sliderNo).setLabel(param.name);
}
void pauseAllSliders() {
for (int i = 0; i < slider.size(); i++) {
slider.get(i).animated = false;
}
}
void update() {
boolean sliderHover = false;
@@ -209,16 +258,26 @@ public class SecondApplet extends PApplet {
pressedBrick = pos;
}
void display() {
noStroke();
if (dragging) brickBGcol = color(51, 51, 51);
else if (dragHovering && !hoveringLineBelow && !hoveringLineAbove) brickBGcol= color (105, 105, 105);
else brickBGcol = color(85, 85, 85);
if (active) {
if (dragging) brickBGcol = color(51, 51, 51);
else if (dragHovering && !hoveringLineBelow && !hoveringLineAbove) brickBGcol= color (105, 105, 105);
else brickBGcol = color(85, 85, 85);
} else {
brickBGcol = color(0);
}
fill(brickBGcol);
rect(0, totalBrickHeight, width, h);
fill(255);
text(name, 10, 10+totalBrickHeight, 10);
text(name, 25, 10+totalBrickHeight, 10);
stroke(255);
if (active) fill(185);
else noFill();
rect(10, 4+totalBrickHeight, 10, 10);
for (int i = 0; i < slider.size(); i++) {
slider.get(i).display();
@@ -265,6 +324,8 @@ public class SecondApplet extends PApplet {
osci = new Oscillator(int(random(5, 15)), osciModes);
osci.amplitude(minVal, maxVal);
osci.update();
setValue(osci.value);
animated = true;