Mir
rectangles.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013-2015 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 2 or 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 
17 #ifndef MIR_GEOMETRY_RECTANGLES_H_
18 #define MIR_GEOMETRY_RECTANGLES_H_
19 
20 #include "mir/geometry/point.h"
21 #include "mir/geometry/rectangle.h"
22 
23 #include <vector>
24 #include <initializer_list>
25 
26 namespace mir
27 {
28 namespace geometry
29 {
30 
31 /// A collection of rectangles (with possible duplicates).
33 {
34 public:
36  Rectangles(std::initializer_list<Rectangle> const& rects);
37  /* We want to keep implicit copy and move methods */
38 
39  void add(Rectangle const& rect);
40  /// removes at most one matching rectangle
41  void remove(Rectangle const& rect);
42  void clear();
43  Rectangle bounding_rectangle() const;
44  void confine(Point& point) const;
45 
50  size_type size() const;
51 
52  bool operator==(Rectangles const& rect) const;
53  bool operator!=(Rectangles const& rect) const;
54 
55 private:
56  std::vector<Rectangle> rectangles;
57 };
58 
59 
60 std::ostream& operator<<(std::ostream& out, Rectangles const& value);
61 
62 }
63 }
64 
65 #endif /* MIR_GEOMETRY_RECTANGLES_H_ */

Copyright © 2012-2022 Canonical Ltd.
Generated on Thu Sep 8 12:37:23 UTC 2022
This documentation is licensed under the GPL version 2 or 3.