diff options
Diffstat (limited to 'volumebox.c')
-rw-r--r-- | volumebox.c | 122 |
1 files changed, 77 insertions, 45 deletions
diff --git a/volumebox.c b/volumebox.c index 5f3cefe..c0897a4 100644 --- a/volumebox.c +++ b/volumebox.c @@ -4,52 +4,86 @@ #include "config.h" #include "helpers.h" -cNopacityVolumeBox::cNopacityVolumeBox(cOsd *osd, const cRect &Rect) { +cNopacityVolumeBox::cNopacityVolumeBox(cOsd *osd, const cRect &Rect, cFont *Font, bool simple, bool altcolor) { this->osd = osd; - - pixmapBackgroundVolume = osd->CreatePixmap(6, cRect(Rect)); - pixmapBackgroundVolume->Fill(clrTransparent); + font = Font; + this->simple = simple; + barWidth = 0; + barHeight = 0; + textLeft = 0; + textTop = 0; - if (config.GetValue("displayType") == dtGraphical) { - cImage *imgBack = imgCache->GetSkinElement(seVolumeBackground); - if (imgBack) { - pixmapBackgroundVolume->DrawImage(cPoint(0, 0), *imgBack); + cString testlabel = cString::sprintf("%s: %s", tr("Volume"), "999"); + if (simple) { + if (altcolor) { + tColor altBackgroundColor = Theme.Color(clrChannelBackground); + pixmapBackgroundVolume = osd->CreatePixmap(6, cRect(Rect.Left() - Rect.Height() / 4, Rect.Top(), Rect.Width() + Rect.Height() / 2, Rect.Height())); + pixmapBackgroundVolume->Fill(clrTransparent); + pixmapBackgroundVolume->DrawEllipse(cRect(0, 0, Rect.Height() / 2, Rect.Height()), altBackgroundColor, 7); + pixmapBackgroundVolume->DrawEllipse(cRect(Rect.Width(), 0, Rect.Height() / 2, Rect.Height()), altBackgroundColor, 5); + pixmapBackgroundVolume->DrawRectangle(cRect(Rect.Height() / 2, 0, Rect.Width() - Rect.Height() / 2, Rect.Height()), altBackgroundColor); + } else { + pixmapBackgroundVolume = osd->CreatePixmap(6, cRect(Rect)); + pixmapBackgroundVolume->Fill(clrTransparent); } + int textHeight = font->Height(); + int textWidth = font->Width(*testlabel); + pixmapLabelVolume = osd->CreatePixmap(7, cRect(Rect.Left(), Rect.Top() + (Rect.Height() - textHeight) / 2, textWidth, textHeight)); + pixmapLabelVolume->Fill(clrTransparent); + + barWidth = Rect.Width() - textWidth - 10; + barHeight = Rect.Height() * 2 / 3; + if (barHeight % 2 != 0) + barHeight++; + int barTop = (Rect.Height() - barHeight) / 2 + 1; + pixmapProgressBarVolume = osd->CreatePixmap(7, cRect(Rect.Left() + textWidth + 10, Rect.Top() + barTop, barWidth, barHeight)); + pixmapProgressBarVolume->Fill(clrTransparent); } else { - pixmapBackgroundVolume->Fill(Theme.Color(clrChannelBackground)); - if (config.GetValue("displayType") == dtBlending) { - DrawBlendedBackground(pixmapBackgroundVolume, - 0, - geoManager->volumeWidth, - Theme.Color(clrChannelBackground), - Theme.Color(clrChannelBackBlend), - true); - DrawBlendedBackground(pixmapBackgroundVolume, - 0, - geoManager->volumeWidth, - Theme.Color(clrChannelBackground), - Theme.Color(clrChannelBackBlend), - false); - } - int cornerRadius = geoManager->volumeHeight/4; - if (cornerRadius > 2) { - DrawRoundedCorners(pixmapBackgroundVolume, - cornerRadius, - 0, - 0, - geoManager->volumeWidth, - geoManager->volumeHeight); + pixmapBackgroundVolume = osd->CreatePixmap(6, cRect(Rect)); + pixmapBackgroundVolume->Fill(clrTransparent); + if (config.GetValue("displayType") == dtGraphical) { + cImage *imgBack = imgCache->GetSkinElement(seVolumeBackground); + if (imgBack) { + pixmapBackgroundVolume->DrawImage(cPoint(0, 0), *imgBack); + } + } else { + pixmapBackgroundVolume->Fill(Theme.Color(clrChannelBackground)); + if (config.GetValue("displayType") == dtBlending) { + DrawBlendedBackground(pixmapBackgroundVolume, + 0, + geoManager->volumeWidth, + Theme.Color(clrChannelBackground), + Theme.Color(clrChannelBackBlend), + true); + DrawBlendedBackground(pixmapBackgroundVolume, + 0, + geoManager->volumeWidth, + Theme.Color(clrChannelBackground), + Theme.Color(clrChannelBackBlend), + false); + } + int cornerRadius = geoManager->volumeHeight/4; + if (cornerRadius > 2) { + DrawRoundedCorners(pixmapBackgroundVolume, + cornerRadius, + 0, + 0, + geoManager->volumeWidth, + geoManager->volumeHeight); + } } - } - barWidth = geoManager->volumeProgressBarWidth; - barHeight = geoManager->volumeProgressBarHeight; - - pixmapLabelVolume = osd->CreatePixmap(7, cRect(Rect.Left(), Rect.Top() + 5, geoManager->volumeWidth, geoManager->volumeLabelHeight)); - pixmapLabelVolume->Fill(clrTransparent); - pixmapProgressBarVolume = osd->CreatePixmap(7, cRect((Rect.Left() + (geoManager->volumeWidth - barWidth) / 2), Rect.Top() + ((geoManager->volumeHeight - barHeight) * 2 / 3), barWidth, barHeight)); - pixmapProgressBarVolume->Fill(clrTransparent); + textLeft = (geoManager->volumeWidth - font->Width(*testlabel)) / 2; + textTop = (geoManager->volumeLabelHeight - font->Height()) / 2; + barWidth = geoManager->volumeProgressBarWidth; + barHeight = geoManager->volumeProgressBarHeight; + + pixmapLabelVolume = osd->CreatePixmap(7, cRect(Rect.Left(), Rect.Top() + 5, geoManager->volumeWidth, geoManager->volumeLabelHeight)); + pixmapLabelVolume->Fill(clrTransparent); + pixmapProgressBarVolume = osd->CreatePixmap(7, cRect((Rect.Left() + (geoManager->volumeWidth - barWidth) / 2), Rect.Top() + ((geoManager->volumeHeight - barHeight) * 2 / 3), barWidth, barHeight)); + pixmapProgressBarVolume->Fill(clrTransparent); + } } cNopacityVolumeBox::~cNopacityVolumeBox(void) { @@ -67,18 +101,16 @@ void cNopacityVolumeBox::SetVolume(int Current, int Total, bool Mute) { return; } - cString label = cString::sprintf("%s: %d", tr("Volume"), Current); - pixmapLabelVolume->DrawText(cPoint((geoManager->volumeWidth - fontManager->volumeText->Width(*label)) / 2, - (geoManager->volumeLabelHeight - fontManager->volumeText->Height()) / 2), - *label, Theme.Color(clrVolumeFont), clrTransparent, fontManager->volumeText); - pixmapProgressBarVolume->DrawEllipse(cRect(0, 0, barHeight, barHeight), Theme.Color(clrProgressBarBack)); pixmapProgressBarVolume->DrawEllipse(cRect(barWidth - barHeight, 0, barHeight, barHeight), Theme.Color(clrProgressBarBack)); pixmapProgressBarVolume->DrawRectangle(cRect(barHeight / 2, 0, barWidth - barHeight, barHeight), Theme.Color(clrProgressBarBack)); DrawProgressbar(pixmapProgressBarVolume, 1, 1, barWidth - 2, barHeight - 2, Current, Total, Theme.Color(clrProgressBar), Theme.Color(clrProgressBarBlend), true); - if (Mute) { + cString label = cString::sprintf("%s: %d", tr("Volume"), Current); + pixmapLabelVolume->DrawText(cPoint(textLeft, textTop), *label, Theme.Color(clrChannelHead), clrTransparent, font); + + if (!simple && Mute) { cBitmap bmMute(mute_xpm); pixmapLabelVolume->DrawBitmap(cPoint(geoManager->volumeWidth - 2 * bmMute.Width(), (geoManager->volumeLabelHeight - bmMute.Height()) / 2), bmMute, Theme.Color(clrDiskAlert), clrTransparent); } |