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 
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);
41  void remove(Rectangle const& rect);
42  void clear();
44  void confine(Point& point) const;
45 
46  typedef std::vector<Rectangle>::const_iterator const_iterator;
47  typedef std::vector<Rectangle>::size_type size_type;
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  Rectangle bounding_rectangle_; // TODO unused: delete on next ABI break
58 };
59 
60 
61 std::ostream& operator<<(std::ostream& out, Rectangles const& value);
62 
63 }
64 }
65 
66 #endif /* MIR_GEOMETRY_RECTANGLES_H_ */
A collection of rectangles (with possible duplicates).
Definition: rectangles.h:33
void confine(Point &point) const
void remove(Rectangle const &rect)
removes at most one matching rectangle
bool operator==(Rectangles const &rect) const
Rectangles(std::initializer_list< Rectangle > const &rects)
std::vector< Rectangle >::size_type size_type
Definition: rectangles.h:47
size_type size() const
void add(Rectangle const &rect)
bool operator!=(Rectangles const &rect) const
std::vector< Rectangle >::const_iterator const_iterator
Definition: rectangles.h:46
const_iterator begin() const
Rectangle bounding_rectangle() const
const_iterator end() const
std::ostream & operator<<(std::ostream &out, Rectangles const &value)
Definition: splash_session.h:22
Definition: point.h:30
Definition: rectangle.h:31

Copyright © 2012-2022 Canonical Ltd.
Generated on Tue May 24 14:35:34 UTC 2022
This documentation is licensed under the GPL version 2 or 3.