Skip to content

Commit 9eb4be6

Browse files
committed
Update message and editor text for SelectedChannelsParameter when no channels are selected
1 parent bc2401a commit 9eb4be6

2 files changed

Lines changed: 37 additions & 30 deletions

File tree

Source/Processors/Parameter/Parameter.cpp

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -775,25 +775,25 @@ String SelectedChannelsParameter::getChangeDescription()
775775
{
776776
// Check number of selected channels:
777777
int selectedChannelCount = currentValue.getArray()->size();
778-
779-
// If more than four channels, state the number selected
780-
if (selectedChannelCount > 4)
781-
return "selected " + String(selectedChannelCount) + " channels";
778+
779+
if (selectedChannelCount == 0) // If no channels selected, return "None"
780+
return "none";
781+
else if (selectedChannelCount > 4) // If more than four channels, state the number selected
782+
return "selected " + String (selectedChannelCount) + " channels";
782783
else // Get string describing selected channels
783784
{
784785
String selectedChannelsString;
785-
786+
786787
for (int i = 0; i < selectedChannelCount; i++)
787788
{
788-
selectedChannelsString += String(int(currentValue[i]) + 1);
789-
789+
selectedChannelsString += String (int (currentValue[i]) + 1);
790+
790791
if (i < selectedChannelCount - 1)
791792
selectedChannelsString += ", ";
792793
}
793-
794+
794795
return selectedChannelsString;
795796
}
796-
797797
}
798798

799799
void SelectedChannelsParameter::toXml (XmlElement* xml)
@@ -985,7 +985,7 @@ String MaskChannelsParameter::getChangeDescription()
985985
if (! prev.contains (curr[i]))
986986
added++;
987987
}
988-
988+
989989
// find how many values in previous are not in current
990990
int removed = 0;
991991

@@ -994,27 +994,27 @@ String MaskChannelsParameter::getChangeDescription()
994994
if (! curr.contains (prev[i]))
995995
removed++;
996996
}
997-
997+
998998
String selectionString;
999999

10001000
if (added > 0) //should never get here
1001-
selectionString += "added " + String(added);
1002-
1001+
selectionString += "added " + String (added);
1002+
10031003
if (removed > 0)
10041004
{
10051005
if (selectionString.length() > 0)
10061006
selectionString += ", ";
1007-
selectionString += "removed " + String(removed);
1007+
selectionString += "removed " + String (removed);
10081008
}
1009-
1009+
10101010
selectionString += " channel";
1011-
1011+
10121012
if (added > 1 || removed > 1)
10131013
selectionString += "s";
1014-
1014+
10151015
if (added == 0 && removed == 0)
10161016
selectionString = "no change";
1017-
1017+
10181018
return selectionString;
10191019
}
10201020

@@ -1169,7 +1169,10 @@ String TtlLineParameter::getValueAsString()
11691169

11701170
String TtlLineParameter::getChangeDescription()
11711171
{
1172-
return String(int(currentValue) + 1);
1172+
if ((int) currentValue == -1)
1173+
return "none";
1174+
else
1175+
return String (int (currentValue) + 1);
11731176
}
11741177

11751178
void TtlLineParameter::toXml (XmlElement* xml)

Source/Processors/Parameter/ParameterEditor.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ SelectedChannelsParameterEditor::SelectedChannelsParameterEditor (Parameter* par
582582
button->setBounds (0, 0, rowWidthPixels / 2, rowHeightPixels);
583583

584584
editor = (Component*) button.get();
585-
585+
586586
updateView();
587587
}
588588

@@ -650,31 +650,35 @@ void SelectedChannelsParameterEditor::updateView()
650650
else
651651
{
652652
button->setEnabled (true);
653-
653+
654654
int numChannels = int (((SelectedChannelsParameter*) param)->getChannelStates().size());
655-
655+
656656
int numSelected = 0;
657657
for (auto chan : ((SelectedChannelsParameter*) param)->getChannelStates())
658658
if (chan)
659659
numSelected++;
660-
661-
if (numSelected > 4)
660+
661+
if (numSelected == 0)
662+
{
663+
button->setButtonText ("None");
664+
}
665+
else if (numSelected > 4)
662666
{
663667
button->setButtonText (String (numSelected) + "/" + String (numChannels));
664-
} else {
668+
}
669+
else
670+
{
665671
String selectedChannelsString;
666-
672+
667673
for (int i = 0; i < numSelected; i++)
668674
{
669-
selectedChannelsString += String(int(param->currentValue[i]) + 1);
670-
675+
selectedChannelsString += String (int (param->currentValue[i]) + 1);
676+
671677
if (i < numSelected - 1)
672678
selectedChannelsString += ", ";
673679
}
674680
button->setButtonText (selectedChannelsString);
675681
}
676-
677-
678682
}
679683
}
680684

0 commit comments

Comments
 (0)