diff options
author | chriszero <zerov83@gmail.com> | 2016-04-03 20:01:36 +0200 |
---|---|---|
committer | Christian <zerov83@gmail.com> | 2016-04-03 20:01:36 +0200 |
commit | 82d13a0734c8a11347d50fcc5ad341c8eb1b7a43 (patch) | |
tree | bddcb812134c0e56cdc04d602c2252031a3f49bb /viewGridNavigator.cpp | |
parent | 6fc296295f0579d730a61070c40d5e05a34be787 (diff) | |
download | vdr-plugin-plex-82d13a0734c8a11347d50fcc5ad341c8eb1b7a43.tar.gz vdr-plugin-plex-82d13a0734c8a11347d50fcc5ad341c8eb1b7a43.tar.bz2 |
Removed some duplicate code.
Diffstat (limited to 'viewGridNavigator.cpp')
-rw-r--r-- | viewGridNavigator.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
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(); +} |