reapack

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

commit 85998a9e90f9fb10f546e960b9c12eae0464b230
parent 249836a81756aa2ca9bbf7a47aece1cb9b7e2607
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Mon, 20 Jun 2016 18:49:40 -0400

refactoring and apply previous commit (249836a81756aa2ca9bbf7a47aece1cb9b7e2607) to about dialog as well

Diffstat:
Msrc/about.cpp | 11++++++-----
Msrc/about.hpp | 3++-
Msrc/browser.cpp | 14+++++---------
Msrc/control.hpp | 2+-
Msrc/dialog.cpp | 6++++--
Msrc/listview.cpp | 5+++--
Msrc/listview.hpp | 2+-
Msrc/manager.cpp | 6++----
Msrc/manager.hpp | 2+-
9 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/src/about.cpp b/src/about.cpp @@ -61,6 +61,7 @@ void About::onInit() m_packages->sortByColumn(0); m_packages->onActivate(bind(&About::packageHistory, this)); + m_packages->onContextMenu(bind(&About::fillContextMenu, this, placeholders::_1)); m_installedFiles = getControl(IDC_LIST); @@ -109,15 +110,15 @@ void About::onCommand(const int id, int) } } -void About::onContextMenu(HWND target, const int x, const int y) +bool About::fillContextMenu(Menu &menu) const { - if(target != m_packages->handle() || m_packages->currentIndex() < 0) - return; + if(m_packages->currentIndex() < 0) + return false; - Menu menu; menu.addAction(AUTO_STR("Package &Contents"), ACTION_CONTENTS); menu.addAction(AUTO_STR("Package &History"), ACTION_HISTORY); - menu.show(x, y, handle()); + + return true; } void About::populate() diff --git a/src/about.hpp b/src/about.hpp @@ -25,6 +25,7 @@ class Index; class ListView; +class Menu; class Package; class RichEdit; class TabBar; @@ -41,9 +42,9 @@ public: protected: void onInit() override; void onCommand(int, int) override; - void onContextMenu(HWND, int x, int y) override; private: + bool fillContextMenu(Menu &) const; void populate(); void updatePackages(); void updateInstalledFiles(); diff --git a/src/browser.cpp b/src/browser.cpp @@ -61,8 +61,6 @@ Browser::Browser(ReaPack *reapack) void Browser::onInit() { - namespace arg = std::placeholders; - m_applyBtn = getControl(IDAPPLY); m_filterHandle = getControl(IDC_FILTER); m_view = getControl(IDC_TABS); @@ -92,7 +90,7 @@ void Browser::onInit() m_list->onActivate([=] { history(m_list->itemUnderMouse()); }); m_list->onSelect([=] { setEnabled(m_list->hasSelection(), m_actionsBtn); }); - m_list->onContextMenu(bind(&Browser::fillContextMenu, this, arg::_1)); + m_list->onContextMenu(bind(&Browser::fillContextMenu, this, placeholders::_1)); m_list->sortByColumn(1); const auto config = m_reapack->config()->browser(); @@ -106,8 +104,6 @@ void Browser::onInit() void Browser::onCommand(const int id, const int event) { - namespace arg = std::placeholders; - switch(id) { case IDC_TABS: if(event == CBN_SELCHANGE) @@ -139,19 +135,19 @@ void Browser::onCommand(const int id, const int event) installLatest(m_currentIndex); break; case ACTION_LATEST_ALL: - selectionDo(bind(&Browser::installLatest, this, arg::_1, false)); + selectionDo(bind(&Browser::installLatest, this, placeholders::_1, false)); break; case ACTION_REINSTALL: reinstall(m_currentIndex); break; case ACTION_REINSTALL_ALL: - selectionDo(bind(&Browser::reinstall, this, arg::_1, false)); + selectionDo(bind(&Browser::reinstall, this, placeholders::_1, false)); break; case ACTION_UNINSTALL: uninstall(m_currentIndex); break; case ACTION_UNINSTALL_ALL: - selectionDo(bind(&Browser::uninstall, this, arg::_1, false)); + selectionDo(bind(&Browser::uninstall, this, placeholders::_1, false)); break; case ACTION_PIN: togglePin(m_currentIndex); @@ -166,7 +162,7 @@ void Browser::onCommand(const int id, const int event) about(m_currentIndex); break; case ACTION_RESET_ALL: - selectionDo(bind(&Browser::resetActions, this, arg::_1)); + selectionDo(bind(&Browser::resetActions, this, placeholders::_1)); break; case ACTION_SHOWDESCS: toggleDescs(); diff --git a/src/control.hpp b/src/control.hpp @@ -44,7 +44,7 @@ public: protected: friend Dialog; virtual void onNotify(LPNMHDR, LPARAM) {} - virtual void onContextMenu(HWND, int, int) {} + virtual bool onContextMenu(HWND, int, int) { return false; } private: HWND m_handle; diff --git a/src/dialog.cpp b/src/dialog.cpp @@ -343,8 +343,10 @@ void Dialog::onContextMenu(HWND, int x, int y) swap(rect.top, rect.bottom); #endif - if(y >= rect.top && y <= rect.bottom && x >= rect.left && x <= rect.right) - return ctrl->onContextMenu(m_handle, x, y); + if(y >= rect.top && y <= rect.bottom && x >= rect.left && x <= rect.right) { + if(ctrl->onContextMenu(m_handle, x, y)) + return; + } } } diff --git a/src/listview.cpp b/src/listview.cpp @@ -261,16 +261,17 @@ void ListView::onNotify(LPNMHDR info, LPARAM lParam) }; } -void ListView::onContextMenu(HWND dialog, int x, int y) +bool ListView::onContextMenu(HWND dialog, int x, int y) { SetFocus(handle()); Menu menu; if(!m_onContextMenu(menu)) - return; + return false; menu.show(x, y, dialog); + return true; } void ListView::handleDoubleClick() diff --git a/src/listview.hpp b/src/listview.hpp @@ -73,7 +73,7 @@ public: protected: void onNotify(LPNMHDR, LPARAM) override; - void onContextMenu(HWND, int, int) override; + bool onContextMenu(HWND, int, int) override; private: static int adjustWidth(int); diff --git a/src/manager.cpp b/src/manager.cpp @@ -42,8 +42,6 @@ Manager::Manager(ReaPack *reapack) void Manager::onInit() { - namespace arg = std::placeholders; - m_apply = getControl(IDAPPLY); disable(m_apply); @@ -54,7 +52,7 @@ void Manager::onInit() }); m_list->onActivate([=] { about(m_list->currentIndex()); }); - m_list->onContextMenu(bind(&Manager::fillContextMenu, this, arg::_1)); + m_list->onContextMenu(bind(&Manager::fillContextMenu, this, placeholders::_1)); refresh(); @@ -137,7 +135,7 @@ void Manager::onCommand(const int id, int) } } -bool Manager::fillContextMenu(Menu &menu) +bool Manager::fillContextMenu(Menu &menu) const { const int index = m_list->itemUnderMouse(); const Remote &remote = getRemote(index); diff --git a/src/manager.hpp b/src/manager.hpp @@ -47,7 +47,7 @@ private: ListView::Row makeRow(const Remote &) const; Remote getRemote(int index) const; - bool fillContextMenu(Menu &); + bool fillContextMenu(Menu &) const; void setRemoteEnabled(bool); bool isRemoteEnabled(const Remote &) const; void uninstall();