]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/anchor.hpp
skins(Win32): add hotkeys support in fullscreen mode
[vlc] / modules / gui / skins2 / src / anchor.hpp
1 /*****************************************************************************
2  * anchor.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teulière <ipkiss@via.ecp.fr>
9  *
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.
14  *
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.
19  *
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  *****************************************************************************/
24
25 #ifndef ANCHOR_HPP
26 #define ANCHOR_HPP
27
28 #include "skin_common.hpp"
29 #include "generic_layout.hpp"
30 #include "../utils/bezier.hpp"
31 #include "../utils/position.hpp"
32
33
34 /// Class for the windows anchors
35 class Anchor: public SkinObject
36 {
37 public:
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 ) { }
42     virtual ~Anchor() { }
43
44     /**
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
48      *    by canHang())
49      *  - the priority of the other anchor must be lower than this one's
50      */
51     bool isHanging( const Anchor &rOther ) const;
52
53     /**
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).
62      */
63     bool canHang( const Anchor &rOther, int &xOffset, int &yOffset ) const;
64
65     // Indicate whether this anchor is reduced to a single point
66     bool isPoint() const { return m_rCurve.getNbCtrlPoints() == 1; }
67
68     // Getters
69     const Position & getPosition() const { return m_position; }
70
71     int getXPosAbs() const
72     {
73         return (m_position.getLeft() + m_rLayout.getLeft());
74     }
75
76     int getYPosAbs() const
77     {
78         return (m_position.getTop() + m_rLayout.getTop());
79     }
80
81 private:
82     /// Position in the layout
83     Position m_position;
84
85     /// Curve of the anchor
86     const Bezier &m_rCurve;
87
88     /// Range of action
89     int m_range;
90
91     /// Priority
92     int m_priority;
93
94     /// Parent layout
95     GenericLayout &m_rLayout;
96 };
97
98
99 #endif