From f8fad963aca75b817fc5a1f7b6c7705a2f449e6a Mon Sep 17 00:00:00 2001
From: Cyril Deguet <asmax@videolan.org>
Date: Tue, 15 Nov 2005 22:30:17 +0000
Subject: [PATCH] * all: fixed a bug occuring when a slider was resized (the
 thickness  of the slider background was proportional to the scaling factor, 
 which is not what we want!)

---
 modules/gui/skins2/controls/ctrl_slider.cpp | 4 ++--
 modules/gui/skins2/utils/bezier.cpp         | 7 ++++---
 modules/gui/skins2/utils/bezier.hpp         | 6 ++++--
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/modules/gui/skins2/controls/ctrl_slider.cpp b/modules/gui/skins2/controls/ctrl_slider.cpp
index 08adabbaf2..641738fb02 100644
--- a/modules/gui/skins2/controls/ctrl_slider.cpp
+++ b/modules/gui/skins2/controls/ctrl_slider.cpp
@@ -377,8 +377,8 @@ bool CtrlSliderBg::mouseOver( int x, int y ) const
     float factorX, factorY;
     getResizeFactors( factorX, factorY );
 
-    return (m_rCurve.getMinDist( (int)(x / factorX),
-                                 (int)(y / factorY) ) < m_thickness );
+    return (m_rCurve.getMinDist( (int)(x / factorX), (int)(y / factorY),
+                                 factorX, factorY ) < m_thickness );
 }
 
 
diff --git a/modules/gui/skins2/utils/bezier.cpp b/modules/gui/skins2/utils/bezier.cpp
index 5d2b83b060..abd5df75f4 100644
--- a/modules/gui/skins2/utils/bezier.cpp
+++ b/modules/gui/skins2/utils/bezier.cpp
@@ -107,11 +107,12 @@ float Bezier::getNearestPercent( int x, int y ) const
 }
 
 
-float Bezier::getMinDist( int x, int y ) const
+float Bezier::getMinDist( int x, int y, float xScale, float yScale ) const
 {
     int nearest = findNearestPoint( x, y );
-    return sqrt( (double)((m_leftVect[nearest] - x) * (m_leftVect[nearest] - x) +
-                 (m_topVect[nearest] - y) * (m_topVect[nearest] - y)) );
+    double xDist = xScale * (m_leftVect[nearest] - x);
+    double yDist = yScale * (m_topVect[nearest] - y);
+    return sqrt( xDist * xDist + yDist * yDist );
 }
 
 
diff --git a/modules/gui/skins2/utils/bezier.hpp b/modules/gui/skins2/utils/bezier.hpp
index d7bda7609f..2657e3d96a 100644
--- a/modules/gui/skins2/utils/bezier.hpp
+++ b/modules/gui/skins2/utils/bezier.hpp
@@ -58,8 +58,10 @@ class Bezier: public SkinObject
         /// from (x, y)
         float getNearestPercent( int x, int y ) const;
 
-        /// Return the distance of (x, y) to the curve
-        float getMinDist( int x, int y ) const;
+        /// Return the distance of (x, y) to the curve, corrected
+        /// by the (optional) given scale factors
+        float getMinDist( int x, int y, float xScale = 1.0f,
+                          float yScale = 1.0f ) const;
 
         /// Get the coordinates of the point at t percent of
         /// the curve (t must be between 0 and 1)
-- 
2.25.4