From 90edcc8c42748949e3637149f271793a094cfa17 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 25 Dec 2022 11:16:37 +0000 Subject: [PATCH] Clarity and Clang-tidy warnings. --- eeschema/widgets/tuner_slider.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/eeschema/widgets/tuner_slider.cpp b/eeschema/widgets/tuner_slider.cpp index dfc3898045..44d0b72066 100644 --- a/eeschema/widgets/tuner_slider.cpp +++ b/eeschema/widgets/tuner_slider.cpp @@ -164,14 +164,22 @@ void TUNER_SLIDER::updateComponentValue() void TUNER_SLIDER::updateSlider() { wxASSERT( m_max >= m_value && m_value >= m_min ); - m_slider->SetValue( ( ( m_value - m_min ) / ( m_max - m_min ) ).ToDouble() * 100 ); + SPICE_VALUE value = ( m_value - m_min ) / ( m_max - m_min ); + m_slider->SetValue( KiROUND( value.ToDouble() * 100.0 ) ); } void TUNER_SLIDER::updateValueText() { - bool spiceString = m_min.IsSpiceString() || m_max.IsSpiceString(); - m_valueText->SetValue( spiceString ? m_value.ToSpiceString() : m_value.ToString() ); + if( m_min.IsSpiceString() || m_max.IsSpiceString() ) + { + m_valueText->SetValue( m_value.ToSpiceString() ); + return; + } + + double value = m_value.ToDouble(); + + m_valueText->SetValue( wxString::Format( "%.3f", value ) ); }