diff options
author | andreas 'randy' weinberger <vdr@smue.org> | 2010-02-21 19:56:01 +0100 |
---|---|---|
committer | andreas 'randy' weinberger <vdr@smue.org> | 2010-02-21 19:56:01 +0100 |
commit | e73252dc58ecd5a27c6d8af94028f311f23687ab (patch) | |
tree | a66d0564de1a0e267ee681e5d731b1864e7a3d12 /widgets.c | |
download | vdr-plugin-graphlcd-e73252dc58ecd5a27c6d8af94028f311f23687ab.tar.gz vdr-plugin-graphlcd-e73252dc58ecd5a27c6d8af94028f311f23687ab.tar.bz2 |
initial git upload, based on graphlcd-0.1.5
Diffstat (limited to 'widgets.c')
-rw-r--r-- | widgets.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/widgets.c b/widgets.c new file mode 100644 index 0000000..68193d5 --- /dev/null +++ b/widgets.c @@ -0,0 +1,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); + } +} |