Re: [Icewing-user] "opts_float_create" and "opts_value_set" precision and gtk
Brought to you by:
floemker
From: Christian L. <chr...@un...> - 2009-06-17 08:30:08
|
Hello Frank, thanks a lot! With the help of the "float_get_digits" function, I modified my code so that it does no longer set values with a too high precision, which solved the problem for me. Kind regards, Christian Frank Loemker wrote: > Helo, > > On Tue, Jun 16, 2009 at 12:28:10PM +0200, Christian Lang wrote: > >> I have a question about the "opts_float_create" and "opts_value_set" >> functions of iceWing. When "opts_float_create" is used to create a slider, >> the given range for the value seems to determine the precision of that >> value implicitly. >> > > Yes, that's right. The corresponding code is: > > static int float_get_digits (float left, float right) > { > int digits = 2; > int i = 1/(1.01*(right-left)); > > if (right-left >= 100) return 1; > while (i > 0) { > digits++; > i = i/10; > } > return digits; > } > > > >> In case one uses "opts_value_set" with an value of higher >> precision in terms of post decimal positions, the value is truncated to >> that implicitly given precision by the call to "opts_value_set". In >> addition, gtk produces a beep to indicate that issue (this is at least my >> interpretation of the situation). >> > > Hmmm, the beep should not happen. During my tests with gtk 2.8 and gtk 2.12 > no beep was produced. And I would call it a bug if one occurs. > > There is a gtk setting which sounds as if it might be involved: > "gtk-error-bell" > When TRUE, keyboard navigation and other input-related errors will > cause a beep. Since the error bell is implemented using > gdk_window_beep(), the windowing system may offer ways to configure > the error bell in many ways, such as flashing the window or similar > visual effects. > > >> I attached a small example which shows the described behavior. It can be >> compiled with "g++ -shared `icewing-config --cflags` -o libTestPlug.so >> TestPlug.cpp" and started by "icewing -l ./libTestPlug.so". When the slider >> is set to a value with two post decimal positions, it is not changed by the >> call to "opts_float_create". But if a value with three post decimal >> postions is used, it is truncated to two post decimal positions and the >> "beep" occurs. >> >> My question is now: How exactly is the precision of the value determined? I >> would like to now this to avoid unintended changes in the value and also to >> avoid the "beep" every time a value with too high precision is set. >> > > Bye, > > |