reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit f7ff871a1ee888e1e4787a74fd2b714e1025cb47
parent 062424aeffe0cc696f1c0c33b7e4521b211648b0
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Fri, 19 Aug 2016 01:43:14 -0400

tabbar: mild refactoring

Diffstat:
Msrc/tabbar.cpp | 14++++++++++----
Msrc/tabbar.hpp | 2+-
2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/tabbar.cpp b/src/tabbar.cpp @@ -30,7 +30,7 @@ TabBar::TabBar(const Tabs &tabs, HWND handle) int TabBar::addTab(const Tab &tab) { - int index = m_size++; + int index = count(); m_pages.push_back(tab.page); @@ -68,10 +68,16 @@ void TabBar::removeTab(const int index) void TabBar::setFocus() { - if(m_lastPage < 0 || (size_t)m_lastPage >= m_pages.size()) - return; + const int index = currentIndex(); + + if(index > -1) + SetFocus(m_pages[index].front()); +} - SetFocus(m_pages[m_lastPage].front()); +int TabBar::count() const +{ + return TabCtrl_GetItemCount(handle()); +} } void TabBar::onNotify(LPNMHDR info, LPARAM) diff --git a/src/tabbar.hpp b/src/tabbar.hpp @@ -36,6 +36,7 @@ public: void setCurrentIndex(int); void removeTab(int); void setFocus(); + int count() const; protected: void onNotify(LPNMHDR, LPARAM) override; @@ -43,7 +44,6 @@ protected: private: void switchPage(); - int m_size; int m_lastPage; std::vector<Page> m_pages; };