My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes    
 
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#include "ControlPanel.h"

NAMESPACE_UPP

ValueSlider::ValueSlider()
{
pos = 0;
shaded = true;
immediate = false;
src = Color(255, 255, 0);
dst = Color(255, 153, 51);
}

void ValueSlider::Paint(Draw &w)
{
Size sz = GetSize();

/*w.DrawRect(0, 0, sz.cx, 1, Black);
w.DrawRect(0, sz.cy - 1, sz.cx, 1, Black);
w.DrawRect(0, 0, 1, sz.cy, Black);
w.DrawRect(sz.cx - 1, 0, 1, sz.cy, Black);*/

int t = (int) (((pos - minValue) * sz.cx) / (maxValue - minValue));
if(t < 1) t = 1;
if(t > sz.cx - 1) t = sz.cx - 1;

if(shaded)
{
for(int i = 1; i < t; i++)
w.DrawRect(i, 1, 1, sz.cy - 2, Blend(src, dst, 256 * i / (sz.cx - 1)));
}
else
{
w.DrawRect(Rect(1, 1, t, sz.cy - 1), dst);
}

if(t < sz.cx - 1)
w.DrawRect(Rect(t, 1, sz.cx - 1, sz.cy - 1), Color(245, 245, 255));

String s = Format("%s : %.2f", text, pos);
Size tsz = GetTextSize(s, StdFont());
w.DrawText((sz.cx - tsz.cx) / 2, (sz.cy - tsz.cy) / 2, s);
}

void ValueSlider::LeftDown(Point p, dword keyflags)
{
pos = minValue + (p.x * (maxValue - minValue)) / (float) GetSize().cx;
Refresh();
SetCapture();
if(immediate)
WhenAction();
}

void ValueSlider::LeftUp(Point p, dword keyflags)
{
ReleaseCapture();
if(!immediate)
WhenAction();
}

void ValueSlider::MouseMove(Point p, dword keyflags)
{
if(HasCapture())
{
pos = minValue + (p.x * (maxValue - minValue)) / (float) GetSize().cx;
if(pos > maxValue) pos = maxValue;
if(pos < minValue) pos = minValue;
Refresh();
if(immediate)
WhenAction();
}
}

void ValueSlider::SetPos(float p, float minv, float maxv)
{
pos = p;
minValue = minv;
maxValue = maxv;
Refresh();
}

float ValueSlider::GetPos()
{
return pos;
}

void SlimButton::Paint(Draw &w)
{
SystemDraw& sw = (SystemDraw&) w;
float a = sw.alpha;
sw.alpha = alpha;
Size sz = GetSize();
if(HasMouseIn(sz))
w.DrawRect(sz, bg);
sw.alpha = a;

Size tsz = GetTextSize(label, StdFont());
w.DrawText((sz.cx - tsz.cx) / 2, (sz.cy - tsz.cy) / 2, label, StdFont(), fg);
}

void SlimButton::LeftDown(Point p, dword keyflags)
{
SetCapture();
}

void SlimButton::LeftUp(Point p, dword keyflags)
{
ReleaseCapture();
Action();
}

void SlimButton::MouseMove(Point p, dword keyflags)
{
}

void SlimButton::SetLabel(const char* s)
{
label = s;
}

SlimButton::SlimButton()
{
fg = White;
bg = Black;
alpha = 255.f;
}

InfoPanel::InfoPanel() : init(true), parent(NULL)
{
Add(alphaSlider.RightPos(199, 100).VSizePos(1, 0));
Add(angleSlider.RightPos(100, 100).VSizePos(1, 0));
Add(scaleSlider.RightPos(1, 100).VSizePos(1, 0));

alphaSlider.text = "Alpha";
angleSlider.text = "Angle";
scaleSlider.text = "Scale";

alphaSlider.shaded = true;
angleSlider.shaded = true;
scaleSlider.shaded = true;
alphaSlider.immediate = true;
angleSlider.immediate = true;
scaleSlider.immediate = true;

alphaSlider.SetPos(255.f, 0.f, 255.f);
angleSlider.SetPos(0.f, 0.f, 360.f);
scaleSlider.SetPos(1.f, 1.f, 5.f);
}

void InfoPanel::Paint(Draw& w)
{
Size sz = GetSize();
Size wsz = screenRect.GetSize();
Color frameColor = Color(183, 183, 183);
Color bgColor = Color(102, 102, 102);
w.DrawRect(sz, bgColor);
w.DrawRect(0, 0, 1, sz.cy, frameColor);
w.DrawRect(0, 0, sz.cx, 1, frameColor);
w.DrawRect(sz.cx - 1, 0, 1, sz.cy, frameColor);
String info = Format("FPS: %.2f, Textures: %d (%d), Size: %d, %d", GetFps(), resources.textures.GetCount(), resources.bindedTextures, wsz.cx, wsz.cy);
w.DrawText(5, sz.cy - 18, info, StdFont(), White);
}

void InfoPanel::Init(Ctrl& parent, float angle, float scale, float alpha)
{
const int width = 585;
SetRect((screenRect.Width() - width) / 2, screenRect.Height() - 22, width, 22);
if(!init)
return;
init = false;
this->parent = &parent;
Show();
alphaSlider.SetPos(alpha, 0.f, 255.f);
angleSlider.SetPos(angle, 0.f, 360.f);
scaleSlider.SetPos(scale, 1.f, 5.f);
}

void InfoPanel::Show(bool b)
{
if(IsOpen())
{
if(!b)
Close();
}
else
{
if(b)
PopUp(parent, true, false);
}
}

float InfoPanel::GetAlpha()
{
return alphaSlider.GetPos();
}

float InfoPanel::GetAngle()
{
return angleSlider.GetPos();
}

float InfoPanel::GetScale()
{
return scaleSlider.GetPos();
}

END_UPP_NAMESPACE

Change log

r4188 by unodgs on Nov 22, 2011   Diff
WinGL: Added automatic atlas textures,
fixed some bugs
Go to: 
Project members, sign in to write a code review

Older revisions

r3915 by unodgs on Sep 26, 2011   Diff
Rainbow: WinGL..
r3683 by unodgs on Jul 20, 2011   Diff
Rainbow: WinGL..
r3677 by unodgs on Jul 19, 2011   Diff
Rainbow: WinGL..
All revisions of this file

File info

Size: 4165 bytes, 207 lines

File properties

svn:eol-style
native
Powered by Google Project Hosting