]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/utils/bezier.hpp
Uniformize source files encoding
[vlc] / modules / gui / skins2 / utils / bezier.hpp
index 93d24a447468d12f44878033a886fb8f5fabd4de..f4e7d0b447ee4773b499d744e392bd00734ddb02 100644 (file)
@@ -1,11 +1,11 @@
 /*****************************************************************************
  * bezier.hpp
  *****************************************************************************
- * Copyright (C) 2003 VideoLAN
- * $Id: bezier.hpp,v 1.3 2004/02/01 16:15:40 asmax Exp $
+ * Copyright (C) 2003 the VideoLAN team
+ * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
- *          Olivier Teulière <ipkiss@via.ecp.fr>
+ *          Olivier Teulière <ipkiss@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #ifndef BEZIER_HPP
@@ -38,12 +38,12 @@ class Bezier: public SkinObject
     public:
         /// Values to indicate which coordinate(s) must be checked to consider
         /// that two points are distinct
-        typedef enum
+        enum Flag_t
         {
             kCoordsBoth,    // x or y must be different (default)
             kCoordsX,       // only x is different
             kCoordsY        // only y is different
-        } Flag_t;
+        };
 
         Bezier( intf_thread_t *p_intf,
                 const vector<float> &pAbscissas,
@@ -51,15 +51,19 @@ class Bezier: public SkinObject
                 Flag_t flag = kCoordsBoth );
         ~Bezier() {}
 
+        /// Get the number of control points used to define the curve
+        int getNbCtrlPoints() const { return m_nbCtrlPt; }
+
         /// Return the percentage (between 0 and 1) of the curve point nearest
         /// 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 precent of
+        /// Get the coordinates of the point at t percent of
         /// the curve (t must be between 0 and 1)
         void getPoint( float t, int &x, int &y ) const;
 
@@ -83,9 +87,14 @@ class Bezier: public SkinObject
         /// Vectors with the coordinates of the different points of the curve
         vector<int> m_leftVect;
         vector<int> m_topVect;
+        /// Vector with the percentages associated with the points of the curve
+        vector<float> m_percVect;
 
         /// Return the index of the curve point that is the nearest from (x, y)
         int findNearestPoint( int x, int y ) const;
+        /// Compute the coordinates of a point corresponding to a given
+        /// percentage
+        void computePoint( float t, int &x, int &y ) const;
         /// Helper function to compute a coefficient of the curve
         inline float computeCoeff( int i, int n, float t ) const;
         /// x^n