summaryrefslogtreecommitdiffhomepage
path: root/public/frameworks/CoreFoundation.fwrk/src/Foundation.cc
blob: 4f4cc2c22ec9088905fd6fbd39b679342c89c5ae (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* -------------------------------------------

  Copyright (C) 2024 Amlal El Mahrouss, licensed under the Apache 2.0 license

------------------------------------------- */

#include <CoreFoundation.fwrk/headers/Foundation.h>

/***********************************************************************************/
/// @brief returns true if the proportions are valid.
/***********************************************************************************/
CF::CFRect::operator bool() {
  return width > 0 && height > 0;
}

/***********************************************************************************/
/// @brief returns true if size matches.
/***********************************************************************************/
BOOL CF::CFRect::SizeMatches(CF::CFRect& rect) noexcept {
  return rect.height == height && rect.width == width;
}

/***********************************************************************************/
/// @brief returns true if position matches.
/***********************************************************************************/
BOOL CF::CFRect::PositionMatches(CF::CFRect& rect) noexcept {
  return rect.y == y && rect.x == x;
}

/***********************************************************************************/
/// @brief Check if point is within the current MLPoint.
/// @param point the current point to check.
/// @retval true if point is within this point.
/// @retval the validations have failed, false otherwise true.
/***********************************************************************************/
BOOL CF::CFPoint::IsWithin(CF::CFPoint& withinOf) {
  return x_1 >= withinOf.x_1 && x_2 <= (withinOf.x_2) && y_1 >= withinOf.y_1 &&
         y_2 <= (withinOf.y_2);
}

/***********************************************************************************/
/// @brief if Point object is correctly set up.
/***********************************************************************************/
CF::CFPoint::operator bool() {
  return x_1 > x_2 && y_1 > y_2;
}