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"
33 /// Class for the windows anchors
34 class Anchor: public SkinObject
37 Anchor( intf_thread_t *pIntf, int xPos, int yPos, int range,
38 int priority, const Bezier &rCurve, GenericLayout &rLayout ):
39 SkinObject( pIntf ), m_xPos( xPos ), m_yPos( yPos ),
40 m_rCurve( rCurve ), m_range( range ), m_priority( priority ),
41 m_rLayout( rLayout ) {}
44 /// Return true if the given anchor is hanged by this one
45 /// Two conditions are required:
46 /// - the other anchor must be in position of anchoring (as defined
48 /// - the priority of the other anchor must be lower than this one's
49 bool isHanging( const Anchor &rOther ) const;
51 /// Return true if the other anchor, moved by the (xOffset, yOffset)
52 /// vector, is "hangable" by this one (i.e. if it is in its range of
53 /// action), else return false.
54 /// When the function returns true, the xOffset and yOffset parameters
55 /// are modified to indicate the position that the other anchor would
56 /// take if hanged by this one (this position is calculated to minimize
57 /// the difference with the old xOffset and yOffset, so that the window
58 /// doesn't "jump" in a strange way).
59 bool canHang( const Anchor &rOther, int &xOffset, int &yOffset ) const;
61 // Indicate whether this anchor is reduced to a single point
62 bool isPoint() const { return m_rCurve.getNbCtrlPoints() == 1; }
65 int getXPosAbs() const { return (m_xPos + m_rLayout.getLeft()); }
66 int getYPosAbs() const { return (m_yPos + m_rLayout.getTop()); }
69 /// Coordinates relative to the window
72 /// Curve of the anchor
73 const Bezier &m_rCurve;
82 GenericLayout &m_rLayout;