diff options
author | chriszero <zerov83@gmail.com> | 2015-07-05 16:28:53 +0200 |
---|---|---|
committer | chriszero <zerov83@gmail.com> | 2015-07-05 16:28:53 +0200 |
commit | d62b88d76ff70116bf581acbb5ba61bbd7c6e9f1 (patch) | |
tree | 4e36cf58e2ee1fab227dbca1ecff776c13891d8f | |
parent | b6a84937d98ee1bf1bb91d87e0d660129f42d367 (diff) | |
download | vdr-plugin-plex-d62b88d76ff70116bf581acbb5ba61bbd7c6e9f1.tar.gz vdr-plugin-plex-d62b88d76ff70116bf581acbb5ba61bbd7c6e9f1.tar.bz2 |
Implements Feature #2202
Scroll all around
Scroll pagewise
-rw-r--r-- | Config.cpp | 15 | ||||
-rw-r--r-- | Config.h | 4 | ||||
-rw-r--r-- | browserGrid.cpp | 4 | ||||
-rw-r--r-- | browserGrid.h | 6 | ||||
-rw-r--r-- | po/de_DE.po | 13 | ||||
-rw-r--r-- | viewGridNavigator.cpp | 121 | ||||
-rw-r--r-- | viewGridNavigator.h | 4 |
7 files changed, 110 insertions, 57 deletions
@@ -18,6 +18,10 @@ Config::Config() { DetailGridColumns = 1; DetailGridRows = 4; + UseMpv = false; + ScrollByPage = true; + ScrollAllAround = true; + DefaultViewMode = ViewMode::Cover; ViewEntry en; @@ -100,6 +104,8 @@ bool Config::Parse(const char *name, const char *value) else if (strcasecmp(name, "ListGridColumns") == 0) Config::GetInstance().ListGridColumns = atoi(value); else if (strcasecmp(name, "ListGridRows") == 0) Config::GetInstance().ListGridRows = atoi(value); else if (strcasecmp(name, "UseMpv") == 0) Config::GetInstance().UseMpv = atoi(value) ? true : false; + else if (strcasecmp(name, "ScrollByPage") == 0) Config::GetInstance().ScrollByPage = atoi(value) ? true : false; + else if (strcasecmp(name, "ScrollAllAround") == 0) Config::GetInstance().ScrollAllAround = atoi(value) ? true : false; else parsed = false; if(!parsed) { @@ -146,12 +152,15 @@ cMyMenuSetupPage::cMyMenuSetupPage(void) ListGridColumns = Config::GetInstance().ListGridColumns; ListGridRows = Config::GetInstance().ListGridRows; UseMpv = Config::GetInstance().UseMpv; - + ScrollByPage = Config::GetInstance().ScrollByPage; + ScrollAllAround = Config::GetInstance().ScrollAllAround; DefaultViewMode = Config::GetInstance().DefaultViewMode; Add(new cMenuEditBoolItem(tr("Hide main menu entry"), (int*)&HideMainMenuEntry, trVDR("no"), trVDR("yes"))); Add(new cMenuEditBoolItem(tr("Use Mpv Plugin (If Availiable)"), (int*)&UseMpv, trVDR("no"), trVDR("yes"))); + Add(new cMenuEditBoolItem(tr("Scroll by Page"), (int*)&ScrollByPage, trVDR("no"), trVDR("yes"))); + Add(new cMenuEditBoolItem(tr("Scroll all around"), (int*)&ScrollAllAround, trVDR("no"), trVDR("yes"))); Add(new cMenuEditBoolItem(tr("Use custom transcoding profile"), (int*)&UseCustomTranscodeProfile, trVDR("no"), trVDR("yes"))); Add(new cMenuEditBoolItem(tr("Use Plex account"), (int*)&UsePlexAccount, trVDR("no"), trVDR("yes"))); Add(new cMenuEditStrItem(tr("Plex Username"), Username, STRING_SIZE)); @@ -198,6 +207,8 @@ void cMyMenuSetupPage::Store(void) Config::GetInstance().ListGridRows = ListGridRows; Config::GetInstance().DefaultViewMode = (ViewMode)DefaultViewMode; Config::GetInstance().UseMpv = UseMpv; + Config::GetInstance().ScrollByPage = ScrollByPage; + Config::GetInstance().ScrollAllAround = ScrollAllAround; SetupStore("UseCustomTranscodeProfile", Config::GetInstance().UseCustomTranscodeProfile); SetupStore("HideMainMenuEntry", Config::GetInstance().HideMainMenuEntry); @@ -216,4 +227,6 @@ void cMyMenuSetupPage::Store(void) SetupStore("ListGridRows", Config::GetInstance().ListGridRows); SetupStore("DefaultViewMode", Config::GetInstance().DefaultViewMode); SetupStore("UseMpv", Config::GetInstance().UseMpv); + SetupStore("ScrollByPage", Config::GetInstance().ScrollByPage); + SetupStore("ScrollAllAround", Config::GetInstance().ScrollAllAround); } @@ -61,6 +61,8 @@ public: std::vector<ViewEntry> m_viewentries; std::vector<ViewEntry> m_serverViewentries; + bool ScrollByPage; + bool ScrollAllAround; bool UseMpv; std::string GetUUID(); @@ -113,6 +115,8 @@ class cMyMenuSetupPage:public cMenuSetupPage int ListGridRows; int DefaultViewMode; int UseMpv; + int ScrollByPage; + int ScrollAllAround; virtual void Store(void); diff --git a/browserGrid.cpp b/browserGrid.cpp index 4dff8a0..9a947e8 100644 --- a/browserGrid.cpp +++ b/browserGrid.cpp @@ -94,7 +94,7 @@ void cBrowserGrid::SwitchView(ViewMode mode) } m_pGrid->Clear(); - m_firstElementIter = m_vElements.begin() + activePos; + m_startIndex = activePos; m_setIterator = true; FilterElements(0); } @@ -200,7 +200,7 @@ void cBrowserGrid::ProcessData() elem->AbsolutePosition = pos++; } - m_firstElementIter = m_vElements.begin(); + m_startIndex = 0; m_pGrid->Clear(); m_setIterator = true; diff --git a/browserGrid.h b/browserGrid.h index a880b76..12b35f8 100644 --- a/browserGrid.h +++ b/browserGrid.h @@ -15,7 +15,7 @@ class cDummyElement : public cGridElement { private: std::string m_title; - + public: cDummyElement(std::string title); cDummyElement(); @@ -63,13 +63,13 @@ private: void DrawBackground(); void DrawInfopane(); void DrawScrollbar(); - + 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); diff --git a/po/de_DE.po b/po/de_DE.po index d22cad9..be74288 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: vdr-plex 0.1.0\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2015-06-05 20:35+0200\n" -"PO-Revision-Date: 2015-05-17 20:51+0200\n" +"POT-Creation-Date: 2015-07-05 13:51+0200\n" +"PO-Revision-Date: 2015-07-05 16:25+0200\n" "Last-Translator: Chris <zerov83@gmail.com>\n" "Language-Team: LANGUAGE <LL@li.org>\n" "Language: de\n" @@ -36,6 +36,15 @@ msgstr "Gesehen" msgid "Hide main menu entry" msgstr "Verstecke Hauptmenüeintrag" +msgid "Use Mpv Plugin (If Availiable)" +msgstr "Verwende MPV-Plugin falls verfügbar" + +msgid "Scroll by Page" +msgstr "Seitenweise Scrollen" + +msgid "Scroll all around" +msgstr "Rundum scrollen" + msgid "Use custom transcoding profile" msgstr "Benutze eigenes Transcoder Profil" diff --git a/viewGridNavigator.cpp b/viewGridNavigator.cpp index 8600edd..0984bb5 100644 --- a/viewGridNavigator.cpp +++ b/viewGridNavigator.cpp @@ -55,24 +55,34 @@ void cViewGridNavigator::FilterElements(int scrollOffset) { if(m_vElements.size() == 0) return; - int startOffset = scrollOffset; - int endOffset = startOffset + (m_rows * m_columns); - if(scrollOffset < 0) { - endOffset = (m_rows * m_columns) + scrollOffset; + m_startIndex += scrollOffset; + if(m_startIndex < 0) m_startIndex = 0; + + m_endIndex = m_startIndex + (m_rows * m_columns); + if(m_endIndex > m_vElements.size()) m_endIndex = m_vElements.size(); + + if(scrollOffset > 0 && m_startIndex >= m_endIndex) { + // allign elements + int delta = m_vElements.size() % m_columns; + delta = m_rows * m_columns - m_columns + delta; + m_startIndex = m_endIndex - delta; } - - //remove non visible elements from grid - if(scrollOffset !=0 ) { - auto startIt = m_firstElementIter; - auto endIt = m_firstElementIter + scrollOffset; - if(scrollOffset < 0) { - startIt = m_lastElementIter + scrollOffset; - endIt = m_lastElementIter; - } - if(startIt < m_vElements.begin()) startIt = m_vElements.begin(); - if(endIt > m_vElements.end()) endIt = m_vElements.end(); - - for(std::vector<cGridElement*>::iterator it = startIt; it != endIt; ++it) { + + unsigned int i = 0; + int pos = 0; + for(auto it = m_vElements.begin(); it != m_vElements.end(); ++it) { + + if(i >= m_startIndex && i < m_endIndex) { + cGridElement *elem = *it; + elem->Position = pos++; + SetGridElementData(elem); + + if(m_setIterator) { + m_activeElementIter = it; + m_pGrid->SetCurrent((*m_activeElementIter)->GridElementId(), true); + m_setIterator = false; + } + } else { m_pGrid->Delete((*it)->GridElementId()); (*it)->Dirty(); (*it)->Position = -1; @@ -80,28 +90,9 @@ void cViewGridNavigator::FilterElements(int scrollOffset) // Remove Queued Downloads cPictureCache::GetInstance().Remove(*it); } + i++; } - std::vector<cGridElement*>::iterator begin = m_firstElementIter + startOffset; - std::vector<cGridElement*>::iterator end = m_firstElementIter + endOffset; - if(begin < m_vElements.begin()) begin = m_vElements.begin(); - if(end > m_vElements.end()) end = m_vElements.end(); - - int pos = 0; - for(std::vector<cGridElement*>::iterator it = begin; it != end; ++it) { - cGridElement *elem = *it; - elem->Position = pos++; - SetGridElementData(elem); - } - - if(m_setIterator) { - m_activeElementIter = begin; - m_pGrid->SetCurrent((*m_activeElementIter)->GridElementId(), true); - m_setIterator = false; - } - - m_firstElementIter = begin; - m_lastElementIter = end; m_newDimensions = false; } @@ -117,7 +108,6 @@ void cViewGridNavigator::SetGridElementData(cGridElement *obj) x = width * column; y= height * row; - //std::cout << "ID: " << obj->GridElementId() << "\tPos: " << obj->Position << "\t\tx: " << x << "\t\ty: " << y << "\t\twi: " << width << "\t\thei: " << height << "\tCol: " << column << "\tRow: " << row << std::endl; cMutexLock MutexLock(&cPlexSdOsd::RedrawMutex); if(obj->IsNew() || m_newDimensions) { // fill data @@ -138,7 +128,7 @@ void cViewGridNavigator::SetGridElementData(cGridElement *obj) cGridElement* cViewGridNavigator::SelectedObject() { - if(!m_setIterator) + if(!m_setIterator) return *m_activeElementIter; return NULL; } @@ -152,13 +142,28 @@ void cViewGridNavigator::SetGridDimensions(int rows, int columns) bool cViewGridNavigator::NavigateDown() { - if (m_setIterator || m_activeElementIter == m_vElements.end() - 1) return false; + if (m_setIterator ) return false; auto next = m_activeElementIter + m_columns; - if(next >= m_vElements.end()) next = m_vElements.end()-1; + + bool scrollallaround = false; + if (next >= m_vElements.end() && Config::GetInstance().ScrollAllAround) { + next = m_vElements.begin(); + scrollallaround = true; + } else if(next >= m_vElements.end()) { + next = m_activeElementIter; // stay at current element //m_vElements.end()-1; + return false; + } // scroll down? if(!(*next)->IsVisible()) { - FilterElements(m_columns); + int scrolloffset = m_columns; + if(Config::GetInstance().ScrollByPage) { + scrolloffset = m_columns*m_rows; + } + if(scrollallaround) + scrolloffset = -((*m_activeElementIter)->AbsolutePosition); + + FilterElements(scrolloffset); } m_pGrid->SetCurrent((*m_activeElementIter)->GridElementId(), false); @@ -169,13 +174,28 @@ bool cViewGridNavigator::NavigateDown() bool cViewGridNavigator::NavigateUp() { - if (m_setIterator || m_activeElementIter == m_vElements.begin()) return false; + if (m_setIterator) return false; auto next = m_activeElementIter - m_columns; - if(next < m_vElements.begin()) next = m_vElements.begin(); + + bool scrollallaround = false; + if (next < m_vElements.begin() && Config::GetInstance().ScrollAllAround) { + next = m_vElements.end() - 1; + scrollallaround = true; + } else if(next < m_vElements.begin()) { + next = m_activeElementIter; // stay at current element //m_vElements.end()-1; + return false; + } //scroll up? if(!(*next)->IsVisible()) { - FilterElements(-m_columns); + int scrolloffset = -m_columns; + if(Config::GetInstance().ScrollByPage) { + scrolloffset = -m_columns*m_rows; + } + if(scrollallaround) + scrolloffset = m_vElements.size(); + + FilterElements(scrolloffset); } m_pGrid->SetCurrent((*m_activeElementIter)->GridElementId(), false); @@ -192,7 +212,11 @@ bool cViewGridNavigator::NavigateLeft() if(!(*next)->IsVisible()) { auto temp = m_activeElementIter; - FilterElements(-m_columns); + if(Config::GetInstance().ScrollByPage) + FilterElements(-m_columns*m_rows); + else + FilterElements(-m_columns); + m_activeElementIter = temp; } @@ -209,7 +233,10 @@ bool cViewGridNavigator::NavigateRight() if(next >= m_vElements.end()) next = m_vElements.end()-1; if(!(*next)->IsVisible()) { - FilterElements(m_columns); + if(Config::GetInstance().ScrollByPage) + FilterElements(m_columns*m_rows); + else + FilterElements(m_columns); } m_pGrid->SetCurrent((*m_activeElementIter)->GridElementId(), false); diff --git a/viewGridNavigator.h b/viewGridNavigator.h index 90e732a..c619300 100644 --- a/viewGridNavigator.h +++ b/viewGridNavigator.h @@ -45,8 +45,8 @@ protected: bool m_setIterator; std::vector<cGridElement*> m_vElements; std::vector<cGridElement*>::iterator m_activeElementIter; - std::vector<cGridElement*>::iterator m_firstElementIter; - std::vector<cGridElement*>::iterator m_lastElementIter; + int m_startIndex = 0; + int m_endIndex = 0; void GenerateServerElements(); void FilterElements(int scrollOffset); |