summaryrefslogtreecommitdiff
path: root/displaytracks.c
blob: bdc4105ea363585397469dc4c9e097c88d058cc3 (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
#include "displaytracks.h"

cFlatDisplayTracks::cFlatDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks) {

    CreateFullOsd();
    TopBarCreate();

    itemHeight = fontHeight + 2;
    currentIndex = -1;
    maxItemWidth = font->Width(Title) + marginItem*2;
    for (int i = 0; i < NumTracks; i++)
        maxItemWidth = max(maxItemWidth, font->Width(Tracks[i]) + marginItem*2);

    int itemsHeight = NumTracks * itemHeight;
    int left = osdWidth - maxItemWidth;
    left /= 2;
    TopBarSetTitle(Title);

    tracksPixmap = osd->CreatePixmap(1, cRect(left, osdHeight - itemsHeight - marginItem, maxItemWidth, itemsHeight));
    tracksPixmap->Fill(clrTransparent);

    for (int i = 0; i < NumTracks; i++)
        SetItem(Tracks[i], i, false);
}

cFlatDisplayTracks::~cFlatDisplayTracks() {
    osd->DestroyPixmap(tracksPixmap);
}

void cFlatDisplayTracks::SetItem(const char *Text, int Index, bool Current) {
    int y = Index * itemHeight;
    tColor ColorFg, ColorBg;
    if (Current) {
        ColorFg = Theme.Color(clrTrackItemCurrentFont);
        ColorBg = Theme.Color(clrTrackItemCurrentBg);
        currentIndex = Index;
    }
    else {
        ColorFg = Theme.Color(clrTrackItemFont);
        ColorBg = Theme.Color(clrTrackItemBg);
    }
    tracksPixmap->DrawText(cPoint(0, y), Text, ColorFg, ColorBg, font, maxItemWidth, itemHeight - 2, taCenter);
}

void cFlatDisplayTracks::SetTrack(int Index, const char * const *Tracks) {
    if (currentIndex >= 0)
        SetItem(Tracks[currentIndex], currentIndex, false);
    SetItem(Tracks[Index], Index, true);
}

void cFlatDisplayTracks::SetAudioChannel(int AudioChannel) {
    return;
}

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