commit 055532aad3a63f66d064660d095d61aea6ea6201
parent 9238e6d66e7bd0f46022dc2806ef416e1b869d0d
Author: Adam M <aemalone@gmail.com>
Date: Fri, 26 Feb 2021 20:45:56 -0600
Use UI components, checkbox and slider in menu instead of paramwidgets. Paramwidgets not supported in menu
Diffstat:
3 files changed, 71 insertions(+), 23 deletions(-)
diff --git a/src/ComputerscareBlank.cpp b/src/ComputerscareBlank.cpp
@@ -780,7 +780,6 @@ struct InvertYMenuItem: MenuItem {
};
struct ssmi : MenuItem
{
- //ComputerscareRolyPouter *pouter;
int mySetVal = 1;
ParamQuantity *myParamQuantity;
ssmi(int i, ParamQuantity* pq)
@@ -1061,7 +1060,7 @@ struct GiantFrameDisplay : TransparentWidget {
}
};
-struct ComputerscareBlankWidget : MenuParamModuleWidget {
+struct ComputerscareBlankWidget : ModuleWidget {
ComputerscareBlankWidget(ComputerscareBlank *blankModule) {
setModule(blankModule);
@@ -1169,28 +1168,30 @@ struct ComputerscareBlankWidget : MenuParamModuleWidget {
//menu->addChild(construct<MenuLabel>(&MenuLabel::text, "Animation Speed"));
menu->addChild(LabeledKnob);*/
- MenuParam* animEnabled = new MenuParam(blank->paramQuantities[ComputerscareBlank::ANIMATION_ENABLED], 0);
+ //MenuParam* animEnabled = new MenuParam(blank->paramQuantities[ComputerscareBlank::ANIMATION_ENABLED], 0);
+ MenuToggle* animEnabled = new MenuToggle(blank->paramQuantities[ComputerscareBlank::ANIMATION_ENABLED]);
menu->addChild(animEnabled);
+ MenuToggle* constantDelay = new MenuToggle(blank->paramQuantities[ComputerscareBlank::CONSTANT_FRAME_DELAY]);
+ menu->addChild(constantDelay);
+
+ MenuToggle* slideshowEnabled = new MenuToggle(blank->paramQuantities[ComputerscareBlank::SLIDESHOW_ACTIVE]);
+ menu->addChild(slideshowEnabled);
+
+ MenuToggle* lightWidgetMode = new MenuToggle(blank->paramQuantities[ComputerscareBlank::LIGHT_WIDGET_MODE]);
+ menu->addChild(lightWidgetMode);
+
+ menu->addChild(construct<MenuLabel>(&MenuLabel::text, ""));
+
MenuParam* speedParam = new MenuParam(blank->paramQuantities[ComputerscareBlank::ANIMATION_SPEED], 2);
menu->addChild(speedParam);
- MenuParam* mp = new MenuParam(blank->paramQuantities[ComputerscareBlank::CONSTANT_FRAME_DELAY], 0);
- menu->addChild(mp);
-
MenuParam* shuffleParam = new MenuParam(blank->paramQuantities[ComputerscareBlank::SHUFFLE_SEED], 2);
menu->addChild(shuffleParam);
-
- MenuParam* slideshowEnabled = new MenuParam(blank->paramQuantities[ComputerscareBlank::SLIDESHOW_ACTIVE], 0);
- menu->addChild(slideshowEnabled);
-
MenuParam* slideshowSpeedParam = new MenuParam(blank->paramQuantities[ComputerscareBlank::SLIDESHOW_TIME], 2);
menu->addChild(slideshowSpeedParam);
- MenuParam* lightWidgetMode = new MenuParam(blank->paramQuantities[ComputerscareBlank::LIGHT_WIDGET_MODE], 0);
- menu->addChild(lightWidgetMode);
-
}
void step() override {
diff --git a/src/ComputerscareHorseADoodleDoo.cpp b/src/ComputerscareHorseADoodleDoo.cpp
@@ -150,7 +150,6 @@ struct HorseSequencer {
struct ComputerscareHorseADoodleDoo : ComputerscareMenuParamModule {
int counter = 0;
- ComputerscareSVGPanel* panelRef;
float currentValues[16] = {0.f};
bool atFirstStepPoly[16] = {false};
int previousStep[16] = { -1};
@@ -760,7 +759,6 @@ struct ComputerscareHorseADoodleDooWidget : ModuleWidget {
}
PolyOutputChannelsWidget* channelWidget;
NumStepsOverKnobDisplay* numStepsKnob;
- InputBlockBackground* background;
SmallLetterDisplay* smallLetterDisplay;
};
diff --git a/src/MenuParams.hpp b/src/MenuParams.hpp
@@ -50,8 +50,46 @@ KeyboardControlChildMenu *kbMenu = new KeyboardControlChildMenu();
kbMenu->rightText = RIGHT_ARROW;
kbMenu->blank = blank;
menu->addChild(kbMenu);*/
+
+struct SmoothSlider : ui::Slider {
+ SmoothSlider(ParamQuantity* paramQ) {
+ box.size.x = 180.0f;
+ quantity = paramQ;
+ }
+};
+
+struct MomentaryButton : ui::Button {
+ MomentaryButton(ParamQuantity* paramQ) {
+ box.size.x = 32.f;
+ quantity = paramQ;
+ }
+};
+
+struct MenuToggle : MenuItem
+{
+ ParamQuantity *myParamQuantity;
+ MenuToggle(ParamQuantity* pq)
+ {
+ myParamQuantity = pq;
+ text = pq->getLabel();
+ }
+
+ void onAction(const event::Action &e) override
+ {
+ myParamQuantity->setValue( myParamQuantity->getValue() == 0 ? 1 : 0);
+ }
+ void step() override {
+ rightText = myParamQuantity->getValue() == 1 ? "✔" : "";
+ MenuItem::step();
+ }
+};
+
struct MenuParam : MenuEntry {
ParamWidget* pWidget;
+
+ SmoothSlider* slider;
+ MenuToggle *toggle;
+
MenuLabel* johnLabel;
MenuLabel* displayString;
SubMenuAndKnob *submenu;
@@ -59,23 +97,34 @@ struct MenuParam : MenuEntry {
MenuParam(ParamQuantity* param, int type) {
if (type == 0) {
- pWidget = new SmallIsoButton();
+ toggle = new MenuToggle(param);
+
+ //toggle->box.pos = Vec(controlRightMargin, 0);
+ addChild(toggle);
+ //johnLabel = construct<MenuLabel>(&MenuLabel::text, param->getLabel());
+ //johnLabel->box.pos = Vec(button->box.size.x + controlRightMargin * 2, 0);
+
+ //addChild(johnLabel);
}
else if (type == 1) {
pWidget = new MediumDotSnapKnob();
+ pWidget->paramQuantity = param;
+ pWidget->box.pos = Vec(controlRightMargin, 0);
+
+ addChild(pWidget);
+ johnLabel = construct<MenuLabel>(&MenuLabel::text, param->getLabel());
+ johnLabel->box.pos = Vec((type == 2 ? slider->box.size.x : pWidget->box.size.x) + controlRightMargin * 2, 0);
+ addChild(johnLabel);
}
else if (type == 2) {
- pWidget = new SmoothKnob();
+ slider = new SmoothSlider(param);
+ slider->box.pos = Vec(controlRightMargin, 0);
+ addChild(slider);
+
}
- pWidget->paramQuantity = param;
- pWidget->box.pos = Vec(controlRightMargin, 0);
box.size.y = 32;
- johnLabel = construct<MenuLabel>(&MenuLabel::text, param->getLabel());
- johnLabel->box.pos = Vec(pWidget->box.size.x + controlRightMargin * 2, 0);
- addChild(pWidget);
- addChild(johnLabel);
//if(type==1) {addChild(submenu);}
}
/*Menu *createChildMenu() override {