diff options
author | chriszero <zerov83@gmail.com> | 2015-05-19 19:06:22 +0200 |
---|---|---|
committer | chriszero <zerov83@gmail.com> | 2015-05-19 19:06:22 +0200 |
commit | 86cfa7fa64406971990160db56b71c7a71dcf3e5 (patch) | |
tree | 8f6d5ba092b16c1c282cd7519a45753bad4be894 | |
parent | d15cd5a30174c7864051d42ba58cd31570fc8ed5 (diff) | |
download | vdr-plugin-plex-86cfa7fa64406971990160db56b71c7a71dcf3e5.tar.gz vdr-plugin-plex-86cfa7fa64406971990160db56b71c7a71dcf3e5.tar.bz2 |
- Dedicicated grid for each viewmode
-rw-r--r-- | browserGrid.cpp | 53 | ||||
-rw-r--r-- | browserGrid.h | 1 | ||||
-rw-r--r-- | plex.cpp | 5 | ||||
-rw-r--r-- | plexSdOsd.h | 7 | ||||
-rw-r--r-- | skins/blackhole/xmlfiles/plug-plex-root.xml | 96 | ||||
-rw-r--r-- | templates/plug-plex-root.xml | 10 | ||||
-rw-r--r-- | viewGridNavigator.cpp | 17 | ||||
-rw-r--r-- | viewGridNavigator.h | 3 |
8 files changed, 175 insertions, 17 deletions
diff --git a/browserGrid.cpp b/browserGrid.cpp index e336fee..b3d5341 100644 --- a/browserGrid.cpp +++ b/browserGrid.cpp @@ -6,19 +6,32 @@ #include "plex.h" #include "pictureCache.h" -cBrowserGrid::cBrowserGrid(skindesignerapi::cOsdView* rootView) : cViewGridNavigator(rootView, rootView->GetViewGrid(eViewGrids::vgBrowser) ) +cBrowserGrid::cBrowserGrid(skindesignerapi::cOsdView* rootView) : cViewGridNavigator(rootView) { m_pBackground = std::shared_ptr<skindesignerapi::cViewElement>(rootView->GetViewElement(eViewElementsRoot::verBackground)); - //m_pViewHeader = std::shared_ptr<cViewHeader>( new cViewHeader(rootView->GetViewElement(eViewElementsRoot::verHeader))); m_pHeader = std::shared_ptr<skindesignerapi::cViewElement>(rootView->GetViewElement(eViewElementsRoot::verHeader)); m_pfooter = std::shared_ptr<skindesignerapi::cViewElement>(rootView->GetViewElement(eViewElementsRoot::verFooter)); m_pInfopane = std::shared_ptr<skindesignerapi::cViewElement>(rootView->GetViewElement(eViewElementsRoot::verInfopane)); m_pWatch = std::shared_ptr<skindesignerapi::cViewElement>(rootView->GetViewElement(eViewElementsRoot::verWatch)); + m_pScrollbar = std::shared_ptr<skindesignerapi::cViewElement>(rootView->GetViewElement(eViewElementsRoot::verScrollbar)); m_lastsecond = 0; m_pService = NULL; m_pContainer = NULL; m_viewEntryIndex = 0; + + Config *conf = &Config::GetInstance(); + if(conf->DefaultViewMode == ViewMode::Cover) { + SetViewGrid(std::shared_ptr<skindesignerapi::cViewGrid>(m_pRootView->GetViewGrid(eViewGrids::vgCover) )); + SetGridDimensions(conf->CoverGridRows, conf->CoverGridColumns); + } else if(conf->DefaultViewMode == ViewMode::Detail) { + SetViewGrid(std::shared_ptr<skindesignerapi::cViewGrid>(m_pRootView->GetViewGrid(eViewGrids::vgDetail) )); + SetGridDimensions(conf->DetailGridRows, conf->DetailGridColumns); + } else if(conf->DefaultViewMode == ViewMode::List) { + SetViewGrid(std::shared_ptr<skindesignerapi::cViewGrid>(m_pRootView->GetViewGrid(eViewGrids::vgList) )); + SetGridDimensions(conf->ListGridRows, conf->ListGridColumns); + } + SwitchGrid(m_viewEntryIndex); SwitchView(); } @@ -52,23 +65,26 @@ void cBrowserGrid::SwitchView(ViewMode mode) Config *conf = &Config::GetInstance(); conf->DefaultViewMode = mode; if(conf->DefaultViewMode == ViewMode::Cover) { + SetViewGrid(std::shared_ptr<skindesignerapi::cViewGrid>(m_pRootView->GetViewGrid(eViewGrids::vgCover) )); SetGridDimensions(conf->CoverGridRows, conf->CoverGridColumns); } else if(conf->DefaultViewMode == ViewMode::Detail) { + SetViewGrid(std::shared_ptr<skindesignerapi::cViewGrid>(m_pRootView->GetViewGrid(eViewGrids::vgDetail) )); SetGridDimensions(conf->DetailGridRows, conf->DetailGridColumns); } else if(conf->DefaultViewMode == ViewMode::List) { + SetViewGrid(std::shared_ptr<skindesignerapi::cViewGrid>(m_pRootView->GetViewGrid(eViewGrids::vgList) )); SetGridDimensions(conf->ListGridRows, conf->ListGridColumns); } int activePos = SelectedObject()->AbsolutePosition; //ProcessData(); - + for(std::vector<cGridElement*>::iterator it = m_vElements.begin(); it != m_vElements.end(); ++it) { cGridElement *elem = *it; elem->Position = -1; elem->Dirty(); elem->SetPosition(-1,-1); } - + m_pGrid->Clear(); m_firstElementIter = m_vElements.begin() + activePos; m_setIterator = true; @@ -155,13 +171,13 @@ void cBrowserGrid::ProcessData() } } } - + int pos = 0; for(std::vector<cGridElement*>::iterator it = m_vElements.begin(); it != m_vElements.end(); ++it) { cGridElement *elem = *it; elem->AbsolutePosition = pos++; } - + m_firstElementIter = m_vElements.begin(); m_pGrid->Clear(); @@ -222,7 +238,7 @@ void cBrowserGrid::DrawGrid() void cBrowserGrid::DrawBackground() { m_pBackground->ClearTokens(); - + auto video = dynamic_cast<plexclient::Video*>(SelectedObject()); if(video) { bool cached = false; @@ -311,6 +327,29 @@ void cBrowserGrid::DrawFooter() m_pfooter->Display(); } +void cBrowserGrid::DrawScrollbar() +{ + /* + if (m_vElements.size() == 0) + return; + int scrollBarHeight = (double)m_rows / (double)m_vElements.size() * 1000; + + // in welcher Zeile sind wir? + int currentRow = SelectedObject()->AbsolutePosition / m_columns; + + int offset = (double)startPos / (double)m_vElements.size() * 1000; + m_pScrollbar->Clear(); + m_pScrollbar->ClearTokens(); + + int y = (100 - GetHeight())/2; + + m_pScrollbar->AddIntToken("posy", y); + m_pScrollbar->AddIntToken("totalheight", menuHeight); + m_pScrollbar->AddIntToken("height", scrollBarHeight); + m_pScrollbar->AddIntToken("offset", offset); + m_pScrollbar->Display();*/ +} + void cBrowserGrid::NextTab() { m_viewEntryIndex++; diff --git a/browserGrid.h b/browserGrid.h index b337a0b..549c081 100644 --- a/browserGrid.h +++ b/browserGrid.h @@ -56,6 +56,7 @@ private: void DrawFooter(); void DrawBackground(); void DrawInfopane(); + void DrawScrollbar(); public: cBrowserGrid(skindesignerapi::cOsdView* rootView); @@ -63,13 +63,16 @@ bool cMyPlugin::Start(void) reg.libskindesignerAPIVersion = LIBSKINDESIGNERAPIVERSION; reg.SetView(viRootView, "root.xml"); - reg.SetViewGrid(eViews::viRootView, eViewGrids::vgBrowser, "browser"); + reg.SetViewGrid(eViews::viRootView, eViewGrids::vgCover, "coverbrowser"); + reg.SetViewGrid(eViews::viRootView, eViewGrids::vgList, "listbrowser"); + reg.SetViewGrid(eViews::viRootView, eViewGrids::vgDetail, "detailbrowser"); reg.SetViewElement(viRootView, verHeader, "header"); reg.SetViewElement(viRootView, verBackground, "background"); reg.SetViewElement(viRootView, verInfopane, "infopane"); reg.SetViewElement(viRootView, verFooter, "footer"); reg.SetViewElement(viRootView, verWatch, "time"); reg.SetViewElement(viRootView, verMessage, "message"); + reg.SetViewElement(viRootView, verScrollbar, "scrollbar"); /* reg.SetSubView(viRootView, viDetailView, "detail.xml"); reg.SetViewElement(viDetailView, vedBackground, "background"); diff --git a/plexSdOsd.h b/plexSdOsd.h index 706ee33..8b2c33e 100644 --- a/plexSdOsd.h +++ b/plexSdOsd.h @@ -31,11 +31,14 @@ enum eViewElementsRoot { verFooter, verInfopane, verWatch, - verMessage + verMessage, + verScrollbar }; enum eViewGrids { - vgBrowser + vgCover, + vgDetail, + vgList }; enum eViewElementsDetail { diff --git a/skins/blackhole/xmlfiles/plug-plex-root.xml b/skins/blackhole/xmlfiles/plug-plex-root.xml index 05da2b7..04b33c8 100644 --- a/skins/blackhole/xmlfiles/plug-plex-root.xml +++ b/skins/blackhole/xmlfiles/plug-plex-root.xml @@ -137,8 +137,56 @@ --> - <grid name="browser" x="0" y="15%" width="75%" height="75%"> + <grid name="coverbrowser" x="0" y="15%" width="75%" height="75%"> <area layer="2"> + <drawtext x="5" y="5" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="Cover" /> + <drawrectangle condition="{current}" x="0" y="0" width="100%" height="100%" color="{clrGray}" /> + </area> + <area layer="3" condition="{ismovie}"> + <drawimage name="thumb" condition="not{hasthumb}" imagetype="skinpart" path="plexplaceholder" x="0" y="0" width="100%" height="76%" /> + <drawimage name="thumb" condition="{hasthumb}" imagetype="image" path="{thumb}" x="0" y="0" width="100%" height="76%" /> + <drawrectangle x="0" y="{height(thumb)}" width="{viewoffset}/{duration}*{areawidth}" height="2%" color="{clrBlue}" /> + <drawtext name="title" x="0" y="{height(thumb)}*1.1" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="{title}" /> + <drawtext x="0" y="{posy(title)} + {height(title)}" width="50%" font="{light}" fontsize="6%" color="{clrWhite}" text="{year}" /> + <drawtext x="50%" y="{posy(title)} + {height(title)}" width="50%" font="{light}" fontsize="6%" color="{clrWhite}" text="{duration} min" /> + </area> + <area layer="3" condition="{isepisode}" > + <drawimage name="thumb" condition="not{hasseriesthumb}" imagetype="skinpart" path="plexplaceholder" x="0" y="0" width="100%" height="76%" /> + <drawimage name="thumb" condition="{hasseriesthumb}" imagetype="image" path="{seriesthumb}" x="0" y="0" width="100%" height="76%" /> + <drawrectangle x="0" y="{height(thumb)}" width="{viewoffset}/{duration}*{areawidth}" height="2%" color="{clrBlue}" /> + <drawtext condition="eq({viewgroup}, 4)" name="title" x="0" y="{height(thumb)}*1.1" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="{title}" /> + <drawtext condition="lt({viewgroup}, 4)" name="title" x="0" y="{height(thumb)}*1.1" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="{seriestitle}" /> + <drawtext name="season" x="0" y="{posy(title)} + {height(title)}" width="50%" font="{light}" fontsize="6%" color="{clrWhite}" text="{printf('S%02d E%02d', season, episode)}" /> + </area> + <area layer="3" condition="{isdirectory}" > + <drawimage name="thumb" condition="not{hasthumb}" imagetype="skinpart" path="plexplaceholder" x="0" y="0" width="100%" height="76%" /> + <drawimage name="thumb" condition="{hasthumb}" imagetype="image" path="{thumb}" x="0" y="0" width="100%" height="76%" /> + <drawtext name="title" x="0" y="{height(thumb)}*1.1" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="{title}" /> + </area> + <area layer="3" condition="{isshow}" > + <drawimage name="thumb" condition="not{hasthumb}" imagetype="skinpart" path="plexplaceholder" x="0" y="0" width="100%" height="76%" /> + <drawimage name="thumb" condition="{hasthumb}" imagetype="image" path="{thumb}" x="0" y="0" width="100%" height="76%" /> + <drawtext name="title" x="0" y="{height(thumb)}*1.1" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="{title}" /> + </area> + <area layer="3" condition="{isseason}" > + <drawimage name="thumb" condition="not{hasthumb}" imagetype="skinpart" path="plexplaceholder" x="0" y="0" width="100%" height="76%" /> + <drawimage name="thumb" condition="{hasthumb}" imagetype="image" path="{thumb}" x="0" y="0" width="100%" height="76%" /> + <drawtext name="title" x="0" y="{height(thumb)}*1.1" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="{title}" /> + </area> + <area layer="3" condition="{isdummy}" > + <drawimage name="thumb" imagetype="skinpart" path="plexplaceholder" x="0" y="0" width="100%" height="76%" /> + <drawtext name="title" x="0" y="{height(thumb)}*1.1" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="{title}" /> + </area> + <area layer="3" condition="{isserver}" > + <drawimage name="thumb" imagetype="skinpart" path="plexplaceholder" x="0" y="0" width="100%" height="76%" /> + <drawtext name="title" x="0" y="{height(thumb)}*1.1" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="{title}" /> + <drawtext x="0" y="{posy(title)} + {height(title)}" width="100%" font="{light}" fontsize="6%" color="{clrWhite}" text="{serverstartpointname}" /> + </area> + </grid> + + <grid name="detailbrowser" x="0" y="15%" width="75%" height="75%"> + <area layer="2"> + <drawtext x="5" y="5" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="Detail" /> <drawrectangle condition="{current}" x="0" y="0" width="100%" height="100%" color="{clrGray}" /> </area> <area layer="3" condition="{ismovie}"> @@ -183,6 +231,52 @@ </area> </grid> + <grid name="listbrowser" x="0" y="15%" width="75%" height="75%"> + <area layer="2"> + <drawtext x="5" y="5" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="List" /> + <drawrectangle condition="{current}" x="0" y="0" width="100%" height="100%" color="{clrGray}" /> + </area> + <area layer="3" condition="{ismovie}"> + <drawimage name="thumb" condition="not{hasthumb}" imagetype="skinpart" path="plexplaceholder" x="0" y="0" width="100%" height="76%" /> + <drawimage name="thumb" condition="{hasthumb}" imagetype="image" path="{thumb}" x="0" y="0" width="100%" height="76%" /> + <drawrectangle x="0" y="{height(thumb)}" width="{viewoffset}/{duration}*{areawidth}" height="2%" color="{clrBlue}" /> + <drawtext name="title" x="0" y="{height(thumb)}*1.1" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="{title}" /> + <drawtext x="0" y="{posy(title)} + {height(title)}" width="50%" font="{light}" fontsize="6%" color="{clrWhite}" text="{year}" /> + <drawtext x="50%" y="{posy(title)} + {height(title)}" width="50%" font="{light}" fontsize="6%" color="{clrWhite}" text="{duration} min" /> + </area> + <area layer="3" condition="{isepisode}" > + <drawimage name="thumb" condition="not{hasseriesthumb}" imagetype="skinpart" path="plexplaceholder" x="0" y="0" width="100%" height="76%" /> + <drawimage name="thumb" condition="{hasseriesthumb}" imagetype="image" path="{seriesthumb}" x="0" y="0" width="100%" height="76%" /> + <drawrectangle x="0" y="{height(thumb)}" width="{viewoffset}/{duration}*{areawidth}" height="2%" color="{clrBlue}" /> + <drawtext condition="eq({viewgroup}, 4)" name="title" x="0" y="{height(thumb)}*1.1" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="{title}" /> + <drawtext condition="lt({viewgroup}, 4)" name="title" x="0" y="{height(thumb)}*1.1" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="{seriestitle}" /> + <drawtext name="season" x="0" y="{posy(title)} + {height(title)}" width="50%" font="{light}" fontsize="6%" color="{clrWhite}" text="{printf('S%02d E%02d', season, episode)}" /> + </area> + <area layer="3" condition="{isdirectory}" > + <drawimage name="thumb" condition="not{hasthumb}" imagetype="skinpart" path="plexplaceholder" x="0" y="0" width="100%" height="76%" /> + <drawimage name="thumb" condition="{hasthumb}" imagetype="image" path="{thumb}" x="0" y="0" width="100%" height="76%" /> + <drawtext name="title" x="0" y="{height(thumb)}*1.1" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="{title}" /> + </area> + <area layer="3" condition="{isshow}" > + <drawimage name="thumb" condition="not{hasthumb}" imagetype="skinpart" path="plexplaceholder" x="0" y="0" width="100%" height="76%" /> + <drawimage name="thumb" condition="{hasthumb}" imagetype="image" path="{thumb}" x="0" y="0" width="100%" height="76%" /> + <drawtext name="title" x="0" y="{height(thumb)}*1.1" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="{title}" /> + </area> + <area layer="3" condition="{isseason}" > + <drawimage name="thumb" condition="not{hasthumb}" imagetype="skinpart" path="plexplaceholder" x="0" y="0" width="100%" height="76%" /> + <drawimage name="thumb" condition="{hasthumb}" imagetype="image" path="{thumb}" x="0" y="0" width="100%" height="76%" /> + <drawtext name="title" x="0" y="{height(thumb)}*1.1" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="{title}" /> + </area> + <area layer="3" condition="{isdummy}" > + <drawimage name="thumb" imagetype="skinpart" path="plexplaceholder" x="0" y="0" width="100%" height="76%" /> + <drawtext name="title" x="0" y="{height(thumb)}*1.1" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="{title}" /> + </area> + <area layer="3" condition="{isserver}" > + <drawimage name="thumb" imagetype="skinpart" path="plexplaceholder" x="0" y="0" width="100%" height="76%" /> + <drawtext name="title" x="0" y="{height(thumb)}*1.1" width="100%" font="{bold}" fontsize="6%" color="{clrWhite}" text="{title}" /> + <drawtext x="0" y="{posy(title)} + {height(title)}" width="100%" font="{light}" fontsize="6%" color="{clrWhite}" text="{serverstartpointname}" /> + </area> + </grid> <!-- Available Variables Footer: {red1} true if red button is button 1 diff --git a/templates/plug-plex-root.xml b/templates/plug-plex-root.xml index e6be997..7959dac 100644 --- a/templates/plug-plex-root.xml +++ b/templates/plug-plex-root.xml @@ -48,6 +48,8 @@ </viewelement> <!-- Tokens available in browser + {totalcount} int: total number of grid elements + {position} int: absolute position of grid element {viewmode} int: enum Cover = 0, List = 1, Detail = 2 {current} bool, currently active element {title} string, Name of the element @@ -117,7 +119,13 @@ --> - <grid name="browser"> + <grid name="coverbrowser"> + </grid> + + <grid name="detailbrowser"> + </grid> + + <grid name="listbrowser"> </grid> diff --git a/viewGridNavigator.cpp b/viewGridNavigator.cpp index 938b49d..50d0951 100644 --- a/viewGridNavigator.cpp +++ b/viewGridNavigator.cpp @@ -12,17 +12,24 @@ cGridElement::cGridElement() m_bInit = true; } -cViewGridNavigator::cViewGridNavigator(skindesignerapi::cOsdView* rootView, skindesignerapi::cViewGrid* viewGrid) +cViewGridNavigator::cViewGridNavigator(skindesignerapi::cOsdView* rootView) { m_columns = 2; m_rows = 2; m_newDimensions = true; m_setIterator = true; - m_pGrid = std::shared_ptr<skindesignerapi::cViewGrid>(viewGrid); + m_pGrid = NULL; m_pRootView = rootView; } +void cViewGridNavigator::SetViewGrid(std::shared_ptr<skindesignerapi::cViewGrid> grid) +{ + if (grid) { + if(m_pGrid) m_pGrid->Clear(); + m_pGrid = std::shared_ptr<skindesignerapi::cViewGrid>(grid); + } +} void cViewGridNavigator::ReDraw(cGridElement* element) { @@ -117,6 +124,8 @@ void cViewGridNavigator::SetGridElementData(cGridElement *obj) // set GridDimensions m_pGrid->AddIntToken("columns", m_columns); m_pGrid->AddIntToken("rows", m_rows); + m_pGrid->AddIntToken("position", obj->AbsolutePosition); + m_pGrid->AddIntToken("totalcount", m_vElements.size()); } else { obj->SetPosition(x, y); m_pGrid->MoveGrid(obj->GridElementId(), x, y, width, height); @@ -135,7 +144,7 @@ bool cViewGridNavigator::NavigateDown() if (m_activeElementIter == m_vElements.end() - 1) return false; auto next = m_activeElementIter + m_columns; if(next >= m_vElements.end()) next = m_vElements.end()-1; - + // scroll down? if(!(*next)->IsVisible()) { FilterElements(m_columns); @@ -152,7 +161,7 @@ bool cViewGridNavigator::NavigateUp() if (m_activeElementIter == m_vElements.begin()) return false; auto next = m_activeElementIter - m_columns; if(next < m_vElements.begin()) next = m_vElements.begin(); - + //scroll up? if(!(*next)->IsVisible()) { FilterElements(-m_columns); diff --git a/viewGridNavigator.h b/viewGridNavigator.h index 3d82eca..c746376 100644 --- a/viewGridNavigator.h +++ b/viewGridNavigator.h @@ -51,9 +51,10 @@ protected: void GenerateServerElements(); void FilterElements(int scrollOffset); void SetGridElementData(cGridElement *obj); + void SetViewGrid(std::shared_ptr<skindesignerapi::cViewGrid> grid); public: - cViewGridNavigator(skindesignerapi::cOsdView* rootView, skindesignerapi::cViewGrid* viewGrid); + cViewGridNavigator(skindesignerapi::cOsdView* rootView); void SetGridDimensions(int rows, int columns); virtual void Flush() { m_pGrid->Display(); }; virtual void Clear() { m_pGrid->Clear(); }; |