-
Notifications
You must be signed in to change notification settings - Fork 0
/
displayreplay.c
637 lines (567 loc) · 26.4 KB
/
displayreplay.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
#include "services/scraper2vdr.h"
#include "displayreplay.h"
#include "config.h"
#include "helpers.h"
#include "imageloader.h"
#include "status.h"
cNopacityDisplayReplay::cNopacityDisplayReplay(bool ModeOnly) : cThread("DisplayReplay") {
initial = true;
fadeout = false;
modeOnly = ModeOnly;
lastDate = "";
createOSD();
CreatePixmaps();
DrawBackground();
LoadControlIcons();
lastVolume = statusMonitor->GetVolume();
lastVolumeTime = time(NULL);
}
cNopacityDisplayReplay::~cNopacityDisplayReplay() {
if (config.GetValue("animation") && config.GetValue("replayFadeOutTime")) {
fadeout = true;
Start();
}
int count = 0;
while (Active()) {
cCondWait::SleepMs(10);
count++;
if (count > 150)
Cancel(1);
}
delete messageBox;
delete volumeBox;
delete osd;
}
void cNopacityDisplayReplay::createOSD(void) {
osd = CreateOsd(geoManager->replayOsdLeft, geoManager->replayOsdTop, geoManager->replayOsdWidth, geoManager->replayOsdHeight);
}
void cNopacityDisplayReplay::CreatePixmaps(void) {
if (!modeOnly) {
pixmapBackground = CreatePixmap(osd, "pixmapBackground", 1,
cRect(0,
0,
geoManager->replayOsdWidth,
geoManager->replayOsdHeight));
pixmapTop = CreatePixmap(osd, "pixmapTop", 5,
cRect(0,
0,
geoManager->replayOsdWidth,
geoManager->replayOsdHeight));
pixmapDate = CreatePixmap(osd, "pixmapDate", 2,
cRect(geoManager->replayInfoWidth,
0,
geoManager->replayDateWidth,
geoManager->replayHeaderHeight));
int y = geoManager->replayHeaderHeight + geoManager->replayInfo2Height + geoManager->replayProgressBarHeight;
pixmapTotal = CreatePixmap(osd, "pixmapTotal", 3,
cRect(4 * geoManager->replayOsdWidth / 5,
y,
geoManager->replayOsdWidth / 5,
geoManager->replayCurrentHeight));
pixmapScreenResBackground = CreatePixmap(osd, "pixmapScreenResBackground", 3,
cRect(geoManager->replayResolutionX - 10,
geoManager->replayResolutionY - 5,
geoManager->replayResolutionSize * 3 + 20,
geoManager->replayResolutionSize + 10));
pixmapScreenRes = CreatePixmap(osd, "pixmapScreenRes", 4,
cRect(geoManager->replayResolutionX,
geoManager->replayResolutionY,
geoManager->replayResolutionSize * 3,
geoManager->replayResolutionSize));
pixmapJump = CreatePixmap(osd, "pixmapJump", 4,
cRect(geoManager->replayJumpX,
geoManager->replayJumpY,
geoManager->replayJumpWidth,
geoManager->replayJumpHeight));
}
int controlY = geoManager->replayHeaderHeight
+ geoManager->replayInfo2Height
+ geoManager->replayProgressBarHeight;
int iconBorder = geoManager->replayIconBorder;
int iconSize = geoManager->replayIconSize;
int iconWidth = 2 * iconBorder + iconSize;
if (!modeOnly) {
pixmapControls = CreatePixmap(osd, "pixmapControls", 2,
cRect(0,
controlY,
geoManager->replayOsdWidth,
geoManager->replayControlsHeight));
} else {
pixmapControls = CreatePixmap(osd, "pixmapControls", 2,
cRect((geoManager->replayOsdWidth - (5 * iconWidth)) / 2,
controlY - 10,
5 * iconWidth,
geoManager->replayControlsHeight + 20));
}
int iconX = (geoManager->replayOsdWidth - (4 * iconSize + 3 * iconBorder)) / 2;
int iconY = controlY + iconBorder;
pixmapRew = CreatePixmap(osd, "pixmapRew", 4, cRect(iconX, iconY, iconSize, iconSize));
iconX = iconX + iconSize + iconBorder;
pixmapPause = CreatePixmap(osd, "pixmapPause", 4, cRect(iconX, iconY, iconSize, iconSize));
iconX = iconX + iconSize + iconBorder;
pixmapPlay = CreatePixmap(osd, "pixmapPlay", 4, cRect(iconX, iconY, iconSize, iconSize));
iconX = iconX + iconSize + iconBorder;
pixmapFwd = CreatePixmap(osd, "pixmapFwd", 4, cRect(iconX, iconY, iconSize, iconSize));
if (!modeOnly) {
int alphaBack = (100 - config.GetValue("channelBackgroundTransparency"))*255/100;
PixmapSetAlpha(pixmapBackground, alphaBack);
}
}
void cNopacityDisplayReplay::CreatePixmaps2(int x) {
if (modeOnly)
return;
pixmapInfo = CreatePixmap(osd, "pixmapInfo", 2,
cRect(x,
0,
geoManager->replayInfoWidth - x,
geoManager->replayHeaderHeight));
pixmapInfo2 = CreatePixmap(osd, "pixmapInfo2", 2,
cRect(x,
geoManager->replayHeaderHeight,
geoManager->replayInfoWidth - x,
geoManager->replayInfo2Height));
pixmapProgressBar = CreatePixmap(osd, "pixmapProgressBar", 2,
cRect(x + geoManager->replayProgressBarHeight / 2,
geoManager->replayHeaderHeight + geoManager->replayInfo2Height,
geoManager->replayOsdWidth - geoManager->replayProgressBarHeight - x,
geoManager->replayProgressBarHeight));
int y = geoManager->replayHeaderHeight + geoManager->replayInfo2Height + geoManager->replayProgressBarHeight;
pixmapCurrent = CreatePixmap(osd, "pixmapCurrent", 3,
cRect(x,
y,
geoManager->replayOsdWidth / 5,
geoManager->replayCurrentHeight));
PixmapFill(pixmapInfo, clrTransparent);
PixmapFill(pixmapInfo2, clrTransparent);
PixmapFill(pixmapProgressBar, clrTransparent);
PixmapFill(pixmapCurrent, clrTransparent);
}
void cNopacityDisplayReplay::SetAlpha(int Alpha) {
if (!modeOnly) {
int alphaBack = (100 - config.GetValue("channelBackgroundTransparency"))*Alpha/100;
PixmapSetAlpha(pixmapBackground, alphaBack);
PixmapSetAlpha(pixmapTop, Alpha);
PixmapSetAlpha(pixmapInfo, Alpha);
PixmapSetAlpha(pixmapInfo2, Alpha);
PixmapSetAlpha(pixmapDate, Alpha);
PixmapSetAlpha(pixmapProgressBar, Alpha);
PixmapSetAlpha(pixmapCurrent, Alpha);
PixmapSetAlpha(pixmapTotal, Alpha);
PixmapSetAlpha(pixmapScreenResBackground, Alpha);
PixmapSetAlpha(pixmapScreenRes, Alpha);
PixmapSetAlpha(pixmapJump, Alpha);
PixmapSetAlpha(pixmapPoster, Alpha);
}
PixmapSetAlpha(pixmapControls, Alpha);
PixmapSetAlpha(pixmapRew, Alpha);
PixmapSetAlpha(pixmapPause, Alpha);
PixmapSetAlpha(pixmapPlay, Alpha);
PixmapSetAlpha(pixmapFwd, Alpha);
if (volumeBox) volumeBox->SetAlpha(Alpha);
}
void cNopacityDisplayReplay::DrawBackground(void) {
if (!modeOnly) {
if (config.GetValue("displayType") == dtGraphical) {
cImage *imgBack = imgCache->GetSkinElement(seReplayBackground);
if (pixmapBackground && imgBack)
pixmapBackground->DrawImage(cPoint(0,0), *imgBack);
cImage *imgTop = imgCache->GetSkinElement(seReplayTop);
if (pixmapTop && imgTop)
pixmapTop->DrawImage(cPoint(0,0), *imgTop);
else
PixmapFill(pixmapTop, clrTransparent);
} else {
PixmapFill(pixmapBackground, Theme.Color(clrReplayBackground));
PixmapFill(pixmapTop, clrTransparent);
if (config.GetValue("displayType") == dtBlending &&
(Theme.Color(clrReplayBackground) != Theme.Color(clrReplayBackBlend))) {
DrawBlendedBackground(pixmapBackground,
0,
geoManager->replayOsdWidth,
Theme.Color(clrReplayBackground),
Theme.Color(clrReplayBackBlend),
true);
DrawBlendedBackground(pixmapBackground,
0,
geoManager->replayOsdWidth,
Theme.Color(clrReplayBackground),
Theme.Color(clrReplayBackBlend),
false);
}
if (config.GetValue("roundedCornersChannel")) {
int cornerRadius = geoManager->replayHeaderHeight/2;
if (cornerRadius > 2) {
DrawRoundedCorners(pixmapBackground,
cornerRadius,
0,
0,
geoManager->replayOsdWidth,
geoManager->replayOsdHeight);
}
}
}
PixmapFill(pixmapControls, clrTransparent);
PixmapFill(pixmapScreenResBackground, clrTransparent);
PixmapFill(pixmapScreenRes, clrTransparent);
PixmapFill(pixmapJump, clrTransparent);
} else {
PixmapFill(pixmapControls, Theme.Color(clrMenuBorder));
if (pixmapControls)
pixmapControls->DrawRectangle(cRect(2, 2, pixmapControls->ViewPort().Width() - 4, pixmapControls->ViewPort().Height() - 4),Theme.Color(clrReplayBackground));
}
}
void cNopacityDisplayReplay::LoadControlIcons(void) {
PixmapFill(pixmapRew, clrTransparent);
PixmapFill(pixmapPause, clrTransparent);
PixmapFill(pixmapPlay, clrTransparent);
PixmapFill(pixmapFwd, clrTransparent);
int iconSize = geoManager->replayIconSize;
cImage *imgRew = imgCache->GetSkinIcon("skinIcons/rewInactive", iconSize, iconSize);
if (pixmapRew && imgRew)
pixmapRew->DrawImage(cPoint(0,0), *imgRew);
cImage *imgPause = imgCache->GetSkinIcon("skinIcons/pauseInactive", iconSize, iconSize);
if (pixmapPause && imgPause)
pixmapPause->DrawImage(cPoint(0,0), *imgPause);
cImage *imgPlay = imgCache->GetSkinIcon("skinIcons/playInactive", iconSize, iconSize);
if (pixmapPlay && imgPlay)
pixmapPlay->DrawImage(cPoint(0,0), *imgPlay);
cImage *imgFwd = imgCache->GetSkinIcon("skinIcons/fwdInactive", iconSize, iconSize);
if (pixmapFwd && imgFwd)
pixmapFwd->DrawImage(cPoint(0,0), *imgFwd);
}
void cNopacityDisplayReplay::DrawDate(void) {
if (!pixmapDate)
return;
cString curDate = DayDateTime();
if (initial || strcmp(curDate, lastDate)) {
int strDateWidth = fontManager->replayText->Width(curDate);
int strDateHeight = fontManager->replayText->Height();
int x = geoManager->replayDateWidth - strDateWidth - geoManager->replayHeaderHeight/2;
int y = (geoManager->replayHeaderHeight - strDateHeight) / 2;
PixmapFill(pixmapDate, clrTransparent);
pixmapDate->DrawText(cPoint(x, y),
curDate,
Theme.Color(clrReplayHead),
clrTransparent,
fontManager->replayText);
lastDate = curDate;
}
}
void cNopacityDisplayReplay::DrawScreenResolution(void) {
int screenWidth = 0;
int screenHeight = 0;
double aspect = 0;
cDevice::PrimaryDevice()->GetVideoSize(screenWidth, screenHeight, aspect);
cString iconName = GetScreenResolutionIcon();
if (strcasecmp(iconName, "") == 0)
return;
int replaySize = geoManager->replayResolutionSize;
cImage *imgRes = imgCache->GetSkinIcon(*iconName, 3 * replaySize, replaySize);
PixmapFill(pixmapScreenResBackground, Theme.Color(clrStatusIconsBack));
if (pixmapScreenResBackground) {
DrawRoundedCorners(pixmapScreenResBackground,
5,
0,
0,
pixmapScreenResBackground->ViewPort().Width(),
pixmapScreenResBackground->ViewPort().Height());
}
if (pixmapScreenRes && imgRes)
pixmapScreenRes->DrawImage(cPoint(0,0), *imgRes);
}
void cNopacityDisplayReplay::SetRecording(const cRecording *Recording) {
int x = DrawPoster(Recording);
CreatePixmaps2(x);
const cRecordingInfo *RecordingInfo = Recording->Info();
const char *recName = RecordingInfo->Title();
if (!recName) {
recName = Recording->Name();
}
SetTitle(recName);
cString info2;
if (RecordingInfo->ShortText())
info2 = cString::sprintf("%s %s - %s", *ShortDateString(Recording->Start()), *TimeString(Recording->Start()), RecordingInfo->ShortText());
else
info2 = cString::sprintf("%s %s", *ShortDateString(Recording->Start()), *TimeString(Recording->Start()));
if (pixmapInfo2) {
pixmapInfo2->DrawText(cPoint(geoManager->replayHeaderHeight / 2,
std::max((geoManager->replayInfo2Height
- fontManager->replayText->Height()) / 2 - 10,
0)),
*info2,
Theme.Color(clrReplayDescription),
clrTransparent,
fontManager->replayText);
}
DrawScreenResolution();
}
void cNopacityDisplayReplay::SetTitle(const char *Title) {
if (!pixmapInfo || !Title)
return;
int titleLength = fontManager->replayHeader->Width(Title);
int titleSpace = geoManager->replayInfoWidth - geoManager->replayHeaderHeight/2;
std::string strTitle = Title;
if (titleLength > titleSpace)
strTitle = CutText(strTitle, titleSpace, fontManager->replayHeader);
pixmapInfo->DrawText(cPoint(geoManager->replayHeaderHeight/2, 0),
strTitle.c_str(),
Theme.Color(clrReplayHead),
clrTransparent,
fontManager->replayHeader);
}
void cNopacityDisplayReplay::SetMode(bool Play, bool Forward, int Speed) {
LoadControlIcons();
int iconSize = geoManager->replayIconSize;
if (Speed == -1) {
if (Play) {
PixmapFill(pixmapPlay, clrTransparent);
cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/play", iconSize, iconSize);
if (pixmapPlay && imgIcon)
pixmapPlay->DrawImage(cPoint(0,0), *imgIcon);
} else {
PixmapFill(pixmapPause, clrTransparent);
cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/pause", iconSize, iconSize);
if (pixmapPause && imgIcon)
pixmapPause->DrawImage(cPoint(0,0), *imgIcon);
}
} else if (Forward) {
if (!Play) {
PixmapFill(pixmapPause, clrTransparent);
cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/pause", iconSize, iconSize);
if (pixmapPause && imgIcon)
pixmapPause->DrawImage(cPoint(0,0), *imgIcon);
}
PixmapFill(pixmapFwd, clrTransparent);
if (Speed > 0) {
cString trickIcon = cString::sprintf("skinIcons/fwdx%d", Speed);
cImage *imgIcon = imgCache->GetSkinIcon(*trickIcon, iconSize, iconSize);
if (pixmapFwd && imgIcon)
pixmapFwd->DrawImage(cPoint(0,0), *imgIcon);
} else {
cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/fwd", iconSize, iconSize);
if (pixmapFwd && imgIcon)
pixmapFwd->DrawImage(cPoint(0,0), *imgIcon);
}
} else {
if (!Play) {
PixmapFill(pixmapPause, clrTransparent);
cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/pause", iconSize, iconSize);
if (pixmapPause && imgIcon)
pixmapPause->DrawImage(cPoint(0,0), *imgIcon);
}
PixmapFill(pixmapRew, clrTransparent);
if (Speed > 0) {
cString trickIcon = cString::sprintf("skinIcons/rewx%d", Speed);
cImage *imgIcon = imgCache->GetSkinIcon(*trickIcon, iconSize, iconSize);
if (pixmapRew && imgIcon)
pixmapRew->DrawImage(cPoint(0,0), *imgIcon);
} else {
cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/rew", iconSize, iconSize);
if (pixmapRew && imgIcon)
pixmapRew->DrawImage(cPoint(0,0), *imgIcon);
}
}
}
void cNopacityDisplayReplay::SetProgress(int Current, int Total) {
if (Running() || geoManager->replayProgressBarHeight < 5)
return;
else if (!pixmapProgressBar)
CreatePixmaps2();
if (!pixmapProgressBar)
return;
int barWidth = pixmapProgressBar->ViewPort().Width();
cProgressBar pb(barWidth - geoManager->replayProgressBarHeight,
geoManager->replayProgressBarHeight - 2,
Current,
Total,
marks,
Theme.Color(clrReplayProgressSeen),
Theme.Color(clrReplayProgressRest),
Theme.Color(clrReplayProgressSelected),
Theme.Color(clrReplayProgressMark),
Theme.Color(clrReplayProgressCurrent));
// left ellipse
pixmapProgressBar->DrawEllipse(cRect(0,
0,
geoManager->replayProgressBarHeight / 2,
geoManager->replayProgressBarHeight),
Theme.Color(clrProgressBarBack), 7);
pixmapProgressBar->DrawEllipse(cRect(1,
1,
geoManager->replayProgressBarHeight / 2 - 1,
geoManager->replayProgressBarHeight - 2),
Theme.Color(clrReplayProgressSeen), 7);
// right ellipse
pixmapProgressBar->DrawEllipse(cRect(barWidth - geoManager->replayProgressBarHeight / 2,
0,
geoManager->replayProgressBarHeight / 2,
geoManager->replayProgressBarHeight),
Theme.Color(clrProgressBarBack), 5);
pixmapProgressBar->DrawEllipse(cRect(barWidth - geoManager->replayProgressBarHeight / 2,
1,
geoManager->replayProgressBarHeight / 2 - 1,
geoManager->replayProgressBarHeight - 2),
Theme.Color(clrReplayProgressRest), 5);
pixmapProgressBar->DrawRectangle(cRect(geoManager->replayProgressBarHeight / 2,
0,
barWidth - geoManager->replayProgressBarHeight,
geoManager->replayProgressBarHeight),
Theme.Color(clrProgressBarBack));
pixmapProgressBar->DrawBitmap(cPoint(geoManager->replayProgressBarHeight / 2, 1), pb);
}
void cNopacityDisplayReplay::SetCurrent(const char *Current) {
if (Running())
return;
PixmapFill(pixmapCurrent, clrTransparent);
if (pixmapCurrent && Current) {
pixmapCurrent->DrawText(cPoint(geoManager->replayHeaderHeight/2, 0),
Current,
Theme.Color(clrReplayCurrentTotal),
clrTransparent,
fontManager->replayText);
}
}
void cNopacityDisplayReplay::SetTotal(const char *Total) {
PixmapFill(pixmapTotal, clrTransparent);
if (pixmapTotal && Total) {
pixmapTotal->DrawText(cPoint(geoManager->replayOsdWidth/5
- (fontManager->replayText->Width(Total)
+ geoManager->replayHeaderHeight/2),
0),
Total,
Theme.Color(clrReplayCurrentTotal),
clrTransparent,
fontManager->replayText);
}
}
void cNopacityDisplayReplay::SetJump(const char *Jump) {
PixmapFill(pixmapJump, clrTransparent);
if (pixmapJump && Jump) {
pixmapJump->DrawText(cPoint(0,
(geoManager->replayJumpHeight
- fontManager->replayHeader->Height())/2),
Jump,
Theme.Color(clrReplayCurrentTotal),
clrTransparent,
fontManager->replayHeader);
}
}
int cNopacityDisplayReplay::DrawPoster(const cRecording *Recording) {
int pixmapWidth = 0;
if (pixmapPoster) {
osd->DestroyPixmap(pixmapPoster);
pixmapPoster = NULL;
}
if (!(config.GetValue("scraperInfo") && config.GetValue("replayDisplayPoster")))
return pixmapWidth;
int border = config.GetValue("replayPosterBorder");
int mediaWidth = osd->Width() / 7;
int mediaHeight = osd->Height() - 2 * border - 20;
std::string mediaPath = "";
cImageLoader imgLoader;
static cPlugin *pScraper = GetScraperPlugin();
if (pScraper) {
ScraperGetPosterBannerV2 call;
call.event = NULL;
call.recording = Recording;
if (pScraper->Service("GetPosterBannerV2", &call))
if (call.poster.path.size() > 0 && call.poster.height > 0)
mediaPath = call.poster.path;
}
if (mediaPath.empty()) {
cString posterFound;
if (imgLoader.SearchRecordingImage(Recording->FileName(), posterFound))
mediaPath = posterFound;
}
if (mediaPath.empty())
return pixmapWidth;
if (!imgLoader.LoadPoster(mediaPath.c_str(), mediaWidth, mediaHeight))
return pixmapWidth;
cImage logo = imgLoader.GetImage();
pixmapPoster = CreatePixmap(osd, "pixmapPoster", 1,
cRect(10,
10,
logo.Width() + 2 * border,
logo.Height() + 2 * border));
if (!pixmapPoster)
return pixmapWidth;
PixmapFill(pixmapPoster, Theme.Color(clrReplayBackground));
pixmapPoster->DrawImage(cPoint(border, border), logo);
pixmapWidth = pixmapPoster->ViewPort().Width();
int pixmapHeight = pixmapPoster->ViewPort().Height();
DrawRoundedCorners(pixmapPoster, border, 0, 0, pixmapWidth, pixmapHeight);
return pixmapWidth + border + 10;
}
void cNopacityDisplayReplay::SetMessage(eMessageType Type, const char *Text) {
DELETENULL(volumeBox);
DELETENULL(messageBox);
if (!Text)
return;
messageBox = new cNopacityMessageBox(osd,
cRect((geoManager->replayOsdWidth - geoManager->messageWidth) / 2,
geoManager->replayOsdHeight - geoManager->messageHeight - 20,
geoManager->messageWidth, geoManager->messageHeight),
Type, Text);
}
void cNopacityDisplayReplay::DrawVolume(void) {
int volume = statusMonitor->GetVolume();
if (volume != lastVolume) {
if (!volumeBox) {
bool simple = (config.GetValue("displayReplayVolume") == vbSimple) ? true : false;
volumeBox = new cNopacityVolumeBox(osd,
cRect(geoManager->replayVolumeLeft,
geoManager->replayVolumeTop,
geoManager->replayVolumeWidth,
geoManager->replayVolumeHeight),
simple ? fontManager->channelSourceInfo : fontManager->volumeText,
simple);
}
volumeBox->SetVolume(volume, MAXVOLUME, volume ? false : true);
lastVolumeTime = time(NULL);
lastVolume = volume;
}
else {
if (volumeBox && (time(NULL) - lastVolumeTime > 2))
DELETENULL(volumeBox);
}
}
void cNopacityDisplayReplay::Flush(void) {
if (Running())
return;
if (!modeOnly) {
DrawDate();
}
if (config.GetValue("displayReplayVolume"))
DrawVolume();
if (initial && config.GetValue("animation") && config.GetValue("replayFadeTime")) {
SetAlpha(0);
Start();
}
initial = false;
osd->Flush();
}
void cNopacityDisplayReplay::Action(void) {
int x = (fadeout) ? 255 : 0;
int FadeTime = (fadeout) ? config.GetValue("replayFadeOutTime") : config.GetValue("replayFadeTime");
int FrameTime = FadeTime / 10;
uint64_t First = cTimeMs::Now();
cPixmap::Lock();
cPixmap::Unlock();
uint64_t Start = cTimeMs::Now();
dsyslog ("skinnopacity: First Lock(): %llums \n", (long long)(Start - First));
while (Running()) {
uint64_t Now = cTimeMs::Now();
double t = std::min(double(Now - Start) / FadeTime, 1.0);
int Alpha = std::abs(x - (int(t * ALPHA_OPAQUE)));
cPixmap::Lock();
SetAlpha(Alpha);
if (Running())
osd->Flush();
cPixmap::Unlock();
int Delta = cTimeMs::Now() - Now;
if (Running() && (Delta < FrameTime))
cCondWait::SleepMs(FrameTime - Delta);
if ((int)(Now - Start) > FadeTime)
break;
}
}