@@ -416,8 +416,10 @@ bool StreamBrowserDialog::renderOnOffToggle(const char* label, bool alignRight,
416416 @param inst the instrument to render the progress channel for
417417 @param chan the channel to render the progress for
418418 @param isLast true if it is the last channel of the instrument
419+
420+ @return Returns true if the progress bar has been rendered
419421 */
420- void StreamBrowserDialog::renderDownloadProgress (std::shared_ptr<Instrument> inst, InstrumentChannel *chan, bool isLast)
422+ bool StreamBrowserDialog::renderDownloadProgress (std::shared_ptr<Instrument> inst, InstrumentChannel *chan, bool isLast)
421423{
422424 static const char * const download[] = {" DOWNLOADING" , " DOWNLOAD" ," DL" ," D" , NULL };
423425
@@ -516,7 +518,7 @@ void StreamBrowserDialog::renderDownloadProgress(std::shared_ptr<Instrument> ins
516518 }
517519
518520 if (!shouldRender)
519- return ;
521+ return false ;
520522
521523// / @brief Width used to display progress bars (e.g. download progress bar)
522524#define PROGRESS_BAR_WIDTH 80
@@ -548,10 +550,11 @@ void StreamBrowserDialog::renderDownloadProgress(std::shared_ptr<Instrument> ins
548550 ImGui::ProgressBar (chan->GetDownloadProgress (), ImVec2 (PROGRESS_BAR_WIDTH, ImGui::GetFontSize ()));
549551 }
550552
551- return ;
553+ return true ;
552554 }
553555 }
554556 // well, shoot -- I guess there wasn't enough room to do *anything* useful!
557+ return true ;
555558}
556559
557560/* *
@@ -1058,10 +1061,11 @@ void StreamBrowserDialog::renderInstrumentNode(shared_ptr<Instrument> instrument
10581061 }
10591062 }
10601063 bool result;
1064+ bool changed;
10611065 if (allOn || someOn)
10621066 {
10631067 result = true ;
1064- renderToggle (
1068+ changed = renderToggle (
10651069 " ###psuon" ,
10661070 true ,
10671071 allOn ?
@@ -1071,9 +1075,9 @@ void StreamBrowserDialog::renderInstrumentNode(shared_ptr<Instrument> instrument
10711075 else
10721076 {
10731077 result = false ;
1074- renderOnOffToggle (" ###psuon" , true , result);
1078+ changed = renderOnOffToggle (" ###psuon" , true , result);
10751079 }
1076- if (result != allOn )
1080+ if (changed )
10771081 {
10781082 if (psu->SupportsMasterOutputSwitching ())
10791083 psu->SetMasterPowerEnable (result);
@@ -1135,12 +1139,74 @@ void StreamBrowserDialog::renderInstrumentNode(shared_ptr<Instrument> instrument
11351139 renderChannelNode (instrument,i,(i == lastEnabledChannelIndex));
11361140 }
11371141 int bankNumber = 1 ;
1142+ bool bankIsOpen;
11381143 for (auto bank : digitalBanks)
11391144 { // Iterate on digital banks
11401145 if (bank.size () > 1 )
11411146 { // Only show Digital Bank node if there is more than on channel in the bank
11421147 string nodeName = " Digital Bank " + to_string (bankNumber);
1143- if (ImGui::TreeNodeEx (nodeName.c_str ()))
1148+ bankIsOpen = ImGui::TreeNodeEx (nodeName.c_str ());
1149+
1150+ // Add dragdrop source for this bank
1151+ if (ImGui::BeginDragDropSource ())
1152+ {
1153+ m_streamGroupDesciptor = make_shared<StreamGroupDescriptor>(nodeName, bank);
1154+ auto ptr = m_streamGroupDesciptor.get ();
1155+ ImGui::SetDragDropPayload (" StreamGroup" , &ptr, sizeof (m_streamGroupDesciptor));
1156+ ImGui::TextUnformatted (m_streamGroupDesciptor->GetName ().c_str ());
1157+ ImGui::EndDragDropSource ();
1158+ }
1159+ else
1160+ DoItemHelp ();
1161+ /* Currently, enable/disable state is coupled to node reference counting, so we can't let the user manually enable/disable channels
1162+ // Add Banck on/off toggle
1163+ startBadgeLine();
1164+ bool allOn = true;
1165+ bool someOn = false;
1166+ for(auto channel : bank)
1167+ { // Iterate on bank's channel
1168+ size_t i = channel->GetIndex();
1169+ if(scope->IsChannelEnabled(i))
1170+ {
1171+ someOn = true;
1172+ }
1173+ else
1174+ {
1175+ allOn = false;
1176+ }
1177+ }
1178+ bool result;
1179+ bool changed;
1180+ string toggleId = "###"+nodeName+"on";
1181+ if(allOn || someOn)
1182+ {
1183+ result = true;
1184+ changed = renderToggle(
1185+ toggleId.c_str(),
1186+ true,
1187+ allOn ?
1188+ ImGui::ColorConvertU32ToFloat4(prefs.GetColor("Appearance.Stream Browser.instrument_on_badge_color")) :
1189+ ImGui::ColorConvertU32ToFloat4(prefs.GetColor("Appearance.Stream Browser.instrument_partial_badge_color")), result,"DISABLE","ENABLED",3);
1190+ }
1191+ else
1192+ {
1193+ result = false;
1194+ changed = renderToggle(
1195+ toggleId.c_str(),
1196+ true,
1197+ ImGui::ColorConvertU32ToFloat4(prefs.GetColor("Appearance.Stream Browser.instrument_off_badge_color")),
1198+ result,"DISABLED","ENABLE",3);
1199+ }
1200+ if(changed)
1201+ {
1202+ for(auto channel : bank)
1203+ { // Iterate on bank's channel
1204+ size_t i = channel->GetIndex();
1205+ result ? scope->EnableChannel(i) : scope->DisableChannel(i);
1206+ }
1207+ }
1208+ */
1209+ if (bankIsOpen)
11441210 {
11451211 ImGui::Unindent (ImGui::GetTreeNodeToLabelSpacing ());
11461212 for (auto channel : bank)
@@ -1525,17 +1591,53 @@ void StreamBrowserDialog::renderChannelNode(shared_ptr<Instrument> instrument, s
15251591 startBadgeLine ();
15261592 if (scopechan)
15271593 {
1594+ bool chanEnabled = scopechan->IsEnabled ();
1595+
15281596 // "trigger" badge on trigger inputs to show they're not displayable channels
15291597 if (scopechan->GetType (0 ) == Stream::STREAM_TYPE_TRIGGER)
15301598 renderBadge (ImGui::ColorConvertU32ToFloat4 (prefs.GetColor (" Appearance.Stream Browser.instrument_disabled_badge_color" )), " TRIG ONLY" , " TRIG" ," --" , nullptr );
15311599
1600+ /* Currently, enable/disable state is coupled to node reference counting, so we can't let the user manually enable/disable channels
15321601 // Scope channel
1533- else if (!scopechan->IsEnabled ())
1534- renderBadge (ImGui::ColorConvertU32ToFloat4 (prefs.GetColor (" Appearance.Stream Browser.instrument_disabled_badge_color" )), " DISABLED" , " DISA" ," --" , nullptr );
1602+ else if (!chanEnabled)
1603+ {
1604+ if(renderToggle(
1605+ "###scopeChanEnable",
1606+ true,
1607+ ImGui::ColorConvertU32ToFloat4(prefs.GetColor("Appearance.Stream Browser.instrument_disabled_badge_color")),
1608+ chanEnabled,
1609+ "DISABLED",
1610+ "ENABLE",
1611+ 3))
1612+ {
1613+ if(chanEnabled)
1614+ scope->EnableChannel(channelIndex);
1615+ }
1616+ //renderBadge(ImGui::ColorConvertU32ToFloat4(prefs.GetColor("Appearance.Stream Browser.instrument_disabled_badge_color")), "DISABLED", "DISA","--", nullptr);
1617+ }
1618+ */
15351619
15361620 // Download in progress
15371621 else
1538- renderDownloadProgress (instrument, channel, isLast);
1622+ {
1623+ if (!renderDownloadProgress (instrument, channel, isLast))
1624+ { // No download in progress, we can show the ENABLE/DISABLE toggle
1625+ /* Currently, enable/disable state is coupled to node reference counting, so we can't let the user manually enable/disable channels
1626+ if(renderToggle(
1627+ "###scopeChanEnable",
1628+ true,
1629+ ImGui::ColorConvertU32ToFloat4(prefs.GetColor("Appearance.Stream Browser.instrument_on_badge_color")),
1630+ chanEnabled,
1631+ "DISABLE",
1632+ "ENABLED",
1633+ 3))
1634+ {
1635+ if(!chanEnabled)
1636+ scope->DisableChannel(channelIndex);
1637+ }
1638+ */
1639+ }
1640+ }
15391641 }
15401642 else if (psu)
15411643 {
0 commit comments