summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helpers.c47
-rw-r--r--helpers.h1
-rw-r--r--volumebox.c63
-rw-r--r--volumebox.h3
4 files changed, 69 insertions, 45 deletions
diff --git a/helpers.c b/helpers.c
index 262789d..2815c5b 100644
--- a/helpers.c
+++ b/helpers.c
@@ -1,6 +1,7 @@
#include <string>
#include <sstream>
#include <vector>
+#include "config.h"
#include "helpers.h"
#include <vdr/skins.h>
@@ -66,6 +67,52 @@ void DrawRoundedCornersWithBorder(cPixmap *p, tColor borderColor, int radius, in
p->DrawEllipse(cRect(width-radius+1,height-radius+1,radius,radius), clrTransparent, -4);
}
+void DrawProgressbar(cPixmap *p, int left, int top, int width, int height, int Current, int Total, tColor clr1, tColor clr2, bool blend) {
+ if (Current == 0) {
+ p->DrawEllipse(cRect(left, top, height, height), blend ? clr2 : clr1);
+ return;
+ } else
+ p->DrawEllipse(cRect(left, top, height, height), clr2);
+
+ width = width - height; // width of gradient (width - ellipse)
+ double percent = ((double)Current) / (double)Total;
+ double progresswidth = width * percent;
+
+ tColor clr = blend ? clr2 : clr1;
+ int alpha = 0x0; // 0...255
+ int alphaStep = 0x1;
+ int maximumsteps = 256; // alphaStep * maximumsteps <= 256
+ int factor = 2; // max. 128 steps
+
+ bool partial = false;
+ double step = 0;
+ if (partial) {
+ step = (double)width / maximumsteps; // shows a progresswidth part of color gradient
+ maximumsteps = (double)maximumsteps * percent;
+ } else
+ step = progresswidth / maximumsteps; // shows a progresswidth full color gradient
+
+ if (!partial && progresswidth < 128) { // width < 128
+ factor = 4 * factor; // 32 steps
+ } else if (progresswidth < 256) { // width < 256
+ factor = 2 * factor; // 64 steps
+ }
+
+ step = step * factor;
+ alphaStep = alphaStep * factor;
+ maximumsteps = maximumsteps / factor;
+
+ int x = left + height / 2;
+ for (int i = 0; i < maximumsteps; i++) {
+ x = left + height / 2 + i * step;
+ clr = AlphaBlend(clr1, clr2, alpha);
+ p->DrawRectangle(cRect(x, top, step + 1, height), clr);
+ alpha += alphaStep;
+ }
+ x = x + step - height / 2;
+ p->DrawEllipse(cRect(x, top, height, height), clr);
+}
+
cSize ScaleToFit(int widthMax, int heightMax, int widthOriginal, int heightOriginal) {
int width = 1;
int height = 1;
diff --git a/helpers.h b/helpers.h
index 63158b4..b5f4cdd 100644
--- a/helpers.h
+++ b/helpers.h
@@ -8,6 +8,7 @@ cOsd *CreateOsd(int Left, int Top, int Width, int Height);
void DrawBlendedBackground(cPixmap *pixmap, int xStart, int width, tColor color, tColor colorBlending, bool fromTop);
void DrawRoundedCorners(cPixmap *p, int radius, int x, int y, int width, int height);
void DrawRoundedCornersWithBorder(cPixmap *p, tColor borderColor, int radius, int width, int height);
+void DrawProgressbar(cPixmap *p, int left, int top, int width, int height, int Current, int Total, tColor color, tColor colorBlending, bool blend = false);
cSize ScaleToFit(int widthMax, int heightMax, int widthOriginal, int heightOriginal);
int Minimum(int a, int b, int c, int d, int e, int f);
std::string CutText(std::string text, int width, const cFont *font);
diff --git a/volumebox.c b/volumebox.c
index edd2302..4d7775c 100644
--- a/volumebox.c
+++ b/volumebox.c
@@ -60,58 +60,35 @@ void cNopacityVolumeBox::SetVolume(int Current, int Total, bool Mute) {
cBitmap bmMute(mute_xpm);
pixmapLabelVolume->DrawBitmap(cPoint(geoManager->volumeWidth - 2 * bmMute.Width(), (geoManager->volumeLabelHeight - bmMute.Height()) / 2), bmMute, Theme.Color(clrDiskAlert), clrTransparent);
}
- DrawProgressBar(Current, Total);
+ DrawProgressBarBackground(Current, Total);
}
-void cNopacityVolumeBox::DrawProgressBar(int Current, int Total) {
+void cNopacityVolumeBox::DrawProgressBarBackground(int Current, int Total) {
pixmapProgressBarVolume->Fill(clrTransparent);
if (geoManager->volumeProgressBarHeight < 5)
return;
- double percent = ((double)Current) / (double)Total;
- int barWidth = geoManager->volumeProgressBarWidth - geoManager->volumeProgressBarHeight;
- if ((Current > 0) || (Total > 0)) {
- pixmapProgressBarVolume->DrawEllipse(cRect(0, 0, geoManager->volumeProgressBarHeight, geoManager->volumeProgressBarHeight), Theme.Color(clrProgressBarBack));
- pixmapProgressBarVolume->DrawEllipse(cRect(geoManager->volumeProgressBarWidth - geoManager->volumeProgressBarHeight, 0, geoManager->volumeProgressBarHeight, geoManager->volumeProgressBarHeight), Theme.Color(clrProgressBarBack));
- pixmapProgressBarVolume->DrawRectangle(cRect(geoManager->volumeProgressBarHeight / 2, 0, geoManager->volumeProgressBarWidth - geoManager->volumeProgressBarHeight, geoManager->volumeProgressBarHeight), Theme.Color(clrProgressBarBack));
-
- pixmapProgressBarVolume->DrawEllipse(cRect(1, 1, geoManager->volumeProgressBarHeight - 2, geoManager->volumeProgressBarHeight - 2), Theme.Color(clrProgressBarBlend));
- if (Current > 0) {
- tColor colAct = DrawProgressbarBackground(geoManager->volumeProgressBarHeight / 2 - 1, 1, barWidth * percent - 2, geoManager->volumeProgressBarHeight - 2);
- pixmapProgressBarVolume->DrawEllipse(cRect(barWidth * percent, 1, geoManager->volumeProgressBarHeight - 2, geoManager->volumeProgressBarHeight - 2), colAct);
- }
- }
-}
-tColor cNopacityVolumeBox::DrawProgressbarBackground(int left, int top, int width, int height) {
-
- tColor clr1 = Theme.Color(clrProgressBar);
- tColor clr2 = Theme.Color(clrProgressBarBlend);
- tColor clr = 0x00000000;
-
- int alpha = 0x0; // 0...255
- int alphaStep = 0x1;
- int maximumsteps = 256; // alphaStep * maximumsteps <= 256
- int factor = 2; // max. 128 steps
-
- double step = width / maximumsteps;
- if (width < 128) { // width < 128
- factor = 4 * factor; // 32 steps
- } else if (width < 256) { // width < 256
- factor = 2 * factor; // 64 steps
- }
+ if ((Current > 0) || (Total > 0)) {
+ pixmapProgressBarVolume->DrawEllipse(cRect(0,
+ 0,
+ geoManager->volumeProgressBarHeight,
+ geoManager->volumeProgressBarHeight),
+ Theme.Color(clrProgressBarBack));
+ pixmapProgressBarVolume->DrawEllipse(cRect(geoManager->volumeProgressBarWidth - geoManager->volumeProgressBarHeight,
+ 0,
+ geoManager->volumeProgressBarHeight,
+ geoManager->volumeProgressBarHeight),
+ Theme.Color(clrProgressBarBack));
+ pixmapProgressBarVolume->DrawRectangle(cRect(geoManager->volumeProgressBarHeight / 2,
+ 0,
+ geoManager->volumeProgressBarWidth - geoManager->volumeProgressBarHeight,
+ geoManager->volumeProgressBarHeight),
+ Theme.Color(clrProgressBarBack));
- step = step * factor;
- alphaStep = alphaStep * factor;
- maximumsteps = maximumsteps / factor;
- int x = left + height / 2;
- for (int i = 0; i < maximumsteps; i++) {
- x = left + height / 2 + i * step;
- clr = AlphaBlend(clr1, clr2, alpha);
- pixmapProgressBarVolume->DrawRectangle(cRect(x, top, step + 1, height), clr);
- alpha += alphaStep;
+ int barWidth = geoManager->volumeProgressBarWidth - geoManager->volumeProgressBarHeight;
+ DrawProgressbar(pixmapProgressBarVolume, 1, 1, barWidth, geoManager->volumeProgressBarHeight - 2, Current, Total, Theme.Color(clrProgressBar), Theme.Color(clrProgressBarBlend), true);
}
- return clr;
}
void cNopacityVolumeBox::SetAlpha(int Alpha) {
diff --git a/volumebox.h b/volumebox.h
index 5284e1a..e2618bf 100644
--- a/volumebox.h
+++ b/volumebox.h
@@ -10,8 +10,7 @@ private:
cPixmap *pixmapBackgroundVolume;
cPixmap *pixmapProgressBarVolume;
cPixmap *pixmapLabelVolume;
- void DrawProgressBar(int Current, int Total);
- tColor DrawProgressbarBackground(int left, int top, int width, int height);
+ void DrawProgressBarBackground(int Current, int Total);
public:
cNopacityVolumeBox(cOsd *Osd, const cRect &Rect);
~cNopacityVolumeBox(void);