summaryrefslogtreecommitdiff
path: root/displaymenu.c
blob: 8c25e66b75dc826b4d06bcfb6739f3ee07c5325a (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
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
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
#include "services/remotetimers.h"
namespace PluginRemoteTimers {
    static int CompareTimers(const void *a, const void *b) {
        return (*(const cTimer **)a)->Compare(**(const cTimer **)b);
    }
}

#include "displaymenuview.h"
#include "displaymenu.h"
#include "config.h"
#include <string>
#include "services/epgsearch.h"

cNopacityDisplayMenu::cNopacityDisplayMenu(void) : cThread("DisplayMenu") {
    menuCategoryLast = mcUndefined;
    menuFadeTime = config.GetValue("menuFadeTime");
    menuFadeOutTime = config.GetValue("menuFadeOutTime");
    fadeout = false;
    initial = true;
    diskUsageDrawn = false;
    timersDrawn = false;
    lastDiskUsageState = -1;
    lastTimersState = -1;
    currentNumItems = 0;
    detailView = NULL;
    SetButtonPositions();
    osd = CreateOsd(geoManager->osdLeft, geoManager->osdTop, geoManager->osdWidth, geoManager->osdHeight);
    menuView = new cNopacityDisplayMenuView(osd);
    currentFeed = 0;
    SetTabs(0);
}

cNopacityDisplayMenu::~cNopacityDisplayMenu(void) {
    if (config.GetValue("animation") && menuFadeOutTime) {
        if ((MenuCategory() != mcPluginSetup) && (MenuCategory() != mcSetupPlugins)) {
            fadeout = true;
            Start();
        }
    }
    int count = 0;
    while (Active()) {
        cCondWait::SleepMs(10);
        count++;
        if (count > 200)
           Cancel(1);
    }
    if (detailView)
        delete detailView;
    if (menuView)
        delete menuView;
    menuItems.clear();
    timers.Clear();
    delete osd;
    cDevice::PrimaryDevice()->ScaleVideo(cRect::Null);
}

void cNopacityDisplayMenu::DrawDisk(void) {
    if (!config.GetValue("narrowMainMenu"))
        return;
    if (initial || ((menuCategoryLast!=mcMain)&&(MenuCategory()==mcMain)&&!diskUsageDrawn)) {
        if (cVideoDiskUsage::HasChanged(lastDiskUsageState)) {
            menuView->DrawDiskUsage();
        } else {
            menuView->ShowDiskUsage(true);
        }
        diskUsageDrawn = true;
    }
}

int cNopacityDisplayMenu::CheckTimerConflict(bool timersChanged) {
    int numConflicts = 0;
    if (initial || ((menuCategoryLast!=mcMain)&&(MenuCategory()==mcMain))) {
        if (timersChanged) {
            cPlugin *p = cPluginManager::GetPlugin("epgsearch");
            if (p) {
                Epgsearch_lastconflictinfo_v1_0 *serviceData = new Epgsearch_lastconflictinfo_v1_0;
                if (serviceData) {
                    serviceData->nextConflict = 0;
                    serviceData->relevantConflicts = 0;
                    serviceData->totalConflicts = 0;
                    p->Service("Epgsearch-lastconflictinfo-v1.0", serviceData);
                    if (serviceData->relevantConflicts > 0) {
                        numConflicts = serviceData->relevantConflicts;
                    }
                    delete serviceData;
                }
            }
        }
    }
    return numConflicts;
}

void cNopacityDisplayMenu::DrawTimers(bool timersChanged, int numConflicts) {
    if (!config.GetValue("narrowMainMenu"))
        return;
    int maxTimersHeight = menuView->GetTimersMaxHeight();
    if (initial || ((menuCategoryLast!=mcMain)&&(MenuCategory()==mcMain)&&!timersDrawn)) {
        if (timersChanged) {
            //check if remotetimers plugin is available
            static cPlugin* pRemoteTimers = cPluginManager::GetPlugin("remotetimers");
            bool drawRemoteTimers = false;
            cString errorMsg;
            if (pRemoteTimers) {
                drawRemoteTimers = pRemoteTimers->Service("RemoteTimers::RefreshTimers-v1.0", &errorMsg);
            }
            timers.Clear();
            LOCK_TIMERS_READ;
            cSortedTimers SortedTimers(Timers);
            //if remotetimers plugin is available, take timers also from him
            if (drawRemoteTimers) {
                cTimer* remoteTimer = NULL;
                int numRemoteTimers = 0;
                while (pRemoteTimers->Service("RemoteTimers::ForEach-v1.0", &remoteTimer) && remoteTimer != NULL) {
                    SortedTimers.Append(remoteTimer);
                    numRemoteTimers++;
                }
                SortedTimers.Sort(PluginRemoteTimers::CompareTimers);
            }
            int numTimers = SortedTimers.Size();
            int currentHeight = menuView->GetTimersInitHeight();
            if (numConflicts > 0) {
                cNopacityTimer *t = menuView->DrawTimerConflict(numConflicts, currentHeight);
                currentHeight += t->GetHeight() + geoManager->menuSpace;
                timers.Add(t);
            }
            int numTimersDisplayed = 0;
            for (int i = 0; i < numTimers; i++) {
                if (const cTimer *Timer = SortedTimers[i]) {
                    if (Timer->HasFlags(tfActive)) {
                        cNopacityTimer *t = menuView->DrawTimer(Timer, currentHeight);
                        currentHeight += t->GetHeight() + geoManager->menuSpace;
                        if (currentHeight < maxTimersHeight) {
                            timers.Add(t);
                        numTimersDisplayed++;
                        if (numTimersDisplayed == config.GetValue("numberTimers"))
                            break;
                        } else {
                            delete t;
                            break;
                        }
                    }
                }
            }
        } else {
            for (cNopacityTimer *t = timers.First(); t; t = timers.Next(t)) {
                t->Show();
            }
        }
        timersDrawn = true;
    }
}

void cNopacityDisplayMenu::Scroll(bool Up, bool Page) {
    if (!detailView)
        return;
    detailView->KeyInput(Up, Page);
}

int cNopacityDisplayMenu::MaxItems(void) {
    int maxItems = 0;
    switch (MenuCategory()) {
        case mcMain:
            if (config.GetValue("narrowMainMenu"))
                maxItems = config.GetValue("numMainMenuItems");
            else
                maxItems = config.GetValue("numDefaultMenuItems");
            break;
        case mcSetup:
            if (config.GetValue("narrowSetupMenu"))
                maxItems = config.GetValue("numMainMenuItems");
            else
                maxItems = config.GetValue("numDefaultMenuItems");
            break;
        case mcSchedule:
        case mcScheduleNow:
        case mcScheduleNext:
            if (config.GetValue("narrowScheduleMenu"))
                maxItems = config.GetValue("numSchedulesMenuItems");
            else
                maxItems = config.GetValue("numDefaultMenuItems");
            break;
        case mcChannel:
            if (config.GetValue("narrowChannelMenu"))
                maxItems = config.GetValue("numSchedulesMenuItems");
            else
                maxItems = config.GetValue("numDefaultMenuItems");
            break;
        case mcTimer:
            if (config.GetValue("narrowTimerMenu"))
                maxItems = config.GetValue("numSchedulesMenuItems");
            else
                maxItems = config.GetValue("numDefaultMenuItems");
            break;
        case mcRecording:
            if (config.GetValue("narrowRecordingMenu"))
                maxItems = config.GetValue("numRecordingsMenuItems");
            else
                maxItems = config.GetValue("numDefaultMenuItems");
            break;
        default:
            maxItems = config.GetValue("numDefaultMenuItems");
    }
    currentNumItems = maxItems;
    return maxItems;
}

void cNopacityDisplayMenu::Clear(void) {
    if (menuFadeOutTime)
        return;
    DELETENULL(detailView);
    menuItems.clear();
}

void cNopacityDisplayMenu::SetMenuCategory(eMenuCategory MenuCategory) {
      /* Categories:
      mcUndefined = -1,
      mcUnknown = 0,
      1  mcMain,
      2  mcSchedule,
      3  mcScheduleNow,
      4  mcScheduleNext,
      5  mcChannel,
      6  mcChannelEdit,
      7  mcTimer,
      8  mcTimerEdit,
      9  mcRecording,
      10 mcRecordingInfo,
      11 mcRecordingEdit,
      12 mcPlugin,
      13 mcPluginSetup,
      14 mcSetup,
      15 mcSetupOsd,
      16 mcSetupEpg,
      17 mcSetupDvb,
      18 mcSetupLnb,
      19 mcSetupCam,
      20 mcSetupRecord,
      21 mcSetupReplay,
      22 mcSetupMisc,
      23 mcSetupPlugins,
      24 mcCommand,
      25 mcEvent,
      26 mcText,
      27 mcFolder,
      28 mcCam
      */
    menuCategoryLast = this->MenuCategory();
    cSkinDisplayMenu::SetMenuCategory(MenuCategory);
    if ((MenuCategory != mcRecordingInfo) && (MenuCategory != mcEvent && MenuCategory != mcText)) {
        DELETENULL(detailView);
    }
    if ((menuCategoryLast == mcMain) && (MenuCategory != mcMain)) {
        if (config.GetValue("showDiscUsage")) {
            menuView->ShowDiskUsage(false);
            diskUsageDrawn = false;
        }
        if (config.GetValue("showTimers")) {
            for (cNopacityTimer *t = timers.First(); t; t = timers.Next(t)) {
                t->Hide();
            }
            timersDrawn = false;
        }
    }
}

void cNopacityDisplayMenu::SetTitle(const char *Title) {
    //resetting menuitems if no call to clear
    DELETENULL(detailView);
    menuItems.clear();
    int left = 5;
    menuView->DestroyHeaderIcon();
    if (Title) {
        cString title = Title;
        switch (MenuCategory()) {
            case mcMain:
                switch (config.GetValue("mainMenuTitleStyle")) {
                    case 0:
                        title = cString::sprintf("%s %s", Title, VDRVERSION);
                        break;
                    case 1:
                        title = cString::sprintf("%s", VDRVERSION);
                        break;
                    case 2:
                        title = " ";
                        break;
                }
                left += menuView->ShowHeaderLogo(true);
                break;
            case mcSchedule:
                menuView->ShowHeaderLogo(false);
                left += menuView->ShowHeaderIconChannelLogo(Title, initial);
                break;
            case mcRecording:
                menuView->ShowHeaderLogo(false);
                title = cString::sprintf("%s (%s)", Title, *cVideoDiskUsage::String());
                left += menuView->DrawHeaderIcon(MenuCategory(), initial);
                break;
            default:
                menuView->ShowHeaderLogo(false);
                left += menuView->DrawHeaderIcon(MenuCategory(), initial);
        }
        menuView->AdjustContentBackground(this->MenuCategory(), menuCategoryLast, videoWindowRect);
        menuView->DrawHeaderLabel(left, title);
    }
}

void cNopacityDisplayMenu::SetButtonPositions(void) {
    for (int i=0; i < 4; i++) {
        positionButtons[i] = -1;
    }
    /*
    red button = 0
    green button = 1
    yellow button = 2
    blue button = 3
    */
    for (int button=0; button<4; button++) {
        if (Setup.ColorKey0 == button) {
            positionButtons[button] = 0;
            continue;
        }
        if (Setup.ColorKey1 == button) {
            positionButtons[button] = 1;
            continue;
        }
        if (Setup.ColorKey2 == button) {
            positionButtons[button] = 2;
            continue;
        }
        if (Setup.ColorKey3 == button) {
            positionButtons[button] = 3;
            continue;
        }
    }
}

void cNopacityDisplayMenu::SetButtons(const char *Red, const char *Green, const char *Yellow, const char *Blue) {
    menuView->ClearButton();
    if (Red)
        menuView->DrawButton(Red, seButtonRed, Theme.Color(clrButtonRed), Theme.Color(clrButtonRedBorder), Theme.Color(clrButtonRedFont), positionButtons[0]);
    if (Green)
        menuView->DrawButton(Green, seButtonGreen,Theme.Color(clrButtonGreen),  Theme.Color(clrButtonGreenBorder), Theme.Color(clrButtonGreenFont), positionButtons[1]);
    if (Yellow)
        menuView->DrawButton(Yellow, seButtonYellow, Theme.Color(clrButtonYellow), Theme.Color(clrButtonYellowBorder), Theme.Color(clrButtonYellowFont), positionButtons[2]);
    if (Blue)
        menuView->DrawButton(Blue, seButtonBlue, Theme.Color(clrButtonBlue), Theme.Color(clrButtonBlueBorder), Theme.Color(clrButtonBlueFont), positionButtons[3]);
}

void cNopacityDisplayMenu::SetMessage(eMessageType Type, const char *Text) {
    menuView->DrawMessage(Type, Text);
}

bool cNopacityDisplayMenu::SetItemEvent(const cEvent *Event, int Index, bool Current,
                                        bool Selectable, const cChannel *Channel, bool WithDate, eTimerMatch TimerMatch, bool TimerActive) {

    if (!config.GetValue("narrowScheduleMenu"))
        return false;
    if ((int)menuItems.size() <= Index)
        menuItems.resize(currentNumItems);
    if (!menuItems[Index]) {
        cNopacityMenuItem *item = new cNopacityScheduleMenuItem(osd, Event, Channel, TimerMatch, Selectable, MenuCategory(), &videoWindowRect);
        cPoint itemSize;
        menuItems[Index].reset(item);
        menuView->GetMenuItemSize(MenuCategory(), &itemSize);
        int spaceTop = menuView->GetMenuTop(currentNumItems, itemSize.Y());
        item->SetGeometry(Index, spaceTop, menuView->GetMenuItemLeft(itemSize.X()), itemSize.X(), itemSize.Y(), geoManager->menuSpace);
        item->SetTextWindow(menuView->GetDescriptionTextWindowSize(mcSchedule));
        item->SetCurrent(Current);
        item->CreateText();
        int textWidth = item->CheckScrollable((Channel)?true:false);
        item->CreatePixmapBackground();
        if (config.GetValue("displayType") == dtGraphical) {
            item->CreatePixmapForeground();
        }
        item->CreatePixmapStatic();
        item->CreatePixmapTextScroller(textWidth);
        item->Render(initial, fadeout);
    } else {
        cNopacityMenuItem *item = menuItems[Index].get();
        item->SetCurrent(Current);
        item->Render();
    }
    return true;
}

bool cNopacityDisplayMenu::SetItemTimer(const cTimer *Timer, int Index, bool Current, bool Selectable) {
    if (!config.GetValue("narrowTimerMenu"))
        return false;
    if ((int)menuItems.size() <= Index)
        menuItems.resize(currentNumItems);
    if (!menuItems[Index]) {
        cNopacityMenuItem *item = new cNopacityTimerMenuItem(osd, Timer, Selectable, &videoWindowRect);
        cPoint itemSize;
        menuItems[Index].reset(item);
        menuView->GetMenuItemSize(MenuCategory(), &itemSize);
        int spaceTop = menuView->GetMenuTop(currentNumItems, itemSize.Y());
        item->SetGeometry(Index, spaceTop, menuView->GetMenuItemLeft(itemSize.X()), itemSize.X(), itemSize.Y(), geoManager->menuSpace);
        item->SetTextWindow(menuView->GetDescriptionTextWindowSize(mcTimer));
        item->SetCurrent(Current);
        item->CreateText();
        int textWidth = item->CheckScrollable(true);
        item->CreatePixmapBackground();
        if (config.GetValue("displayType") == dtGraphical) {
            item->CreatePixmapForeground();
        }
        item->CreatePixmapStatic();
        item->CreatePixmapTextScroller(textWidth);
        item->Render(initial, fadeout);
    } else {
        cNopacityMenuItem *item = menuItems[Index].get();
        item->SetCurrent(Current);
        item->Render();
    }
    return true;
}

bool cNopacityDisplayMenu::SetItemChannel(const cChannel *Channel, int Index, bool Current, bool Selectable, bool WithProvider) {
    if (!config.GetValue("narrowChannelMenu"))
        return false;
    if ((int)menuItems.size() <= Index)
        menuItems.resize(currentNumItems);
    if (!menuItems[Index]) {
        cNopacityMenuItem *item = new cNopacityChannelMenuItem(osd, Channel, Selectable, &videoWindowRect);
        cPoint itemSize;
        menuItems[Index].reset(item);
        menuView->GetMenuItemSize(MenuCategory(), &itemSize);
        int spaceTop = menuView->GetMenuTop(currentNumItems, itemSize.Y());
        item->SetGeometry(Index, spaceTop, menuView->GetMenuItemLeft(itemSize.X()), itemSize.X(), itemSize.Y(), geoManager->menuSpace);
        item->SetTextWindow(menuView->GetDescriptionTextWindowSize(mcChannel));
        item->SetCurrent(Current);
        item->CreateText();
        int textWidth = item->CheckScrollable(true);
        item->CreatePixmapBackground();
        item->CreatePixmapStatic();
        item->CreatePixmapTextScroller(textWidth);
        if (config.GetValue("displayType") == dtGraphical) {
            item->CreatePixmapForeground();
        }
        item->Render(initial, fadeout);
    } else {
        cNopacityMenuItem *item = menuItems[Index].get();
        item->SetCurrent(Current);
        item->Render();
    }
    return true;
}

bool cNopacityDisplayMenu::SetItemRecording(const cRecording *Recording, int Index, bool Current, bool Selectable,
                                            int Level, int Total, int New) {
    if (!config.GetValue("narrowRecordingMenu"))
        return false;
    if ((int)menuItems.size() <= Index)
        menuItems.resize(currentNumItems);
    if (!menuItems[Index]) {
        cNopacityMenuItem *item = new cNopacityRecordingMenuItem(osd, Recording, Selectable, Level, Total, New, &videoWindowRect);
        cPoint itemSize;
        menuItems[Index].reset(item);
        menuView->GetMenuItemSize(MenuCategory(), &itemSize);
        int spaceTop = menuView->GetMenuTop(currentNumItems, itemSize.Y());
        item->SetGeometry(Index, spaceTop, menuView->GetMenuItemLeft(itemSize.X()), itemSize.X(), itemSize.Y(), geoManager->menuSpace);
        item->SetTextWindow(menuView->GetDescriptionTextWindowSize(mcRecording));
        item->SetCurrent(Current);
        item->CreateText();
        item->SetPoster();
        int textWidth = item->CheckScrollable(false);
        item->CreatePixmapBackground();
        item->CreatePixmapStatic();
        item->CreatePixmapTextScroller(textWidth);
        if (config.GetValue("displayType") == dtGraphical) {
            item->CreatePixmapForeground();
        }
        item->Render(initial, fadeout);
    } else {
        cNopacityMenuItem *item = menuItems[Index].get();
        item->SetCurrent(Current);
        item->Render();
    }
    return true;
}


void cNopacityDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Selectable) {
    bool hasIcons = false;
    bool MainOrSetup = false;
    cString *strItems = new cString[MaxTabs];
    int *tabItems = new int[2*MaxTabs];
    for (int i=0; i<MaxTabs; i++) {
        strItems[i] = "";
        tabItems[i] = 0;
        tabItems[i+MaxTabs] = 0;
    }
    SplitItem(Text, strItems, tabItems);
    if ((int)menuItems.size() <= Index)
        menuItems.resize(MaxItems());
    menuItems[Index].reset();
    if (*Text != '\0') {
        cNopacityMenuItem *item;
        cPoint itemSize;
        if (((MenuCategory() == mcMain)&&(config.GetValue("narrowMainMenu"))) || ((MenuCategory() == mcSetup)&&(config.GetValue("narrowSetupMenu")))){
            MainOrSetup = true;
            bool isSetup = (MenuCategory() == mcSetup)?true:false;
            item = new cNopacityMainMenuItem(osd, Text, Selectable, isSetup);
            menuItems[Index].reset(item);
            menuView->GetMenuItemSize(MenuCategory(), &itemSize);
            if (config.GetValue("useMenuIcons"))
                hasIcons = true;
        } else {
            item = new cNopacityDefaultMenuItem(osd, Text, Selectable);
            menuItems[Index].reset(item);
            menuView->GetMenuItemSize(mcUnknown, &itemSize);
        }
        int spaceTop = menuView->GetMenuTop(currentNumItems, itemSize.Y());
        item->SetGeometry(Index, spaceTop, menuView->GetMenuItemLeft(itemSize.X()), itemSize.X(), itemSize.Y(), geoManager->menuSpace);
        item->SetCurrent(Current);
        item->SetTabs(strItems, tabItems, MaxTabs);
        item->CreateText();
        int textWidth = item->CheckScrollable(hasIcons);
        item->CreatePixmapBackground();
        if (config.GetValue("displayType") == dtGraphical && MainOrSetup) {
            item->CreatePixmapForeground();
        }
        item->CreatePixmapStatic();
        if (textWidth > 0)
            item->CreatePixmapTextScroller(textWidth);
        item->Render(initial, fadeout);
    }
    SetEditableWidth(menuView->GetEditableWidth());
}

