-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
103 lines (82 loc) · 2.64 KB
/
main.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
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
#include <SFML/Graphics.hpp>
#include <iostream>
#include <time.h>
#include <set>
#include <map>
#include "add_functions.h"
#include "common_classes/Vect2.h"
#include "common_classes/Vect3.h"
#include "common_classes/Line2.h"
#include "common_classes/Complex.h"
#include "special_classes/Complex_expression.h"
#include "Interface_classes/Interface_feature.h"
#include "Interface_classes/Button.h"
#include "Interface_classes/Text_input.h"
#include "Interface_classes/Coordinate_system.h"
#include "Interface_classes/Complex_graphic.h"
const int Cw = 1240, Ch = 670, FPS = 30, max_cnt = 2;
Color background(0, 0, 0);
Font arial;
int main() {
setlocale(LC_ALL, "RU");
RenderWindow window(VideoMode(Cw, Ch), "Complex graphics");
window.setFramerateLimit(FPS);
arial.loadFromFile("fonts/arial.ttf");
Text_input text(Vector2f(20, 20), Vector2f(400, 40), arial);
Complex_graphic graphic(Vector2f(20, 70), Vector2f(1200, 580), &text, arial);
int cnt = 0;
while (window.isOpen()) {
Event event;
while (window.pollEvent(event))
switch (event.type) {
case Event::Closed: {
window.close();
break;
}
case Event::MouseMoved: {
cnt++;
if (cnt == max_cnt) {
graphic.check_move(event.mouseMove.x, event.mouseMove.y);
cnt = 0;
}
break;
}
case Event::MouseButtonPressed: {
graphic.check_target(event.mouseButton.x, event.mouseButton.y, true, event.mouseButton.button);
break;
}
case Event::MouseButtonReleased: {
text.check_target(event.mouseButton.x, event.mouseButton.y);
graphic.check_target(event.mouseButton.x, event.mouseButton.y, false, event.mouseButton.button);
break;
}
case Event::MouseWheelScrolled: {
if (event.mouseWheelScroll.wheel == Mouse::VerticalWheel) {
graphic.check_scrol(event.mouseWheelScroll.x, event.mouseWheelScroll.y, event.mouseWheelScroll.delta);
}
break;
}
case Event::TextEntered: {
text.check_input(event.text.unicode, 't');
graphic.check_input(event.text.unicode, 't');
//cout << event.text.unicode << "\t" << char(event.text.unicode) << "\t";
break;
}
case::Event::KeyPressed: {
text.check_input(event.key.code, 's', event.key.shift, event.key.control);
graphic.check_input(event.key.code, 's', event.key.shift, event.key.control);
//cout << event.key.code << "\n";
break;
}
default:
break;
}
window.clear(background);
window.draw(graphic);
window.draw(text);
window.display();
text.check_counter();
graphic.check_counter();
}
return 0;
}