-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUIUtil.cpp
More file actions
42 lines (32 loc) · 872 Bytes
/
Copy pathGUIUtil.cpp
File metadata and controls
42 lines (32 loc) · 872 Bytes
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
#include "GUIUtil.h"
#include "WidgetButton.h"
#include "Config.h"
unsigned TranslateMap(int x, int y) {
if (x < 0 || x > winWidth || y < 0 || y > winHeight)
return winWidth * winHeight;
return y * winWidth + x;
}
Point2i::Point2i(int x, int y) :
x(x), y(y) {
}
Point2i::Point2i() {
x = y = 0;
}
Point2i Point2i::operator+(Point2i other) {
return Point2i(x + other.x, y + other.y);
}
Point2i Point2i::operator-(Point2i other) {
return Point2i(x - other.x, y - other.y);
}
void initGUISys(int winWid, int winHei) {
winWidth = winWid;
winHeight = winHei;
}
int operator-(timespec p1, timespec p2){
return (p1.tv_sec - p2.tv_sec)*1000+(p1.tv_nsec - p2.tv_nsec)/1e6;
}