anchor.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * anchor.hpp
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id: 4758bf11508d27c8044d391f2350cfea3543c5fd $
00006  *
00007  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
00008  *          Olivier Teulière <ipkiss@via.ecp.fr>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License along
00021  * with this program; if not, write to the Free Software Foundation, Inc.,
00022  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef ANCHOR_HPP
00026 #define ANCHOR_HPP
00027 
00028 #include "skin_common.hpp"
00029 #include "generic_layout.hpp"
00030 #include "../utils/bezier.hpp"
00031 #include "../utils/position.hpp"
00032 
00033 
00034 /// Class for the windows anchors
00035 class Anchor: public SkinObject
00036 {
00037 public:
00038     Anchor( intf_thread_t *pIntf, const Position &rPosition, int range,
00039             int priority, const Bezier &rCurve, GenericLayout &rLayout )
00040           : SkinObject( pIntf ), m_position( rPosition ), m_rCurve( rCurve ),
00041             m_range( range ), m_priority( priority ), m_rLayout( rLayout ) { }
00042     virtual ~Anchor() { }
00043 
00044     /**
00045      * Return true if the given anchor is hanged by this one
00046      * Two conditions are required:
00047      *  - the other anchor must be in position of anchoring (as defined
00048      *    by canHang())
00049      *  - the priority of the other anchor must be lower than this one's
00050      */
00051     bool isHanging( const Anchor &rOther ) const;
00052 
00053     /**
00054      * Return true if the other anchor, moved by the (xOffset, yOffset)
00055      * vector, is "hangable" by this one (i.e. if it is in its range of
00056      * action), else return false.
00057      * When the function returns true, the xOffset and yOffset parameters
00058      * are modified to indicate the position that the other anchor would
00059      * take if hanged by this one (this position is calculated to minimize
00060      * the difference with the old xOffset and yOffset, so that the window
00061      * doesn't "jump" in a strange way).
00062      */
00063     bool canHang( const Anchor &rOther, int &xOffset, int &yOffset ) const;
00064 
00065     // Indicate whether this anchor is reduced to a single point
00066     bool isPoint() const { return m_rCurve.getNbCtrlPoints() == 1; }
00067 
00068     // Getters
00069     const Position & getPosition() const { return m_position; }
00070 
00071     int getXPosAbs() const
00072     {
00073         return (m_position.getLeft() + m_rLayout.getLeft());
00074     }
00075 
00076     int getYPosAbs() const
00077     {
00078         return (m_position.getTop() + m_rLayout.getTop());
00079     }
00080 
00081 private:
00082     /// Position in the layout
00083     Position m_position;
00084 
00085     /// Curve of the anchor
00086     const Bezier &m_rCurve;
00087 
00088     /// Range of action
00089     int m_range;
00090 
00091     /// Priority
00092     int m_priority;
00093 
00094     /// Parent layout
00095     GenericLayout &m_rLayout;
00096 };
00097 
00098 
00099 #endif

Generated on Tue May 25 08:04:58 2010 for VLC by  doxygen 1.5.6