@@ -220,7 +220,8 @@ void ChannelSelector::refreshButtonBoundaries()
220220
221221 int xLoc = columnWidth / 2 + offsetLR + columnWidth*column;
222222 int yLoc = row * rowHeight + offsetUD + 25 ;
223- if (i == 0 ){
223+ if (i == 0 )
224+ {
224225 px = xLoc; py = yLoc - 25 ;
225226 rx = xLoc - getDesiredWidth (); ry = yLoc - 25 ;
226227 ax = xLoc - getDesiredWidth () * 2 ; ay = yLoc - 25 ;
@@ -273,7 +274,9 @@ void ChannelSelector::refreshButtonBoundaries()
273274
274275 selectButtonAudio->setBounds (ax + 95 , ay + 20 , 20 , 20 );
275276 deselectButtonAudio->setBounds (ax + 117 , ay + 20 , 20 , 20 );
276-
277+ /*
278+ All and None buttons
279+ */
277280 allButton->setBounds (0 , getHeight () - 15 , getWidth () / 2 , 15 );
278281 noneButton->setBounds (getWidth () / 2 , getHeight () - 15 , getWidth () / 2 , 15 );
279282
@@ -670,125 +673,149 @@ void ChannelSelector::buttonClicked(Button* button)
670673 editor->channelChanged (-1 );
671674 }
672675 }
673- else if (button == selectButtonParam){ // select channels in parameter tab
676+ else if (button == selectButtonParam)
677+ { // select channels in parameter tab
674678 selectButtonParam->removeListener (this );
675679 deselectButtonParam->removeListener (this );
676680 std::vector<int > getBoxList;
677681 int fa, lim, comd, i, j;
678682 getBoxList = paramBox->getBoxInfo (parameterButtons.size ());
679- if (getBoxList.size () < 3 ){
683+ if (getBoxList.size () < 3 )
684+ {
680685 selectButtonParam->addListener (this );
681686 deselectButtonParam->addListener (this ); return ;
682687 }
683688 i = 0 ;
684- while (i <= getBoxList.size () - 3 ){
689+ while (i <= getBoxList.size () - 3 )
690+ {
685691 fa = getBoxList[i]; lim = getBoxList[i + 1 ]; comd = getBoxList[i + 2 ];
686- for (; fa <= lim; fa += comd){
692+ for (; fa <= lim; fa += comd)
693+ {
687694 parameterButtons[fa]->setToggleState (true , sendNotification);
688695 }
689696 i += 3 ;
690697 }
691698 selectButtonParam->addListener (this );
692699 deselectButtonParam->addListener (this );
693700 }
694- else if (button == selectButtonRecord){ // select channels in record tab
701+ else if (button == selectButtonRecord)
702+ { // select channels in record tab
695703 selectButtonRecord->removeListener (this );
696704 deselectButtonRecord->removeListener (this );
697705 std::vector<int > getBoxList;
698706 int fa, lim, comd, i, j;
699707 getBoxList = recordBox->getBoxInfo (recordButtons.size ());
700- if (getBoxList.size () < 3 ){
708+ if (getBoxList.size () < 3 )
709+ {
701710 selectButtonRecord->addListener (this );
702711 deselectButtonRecord->addListener (this ); return ;
703712 }
704713 i = 0 ;
705- while (i <= getBoxList.size () - 3 ){
714+ while (i <= getBoxList.size () - 3 )
715+ {
706716 fa = getBoxList[i]; lim = getBoxList[i + 1 ]; comd = getBoxList[i + 2 ];
707- for (; fa <= lim; fa += comd){
717+ for (; fa <= lim; fa += comd)
718+ {
708719 recordButtons[fa]->setToggleState (true , sendNotification);
709720 }
710721 i += 3 ;
711722 }
712723 selectButtonRecord->addListener (this );
713724 deselectButtonRecord->addListener (this );
714725 }
715- else if (button == selectButtonAudio){ // select channels in audio tab
726+ else if (button == selectButtonAudio)
727+ { // select channels in audio tab
716728 selectButtonAudio->removeListener (this );
717729 deselectButtonAudio->removeListener (this );
718730 std::vector<int > getBoxList;
719731 int fa, lim, comd, i, j;
720732 getBoxList = audioBox->getBoxInfo (audioButtons.size ());
721- if (getBoxList.size () < 3 ){
733+ if (getBoxList.size () < 3 )
734+ {
722735 selectButtonAudio->addListener (this );
723736 deselectButtonAudio->addListener (this ); return ;
724737 }
725738 i = 0 ;
726- while (i <= getBoxList.size () - 3 ){
739+ while (i <= getBoxList.size () - 3 )
740+ {
727741 fa = getBoxList[i]; lim = getBoxList[i + 1 ]; comd = getBoxList[i + 2 ];
728- for (; fa <= lim; fa += comd){
742+ for (; fa <= lim; fa += comd)
743+ {
729744 audioButtons[fa]->setToggleState (true , sendNotification);
730745 }
731746 i += 3 ;
732747 }
733748 selectButtonAudio->addListener (this );
734749 deselectButtonAudio->addListener (this );
735750 }
736- else if (button == deselectButtonParam){ // deselect channels in param tab
751+ else if (button == deselectButtonParam)
752+ { // deselect channels in param tab
737753 selectButtonParam->removeListener (this );
738754 deselectButtonParam->removeListener (this );
739755 std::vector<int > getBoxList;
740756 int fa, lim, comd, i, j;
741757 getBoxList = paramBox->getBoxInfo (parameterButtons.size ());
742- if (getBoxList.size () < 3 ){
758+ if (getBoxList.size () < 3 )
759+ {
743760 selectButtonParam->addListener (this );
744761 deselectButtonParam->addListener (this ); return ;
745762 }
746763 i = 0 ;
747- while (i <= getBoxList.size () - 3 ){
764+ while (i <= getBoxList.size () - 3 )
765+ {
748766 fa = getBoxList[i]; lim = getBoxList[i + 1 ]; comd = getBoxList[i + 2 ];
749- for (; fa <= lim; fa += comd){
767+ for (; fa <= lim; fa += comd)
768+ {
750769 parameterButtons[fa]->setToggleState (false , sendNotification);
751770 }
752771 i += 3 ;
753772 }
754773 selectButtonParam->addListener (this );
755774 deselectButtonParam->addListener (this );
756775 }
757- else if (button == deselectButtonRecord){ // deselect channels in record tab
776+ else if (button == deselectButtonRecord)
777+ { // deselect channels in record tab
758778 selectButtonRecord->removeListener (this );
759779 deselectButtonRecord->removeListener (this );
760780 std::vector<int > getBoxList;
761781 int fa, lim, comd, i, j;
762782 getBoxList = recordBox->getBoxInfo (recordButtons.size ());
763- if (getBoxList.size () < 3 ){
783+ if (getBoxList.size () < 3 )
784+ {
764785 selectButtonRecord->addListener (this );
765786 deselectButtonRecord->addListener (this ); return ;
766787 }
767788 i = 0 ;
768- while (i <= getBoxList.size () - 3 ){
789+ while (i <= getBoxList.size () - 3 )
790+ {
769791 fa = getBoxList[i]; lim = getBoxList[i + 1 ]; comd = getBoxList[i + 2 ];
770- for (; fa <= lim; fa += comd){
792+ for (; fa <= lim; fa += comd)
793+ {
771794 recordButtons[fa]->setToggleState (false , sendNotification);
772795 }
773796 i += 3 ;
774797 }
775798 selectButtonRecord->addListener (this );
776799 deselectButtonRecord->addListener (this );
777800 }
778- else if (button == deselectButtonAudio){ // deselect channels in audio tab
801+ else if (button == deselectButtonAudio)
802+ { // deselect channels in audio tab
779803 selectButtonAudio->removeListener (this );
780804 deselectButtonAudio->removeListener (this );
781805 std::vector<int > getBoxList;
782806 int fa, lim, comd, i, j;
783807 getBoxList = audioBox->getBoxInfo (audioButtons.size ());
784- if (getBoxList.size () < 3 ){
808+ if (getBoxList.size () < 3 )
809+ {
785810 selectButtonAudio->addListener (this );
786811 deselectButtonAudio->addListener (this ); return ;
787812 }
788813 i = 0 ;
789- while (i <= getBoxList.size () - 3 ){
814+ while (i <= getBoxList.size () - 3 )
815+ {
790816 fa = getBoxList[i]; lim = getBoxList[i + 1 ]; comd = getBoxList[i + 2 ];
791- for (; fa <= lim; fa += comd){
817+ for (; fa <= lim; fa += comd)
818+ {
792819 audioButtons[fa]->setToggleState (false , sendNotification);
793820 }
794821 i += 3 ;
@@ -1165,18 +1192,24 @@ void ChannelSelectorRegion::paint(Graphics& g)
11651192/*
11661193 Constructor and Destructor of ChannelSelectorBox.
11671194*/
1168- ChannelSelectorBox::ChannelSelectorBox (){
1195+ ChannelSelectorBox::ChannelSelectorBox ()
1196+ {
11691197 setMultiLine (false , true ); // No multi lines.
11701198 setReturnKeyStartsNewLine (false ); // Return key donot start a new line.
11711199 setTabKeyUsedAsCharacter (false );
1200+ setTooltip (" General Format: [a:b:c]->to select all channels from a to c at intervals of b" );
11721201}
11731202
1174- ChannelSelectorBox::~ChannelSelectorBox (){}
1203+ ChannelSelectorBox::~ChannelSelectorBox ()
1204+ {
1205+
1206+ }
11751207
11761208/*
11771209 convert a string to integer.
11781210*/
1179- int ChannelSelectorBox::convertToInteger (std::string s){
1211+ int ChannelSelectorBox::convertToInteger (std::string s)
1212+ {
11801213 if (s.size () > 9 ){
11811214 return INT_MAX;
11821215 }
@@ -1198,50 +1231,80 @@ int ChannelSelectorBox::convertToInteger(std::string s){
11981231 2. [ a : b] -> select/deselect all channels from a to b.
11991232 3. [ a : c : b] -> select/deselect all channels from a to b such that the difference between in each consecutive selected channel is c.
12001233*/
1201- std::vector<int > ChannelSelectorBox::getBoxInfo (int len){
1234+ std::vector<int > ChannelSelectorBox::getBoxInfo (int len)
1235+ {
12021236 std::string s = getText ().toStdString ();
12031237 std::vector<std::string> parsed;
12041238 std::vector<int > finalList,colonNum;
12051239 finalList.clear ();
12061240 int i, j, k, a, otherChar = 0 , b, openb = 0 , closeb = 0 ;
12071241
1208- for (i = 0 ; i < s.size (); i++){
1209- if (s[i] == ' :' ){
1242+ for (i = 0 ; i < s.size (); i++) // Fetch the box ([a:b:c]) from the string.
1243+ {
1244+ if (s[i] == ' :' )
1245+ {
12101246 colonNum.push_back (i);
12111247 }
1212- else if (s[i] == ' [' ){
1248+ else if (s[i] == ' [' )
1249+ {
12131250 openb++;
12141251 }
1215- else if (s[i] == ' ]' ){
1252+ else if (s[i] == ' ]' )
1253+ {
12161254 closeb++; break ;
12171255 }
1218- else if (s[i] < 48 && s[i]>57 && s[i] != 32 ){
1256+ else if (s[i] < 48 && s[i]>57 && s[i] != 32 )
1257+ {
12191258 otherChar++;
12201259 }
12211260 }
12221261
1223- if (colonNum.size () > 2 || colonNum.size () < 1 || openb != 1 || closeb != 1 || otherChar > 0 ){
1262+ if (colonNum.size () > 2 || colonNum.size () < 1 || openb != 1 || closeb != 1 || otherChar > 0 ) // If proper syntax not maintained, return.
1263+ {
12241264 return finalList;
12251265 }
12261266
1227- if (colonNum.size () == 1 ){
1267+ if (colonNum.size () == 1 ) // Case when input is in the form [a:b]
1268+ {
12281269 a = convertToInteger (s.substr (0 , colonNum[0 ] + 1 ));
12291270 b = convertToInteger (s.substr (colonNum[0 ], s.size () - colonNum[0 ] + 1 ));
1230- if (a > len || b > len || a > b){ return finalList; }
1231- if (a == 0 ){ a = 1 ; }
1232- if (b == 0 ){ b = len; }
1271+ if (a > len || b > len || a > b)
1272+ {
1273+ return finalList;
1274+ }
1275+ if (a == 0 )
1276+ {
1277+ a = 1 ;
1278+ }
1279+ if (b == 0 )
1280+ {
1281+ b = len;
1282+ }
12331283 finalList.push_back (a - 1 ); finalList.push_back (b - 1 ); finalList.push_back (1 );
12341284 return finalList;
12351285 }
1236- else if (colonNum.size () == 2 ){
1286+ else if (colonNum.size () == 2 ) // Case when input is in the form [a:b:c]
1287+ {
12371288 a = convertToInteger (s.substr (0 , colonNum[0 ] + 1 ));
12381289 k = convertToInteger (s.substr (colonNum[0 ], colonNum[1 ] - colonNum[0 ] + 1 ));
12391290 b = convertToInteger (s.substr (colonNum[1 ], s.size () - colonNum[1 ] + 1 ));
1240- if (k == 0 ){ k = 1 ; }
1241- if (a == 0 ){ a = 1 ; }
1242- if (b == 0 ){ b = len; }
1291+ if (k == 0 )
1292+ {
1293+ k = 1 ;
1294+ }
1295+ if (a == 0 )
1296+ {
1297+ a = 1 ;
1298+ }
1299+ if (b == 0 )
1300+ {
1301+ b = len;
1302+ }
12431303
1244- if (a > len || b > len || a > b){ return finalList; }
1304+ if (a > len || b > len || a > b)
1305+ {
1306+ return finalList;
1307+ }
12451308 finalList.push_back (a - 1 ); finalList.push_back (b - 1 ); finalList.push_back (k);
12461309 return finalList;
12471310 }
0 commit comments