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
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 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 ),
41 m_rCurve( rCurve ), m_range( range ), m_priority( priority ),
42 m_rLayout( rLayout ) {}
46 * Return true if the given anchor is hanged by this one
47 * Two conditions are required:
48 * - the other anchor must be in position of anchoring (as defined
50 * - the priority of the other anchor must be lower than this one's
52 bool isHanging( const Anchor &rOther ) const;
55 * Return true if the other anchor, moved by the (xOffset, yOffset)
56 * vector, is "hangable" by this one (i.e. if it is in its range of
57 * action), else return false.
58 * When the function returns true, the xOffset and yOffset parameters
59 * are modified to indicate the position that the other anchor would
60 * take if hanged by this one (this position is calculated to minimize
61 * the difference with the old xOffset and yOffset, so that the window
62 * doesn't "jump" in a strange way).
64 bool canHang( const Anchor &rOther, int &xOffset, int &yOffset ) const;
66 // Indicate whether this anchor is reduced to a single point
67 bool isPoint() const { return m_rCurve.getNbCtrlPoints() == 1; }
70 const Position & getPosition() const { return m_position; }
72 int getXPosAbs() const
74 return (m_position.getLeft() + m_rLayout.getLeft());
77 int getYPosAbs() const
79 return (m_position.getTop() + m_rLayout.getTop());
83 /// Position in the layout
86 /// Curve of the anchor
87 const Bezier &m_rCurve;
96 GenericLayout &m_rLayout;