void cNopacityDisplayMenu::SplitItem(const char *Text, cString *strItems, int *tabItems) {
    int x = 0;
    for (int i = 0; i < MaxTabs; i++) {
        const char *s = GetTabbedText(Text, i);
        if (s) {
            strItems[i] = s;
            tabItems[i] = Tab(i);
        } else {
            if (i>0)
                tabItems[i - 1 + MaxTabs] = menuView->GetWidthDefaultMenu() - x;
            break;
        }
        if (i>0) {
            tabItems[(i-1) + MaxTabs] = Tab(i) - x;
            x += Tab(i) - x;
        }
        if (!Tab(i + 1)) {
            if (s)
                tabItems[i + MaxTabs] = menuView->GetWidthDefaultMenu() - x;
            else if (i==1) {
                tabItems[MaxTabs] = menuView->GetWidthDefaultMenu() - 1;
                tabItems[1] = 0;
                tabItems[MaxTabs+1] = 0;
            }
            break;
        }
    }
}

int cNopacityDisplayMenu::Tab(int n) {
    return (n >= 0 && n < MaxTabs) ? menuView->mytabs[n] : 0;
}

void cNopacityDisplayMenu::SetTabs(int Tab1, int Tab2, int Tab3, int Tab4, int Tab5) {
    menuView->SetTabs(Tab1, Tab2, Tab3, Tab4, Tab5);
}

