summaryrefslogtreecommitdiff
path: root/browserGrid.h
blob: ee621703ce8df6307b59fb7d6f7a9937a376f315 (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
#ifndef CBROWSERGRID_H
#define CBROWSERGRID_H

#include <memory>
#include <vector>
#include <functional>
#include "Plexservice.h"
#include "plexgdm.h"
#include "PlexServer.h"
#include "viewGridNavigator.h"
#include "sdGenericViewElements.h"
//#include "viewHeader.h"
#include <libskindesignerapi/osdelements.h>

class cDummyElement : public cGridElement {
private:
    std::string m_title;

public:
    cDummyElement(std::string title);

    cDummyElement();

    virtual std::string GetTitle();

    virtual void AddTokens(std::shared_ptr<skindesignerapi::cOsdElement> grid, bool clear = true,
                           std::function<void(cGridElement *)> OnCached = NULL);
};

class cServerElement : public cGridElement {
private:
    plexclient::PlexServer *m_pServer;
    std::string m_sStartPath;
    std::string m_sStartName;
public:
    cServerElement(plexclient::PlexServer *server, std::string startPath, std::string startName);

    virtual std::string GetTitle();

    virtual void AddTokens(std::shared_ptr<skindesignerapi::cOsdElement> grid, bool clear = true,
                           std::function<void(cGridElement *)> OnCached = NULL);

    std::string StartPath() { return m_sStartPath; }

    plexclient::PlexServer *Server() { return m_pServer; }
};

class cBrowserGrid : public cViewGridNavigator, public cSdClock {
private:
    //std::shared_ptr<cViewHeader> m_pViewHeader;
    std::shared_ptr<skindesignerapi::cViewElement> m_pHeader;
    std::shared_ptr<skindesignerapi::cViewElement> m_pBackground;
    std::shared_ptr<skindesignerapi::cViewElement> m_pfooter;
    std::shared_ptr<skindesignerapi::cViewElement> m_pInfopane;

    int m_viewEntryIndex;
    bool m_redrawBackground;

    bool m_bServersAreRoot;
    std::vector<cServerElement> m_vServerElements;
    std::shared_ptr<plexclient::MediaContainer> m_pContainer;
    std::shared_ptr<plexclient::Plexservice> m_pService;
    cDummyElement m_Dummy;

    void ProcessData();

    void SetServerElements();

    void DrawFooter();

    void DrawBackground();

    void DrawInfopane();

public:
    cBrowserGrid(std::shared_ptr<skindesignerapi::cOsdView> rootView);

    ~cBrowserGrid();

    //cBrowserGrid(skindesignerapi::cViewGrid* viewGrid, std::shared_ptr<plexclient::Plexservice> service);
    std::shared_ptr<plexclient::MediaContainer> MediaContainer() { return m_pContainer; }

    void DrawGrid();

    void SwitchGrid(int index);

    void SwitchView(ViewMode mode = Config::GetInstance().DefaultViewMode);

    void NextViewMode();

    virtual eOSState NavigateSelect();

    virtual eOSState NavigateBack();

    void NextTab();

    void PrevTab();

    virtual void Flush();

    virtual void Clear();
};

#endif // CBROWSERGRID_H