From 8703bcd103c7bfdac73f8f6bd4c34b4dbf5374aa Mon Sep 17 00:00:00 2001 From: natureh Date: Mon, 16 Jan 2012 02:16:09 +0100 Subject: [PATCH] Fix a bug in the Adjuster class that were causing system Beep when reaching the limits, or at each move when the limits where below 1.0 (like for Distortion). Also fix the bug of the too small spin button (displaying not enough digits). --- rtgui/guiutils.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rtgui/guiutils.cc b/rtgui/guiutils.cc index 241b0853b..11d7e8ef1 100644 --- a/rtgui/guiutils.cc +++ b/rtgui/guiutils.cc @@ -320,18 +320,22 @@ MySpinButton::MySpinButton () { void MySpinButton::updateSize() { double vMin, vMax; double step, page; - double maxAbs; + int maxAbs; unsigned int digits, digits2; unsigned int maxLen; get_range(vMin, vMax); get_increments (step, page); - maxAbs = fmax(fabs(vMin), fabs(vMax)); digits = get_digits(); - for (digits2=0; maxAbs/pow(double(10),digits2)>=1.0; digits2++); + maxAbs = (int)(fmax(fabs(vMin), fabs(vMax))+0.000001); + if (maxAbs==0) + digits2 = 1; + else { + digits2 = (int)(log10(double(maxAbs))+0.000001); + digits2++; + } maxLen = digits+digits2+(vMin<0?1:0)+(digits>0?1:0); - set_max_length(maxLen); set_width_chars(maxLen); }