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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
/*******************************************************************************
This file is part of LayoutStudio (http://github.com/Treeki/LayoutStudio)
Copyright (c) 2010 Treeki (treeki@gmail.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 2.0.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License 2.0 for more details.
You should have received a copy of the GNU General Public License 2.0
along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "pane.h"
#include "layout.h"
LYTPane::LYTPane(LYTLayout &layout) : m_layout(layout) {
this->parent = 0;
m_type = PaneType;
}
LYTPane::~LYTPane() {
foreach (LYTPane *ptr, this->children)
delete ptr;
}
LYTPane *LYTPane::findPaneByName(QString name, bool recursive) const {
foreach (LYTPane *pane, this->children) {
if (pane->name == name)
return pane;
if (recursive) {
LYTPane *tryThis = pane->findPaneByName(name, recursive);
if (tryThis != 0)
return tryThis;
}
}
return 0;
}
LYTLayout &LYTPane::layout() const {
return m_layout;
}
Magic LYTPane::magic() const {
return Magic('pan1');
}
void LYTPane::dumpToDebug(bool showHeading) const {
if (showHeading)
qDebug() << "LYTPane" << name << "@" << (void*)this;
qDebug() << "- Translation:" << xTrans << "," << yTrans << "," << zTrans;
qDebug() << "- Rotation:" << xRot << "," << yRot << "," << zRot;
qDebug() << "- Scale:" << xScale << "," << yScale;
qDebug() << "- Size:" << width << "x" << height;
qDebug() << "- Flags:" << flags << "- Origin:" << horzOrigin << "," << vertOrigin;
qDebug() << "- Alpha:" << alpha << "- Userdata:" << userdata;
}
void LYTPane::writeToDataStream(QDataStream &out) const {
out << (quint8)flags;
out << (quint8)((int)horzOrigin + ((int)vertOrigin * 3));
out << (quint8)alpha;
WritePadding(1, out);
WriteFixedLengthASCII(out, name, 0x10);
WriteFixedLengthASCII(out, userdata, 8);
out << (float)xTrans;
out << (float)yTrans;
out << (float)zTrans;
out << (float)xRot;
out << (float)yRot;
out << (float)zRot;
out << (float)xScale;
out << (float)yScale;
out << (float)width;
out << (float)height;
}
void LYTPane::readFromDataStream(QDataStream &in) {
in >> (quint8&)flags;
quint8 rawOrigin;
in >> rawOrigin;
horzOrigin = (OriginType)(rawOrigin % 3);
vertOrigin = (OriginType)(rawOrigin / 3);
in >> (quint8&)alpha;
in.skipRawData(1); // padding
name = ReadFixedLengthASCII(in, 0x10);
userdata = ReadFixedLengthASCII(in, 8);
in >> (float&)xTrans;
in >> (float&)yTrans;
in >> (float&)zTrans;
in >> (float&)xRot;
in >> (float&)yRot;
in >> (float&)zRot;
in >> (float&)xScale;
in >> (float&)yScale;
in >> (float&)width;
in >> (float&)height;
}
void LYTPane::addFontRefsToList(QStringList &list) const {
//qDebug() << "Getting font refs for" << this->name;
foreach (LYTPane *p, this->children) {
p->addFontRefsToList(list);
}
}
float LYTPane::drawnVertexX() const {
switch (horzOrigin) {
case Center:
return -width / 2.0f;
case Right:
return -width;
default:
return 0.0f;
}
}
float LYTPane::drawnVertexY() const {
switch (vertOrigin) {
case Center:
return height / 2.0f;
case Bottom:
return height;
default:
return 0.0f;
}
}
|