Repository navigation
Expand file tree
/
Copy pathdisplaytracks.cpp
More file actions
117 lines (96 loc) · 4.43 KB
/
Copy pathdisplaytracks.cpp
File metadata and controls
117 lines (96 loc) · 4.43 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
* Skin flatPlus: A plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
* $Id$
*/
#include "./displaytracks.h"
#include "./flat.h"
#include "./fontcache.h"
cFlatDisplayTracks::cFlatDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks) {
CreateFullOsd();
TopBarCreate();
img_ac3 = ImgLoader.GetIcon("tracks_ac3", kIconMaxSize, m_FontHeight);
img_stereo = ImgLoader.GetIcon("tracks_stereo", kIconMaxSize, m_FontHeight);
m_Ac3Width = (img_ac3) ? img_ac3->Width() : 0;
m_StereoWidth = (img_stereo) ? img_stereo->Width() : 0;
m_ItemHeight = m_FontHeight + Config.MenuItemPadding + Config.decorBorderTrackSize * 2;
m_CurrentIndex = -1;
const int TitleWidth {m_Font->Width(Title) + FontCache.GetStringWidth(m_FontName, m_FontHeight, " ")};
m_MaxItemWidth = TitleWidth + m_MarginItem * 4;
for (int16_t i {0}; i < NumTracks; ++i)
m_MaxItemWidth = std::max(m_MaxItemWidth, m_Font->Width(Tracks[i]) + m_MarginItem2);
const int ImgWidthMax {std::max(m_Ac3Width, m_StereoWidth)};
const int HeaderWidth {TitleWidth + m_MarginItem2 + ImgWidthMax};
m_MaxItemWidth = std::max(m_MaxItemWidth, HeaderWidth);
ItemsHeight = (NumTracks + 1) * m_ItemHeight;
const int left {(m_OsdWidth - m_MaxItemWidth) / 2};
TopBarSetTitle(Title);
const cRect TracksPixmapViewPort{left, m_OsdHeight - ItemsHeight - m_MarginItem, m_MaxItemWidth, ItemsHeight};
TracksPixmap = CreatePixmap(m_Osd, "TracksPixmap", 1, TracksPixmapViewPort);
TracksLogoPixmap = CreatePixmap(m_Osd, "TracksLogoPixmap", 1, TracksPixmapViewPort);
PixmapClear(TracksPixmap);
PixmapClear(TracksLogoPixmap);
SetItem(Title, -1, false);
for (int16_t i {0}; i < NumTracks; ++i)
SetItem(Tracks[i], i, false);
}
cFlatDisplayTracks::~cFlatDisplayTracks() {
m_Osd->DestroyPixmap(TracksPixmap);
m_Osd->DestroyPixmap(TracksLogoPixmap);
}
void cFlatDisplayTracks::SetItem(const char *Text, int Index, bool Current) {
if (!TracksPixmap) return;
if (Current) m_CurrentIndex = Index;
const int y {(Index + 1) * m_ItemHeight};
const auto [ColorFg, ColorBg] =
Current ? std::make_pair(Theme.Color(clrTrackItemCurrentFont), Theme.Color(clrTrackItemCurrentBg))
: Index >= 0 ? std::make_pair(Theme.Color(clrTrackItemSelableFont), Theme.Color(clrTrackItemSelableBg))
: std::make_pair(Theme.Color(clrTrackItemFont), Theme.Color(clrTrackItemBg));
const cString TextWithSpace {cString::sprintf(" %s", Text)};
TracksPixmap->DrawText(cPoint(0, y), TextWithSpace, ColorFg, ColorBg, m_Font, m_MaxItemWidth,
m_ItemHeight - Config.MenuItemPadding - Config.decorBorderTrackSize * 2,
(Index == -1) ? taLeft : taCenter);
const int left {(m_OsdWidth - m_MaxItemWidth) / 2};
const int top {m_OsdHeight - ItemsHeight - m_MarginItem + y};
sDecorBorder ib {left,
top,
m_MaxItemWidth,
m_FontHeight,
Config.decorBorderTrackSize,
Config.decorBorderTrackType,
Config.decorBorderTrackFg,
Config.decorBorderTrackBg};
if (Current) {
ib.ColorFg = Config.decorBorderTrackCurFg;
ib.ColorBg = Config.decorBorderTrackCurBg;
} else if (Index >= 0) {
ib.ColorFg = Config.decorBorderTrackSelFg;
ib.ColorBg = Config.decorBorderTrackSelBg;
}
DecorBorderDraw(ib);
}
void cFlatDisplayTracks::SetTrack(int Index, const char * const *Tracks) {
if (m_CurrentIndex >= 0)
SetItem(Tracks[m_CurrentIndex], m_CurrentIndex, false);
SetItem(Tracks[Index], Index, true);
}
void cFlatDisplayTracks::SetAudioChannel(int AudioChannel) {
if (!TracksLogoPixmap) return;
PixmapClear(TracksLogoPixmap);
// From vdr: 0=stereo, 1=left, 2=right, -1=don't display the audio channel indicator.
// From skinnopacity: -1 ac3, else stereo
if (AudioChannel == -1 && img_ac3) {
const int IconLeft {m_MaxItemWidth - m_Ac3Width - m_MarginItem};
TracksLogoPixmap->DrawImage(cPoint(IconLeft, 0), *img_ac3);
} else if (img_stereo) {
const int IconLeft {m_MaxItemWidth - m_StereoWidth - m_MarginItem};
TracksLogoPixmap->DrawImage(cPoint(IconLeft, 0), *img_stereo);
}
return;
}
void cFlatDisplayTracks::Flush() {
TopBarUpdate();
m_Osd->Flush();
}