summaryrefslogtreecommitdiff
path: root/browserGrid.h
blob: 549c0812b35efa71c517a411f5f41998b1e28314 (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
#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 "viewHeader.h"
#include <libskindesignerapi/osdelements.h>

class cDummyElement : public cGridElement
{
public:
	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
{
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;
	std::shared_ptr<skindesignerapi::cViewElement> m_pScrollbar;
	std::shared_ptr<skindesignerapi::cViewElement> m_pWatch;
	int m_lastsecond;
	int m_viewEntryIndex;

	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();
	void DrawScrollbar();
	
public:
	cBrowserGrid(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();
	bool DrawTime();
	virtual void Flush();
	virtual void Clear();
};

#endif // CBROWSERGRID_H