1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
8 * Olivier Teulière <ipkiss@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
28 #include "skin_common.hpp"
29 #include "generic_layout.hpp"
30 #include "../utils/bezier.hpp"
31 #include "../utils/position.hpp"
34 /// Class for the windows anchors
35 class Anchor: public SkinObject
38 Anchor( intf_thread_t *pIntf, const Position &rPosition, int range,
39 int priority, const Bezier &rCurve, GenericLayout &rLayout )
40 : SkinObject( pIntf ), m_position( rPosition ), m_rCurve( rCurve ),
41 m_range( range ), m_priority( priority ), m_rLayout( rLayout ) { }
45 * Return true if the given anchor is hanged by this one
46 * Two conditions are required:
47 * - the other anchor must be in position of anchoring (as defined
49 * - the priority of the other anchor must be lower than this one's
51 bool isHanging( const Anchor &rOther ) const;
54 * Return true if the other anchor, moved by the (xOffset, yOffset)
55 * vector, is "hangable" by this one (i.e. if it is in its range of
56 * action), else return false.
57 * When the function returns true, the xOffset and yOffset parameters
58 * are modified to indicate the position that the other anchor would
59 * take if hanged by this one (this position is calculated to minimize
60 * the difference with the old xOffset and yOffset, so that the window
61 * doesn't "jump" in a strange way).
63 bool canHang( const Anchor &rOther, int &xOffset, int &yOffset ) const;
65 // Indicate whether this anchor is reduced to a single point
66 bool isPoint() const { return m_rCurve.getNbCtrlPoints() == 1; }
69 const Position & getPosition() const { return m_position; }
71 int getXPosAbs() const
73 return (m_position.getLeft() + m_rLayout.getLeft());
76 int getYPosAbs() const
78 return (m_position.getTop() + m_rLayout.getTop());
82 /// Position in the layout
85 /// Curve of the anchor
86 const Bezier &m_rCurve;
95 GenericLayout &m_rLayout;