This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
/
thickness.h
89 lines (75 loc) · 1.74 KB
/
thickness.h
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
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* thickness.h:
*
* Copyright 2007 Novell, Inc. (http://www.novell.com)
*
* See the LICENSE file included with the distribution for details.
*
*/
#ifndef __MOON_THICKNESS_H__
#define __MOON_THICKNESS_H__
#include <glib.h>
#include "enums.h"
namespace Moonlight {
/* @IncludeInKinds */
struct Thickness {
double left;
double top;
double right;
double bottom;
Thickness ()
: left (0), top (0),
right (0), bottom (0)
{
}
Thickness (double uniform)
{
bottom = uniform;
right = uniform;
left = uniform;
top = uniform;
}
Thickness (double hori, double vert)
{
bottom = vert;
right = hori;
left = hori;
top = vert;
}
Thickness (double left, double top, double right, double bottom)
{
this->bottom = bottom;
this->right = right;
this->left = left;
this->top = top;
}
Thickness operator- ()
{
return Thickness (-left, -top, -right, -bottom);
}
Thickness operator+ (const Thickness &th)
{
return Thickness (left + th.left, top + th.top, right + th.right, bottom + th.bottom);
}
Thickness operator- (const Thickness &th)
{
return Thickness (left - th.left, top - th.top, right - th.right, bottom - th.bottom);
}
bool operator == (const Thickness &v) const
{
return fabs (bottom - v.bottom) < DBL_EPSILON && fabs(right - v.right) < DBL_EPSILON && fabs (left - v.left) < DBL_EPSILON && fabs (top - v.top) < DBL_EPSILON;
}
bool operator != (const Thickness &v) const
{
return !(*this == v);
}
//
// FromStr
// Parses @s and return a new Thickness in @t. Returns
// true if this was successful, false otherwise.
//
static bool FromStr (const char *s, Thickness *t);
};
};
#endif /* __MOON_THICKNESS_H__ */