Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rectangle.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Alan Griffiths <alan@octopull.co.uk>
17  * Alexandros Frantzis <alexandros.frantzis@canonical.com>
18  */
19 
20 #ifndef MIR_GEOMETRY_RECTANGLE_H_
21 #define MIR_GEOMETRY_RECTANGLE_H_
22 
23 #include "point.h"
24 #include "size.h"
25 
26 #include <ostream>
27 
28 namespace mir
29 {
30 namespace geometry
31 {
32 
33 struct Rectangle
34 {
37 
44  Point bottom_right() const;
45  bool contains(Point const& p) const;
46 
53  bool contains(Rectangle const& r) const;
54 
55  bool overlaps(Rectangle const& r) const;
56 };
57 
58 inline bool operator == (Rectangle const& lhs, Rectangle const& rhs)
59 {
60  return lhs.top_left == rhs.top_left && lhs.size == rhs.size;
61 }
62 
63 inline bool operator != (Rectangle const& lhs, Rectangle const& rhs)
64 {
65  return lhs.top_left != rhs.top_left || lhs.size != rhs.size;
66 }
67 
68 inline std::ostream& operator<<(std::ostream& out, Rectangle const& value)
69 {
70  out << '(' << value.top_left << ", " << value.size << ')';
71  return out;
72 }
73 
74 }
75 }
76 
77 #endif /* MIR_GEOMETRY_RECTANGLE_H_ */

Copyright © 2012,2013 Canonical Ltd.
Generated on Wed Oct 30 18:52:19 UTC 2013