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
|
#include "setup.h"
#include "widgets.h"
#include <vdr/config.h>
#include <vdr/tools.h>
#include "compat.h"
cScroller::cScroller()
{
Reset();
}
void cScroller::Reset()
{
x = 0;
y = 0;
xmax = 0;
font = NULL;
text = "";
active = false;
update = false;
position = 0;
increment = 0;
lastUpdate = 0;
}
bool cScroller::NeedsUpdate()
{
if (active &&
TimeMs() - lastUpdate > (uint64_t) GraphLCDSetup.ScrollTime)
{
update = true;
return true;
}
return false;
}
void cScroller::Init(int X, int Y, int Xmax, const GLCD::cFont * Font, const std::string & Text)
{
x = X;
y = Y;
xmax = Xmax;
font = Font;
text = Text;
increment = GraphLCDSetup.ScrollSpeed;
position = 0;
if (GraphLCDSetup.ScrollMode != 0 &&
font->Width(text) > xmax - x + 1)
active = true;
else
active = false;
update = false;
lastUpdate = TimeMs() + 2000;
}
void cScroller::Draw(GLCD::cBitmap * bitmap)
{
if (!active)
{
bitmap->DrawText(x, y, xmax, text, font);
}
else
{
if (update)
{
if (increment > 0)
{
if (font->Width(text) - position + font->TotalWidth() * 5 < increment)
{
increment = 0;
position = 0;
}
}
else
{
if (GraphLCDSetup.ScrollMode == 2)
{
increment = GraphLCDSetup.ScrollSpeed;
}
else
{
active = false;
}
}
position += increment;
lastUpdate = TimeMs();
update = false;
}
bitmap->DrawText(x, y, xmax, text, font, GLCD::clrBlack, true, position);
if (font->Width(text) - position <= xmax - x + 10 + font->TotalWidth() * 5)
bitmap->DrawText(x + font->Width(text) - position + font->TotalWidth() * 5, y, xmax, text, font);
}
}
|