int cNopacityDisplayMenu::GetTextAreaWidth(void) const {
    return menuView->GetTextAreaWidth();
}

const cFont *cNopacityDisplayMenu::GetTextAreaFont(bool FixedFont) const {
    return menuView->GetTextAreaFont(FixedFont);
}

void cNopacityDisplayMenu::SetScrollbar(int Total, int Offset) {
    if (MaxItems() >= Total) {
        menuView->ClearScrollbar();
        return;
    }
    double height = (double)MaxItems()/(double)Total;
    double offset = (double)Offset/(double)Total;

    menuView->DrawScrollbar(height, offset);
}

void cNopacityDisplayMenu::SetEvent(const cEvent *Event) {
    if (!Event)
        return;
    menuView->AdjustContentBackground(this->MenuCategory(), menuCategoryLast, videoWindowRect);
    detailView = new cNopacityDetailView(osd, Event, menuView->GetPixmapScrollbar(), menuView->GetPixmapScrollbarBack());
    deatilViewRenderDone = false;
}

void cNopacityDisplayMenu::SetRecording(const cRecording *Recording) {
    if (!Recording)
        return;
    const cRecordingInfo *Info = Recording->Info();
    if (!Info) {
        return;
    }
    menuView->AdjustContentBackground(this->MenuCategory(), menuCategoryLast, videoWindowRect);
    detailView = new cNopacityDetailView(osd, Recording, menuView->GetPixmapScrollbar(), menuView->GetPixmapScrollbarBack());
    deatilViewRenderDone = false;
}

