summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchriszero <zerov83@gmail.com>2016-04-03 20:01:36 +0200
committerChristian <zerov83@gmail.com>2016-04-03 20:01:36 +0200
commit82d13a0734c8a11347d50fcc5ad341c8eb1b7a43 (patch)
treebddcb812134c0e56cdc04d602c2252031a3f49bb
parent6fc296295f0579d730a61070c40d5e05a34be787 (diff)
downloadvdr-plugin-plex-82d13a0734c8a11347d50fcc5ad341c8eb1b7a43.tar.gz
vdr-plugin-plex-82d13a0734c8a11347d50fcc5ad341c8eb1b7a43.tar.bz2
Removed some duplicate code.
-rw-r--r--Makefile3
-rw-r--r--browserGrid.cpp71
-rw-r--r--browserGrid.h11
-rw-r--r--detailView.cpp71
-rw-r--r--detailView.h10
-rw-r--r--plexSdOsd.cpp2
-rw-r--r--sdGenericViewElements.cpp52
-rw-r--r--sdGenericViewElements.h24
-rw-r--r--viewGridNavigator.cpp28
-rw-r--r--viewGridNavigator.h6
10 files changed, 126 insertions, 152 deletions
diff --git a/Makefile b/Makefile
index 55c4098..2acf3ff 100644
--- a/Makefile
+++ b/Makefile
@@ -104,7 +104,8 @@ OBJS += plexSdOsd.o \
viewHeader.o \
detailView.o \
pictureCache.o \
- displayReplaySD.o
+ displayReplaySD.o \
+ sdGenericViewElements.o
endif
SRCS = $(wildcard $(OBJS:.o=.c)) $(PLUGIN).cpp
diff --git a/browserGrid.cpp b/browserGrid.cpp
index 8cebb83..d4cde96 100644
--- a/browserGrid.cpp
+++ b/browserGrid.cpp
@@ -7,7 +7,11 @@
#include "pictureCache.h"
#include "tokendefinitions.h"
-cBrowserGrid::cBrowserGrid(std::shared_ptr<skindesignerapi::cOsdView> rootView) : cViewGridNavigator(rootView) {
+cBrowserGrid::cBrowserGrid(std::shared_ptr<skindesignerapi::cOsdView> rootView)
+ : cViewGridNavigator(rootView, std::shared_ptr<skindesignerapi::cViewElement>(
+ rootView->GetViewElement((int) eViewElementsRoot::scrollbar))),
+ cSdClock(std::shared_ptr<skindesignerapi::cViewElement>(
+ rootView->GetViewElement((int) eViewElementsRoot::watch))) {
m_pBackground = std::shared_ptr<skindesignerapi::cViewElement>(
rootView->GetViewElement((int) eViewElementsRoot::background));
m_pHeader = std::shared_ptr<skindesignerapi::cViewElement>(
@@ -16,10 +20,6 @@ cBrowserGrid::cBrowserGrid(std::shared_ptr<skindesignerapi::cOsdView> rootView)
rootView->GetViewElement((int) eViewElementsRoot::footer));
m_pInfopane = std::shared_ptr<skindesignerapi::cViewElement>(
rootView->GetViewElement((int) eViewElementsRoot::infopane));
- m_pWatch = std::shared_ptr<skindesignerapi::cViewElement>(rootView->GetViewElement((int) eViewElementsRoot::watch));
- m_pScrollbar = std::shared_ptr<skindesignerapi::cViewElement>(
- rootView->GetViewElement((int) eViewElementsRoot::scrollbar));
- m_lastsecond = 0;
m_pService = NULL;
m_pContainer = NULL;
@@ -347,30 +347,6 @@ void cBrowserGrid::DrawFooter() {
m_pfooter->Display();
}
-void cBrowserGrid::DrawScrollbar() {
- m_pScrollbar->Clear();
- m_pScrollbar->ClearTokens();
-
- if ((int) m_vElements.size() > (m_columns * m_rows)) {
- int currentRow = SelectedObject()->AbsolutePosition / m_columns;
- int totalRows = ceil((double) m_vElements.size() / m_columns);
-
- int scrollBarHeight = 100.0 / totalRows * m_rows;
-
- int offset = 100.0 / totalRows * currentRow;
- if (offset >= 100 - scrollBarHeight) {
- offset = 100.0 - scrollBarHeight;
- }
- m_pScrollbar->AddIntToken((int) eTokenScrollbarInt::height, scrollBarHeight);
- m_pScrollbar->AddIntToken((int) eTokenScrollbarInt::offset, offset);
- m_pScrollbar->AddIntToken((int) eTokenScrollbarInt::hasscrollbar, true);
- } else {
- m_pScrollbar->AddIntToken((int) eTokenScrollbarInt::hasscrollbar, false);
- }
-
- m_pScrollbar->Display();
-}
-
void cBrowserGrid::NextTab() {
m_viewEntryIndex++;
if (m_viewEntryIndex > (int) Config::GetInstance().m_viewentries.size()) {
@@ -387,43 +363,6 @@ void cBrowserGrid::PrevTab() {
SwitchGrid(m_viewEntryIndex);
}
-bool cBrowserGrid::DrawTime() {
- time_t t = time(0); // get time now
- struct tm *now = localtime(&t);
- int sec = now->tm_sec;
- if (sec == m_lastsecond)
- return false;
-
- int min = now->tm_min;
- int hour = now->tm_hour;
- int hourMinutes = hour % 12 * 5 + min / 12;
-
- char monthname[20];
- char monthshort[10];
- strftime(monthshort, sizeof(monthshort), "%b", now);
- strftime(monthname, sizeof(monthname), "%B", now);
-
- m_pWatch->Clear();
- m_pWatch->ClearTokens();
- m_pWatch->AddIntToken((int) eTokenTimeInt::sec, sec);
- m_pWatch->AddIntToken((int) eTokenTimeInt::min, min);
- m_pWatch->AddIntToken((int) eTokenTimeInt::hour, hour);
- m_pWatch->AddIntToken((int) eTokenTimeInt::hmins, hourMinutes);
- m_pWatch->AddIntToken((int) eTokenTimeInt::year, now->tm_year + 1900);
- m_pWatch->AddIntToken((int) eTokenTimeInt::day, now->tm_mday);
- m_pWatch->AddStringToken((int) eTokenTimeStr::time, *TimeString(t));
- m_pWatch->AddStringToken((int) eTokenTimeStr::monthname, monthname);
- m_pWatch->AddStringToken((int) eTokenTimeStr::monthnameshort, monthshort);
- m_pWatch->AddStringToken((int) eTokenTimeStr::month, *cString::sprintf("%02d", now->tm_mon + 1));
- m_pWatch->AddStringToken((int) eTokenTimeStr::dayleadingzero, *cString::sprintf("%02d", now->tm_mday));
- m_pWatch->AddStringToken((int) eTokenTimeStr::dayname, *WeekDayNameFull(now->tm_wday));
- m_pWatch->AddStringToken((int) eTokenTimeStr::daynameshort, *WeekDayName(now->tm_wday));
- m_pWatch->Display();
-
- m_lastsecond = sec;
- return true;
-}
-
/*
* cDummyElement
*/
diff --git a/browserGrid.h b/browserGrid.h
index 19cd501..ee62170 100644
--- a/browserGrid.h
+++ b/browserGrid.h
@@ -8,6 +8,7 @@
#include "plexgdm.h"
#include "PlexServer.h"
#include "viewGridNavigator.h"
+#include "sdGenericViewElements.h"
//#include "viewHeader.h"
#include <libskindesignerapi/osdelements.h>
@@ -44,16 +45,14 @@ public:
plexclient::PlexServer *Server() { return m_pServer; }
};
-class cBrowserGrid : public cViewGridNavigator {
+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;
- std::shared_ptr<skindesignerapi::cViewElement> m_pScrollbar;
- std::shared_ptr<skindesignerapi::cViewElement> m_pWatch;
- int m_lastsecond;
+
int m_viewEntryIndex;
bool m_redrawBackground;
@@ -73,8 +72,6 @@ private:
void DrawInfopane();
- void DrawScrollbar();
-
public:
cBrowserGrid(std::shared_ptr<skindesignerapi::cOsdView> rootView);
@@ -99,8 +96,6 @@ public:
void PrevTab();
- bool DrawTime();
-
virtual void Flush();
virtual void Clear();
diff --git a/detailView.cpp b/detailView.cpp
index f44869d..2d1ae3f 100644
--- a/detailView.cpp
+++ b/detailView.cpp
@@ -2,17 +2,17 @@
#include "Config.h"
cDetailView::cDetailView(std::shared_ptr<skindesignerapi::cOsdView> detailView, plexclient::cVideo *video)
- : cViewGridNavigator(detailView) {
+ : cViewGridNavigator(detailView, std::shared_ptr<skindesignerapi::cViewElement>(
+ detailView->GetViewElement((int) eViewElementsDetail::scrollbar))),
+ cSdClock(std::shared_ptr<skindesignerapi::cViewElement>(
+ detailView->GetViewElement((int) eViewElementsDetail::watch))) {
+
m_pBackground = std::shared_ptr<skindesignerapi::cViewElement>(
detailView->GetViewElement((int) eViewElementsDetail::background));
m_pfooter = std::shared_ptr<skindesignerapi::cViewElement>(
detailView->GetViewElement((int) eViewElementsDetail::footer));
m_pInfo = std::shared_ptr<skindesignerapi::cViewElement>(
detailView->GetViewElement((int) eViewElementsDetail::info));
- m_pScrollbar = std::shared_ptr<skindesignerapi::cViewElement>(
- detailView->GetViewElement((int) eViewElementsDetail::scrollbar));
- m_pWatch = std::shared_ptr<skindesignerapi::cViewElement>(
- detailView->GetViewElement((int) eViewElementsDetail::watch));
m_pVideo = video;
m_drawall = true;
@@ -135,67 +135,6 @@ void cDetailView::DrawInfo() {
m_pInfo->Display();
}
-void cDetailView::DrawScrollbar() {
- m_pScrollbar->Clear();
- m_pScrollbar->ClearTokens();
-
- if ((int) m_vElements.size() > (m_columns * m_rows)) {
- int currentRow = SelectedObject()->AbsolutePosition / m_columns;
- int totalRows = ceil((double) m_vElements.size() / m_columns);
-
- int scrollBarHeight = 100.0 / totalRows * m_rows;
-
- int offset = 100.0 / totalRows * currentRow;
- if (offset >= 100 - scrollBarHeight) {
- offset = 100.0 - scrollBarHeight;
- }
- m_pScrollbar->AddIntToken((int) eTokenScrollbarInt::height, scrollBarHeight);
- m_pScrollbar->AddIntToken((int) eTokenScrollbarInt::offset, offset);
- m_pScrollbar->AddIntToken((int) eTokenScrollbarInt::hasscrollbar, true);
- } else {
- m_pScrollbar->AddIntToken((int) eTokenScrollbarInt::hasscrollbar, false);
- }
-
- m_pScrollbar->Display();
-}
-
-bool cDetailView::DrawTime() {
- time_t t = time(0); // get time now
- struct tm *now = localtime(&t);
- int sec = now->tm_sec;
- if (sec == m_lastsecond)
- return false;
-
- int min = now->tm_min;
- int hour = now->tm_hour;
- int hourMinutes = hour % 12 * 5 + min / 12;
-
- char monthname[20];
- char monthshort[10];
- strftime(monthshort, sizeof(monthshort), "%b", now);
- strftime(monthname, sizeof(monthname), "%B", now);
-
- m_pWatch->Clear();
- m_pWatch->ClearTokens();
- m_pWatch->AddIntToken((int) eTokenTimeInt::sec, sec);
- m_pWatch->AddIntToken((int) eTokenTimeInt::min, min);
- m_pWatch->AddIntToken((int) eTokenTimeInt::hour, hour);
- m_pWatch->AddIntToken((int) eTokenTimeInt::hmins, hourMinutes);
- m_pWatch->AddIntToken((int) eTokenTimeInt::year, now->tm_year + 1900);
- m_pWatch->AddIntToken((int) eTokenTimeInt::day, now->tm_mday);
- m_pWatch->AddStringToken((int) eTokenTimeStr::time, *TimeString(t));
- m_pWatch->AddStringToken((int) eTokenTimeStr::monthname, monthname);
- m_pWatch->AddStringToken((int) eTokenTimeStr::monthnameshort, monthshort);
- m_pWatch->AddStringToken((int) eTokenTimeStr::month, *cString::sprintf("%02d", now->tm_mon + 1));
- m_pWatch->AddStringToken((int) eTokenTimeStr::dayleadingzero, *cString::sprintf("%02d", now->tm_mday));
- m_pWatch->AddStringToken((int) eTokenTimeStr::dayname, *WeekDayNameFull(now->tm_wday));
- m_pWatch->AddStringToken((int) eTokenTimeStr::daynameshort, *WeekDayName(now->tm_wday));
- m_pWatch->Display();
-
- m_lastsecond = sec;
- return true;
-}
-
eOSState cDetailView::NavigateSelect() {
if (m_setIterator) return eOSState::osContinue;
diff --git a/detailView.h b/detailView.h
index bf0eb33..feb73e2 100644
--- a/detailView.h
+++ b/detailView.h
@@ -5,10 +5,11 @@
#include "PVideo.h"
#include "tokendefinitions.h"
+#include "sdGenericViewElements.h"
#include <libskindesignerapi/osdelements.h>
#include <libskindesignerapi/skindesignerosdbase.h>
-class cDetailView : public cViewGridNavigator {
+class cDetailView : public cViewGridNavigator, public cSdClock {
public:
cDetailView(std::shared_ptr<skindesignerapi::cOsdView> detailView, plexclient::cVideo *video);
@@ -24,26 +25,19 @@ public:
virtual void Clear();
- bool DrawTime();
-
private:
std::shared_ptr<skindesignerapi::cViewElement> m_pBackground;
std::shared_ptr<skindesignerapi::cViewElement> m_pfooter;
std::shared_ptr<skindesignerapi::cViewElement> m_pInfo;
- std::shared_ptr<skindesignerapi::cViewElement> m_pScrollbar;
- std::shared_ptr<skindesignerapi::cViewElement> m_pWatch;
plexclient::cVideo *m_pVideo;
bool m_drawall;
- int m_lastsecond;
void DrawBackground();
void DrawFooter();
void DrawInfo();
-
- void DrawScrollbar();
};
#endif // CDETAILVIEW_H
diff --git a/plexSdOsd.cpp b/plexSdOsd.cpp
index f7f1228..0091ff1 100644
--- a/plexSdOsd.cpp
+++ b/plexSdOsd.cpp
@@ -225,7 +225,7 @@ void cPlexSdOsd::ShowDetails(plexclient::cVideo *vid) {
m_pBrowserGrid->Deactivate(true);
m_pDetailsView = std::shared_ptr<skindesignerapi::cOsdView>(GetOsdView((int) eViews::detailView));
- m_pDetailGrid = std::shared_ptr<cDetailView>(new cDetailView(m_pDetailsView, vid));
+ m_pDetailGrid = std::make_shared<cDetailView>(m_pDetailsView, vid);
m_pDetailGrid->Activate();
m_pDetailGrid->Draw();
diff --git a/sdGenericViewElements.cpp b/sdGenericViewElements.cpp
new file mode 100644
index 0000000..8b1562d
--- /dev/null
+++ b/sdGenericViewElements.cpp
@@ -0,0 +1,52 @@
+//
+// Created by chris on 03.04.16.
+//
+
+#include "sdGenericViewElements.h"
+#include "tokendefinitions.h"
+
+cSdClock::cSdClock(std::shared_ptr<skindesignerapi::cViewElement> pViewelement) {
+ m_pWatch = pViewelement;
+}
+
+bool cSdClock::DrawTime() {
+ time_t t = time(0); // get time now
+ struct tm *now = localtime(&t);
+ int sec = now->tm_sec;
+ if (sec == m_lastsecond)
+ return false;
+
+ int min = now->tm_min;
+ int hour = now->tm_hour;
+ int hourMinutes = hour % 12 * 5 + min / 12;
+
+ char monthname[20];
+ char monthshort[10];
+ strftime(monthshort, sizeof(monthshort), "%b", now);
+ strftime(monthname, sizeof(monthname), "%B", now);
+
+ m_pWatch->Clear();
+ m_pWatch->ClearTokens();
+ m_pWatch->AddIntToken((int) eTokenTimeInt::sec, sec);
+ m_pWatch->AddIntToken((int) eTokenTimeInt::min, min);
+ m_pWatch->AddIntToken((int) eTokenTimeInt::hour, hour);
+ m_pWatch->AddIntToken((int) eTokenTimeInt::hmins, hourMinutes);
+ m_pWatch->AddIntToken((int) eTokenTimeInt::year, now->tm_year + 1900);
+ m_pWatch->AddIntToken((int) eTokenTimeInt::day, now->tm_mday);
+ m_pWatch->AddStringToken((int) eTokenTimeStr::time, *TimeString(t));
+ m_pWatch->AddStringToken((int) eTokenTimeStr::monthname, monthname);
+ m_pWatch->AddStringToken((int) eTokenTimeStr::monthnameshort, monthshort);
+ m_pWatch->AddStringToken((int) eTokenTimeStr::month, *cString::sprintf("%02d", now->tm_mon + 1));
+ m_pWatch->AddStringToken((int) eTokenTimeStr::dayleadingzero, *cString::sprintf("%02d", now->tm_mday));
+ m_pWatch->AddStringToken((int) eTokenTimeStr::dayname, *WeekDayNameFull(now->tm_wday));
+ m_pWatch->AddStringToken((int) eTokenTimeStr::daynameshort, *WeekDayName(now->tm_wday));
+ m_pWatch->Display();
+
+ m_lastsecond = sec;
+ return true;
+
+}
+
+
+
+
diff --git a/sdGenericViewElements.h b/sdGenericViewElements.h
new file mode 100644
index 0000000..a5cf3cd
--- /dev/null
+++ b/sdGenericViewElements.h
@@ -0,0 +1,24 @@
+//
+// Created by chris on 03.04.16.
+//
+
+#ifndef VDR_PLUGIN_PLEX_SDGENERICVIEWELEMENTS_H
+#define VDR_PLUGIN_PLEX_SDGENERICVIEWELEMENTS_H
+
+#include <memory>
+#include <libskindesignerapi/osdelements.h>
+
+class cSdClock {
+private:
+ int m_lastsecond = 0;
+
+protected:
+ std::shared_ptr<skindesignerapi::cViewElement> m_pWatch = nullptr;
+
+public:
+ cSdClock(std::shared_ptr<skindesignerapi::cViewElement> pViewelement);
+
+ bool DrawTime();
+};
+
+#endif //VDR_PLUGIN_PLEX_SDGENERICVIEWELEMENTS_H
diff --git a/viewGridNavigator.cpp b/viewGridNavigator.cpp
index 8bd5b5b..1469856 100644
--- a/viewGridNavigator.cpp
+++ b/viewGridNavigator.cpp
@@ -12,7 +12,8 @@ cGridElement::cGridElement() {
m_bInit = true;
}
-cViewGridNavigator::cViewGridNavigator(std::shared_ptr<skindesignerapi::cOsdView> rootView) {
+cViewGridNavigator::cViewGridNavigator(std::shared_ptr<skindesignerapi::cOsdView> rootView,
+ std::shared_ptr<skindesignerapi::cViewElement> pScrollbar) {
m_columns = 2;
m_rows = 2;
m_startIndex = 0;
@@ -23,6 +24,7 @@ cViewGridNavigator::cViewGridNavigator(std::shared_ptr<skindesignerapi::cOsdView
m_pGrid = NULL;
m_pRootView = rootView;
+ m_pScrollbar = pScrollbar;
}
void cViewGridNavigator::SetViewGrid(std::shared_ptr<skindesignerapi::cViewGrid> grid) {
@@ -261,3 +263,27 @@ void cViewGridNavigator::Activate() {
m_bHidden = false;
}
}
+
+void cViewGridNavigator::DrawScrollbar() {
+ m_pScrollbar->Clear();
+ m_pScrollbar->ClearTokens();
+
+ if ((int) m_vElements.size() > (m_columns * m_rows)) {
+ int currentRow = SelectedObject()->AbsolutePosition / m_columns;
+ int totalRows = ceil((double) m_vElements.size() / m_columns);
+
+ int scrollBarHeight = 100.0 / totalRows * m_rows;
+
+ int offset = 100.0 / totalRows * currentRow;
+ if (offset >= 100 - scrollBarHeight) {
+ offset = 100.0 - scrollBarHeight;
+ }
+ m_pScrollbar->AddIntToken((int) eTokenScrollbarInt::height, scrollBarHeight);
+ m_pScrollbar->AddIntToken((int) eTokenScrollbarInt::offset, offset);
+ m_pScrollbar->AddIntToken((int) eTokenScrollbarInt::hasscrollbar, true);
+ } else {
+ m_pScrollbar->AddIntToken((int) eTokenScrollbarInt::hasscrollbar, false);
+ }
+
+ m_pScrollbar->Display();
+}
diff --git a/viewGridNavigator.h b/viewGridNavigator.h
index 8cfd259..63db45a 100644
--- a/viewGridNavigator.h
+++ b/viewGridNavigator.h
@@ -55,6 +55,7 @@ protected:
std::shared_ptr<skindesignerapi::cOsdView> m_pRootView;
std::shared_ptr<skindesignerapi::cViewGrid> m_pGrid;
+ std::shared_ptr<skindesignerapi::cViewElement> m_pScrollbar = nullptr;
bool m_newDimensions;
bool m_setIterator;
@@ -70,7 +71,8 @@ protected:
void SetViewGrid(std::shared_ptr<skindesignerapi::cViewGrid> grid);
public:
- cViewGridNavigator(std::shared_ptr<skindesignerapi::cOsdView> rootView);
+ cViewGridNavigator(std::shared_ptr<skindesignerapi::cOsdView> rootView,
+ std::shared_ptr<skindesignerapi::cViewElement> pScrollbar);
void SetGridDimensions(int rows, int columns);
@@ -100,6 +102,8 @@ public:
virtual void Deactivate(bool hide);
virtual void Activate();
+
+ void DrawScrollbar();
};
#endif // cViewGridNAVIGATOR_H