all repos — openbox @ 83b39a9a3e366d9bc4baadb7c988b874cfe25a08

openbox fork - make it a bit more like ryudo

src/Geometry.cc (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// Geometry.cc for Openbox
// Copyright (c) 2002 - 2002 ben Jansens (ben@orodu.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

#include "Geometry.h"

Point::Point() : m_x(0), m_y(0) {
}

Point::Point(const Point &point) : m_x(point.m_x), m_y(point.m_y) {
}

Point::Point(const int x, const int y) : m_x(x), m_y(y) {
}

void Point::setX(const int x) {
  m_x = x;
}

void Point::setY(const int y) {
  m_y = y;
}

Size::Size() : m_w(0), m_h(0) {
}

Size::Size(const Size &size) : m_w(size.m_w), m_h(size.m_h) {
}

Size::Size(const unsigned int w, const unsigned int h) : m_w(w), m_h(h) {
}

void Size::setW(const unsigned int w) {
  m_w = w;
}

void Size::setH(const unsigned int h) {
  m_h = h;
}

Rect::Rect() : m_origin(0, 0), m_size(0, 0) {
}

Rect::Rect(const Point &origin, const Size &size) : m_origin(origin),
  m_size(size) {
}

Rect::Rect(const int x, const int y, const unsigned int w, const unsigned int h)
  : m_origin(x, y), m_size(w, h) {
}

void Rect::setSize(const Size &size) {
  m_size = size;
}

void Rect::setSize(const unsigned int w, const unsigned int h) {
  m_size.setW(w);
  m_size.setH(h);
}

void Rect::setOrigin(const Point &origin) {
  m_origin = origin;
}

void Rect::setOrigin(const int x, const int y) {
  m_origin.setX(x);
  m_origin.setY(y);
}

void Rect::setX(const int x) {
  m_origin.setX(x);
}

void Rect::setY(const int y) {
  m_origin.setY(y);
}

void Rect::setW(unsigned int w) {
  m_size.setW(w);
}

void Rect::setH(unsigned int h) {
  m_size.setH(h);
}

bool Rect::Intersect(const Rect &r) const {
  return
    (x() < (r.x()+r.w()) ) &&
    ( (x()+w()) > r.x()) &&
    (y() < (r.y()+r.h()) ) &&
    ( (y()+h()) > r.y());
}

Rect Rect::Inflate(const unsigned int i) const {
  return Rect(x(), y(), w()+i, h()+i);
}

Rect Rect::Inflate(const unsigned int iw, const unsigned int ih) const {
  return Rect(x(), y(), w()+iw, h()+ih);
}

Rect Rect::Inflate(const Size &i) const {
  return Rect(x(), y(), w()+i.w(), h()+i.h());
}

Rect Rect::Deflate(const unsigned int d) const {
  return Rect(x(), y(), w()-d, h()-d);
}

Rect Rect::Deflate(const unsigned int dw, const unsigned int dh) const {
  return Rect(x(), y(), w()-dw, h()-dh);
}

Rect Rect::Deflate(const Size &d) const {
  return Rect(x(), y(), w()-d.w(), h()-d.h());
}

Rect Rect::Translate(const int t) const {
  return Rect(x()+t, y()+t, w(), h());
}

Rect Rect::Translate(const int tx, const int ty) const {
  return Rect(x()+tx, y()+ty, w(), h());
}

Rect Rect::Translate(const Point &t) const {
  return Rect(x()+t.x(), y()+t.y(), w(), h());
}