forked from vdr-projects/vdr-plugin-skinflatplus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdisplayvolume.c
94 lines (78 loc) · 4.07 KB
/
displayvolume.c
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
/*
* Skin flatPlus: A plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
* $Id$
*/
#include "./displayvolume.h"
#include "./flat.h"
cFlatDisplayVolume::cFlatDisplayVolume() {
m_LabelHeight = m_FontHeight + m_MarginItem2;
CreateFullOsd();
TopBarCreate();
const int width {m_OsdWidth / 4 * 3};
const int top {m_OsdHeight - 50 - Config.decorProgressVolumeSize - m_LabelHeight - m_MarginItem -
Config.decorBorderVolumeSize * 2};
const int left {(m_OsdWidth - width - Config.decorBorderVolumeSize) / 2};
LabelPixmap = CreatePixmap(m_Osd, "LabelPixmap", 1, cRect(0, top, m_OsdWidth, m_LabelHeight));
MuteLogoPixmap = CreatePixmap(m_Osd, "MuteLogoPixmap", 2, cRect(0, top, m_OsdWidth, m_LabelHeight));
ProgressBarCreate(cRect(left, m_OsdHeight - 50 - Config.decorProgressVolumeSize, width,
Config.decorProgressVolumeSize),
m_MarginItem, m_MarginItem, Config.decorProgressVolumeFg, Config.decorProgressVolumeBarFg,
Config.decorProgressVolumeBg, Config.decorProgressVolumeType, true);
}
cFlatDisplayVolume::~cFlatDisplayVolume() {
m_Osd->DestroyPixmap(LabelPixmap);
m_Osd->DestroyPixmap(MuteLogoPixmap);
}
void cFlatDisplayVolume::SetVolume(int Current, int Total, bool Mute) {
if (!LabelPixmap || !MuteLogoPixmap) return;
PixmapFill(LabelPixmap, clrTransparent);
PixmapFill(MuteLogoPixmap, clrTransparent);
const cString label = cString::sprintf("%s: %d", tr("Volume"), Current);
const cString MaxLabel = cString::sprintf("%s: %d", tr("Volume"), 555);
const int MaxLabelWidth {m_Font->Width(*MaxLabel) + m_MarginItem};
int left {m_OsdWidth / 2 - MaxLabelWidth / 2};
LabelPixmap->DrawRectangle(cRect(left - m_MarginItem, m_MarginItem, m_MarginItem, m_FontHeight),
Theme.Color(clrVolumeBg));
const int DecorTop {
m_OsdHeight - 50 - Config.decorProgressVolumeSize - m_LabelHeight - Config.decorBorderVolumeSize * 2};
DecorBorderClear(
cRect(left - m_MarginItem, DecorTop, MaxLabelWidth + m_MarginItem * 4 + m_FontHeight, m_FontHeight),
Config.decorBorderVolumeSize);
DecorBorderClear(cRect(left - m_MarginItem, DecorTop, MaxLabelWidth + m_MarginItem, m_FontHeight),
Config.decorBorderVolumeSize);
sDecorBorder ib {left - m_MarginItem, DecorTop,
MaxLabelWidth + m_MarginItem, m_FontHeight,
Config.decorBorderVolumeSize, Config.decorBorderVolumeType,
Config.decorBorderVolumeFg, Config.decorBorderVolumeBg};
if (Mute) {
LabelPixmap->DrawText(cPoint(left, m_MarginItem), *label, Theme.Color(clrVolumeFont), Theme.Color(clrVolumeBg),
m_Font, MaxLabelWidth + m_MarginItem + m_LabelHeight, m_FontHeight, taLeft);
cImage *img {ImgLoader.LoadIcon("mute", m_FontHeight, m_FontHeight)};
if (img)
MuteLogoPixmap->DrawImage(cPoint(left + MaxLabelWidth + m_MarginItem, m_MarginItem), *img);
ib.Width = MaxLabelWidth + m_MarginItem * 4 + m_FontHeight;
} else {
LabelPixmap->DrawText(cPoint(left, m_MarginItem), *label, Theme.Color(clrVolumeFont), Theme.Color(clrVolumeBg),
m_Font, MaxLabelWidth, m_FontHeight, taLeft);
}
DecorBorderDraw(ib);
ProgressBarDraw(Current, Total);
const int width {(m_OsdWidth / 4 * 3)};
left = (m_OsdWidth - width - Config.decorBorderVolumeSize) / 2;
const sDecorBorder ibVolume {
left - m_MarginItem, m_OsdHeight - 50 - Config.decorProgressVolumeSize - m_MarginItem,
width + m_MarginItem2, Config.decorProgressVolumeSize + m_MarginItem2,
Config.decorBorderVolumeSize, Config.decorBorderVolumeType,
Theme.Color(clrTopBarBg), Theme.Color(clrTopBarBg)};
DecorBorderDraw(ibVolume);
}
void cFlatDisplayVolume::Flush() {
TopBarUpdate();
m_Osd->Flush();
}
void cFlatDisplayVolume::PreLoadImages() {
ImgLoader.LoadIcon("mute", m_FontHeight, m_FontHeight);
}