mirror of
https://github.com/LMMS/lmms.git
synced 2026-04-29 02:16:20 -04:00
Lv2: Fix overflow and enum visualization
* Fix arithmetic overflow in `Lv2Ports::Meta::get()` in case min and max are not set * Fix combo boxes with >16 values being wrongly visualized as knobs * Rename `Lv2Ports::Vis` enum value `None` to `Generic`
This commit is contained in:
committed by
Johannes Lorenz
parent
827d44be32
commit
ddf69feebc
@@ -61,10 +61,10 @@ enum class Type {
|
||||
//! Port visualization
|
||||
//! @note All Lv2 audio ports are float, this is only the visualisation
|
||||
enum class Vis {
|
||||
None,
|
||||
Integer,
|
||||
Enumeration,
|
||||
Toggled
|
||||
Generic, //!< nothing specific, a generic knob or slider shall be used
|
||||
Integer, //!< counter
|
||||
Enumeration, //!< selection from enumerated values
|
||||
Toggled //!< boolean widget
|
||||
};
|
||||
|
||||
const char* toStr(Lv2Ports::Flow pf);
|
||||
@@ -106,7 +106,7 @@ struct Meta
|
||||
{
|
||||
Type m_type = Type::Unknown;
|
||||
Flow m_flow = Flow::Unknown;
|
||||
Vis m_vis = Vis::None;
|
||||
Vis m_vis = Vis::Generic;
|
||||
|
||||
bool m_logarithmic = false;
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ const char *toStr(Vis pv)
|
||||
case Vis::Toggled: return "toggled";
|
||||
case Vis::Enumeration: return "enumeration";
|
||||
case Vis::Integer: return "integer";
|
||||
case Vis::None: return "none";
|
||||
case Vis::Generic: return "none";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -118,7 +118,7 @@ std::vector<PluginIssue> Meta::get(const LilvPlugin *plugin,
|
||||
? Vis::Enumeration
|
||||
: hasProperty(LV2_CORE__toggled)
|
||||
? Vis::Toggled
|
||||
: Vis::None;
|
||||
: Vis::Generic;
|
||||
|
||||
if (isA(LV2_CORE__InputPort)) { m_flow = Flow::Input; }
|
||||
else if (isA(LV2_CORE__OutputPort)) { m_flow = Flow::Output; }
|
||||
@@ -218,11 +218,14 @@ std::vector<PluginIssue> Meta::get(const LilvPlugin *plugin,
|
||||
}
|
||||
|
||||
// visualization
|
||||
if (m_max - m_min > 15.0f)
|
||||
if (!m_min_set() ||
|
||||
!m_max_set() ||
|
||||
// if we get here, min and max are set, so max-min should not overflow:
|
||||
(m_vis == Vis::Integer && m_max - m_min > 15.0f))
|
||||
{
|
||||
// range too large for spinbox visualisation, use knobs
|
||||
// e.g. 0...15 would be OK
|
||||
m_vis = Vis::None;
|
||||
m_vis = Vis::Generic;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -471,7 +471,7 @@ void Lv2Proc::createPort(std::size_t portNum)
|
||||
}
|
||||
switch (meta.m_vis)
|
||||
{
|
||||
case Lv2Ports::Vis::None:
|
||||
case Lv2Ports::Vis::Generic:
|
||||
{
|
||||
// allow ~1000 steps
|
||||
float stepSize = (meta.max(sr) - meta.min(sr)) / 1000.0f;
|
||||
|
||||
@@ -67,7 +67,7 @@ Lv2ViewProc::Lv2ViewProc(QWidget* parent, Lv2Proc* ctrlBase, int colNum) :
|
||||
|
||||
switch (port.m_vis)
|
||||
{
|
||||
case PortVis::None:
|
||||
case PortVis::Generic:
|
||||
m_control = new KnobControl(m_par);
|
||||
break;
|
||||
case PortVis::Integer:
|
||||
|
||||
Reference in New Issue
Block a user