~ubuntu-branches/debian/wheezy/vlc/wheezy

« back to all changes in this revision

Viewing changes to modules/gui/skins2/src/anchor.hpp

Tags: upstream-0.7.2.final
Import upstream version 0.7.2.final

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 * anchor.hpp
 
3
 *****************************************************************************
 
4
 * Copyright (C) 2003 VideoLAN
 
5
 * $Id: anchor.hpp 7228 2004-04-01 21:04:43Z ipkiss $
 
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
 
21
 * along with this program; if not, write to the Free Software
 
22
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, 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
 
 
32
 
 
33
/// Class for the windows anchors
 
34
class Anchor: public SkinObject
 
35
{
 
36
    public:
 
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 ) {}
 
42
        virtual ~Anchor() {}
 
43
 
 
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
 
47
        ///    by canHang())
 
48
        ///  - the priority of the other anchor must be lower than this one's
 
49
        bool isHanging( const Anchor &rOther ) const;
 
50
 
 
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;
 
60
 
 
61
        // Indicate whether this anchor is reduced to a single point
 
62
        bool isPoint() const { return m_rCurve.getNbCtrlPoints() == 1; }
 
63
 
 
64
        // Getters
 
65
        int getXPosAbs() const { return (m_xPos + m_rLayout.getLeft()); }
 
66
        int getYPosAbs() const { return (m_yPos + m_rLayout.getTop()); }
 
67
 
 
68
    private:
 
69
        /// Coordinates relative to the window
 
70
        int m_xPos, m_yPos;
 
71
 
 
72
        /// Curve of the anchor
 
73
        const Bezier &m_rCurve;
 
74
 
 
75
        /// Range of action
 
76
        int m_range;
 
77
 
 
78
        /// Priority
 
79
        int m_priority;
 
80
 
 
81
        /// Parent window
 
82
        GenericLayout &m_rLayout;
 
83
};
 
84
 
 
85
 
 
86
#endif