commit 0f5b171a448a2133556ba7318e1fddcfba6510a0
parent 6ec6d43f8f4cb3d4d6d8bf895c5b3059d544e4cc
Author: Adam M <[email protected]>
Date: Fri, 25 Dec 2020 23:24:53 -0600
put params in menu
Diffstat:
3 files changed, 86 insertions(+), 11 deletions(-)
diff --git a/src/Computerscare.hpp b/src/Computerscare.hpp
@@ -523,3 +523,4 @@ struct SmallLetterDisplay : Widget {
#include "pointFunctions.hpp"
#include "drawFunctions.hpp"
#include "ComputerscarePolyModule.hpp"
+#include "MenuParams.hpp"
diff --git a/src/ComputerscareBlank.cpp b/src/ComputerscareBlank.cpp
@@ -37,6 +37,7 @@ struct ComputerscareBlank : Module {
ANIMATION_SPEED,
ANIMATION_ENABLED,
CONSTANT_FRAME_DELAY,
+ ANIMATION_MODE,
NUM_PARAMS
};
enum InputIds {
@@ -54,10 +55,10 @@ struct ComputerscareBlank : Module {
ComputerscareBlank() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
- configParam(ANIMATION_SPEED, 0.f, 2.f, 0.1, "Animation Speed");
+ configParam(ANIMATION_SPEED, -2.f, 2.f, 1.0, "Animation Speed");
configParam(ANIMATION_ENABLED, 0.f, 1.f, 1.f, "Animation Enabled");
configParam(CONSTANT_FRAME_DELAY, 0.f, 1.f, 0.f, "Constant Frame Delay");
-
+ configParam(ANIMATION_MODE, 0.f, 3.f, 0.f, "Animation Mode");
paths.push_back("empty");
}
void process(const ProcessArgs &args) override {
@@ -111,11 +112,18 @@ struct ComputerscareBlank : Module {
imageStatus = status;
}
void setFrameDelay(float frameDelaySeconds) {
- if (params[CONSTANT_FRAME_DELAY].getValue()) {
- frameDelay = params[ANIMATION_SPEED].getValue();
+ float speedKnob = abs(params[ANIMATION_SPEED].getValue());
+ float base = frameDelaySeconds;
+ if (speedKnob == 0) {
+ frameDelay = 10000000;
}
else {
- frameDelay = frameDelaySeconds;
+ if (params[CONSTANT_FRAME_DELAY].getValue()) {
+ frameDelay = base/speedKnob;
+ }
+ else {
+ frameDelay = frameDelaySeconds/speedKnob;
+ }
}
}
std::string getPath() {
@@ -135,7 +143,7 @@ struct ComputerscareBlank : Module {
currentFrame = 0;
}
void goToRandomFrame() {
- currentFrame = (int) std::floor(random::uniform()*numFrames);
+ currentFrame = (int) std::floor(random::uniform() * numFrames);
}
void toggleAnimationEnabled() {
float current = params[ANIMATION_ENABLED].getValue();
@@ -404,9 +412,9 @@ struct ComputerscareBlankWidget : ModuleWidget {
invertYMenuItem->blank = blank;
menu->addChild(invertYMenuItem);
- SmoothKnob* speedParam = new SmoothKnob();
+ /*SmoothKnob* speedParam = new SmoothKnob();
speedParam->paramQuantity = blankModule->paramQuantities[ComputerscareBlank::ANIMATION_SPEED];
-
+
MenuEntry* LabeledKnob = new MenuEntry();
MenuLabel* johnLabel = construct<MenuLabel>(&MenuLabel::text, "Animation Speed");
johnLabel->box.pos = Vec(speedParam->box.size.x,0);
@@ -415,10 +423,20 @@ struct ComputerscareBlankWidget : ModuleWidget {
LabeledKnob->addChild(speedParam);
//menu->addChild(construct<MenuLabel>(&MenuLabel::text, "Animation Speed"));
- menu->addChild(LabeledKnob);
+ menu->addChild(LabeledKnob);*/
+
+ MenuParam* animEnabled = new MenuParam(blankModule->paramQuantities[ComputerscareBlank::ANIMATION_ENABLED],0);
+ menu->addChild(animEnabled);
+
+ MenuParam* speedParam = new MenuParam(blankModule->paramQuantities[ComputerscareBlank::ANIMATION_SPEED], 2);
+ menu->addChild(speedParam);
+
+ MenuParam* mp = new MenuParam(blankModule->paramQuantities[ComputerscareBlank::CONSTANT_FRAME_DELAY], 2);
+ menu->addChild(mp);
+
+ MenuParam* am = new MenuParam(blankModule->paramQuantities[ComputerscareBlank::ANIMATION_MODE], 1);
+ menu->addChild(am);
- menu->addChild(construct<MenuLabel>(&MenuLabel::text, ""));
- menu->addChild(construct<MenuLabel>(&MenuLabel::text, ""));
diff --git a/src/MenuParams.hpp b/src/MenuParams.hpp
@@ -0,0 +1,56 @@
+#pragma once
+
+using namespace rack;
+/*struct AutoParamQuantity : ParamQuantity {
+ std::string getDisplayValueString() override {
+ std::string disp = Quantity::getDisplayValueString();
+ return disp == "0" ? "Auto" : disp;
+ }
+};*/
+
+/*
+MenuParam
+
+a few options:
+
+-continuous
+-on/off toggle
+-multiselect
+-xy
+
+
+*/
+struct MenuParam : MenuEntry {
+ ParamWidget* speedParam;
+
+ MenuLabel* johnLabel;
+
+ MenuParam(ParamQuantity* pq,int type) {
+ if(type==0) {
+ speedParam = new SmallIsoButton();
+ // DisableableParamWidget* button = createParam<DisableableParamWidget>(Vec(x, y), module, ComputerscareBolyPuttons::TOGGLE + index);
+
+ }
+ if(type==1) {
+ speedParam = new MediumDotSnapKnob();
+ }
+
+ if(type==2) {
+ speedParam = new SmoothKnob();
+ }
+
+
+
+ speedParam->paramQuantity = pq;
+
+ johnLabel = construct<MenuLabel>(&MenuLabel::text, pq->getLabel());
+ johnLabel->box.pos = Vec(speedParam->box.size.x+20, 0);
+
+ addChild(speedParam);
+ addChild(johnLabel);
+
+
+
+
+ }
+};