-
Notifications
You must be signed in to change notification settings - Fork 1
/
about_view_layout.cpp
65 lines (59 loc) · 1.35 KB
/
about_view_layout.cpp
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
#include "about_view_layout.h"
#include <cassert>
#include <cmath>
about_view_layout::about_view_layout(
const screen_coordinat& window_size,
const int margin_width
) : m_font_size{64},
m_window_size{window_size}
{
const int panel_height{
static_cast<int>(
static_cast<double>(window_size.get_y() - (4 * margin_width)) / 7.0
)
};
const int panel_width{window_size.get_x() - (2 * margin_width)};
const int x1{margin_width};
const int x2{x1 + panel_width};
const int y1{margin_width};
const int y2{y1 + (2 * panel_height)};
const int y3{y2 + margin_width};
const int y4{y3 + (1 * panel_height)};
const int y5{y4 + margin_width};
const int y6{y5 + (4 * panel_height)};
m_title = screen_rect(
screen_coordinat(x1, y1),
screen_coordinat(x2, y2)
);
m_subtitle = screen_rect(
screen_coordinat(x1, y3),
screen_coordinat(x2, y4)
);
m_text = screen_rect(
screen_coordinat(x1, y5),
screen_coordinat(x2, y6)
);
m_font_size = std::min(
panel_height / 4,
panel_width / 9
);
}
std::vector<screen_rect> get_panels(const about_view_layout& layout)
{
return
{
layout.get_title(),
layout.get_subtitle(),
layout.get_text()
};
}
void test_about_view_layout()
{
#ifndef NDEBUG
// get_panels
{
const about_view_layout layout;
assert(!get_panels(layout).empty());
}
#endif
}