Browse Source

Handle int scalepoints better

tags/1.9.4
falkTX 11 years ago
parent
commit
fba5219f67
2 changed files with 37 additions and 31 deletions
  1. +1
    -1
      source/backend/engine/CarlaEngine.cpp
  2. +36
    -30
      source/widgets/paramspinbox.py

+ 1
- 1
source/backend/engine/CarlaEngine.cpp View File

@@ -1969,7 +1969,7 @@ void CarlaEngine::setOption(const EngineOption option, const int value, const ch
break; break;


case ENGINE_OPTION_AUDIO_DEVICE: case ENGINE_OPTION_AUDIO_DEVICE:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr,);


if (pData->options.audioDevice != nullptr) if (pData->options.audioDevice != nullptr)
delete[] pData->options.audioDevice; delete[] pData->options.audioDevice;


+ 36
- 30
source/widgets/paramspinbox.py View File

@@ -295,43 +295,49 @@ class ParamSpinBox(QAbstractSpinBox):
self.fScalePoints = scalePoints self.fScalePoints = scalePoints
self.fHaveScalePoints = useScalePoints self.fHaveScalePoints = useScalePoints


if useScalePoints:
# Hide ProgressBar and create a ComboBox
self.fBar.close()
self.fBox = QComboBox(self)
self.fBox.setContextMenuPolicy(Qt.NoContextMenu)
self.fBox.show()
self.slot_updateProgressBarGeometry()
if not useScalePoints:
return


# Add items, sorted
boxItemValues = []
# Hide ProgressBar and create a ComboBox
self.fBar.close()
self.fBox = QComboBox(self)
self.fBox.setContextMenuPolicy(Qt.NoContextMenu)
self.fBox.show()
self.slot_updateProgressBarGeometry()


for scalePoint in scalePoints:
value = scalePoint['value']
# Add items, sorted
boxItemValues = []

for scalePoint in scalePoints:
value = scalePoint['value']

if self.fStep == 1.0:
label = "%i - %s" % (int(value), scalePoint['label'])
else:
label = "%f - %s" % (value, scalePoint['label']) label = "%f - %s" % (value, scalePoint['label'])


if len(boxItemValues) == 0:
if len(boxItemValues) == 0:
self.fBox.addItem(label)
boxItemValues.append(value)

else:
if value < boxItemValues[0]:
self.fBox.insertItem(0, label)
boxItemValues.insert(0, value)
elif value > boxItemValues[-1]:
self.fBox.addItem(label) self.fBox.addItem(label)
boxItemValues.append(value) boxItemValues.append(value)

else: else:
if value < boxItemValues[0]:
self.fBox.insertItem(0, label)
boxItemValues.insert(0, value)
elif value > boxItemValues[-1]:
self.fBox.addItem(label)
boxItemValues.append(value)
else:
for index in range(len(boxItemValues)):
if value >= boxItemValues[index]:
self.fBox.insertItem(index+1, label)
boxItemValues.insert(index+1, value)
break

if self.fValue != None:
self._setScalePointValue(self.fValue)

self.fBox.currentIndexChanged['QString'].connect(self.slot_comboBoxIndexChanged)
for index in range(len(boxItemValues)):
if value >= boxItemValues[index]:
self.fBox.insertItem(index+1, label)
boxItemValues.insert(index+1, value)
break

if self.fValue != None:
self._setScalePointValue(self.fValue)

self.fBox.currentIndexChanged['QString'].connect(self.slot_comboBoxIndexChanged)


def stepBy(self, steps): def stepBy(self, steps):
if steps == 0 or self.fValue is None: if steps == 0 or self.fValue is None:


Loading…
Cancel
Save