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
|
#include "monoscope.h"
#include <noatun/player.h>
#include <noatun/app.h>
#include <math.h>
#include <tqpainter.h>
#include <tdeactionclasses.h>
#include <noatun/stdaction.h>
#include <tdelocale.h>
extern "C"
{
TDE_EXPORT Plugin *create_plugin()
{
return new Monoscope();
}
}
Monoscope::Monoscope() : TQWidget(0,0,WRepaintNoErase), MonoScope(30), Plugin()
{
NOATUNPLUGINC(Monoscope);
mAction=0L;
mLowColor=tqRgb(0,0,0);
mHighColor=tqRgb(238,238,238);
resize(320, 240);
MonoScope::start();
setCaption(i18n("Monoscope"));
show();
resizeEvent(0);
repaint(0,0, TQWidget::width(), height(), false);
resizeEvent(0);
setBackgroundColor(mLowColor);
}
Monoscope::~Monoscope()
{
if(mAction)
napp->pluginActionMenu()->remove(mAction);
}
void Monoscope::init()
{
mAction = new TDEToggleAction(i18n("Toggle Monoscope"), 0, 0,
this, TQ_SLOT(toggle()), this, "togglemonoscope");
mAction->setChecked(!isHidden());
napp->pluginActionMenu()->insert(mAction);
}
void Monoscope::toggle(void)
{
if(isHidden())
show();
else
hide();
}
void Monoscope::closeEvent(TQCloseEvent *)
{
hide();
}
void Monoscope::resizeEvent(TQResizeEvent *)
{
setSamples(width());
}
void Monoscope::scopeEvent(float *d, int size)
{
// save cpu
if(isHidden()) return;
const bool line=false;
int viewWidth =width();
int viewHeight=height();
float *end=d+size;
int x=0;
int heightHalf=viewHeight/4;
int y=viewHeight/2;
// reduce flicker
TQPixmap buffer(viewWidth, viewHeight, -1, TQPixmap::BestOptim);
buffer.fill(mLowColor);
TQPainter p(&buffer);
p.setPen(mHighColor);
repaint(rect());
if (line)
p.moveTo(0, y);
while (d<=end)
{
float &n=*d;
n *= heightHalf;
int amp=(int)n;
if (line) // line
p.lineTo(x, y+amp);
else // fill
p.drawLine(x, y, x, y+amp);
d++;
x++;
}
if (line)
p.drawLine(0, y, size, y);
bitBlt(this, 0, 0, &buffer, 0, 0, viewWidth, viewHeight, TQt::CopyROP);
}
#include "monoscope.moc"
|