void cNopacityDisplayMenu::SetText(const char *Text, bool FixedFont) {
    if (!Text)
        return;
    menuView->AdjustContentBackground(this->MenuCategory(), menuCategoryLast, videoWindowRect);
    detailView = new cNopacityDetailView(osd, Text, menuView->GetPixmapScrollbar(), menuView->GetPixmapScrollbarBack());
    deatilViewRenderDone = false;
}

void cNopacityDisplayMenu::SetAlpha(int Alpha, bool Force) {
    if (menuView && (Force || Running()))
        menuView->SetAlpha(Alpha);
    if (detailView && (Force || Running()))
        detailView->SetAlpha(Alpha);
    for (auto i = menuItems.begin(); i != menuItems.end(); ++i) {
        if (*i && (Force || Running())) {
            cNopacityMenuItem *item = i->get();
            item->SetAlpha(Alpha);
        }
    }
    for (cNopacityTimer *t = timers.First(); (Force || Running()) && t; t = timers.Next(t))
        t->SetAlpha(Alpha);
}

void cNopacityDisplayMenu::Flush(void) {
    if (Running())
        return;

    if (detailView && !deatilViewRenderDone) {
        detailView->Render();
        deatilViewRenderDone = true;
    }
    menuView->DrawDate(initial);
    if (MenuCategory() == mcMain) {
        if (config.GetValue("showDiscUsage"))
            DrawDisk();
        bool timersChanged = true;
        int numConflicts = 0;
        if (config.GetValue("checkTimerConflict"))
            numConflicts = CheckTimerConflict(timersChanged);
        if (config.GetValue("showTimers"))
            DrawTimers(timersChanged, numConflicts);
    }
    if (initial && config.GetValue("animation") && menuFadeTime) {
        if ((MenuCategory() != mcPluginSetup) && (MenuCategory() != mcSetupPlugins)) {
            SetAlpha(0, true);
            Start();
        }
    }
    if (config.GetValue("displayMenuVolume"))
        menuView->DrawVolume();
    osd->Flush();
    initial = false;
    cDevice::PrimaryDevice()->ScaleVideo(videoWindowRect);
}

void cNopacityDisplayMenu::Action(void) {
    int x = (fadeout) ? 255 : 0;
    int FadeTime = (fadeout) ? menuFadeOutTime : menuFadeTime;
    int FrameTime = FadeTime / 10;
    uint64_t First = cTimeMs::Now();
    cPixmap::Lock();
    cPixmap::Unlock();
    uint64_t Start = cTimeMs::Now();
    dsyslog ("skinnopacity: First Lock(): %lims\n", 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;
    }
}