Conquer Chess
Chess and Starcraft combined
Loading...
Searching...
No Matches
screen_rect.h
Go to the documentation of this file.
1#ifndef SCREEN_RECT_H
2#define SCREEN_RECT_H
3
4#include "screen_coordinate.h"
5#include "side.h"
6
7#include <iosfwd>
8
15{
16public:
17 explicit screen_rect(
18 const screen_coordinate& top_left = screen_coordinate(0, 0),
19 const screen_coordinate& bottom_right = screen_coordinate(20, 20)
20 );
21
22 const auto& get_tl() const noexcept { return m_top_left; }
23 const auto& get_br() const noexcept { return m_bottom_right; }
24
25private:
26 screen_coordinate m_top_left;
27 screen_coordinate m_bottom_right;
28};
29
30
35screen_rect create_centered_rect(const screen_coordinate c, const int w, const int h) noexcept;
36
57
78
85screen_rect create_partial_rect_from_side(const side s, const screen_rect& r, const double f);
86
89
91
94
97
102
103int get_height(const screen_rect& r) noexcept;
104
106screen_rect get_lhs_half(const screen_rect& r) noexcept;
107
110screen_rect get_lower_eighth(const screen_rect& r) noexcept;
111
113screen_rect get_lower_fourth(const screen_rect& r) noexcept;
114
116screen_rect get_lower_half(const screen_rect& r) noexcept;
117
119screen_rect get_rhs_half(const screen_rect& r) noexcept;
120
123
126
128screen_rect get_upper_half(const screen_rect& r) noexcept;
129
130int get_width(const screen_rect& r) noexcept;
131
133bool is_in(const screen_coordinate& pos, const screen_rect& r) noexcept;
134
136void test_screen_rect();
137
138bool operator==(const screen_rect& lhs, const screen_rect& rhs) noexcept;
139bool operator!=(const screen_rect& lhs, const screen_rect& rhs) noexcept;
140
141std::ostream& operator<<(std::ostream& os, const screen_rect& r) noexcept;
142
143#endif // SCREEN_RECT_H
The coordinate on a screen.
Definition screen_coordinate.h:12
A rectangle-shaped area on the screen.
Definition screen_rect.h:15
const auto & get_tl() const noexcept
Definition screen_rect.h:22
const auto & get_br() const noexcept
Definition screen_rect.h:23
screen_rect get_lhs_half(const screen_rect &r) noexcept
Get the left-hand side half (i.e. 50% of the rect)
Definition screen_rect.cpp:152
screen_rect get_lower_fourth(const screen_rect &r) noexcept
Get the lower fourth (i.e. 25% of the rect, half of the lower half)
Definition screen_rect.cpp:171
screen_rect create_centered_rect(const screen_coordinate c, const int w, const int h) noexcept
Create a rectangle that is centered around a point, with a custom height and width.
Definition screen_rect.cpp:117
screen_rect create_rect_inside(const screen_rect &r) noexcept
Create a rectangle that is exactly one pixel inside the given one.
Definition screen_rect.cpp:81
screen_rect create_partial_rect_from_side(const side s, const screen_rect &r, const double f)
Create a partial rectangle from a certain side.
Definition screen_rect.cpp:71
screen_rect get_bottom_left_corner(const screen_rect &r) noexcept
Get the bottom-left corner (i.e. 25% of the rect)
Definition screen_rect.cpp:88
screen_rect get_rhs_half(const screen_rect &r) noexcept
Get the right-hand side half (i.e. 50% of the rect)
Definition screen_rect.cpp:190
screen_rect get_upper_half(const screen_rect &r) noexcept
Get the upper half (i.e. 50% of the rect)
Definition screen_rect.cpp:231
screen_rect get_bottom_right_corner(const screen_rect &r) noexcept
Get the bottom-right corner (i.e. 25% of the rect)
Definition screen_rect.cpp:102
screen_rect create_partial_rect_from_rhs(const screen_rect &r, const double f)
Create a partial rectangle, from the right hand side.
Definition screen_rect.cpp:45
screen_rect get_lower_half(const screen_rect &r) noexcept
Get the lower half (i.e. 50% of the rect)
Definition screen_rect.cpp:176
screen_rect get_lower_eighth(const screen_rect &r) noexcept
Get the lower eighth (i.e.
Definition screen_rect.cpp:166
screen_coordinate get_center(const screen_rect &r) noexcept
Definition screen_rect.cpp:132
screen_rect get_top_right_corner(const screen_rect &r) noexcept
Get the top-right corner (i.e. 25% of the rect)
Definition screen_rect.cpp:217
void test_screen_rect()
Test this class and its free functions.
Definition screen_rect.cpp:259
screen_rect create_partial_rect_from_lhs(const screen_rect &r, const double f)
Create a partial rectangle, from the left hand side.
Definition screen_rect.cpp:28
int get_height(const screen_rect &r) noexcept
Definition screen_rect.cpp:147
screen_rect get_top_left_corner(const screen_rect &r) noexcept
Get the top-left corner (i.e. 25% of the rect)
Definition screen_rect.cpp:203
int get_width(const screen_rect &r) noexcept
Definition screen_rect.cpp:245
screen_rect get_default_screen_rect() noexcept
Get the default screen rectangle.
Definition screen_rect.cpp:140
bool is_in(const screen_coordinate &pos, const screen_rect &r) noexcept
Is the coordinat in the rectangle?
Definition screen_rect.cpp:250
side
The side the player/piece is on.
Definition side.h:11