summaryrefslogtreecommitdiff
path: root/displayvolume.c
blob: ee48f905ff34e4ce1b540a16173deddb91d62c90 (plain)
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
#include "displayvolume.h"

cFlatDisplayVolume::cFlatDisplayVolume(void) {
    muted = false;

    labelHeight = fontHeight + marginItem*2;

    CreateFullOsd();
    TopBarCreate();
    
    int width = osdWidth /4*3;
    int left = osdWidth - width;
    left /= 2;
    
    ProgressBarCreate(left, osdHeight - 50 - ProgressBarHeight(), width,
        Theme.Color(clrVolumeProgressFg), Theme.Color(clrVolumeProgressBarFg), Theme.Color(clrVolumeProgressBg));
    labelPixmap = osd->CreatePixmap(1, cRect(0, osdHeight - 50 - progressBarHeight - labelHeight - marginItem, osdWidth, labelHeight));
    muteLogoPixmap = osd->CreatePixmap(2, cRect(0, osdHeight - 50 - progressBarHeight - labelHeight - marginItem, osdWidth, labelHeight));
}

cFlatDisplayVolume::~cFlatDisplayVolume() {
    osd->DestroyPixmap(labelPixmap);
    osd->DestroyPixmap(muteLogoPixmap);
}

void cFlatDisplayVolume::SetVolume(int Current, int Total, bool Mute) {
    labelPixmap->Fill(clrTransparent);
    muteLogoPixmap->Fill(clrTransparent);
    
    cString label = cString::sprintf("%s: %d", tr("Volume"), Current);
    cString maxLabel = cString::sprintf("%s: %d", tr("Volume"), 555);
    int maxlabelWidth = font->Width(maxLabel) + marginItem;
    int left = osdWidth / 2 - maxlabelWidth / 2;

    labelPixmap->DrawRectangle(cRect(left - marginItem, marginItem, marginItem, fontHeight), Theme.Color(clrVolumeBg));
    
    if (Mute) {
        labelPixmap->DrawText(cPoint(left, marginItem), *label, Theme.Color(clrVolumeFont), Theme.Color(clrVolumeBg),
            font, maxlabelWidth + marginItem + labelHeight, fontHeight, taLeft);
        if( imgLoader.LoadIcon("mute", fontHeight, fontHeight) ) {
            muteLogoPixmap->DrawImage( cPoint(left + maxlabelWidth + marginItem, marginItem), imgLoader.GetImage() );
        }
    } else {
        labelPixmap->DrawText(cPoint(left, marginItem), *label, Theme.Color(clrVolumeFont), Theme.Color(clrVolumeBg),
            font, maxlabelWidth, fontHeight, taLeft);
    }
    ProgressBarDraw(Current, Total);
}

void cFlatDisplayVolume::Flush(void) {
    TopBarUpdate();
    osd->Flush();
}