Skip to content

Commit

Permalink
Fixed #45 - Moots panel toggles GATE/TRIGGER.
Browse files Browse the repository at this point in the history
  • Loading branch information
cosinekitty committed Apr 22, 2024
1 parent 922310b commit 7705c50
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 9 deletions.
2 changes: 0 additions & 2 deletions res/moots.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions res/moots_label_gate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions res/moots_label_trigger.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions src/moots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,22 @@ namespace Sapphire
struct MootsWidget : ModuleWidget
{
MootsModule* mootsModule;
SvgOverlay* gateLabel{};
SvgOverlay* triggerLabel{};

explicit MootsWidget(MootsModule* module)
: mootsModule(module)
{
setModule(module);
setPanel(createPanel(asset::plugin(pluginInstance, "res/moots.svg")));

gateLabel = SvgOverlay::Load("res/moots_label_gate.svg");
addChild(gateLabel);

triggerLabel = SvgOverlay::Load("res/moots_label_trigger.svg");
triggerLabel->hide();
addChild(triggerLabel);

addParam(createLightParamCentered<VCVLightBezelLatch<>>(mm2px(Vec(25.05, 17.25)), module, TOGGLEBUTTON1_PARAM, MOOTLIGHT1));
addParam(createLightParamCentered<VCVLightBezelLatch<>>(mm2px(Vec(25.05, 38.75)), module, TOGGLEBUTTON2_PARAM, MOOTLIGHT2));
addParam(createLightParamCentered<VCVLightBezelLatch<>>(mm2px(Vec(25.05, 60.25)), module, TOGGLEBUTTON3_PARAM, MOOTLIGHT3));
Expand Down Expand Up @@ -344,6 +353,21 @@ namespace Sapphire
));
}
}

void step() override
{
if (mootsModule && gateLabel && triggerLabel)
{
// Toggle between showing "GATE" or "TRIGGER" depending on the toggle state.
bool showGate = (mootsModule->controlMode == ControlMode::Gate);
if (gateLabel->isVisible() != showGate)
{
gateLabel->setVisible(showGate);
triggerLabel->setVisible(!showGate);
}
}
ModuleWidget::step();
}
};
}
}
Expand Down
22 changes: 15 additions & 7 deletions util/make_sapphire_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,20 +563,26 @@ def GenerateHissPanel() -> int:
</g>
'''

MOOTS_PANEL_WIDTH = 10


def GenerateMootsPanel() -> int:
svgFileName = '../res/moots.svg'
PANEL_WIDTH = 10
panel = Panel(PANEL_WIDTH)
panel = Panel(MOOTS_PANEL_WIDTH)
pl = Element('g', 'PanelLayer')
panel.append(pl)
controls = ControlLayer()
pl.append(controls)
#controls = ControlLayer()
#pl.append(controls)
pl.append(LiteralXml(MootsPanelLayerXml))
xmid = panel.mmWidth / 2
yControlLabel = 74.5
return Save(panel, svgFileName)


def GenerateMootsLabel(svgFileName:str, text:str) -> int:
panel = Panel(MOOTS_PANEL_WIDTH)
x = panel.mmWidth / 2
y = 74.5
with Font(SAPPHIRE_FONT_FILENAME) as font:
pl.append(CenteredControlTextPath(font, "CONTROL", xmid, yControlLabel, pointSize = 8.0))
panel.append(CenteredControlTextPath(font, text, x, y, pointSize = 8.0))
return Save(panel, svgFileName)


Expand All @@ -591,5 +597,7 @@ def GenerateMootsPanel() -> int:
GeneratePolynucleusPanel() or
GenerateHissPanel() or
GenerateMootsPanel() or
GenerateMootsLabel('../res/moots_label_gate.svg', 'GATE') or
GenerateMootsLabel('../res/moots_label_trigger.svg', 'TRIGGER') or
Print('SUCCESS')
)

0 comments on commit 7705c50

Please sign in to comment.