projects
/
dcpomatic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Basic release notes support (#2282).
[dcpomatic.git]
/
src
/
lib
/
rect.h
diff --git
a/src/lib/rect.h
b/src/lib/rect.h
index 602acfc4b8bb5cd6fb691c21861e5a19a54a2248..a01e0f8858ffba6d31eb6b9675d0cff571b4571d 100644
(file)
--- a/
src/lib/rect.h
+++ b/
src/lib/rect.h
@@
-1,34
+1,39
@@
/*
/*
- Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013
-2021
Carl Hetherington <cth@carlh.net>
- This program is free software; you can redistribute it and/or modify
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
This program
is distributed in the hope that it will be useful,
+
DCP-o-matic
is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
*/
*/
+
#ifndef DCPOMATIC_RECT_H
#define DCPOMATIC_RECT_H
#ifndef DCPOMATIC_RECT_H
#define DCPOMATIC_RECT_H
+
#include "position.h"
#include <boost/optional.hpp>
#include <algorithm>
#include "position.h"
#include <boost/optional.hpp>
#include <algorithm>
+
/* Put this inside a namespace as Apple put a Rect in the global namespace */
namespace dcpomatic
{
/* Put this inside a namespace as Apple put a Rect in the global namespace */
namespace dcpomatic
{
+
/** @struct Rect
* @brief A rectangle.
*/
/** @struct Rect
* @brief A rectangle.
*/
@@
-68,7
+73,7
@@
public:
return Position<T> (x, y);
}
return Position<T> (x, y);
}
- boost::optional<Rect<T>
> intersection (Rect<T> const & other) const
+ boost::optional<Rect<T>> intersection (Rect<T> const & other) const
{
/* This isn't exactly the paragon of mathematical precision */
{
/* This isn't exactly the paragon of mathematical precision */
@@
-82,7
+87,7
@@
public:
);
if (r.width < 0 || r.height < 0) {
);
if (r.width < 0 || r.height < 0) {
- return
boost::optional<Rect<T> > ()
;
+ return
{}
;
}
return r;
}
return r;
@@
-90,10
+95,12
@@
public:
void extend (Rect<T> const & other)
{
void extend (Rect<T> const & other)
{
+ T old_x = x;
+ T old_y = y;
x = std::min (x, other.x);
y = std::min (y, other.y);
x = std::min (x, other.x);
y = std::min (y, other.y);
- width = std::max (x + width, other.x + other.width) - x;
- height = std::max (y + height, other.y + other.height) - y;
+ width = std::max (
old_
x + width, other.x + other.width) - x;
+ height = std::max (
old_
y + height, other.y + other.height) - y;
}
Rect<T> extended (T amount) const {
}
Rect<T> extended (T amount) const {
@@
-111,6
+118,15
@@
public:
}
};
}
};
+
+template <class T>
+bool operator== (Rect<T> const& a, Rect<T> const& b)
+{
+ return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height;
+}
+
+
}
}
+
#endif
#endif