Browse Source

Add Module::configButton() for configuring momentary switches (which I'll now call buttons).

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
64cc9dddb0
2 changed files with 11 additions and 4 deletions
  1. +6
    -0
      include/engine/Module.hpp
  2. +5
    -4
      src/Quantity.cpp

+ 6
- 0
include/engine/Module.hpp View File

@@ -134,6 +134,12 @@ struct Module {
return sq; return sq;
} }


template <class TSwitchQuantity = SwitchQuantity>
TSwitchQuantity* configButton(int paramId, std::string name = "") {
TSwitchQuantity* sq = configParam<TSwitchQuantity>(paramId, 0.f, 1.f, 0.f, name);
return sq;
}

/** Helper for creating a PortInfo for an input port and setting its properties. /** Helper for creating a PortInfo for an input port and setting its properties.
See PortInfo for documentation of arguments. See PortInfo for documentation of arguments.
*/ */


+ 5
- 4
src/Quantity.cpp View File

@@ -40,10 +40,11 @@ void Quantity::setDisplayValueString(std::string s) {
std::string Quantity::getString() { std::string Quantity::getString() {
std::string s; std::string s;
std::string label = getLabel(); std::string label = getLabel();
if (!label.empty())
s += label + ": ";
s += getDisplayValueString();
s += getUnit();
std::string valueString = getDisplayValueString() + getUnit();
s += label;
if (label != "" && valueString != "")
s += ": ";
s += valueString;
return s; return s;
} }




Loading…
Cancel
Save