Skip to content

Commit 1f01df2

Browse files
committed
Added RenderOnOffToggleEXT, fixed interleaving toggle to work properly
1 parent d906d3e commit 1f01df2

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

src/ngscopeclient/StreamBrowserDialog.cpp

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ bool StreamBrowserDialog::renderCombo(
370370
@param color the color of the toggle button
371371
@param curValue the value of the toggle button
372372
@return the selected value for the toggle button
373+
374+
TODO: replace with renderToggleEXT
373375
*/
374376
bool StreamBrowserDialog::renderToggle(const char* label, bool alignRight, ImVec4 color, bool curValue)
375377
{
@@ -378,11 +380,28 @@ bool StreamBrowserDialog::renderToggle(const char* label, bool alignRight, ImVec
378380
return (selection == 1);
379381
}
380382

383+
/**
384+
@brief Render a toggle button combo
385+
386+
@param color the color of the toggle button
387+
@param curValue the value of the toggle button
388+
@return true if selection has changed
389+
*/
390+
bool StreamBrowserDialog::renderToggleEXT(const char* label, bool alignRight, ImVec4 color, bool& curValue)
391+
{
392+
int selection = (int)curValue;
393+
bool ret = renderCombo(label, alignRight, color, &selection, "OFF", "ON", nullptr);
394+
curValue = (selection == 1);
395+
return ret;
396+
}
397+
381398
/**
382399
@brief Render an on/off toggle button combo
383400
384401
@param curValue the value of the toggle button
385402
@return the selected value for the toggle button
403+
404+
TODO: replace with renderOnOffToggleEXT
386405
*/
387406
bool StreamBrowserDialog::renderOnOffToggle(const char* label, bool alignRight, bool curValue)
388407
{
@@ -394,6 +413,22 @@ bool StreamBrowserDialog::renderOnOffToggle(const char* label, bool alignRight,
394413
return renderToggle(label, alignRight, color, curValue);
395414
}
396415

416+
/**
417+
@brief Render an on/off toggle button combo
418+
419+
@param curValue the value of the toggle button
420+
@return true if value has changed
421+
*/
422+
bool StreamBrowserDialog::renderOnOffToggleEXT(const char* label, bool alignRight, bool& curValue)
423+
{
424+
auto& prefs = m_session.GetPreferences();
425+
ImVec4 color = ImGui::ColorConvertU32ToFloat4(
426+
(curValue ?
427+
prefs.GetColor("Appearance.Stream Browser.instrument_on_badge_color") :
428+
prefs.GetColor("Appearance.Stream Browser.instrument_off_badge_color")));
429+
return renderToggleEXT(label, alignRight, color, curValue);
430+
}
431+
397432
/**
398433
@brief Render a download progress bar for a given instrument channel
399434
@@ -1053,7 +1088,7 @@ void StreamBrowserDialog::DoTimebaseSettings(shared_ptr<Oscilloscope> scope)
10531088
ImGui::SetNextItemWidth(width);
10541089
bool disabled = !scope->CanInterleave();
10551090
ImGui::BeginDisabled(disabled);
1056-
if(renderOnOffToggle("Interleaving", false, config->m_interleaving))
1091+
if(renderOnOffToggleEXT("Interleaving", false, config->m_interleaving))
10571092
{
10581093
scope->SetInterleaving(config->m_interleaving);
10591094
refresh = true;

src/ngscopeclient/StreamBrowserDialog.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,13 @@ class StreamBrowserDialog : public Dialog
134134
bool alignRight,
135135
ImVec4 color,
136136
bool curValue);
137+
bool renderToggleEXT(
138+
const char* label,
139+
bool alignRight,
140+
ImVec4 color,
141+
bool& curValue);
137142
bool renderOnOffToggle(const char* label, bool alignRight, bool curValue);
143+
bool renderOnOffToggleEXT(const char* label, bool alignRight, bool& curValue);
138144
void renderDownloadProgress(std::shared_ptr<Instrument> inst, InstrumentChannel *chan, bool isLast);
139145
void renderPsuRows(bool isVoltage, bool cc, PowerSupplyChannel* chan,const char *setValue, const char *measuredValue, bool &clicked, bool &hovered);
140146
void renderAwgProperties(std::shared_ptr<FunctionGenerator> awg, FunctionGeneratorChannel* awgchan);

0 commit comments

Comments
 (0)