Patch: Fix for slider thumb not showing
Posted: Sat Jan 29, 2011 12:58
Hi, I still cannot log in to Mantis for some reason, so I'll post this here instead.
There's a bug with FalSlider which has the effect that if the size of any of the dimensions of the slider track is zero at any point, it will cause the position sent to the thumb to be {{NaN, 0},{NaN,0}}, due to a division of zero. This seems then to cause the thumb window to never be able to recover (I'm not sure exactly what happens, but it seems like when setSize later is called, the NaNs will make that turn out invalid. Perhaps there should be an assert in CEGUIWindow for sizes and positions that contain NaN?)
Anyway, this patch will fix this issue (apply in the "0.7" branch):
Btw, when doing this it became apparent how much cumbersome the process of providing such a patch like this is when using svn in contrast to using a DVCS. While svn works very well for the regular developers, I would argue that the barrier of entry for non-regular developers wanting to provide a patch is a magnitude lower when using a DVCS.
There's a bug with FalSlider which has the effect that if the size of any of the dimensions of the slider track is zero at any point, it will cause the position sent to the thumb to be {{NaN, 0},{NaN,0}}, due to a division of zero. This seems then to cause the thumb window to never be able to recover (I'm not sure exactly what happens, but it seems like when setSize later is called, the NaNs will make that turn out invalid. Perhaps there should be an assert in CEGUIWindow for sizes and positions that contain NaN?)
Anyway, this patch will fix this issue (apply in the "0.7" branch):
Code: Select all
Index: cegui/src/WindowRendererSets/Falagard/FalSlider.cpp
===================================================================
--- cegui/src/WindowRendererSets/Falagard/FalSlider.cpp (revision 2787)
+++ cegui/src/WindowRendererSets/Falagard/FalSlider.cpp (arbetskopia)
@@ -76,9 +76,10 @@
const Size w_pixel_size(w->getPixelSize());
+ float thumbRelXPos = w_pixel_size.d_width == 0.0f ? 0.0f : (area.d_left / w_pixel_size.d_width);
+ float thumbRelYPos = w_pixel_size.d_height == 0.0f ? 0.0f : (area.d_top / w_pixel_size.d_height);
// get base location for thumb widget
- UVector2 thumbPosition(cegui_reldim(area.d_left / w_pixel_size.d_width),
- cegui_reldim(area.d_top / w_pixel_size.d_height));
+ UVector2 thumbPosition(cegui_reldim(thumbRelXPos), cegui_reldim(thumbRelYPos));
// Is this a vertical slider
if (d_vertical)
Btw, when doing this it became apparent how much cumbersome the process of providing such a patch like this is when using svn in contrast to using a DVCS. While svn works very well for the regular developers, I would argue that the barrier of entry for non-regular developers wanting to provide a patch is a magnitude lower when using a DVCS.