aboutsummaryrefslogtreecommitdiff
path: root/src/Types.cpp
blob: 76bf39824d7b48db3e6bd629b18f2fbee733e00c (plain)
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
#include "Types.hpp"

namespace cgeditor {

bool Element::IsOver(const double &X, const double &Y) const {
  if (width < 0) {
    return (x >= x && Y >= y && Y <= (y + height));
  }
  return ((X >= x && X <= (x + width) && Y >= y && Y <= (y + height)));
}

Property operator|(Property lhs, Property rhs) {
  return static_cast<Property>(
      static_cast<std::underlying_type_t<Property>>(lhs) |
      static_cast<std::underlying_type_t<Property>>(rhs));
}

bool operator&(Property lhs, Property rhs) {
  return (static_cast<std::underlying_type_t<Property>>(lhs) &
          static_cast<std::underlying_type_t<Property>>(rhs));
}

Property &operator|=(Property &lhs, Property rhs) {
  return lhs = static_cast<Property>(
             static_cast<std::underlying_type_t<Property>>(lhs) |
             static_cast<std::underlying_type_t<Property>>(rhs));
}

} // namespace cgeditor