Skip to content

Commit

Permalink
* all: fixed a bug occuring when a slider was resized (the thickness
Browse files Browse the repository at this point in the history
 of the slider background was proportional to the scaling factor,
 which is not what we want!)
  • Loading branch information
Cyril Deguet committed Nov 15, 2005
1 parent 8753c93 commit f8fad96
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions modules/gui/skins2/controls/ctrl_slider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}


Expand Down
7 changes: 4 additions & 3 deletions modules/gui/skins2/utils/bezier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}


Expand Down
6 changes: 4 additions & 2 deletions modules/gui/skins2/utils/bezier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f8fad96

Please sign in to comment.