Lumiera  0.pre.03
»edit your freedom«
rectangle.cpp
Go to the documentation of this file.
1 /*
2  Rectangle - utility functions for GDK rectangles
3 
4  Copyright (C)
5  2008, Joel Holdsworth <joel@airwebreathe.org.uk>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
14 
21 #include "stage/draw/rectangle.hpp"
22 #include <algorithm>
23 
24 
25 using std::max;
26 using std::min;
27 
28 namespace stage {
29 namespace draw{
30 
31  bool
32  pt_in_rect(const Gdk::Point &point, const Gdk::Rectangle &rect)
33  {
34  return (point.get_x() >= rect.get_x() &&
35  point.get_x() < rect.get_x() + rect.get_width() &&
36  point.get_y() >= rect.get_y() &&
37  point.get_y() < rect.get_y() + rect.get_height());
38  }
39 
40  bool
41  rects_overlap (Gdk::Rectangle const& a, Gdk::Rectangle const& b)
42  {
43  return (
44  max(a.get_x(), b.get_x()) <
45  min(a.get_x() + a.get_width(), b.get_x() + b.get_width())
46  &&
47  max(a.get_y(), b.get_y()) <
48  min(a.get_y() + a.get_height(), b.get_y() + b.get_height())
49  );
50  }
51 
52 
53 }}// namespace stage::draw
bool rects_overlap(Gdk::Rectangle const &a, Gdk::Rectangle const &b)
determine whether two rectangles overlap
Definition: rectangle.cpp:41
Helper functions to work with rectangular screen ranges.
bool pt_in_rect(const Gdk::Point &point, const Gdk::Rectangle &rect)
determine whether point is within the bounding box of a rectangle
Definition: rectangle.cpp:32
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:37