From: Joel Holdsworth Date: Sun, 19 Jan 2014 14:36:34 +0000 (+0000) Subject: SamplingBar: Show a 1-2-5 for min-max sample rate values X-Git-Tag: pulseview-0.2.0~119 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=aafe53af3e610a955dac362fd4066d7baefce774;p=pulseview.git SamplingBar: Show a 1-2-5 for min-max sample rate values --- diff --git a/pv/toolbars/samplingbar.cpp b/pv/toolbars/samplingbar.cpp index 80c822e2..79dd7a1a 100644 --- a/pv/toolbars/samplingbar.cpp +++ b/pv/toolbars/samplingbar.cpp @@ -160,9 +160,28 @@ void SamplingBar::update_sample_rate_selector() { elements = (const uint64_t *)g_variant_get_fixed_array( gvar_list, &num_elements, sizeof(uint64_t)); - _sample_rate.show_min_max_step(elements[0], elements[1], - elements[2]); + + const uint64_t min = elements[0]; + const uint64_t max = elements[1]; + const uint64_t step = elements[2]; + g_variant_unref(gvar_list); + + assert(min > 0); + assert(max > 0); + assert(max > min); + assert(step > 0); + + if (step == 1) + _sample_rate.show_125_list(min, max); + else + { + // When the step is not 1, we cam't make a 1-2-5-10 + // list of sample rates, because we may not be able to + // make round numbers. Therefore in this case, show a + // spin box. + _sample_rate.show_min_max_step(min, max, step); + } } else if ((gvar_list = g_variant_lookup_value(gvar_dict, "samplerates", G_VARIANT_TYPE("at"))))