reapack

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

commit 39ffa1610c8e5f025814717d72c9bd3747f3da6f
parent 9a54925dfb0cd3cce2318ff646f9260d3ac25fa3
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Tue,  4 Sep 2018 05:45:41 -0400

move named command lookup responsability to Menu

Diffstat:
Msrc/main.cpp | 30+++++++++---------------------
Msrc/menu.cpp | 13+++++++++----
Msrc/menu.hpp | 1+
3 files changed, 19 insertions(+), 25 deletions(-)

diff --git a/src/main.cpp b/src/main.cpp @@ -75,23 +75,12 @@ static void menuHook(const char *name, HMENU handle, const int f) return; Menu menu = Menu(handle).addMenu("ReaPack"); - - menu.addAction("&Synchronize packages", - NamedCommandLookup("_REAPACK_SYNC")); - - menu.addAction("&Browse packages...", - NamedCommandLookup("_REAPACK_BROWSE")); - - menu.addAction("&Import repositories...", - NamedCommandLookup("_REAPACK_IMPORT")); - - menu.addAction("&Manage repositories...", - NamedCommandLookup("_REAPACK_MANAGE")); - + menu.addAction("&Synchronize packages", "_REAPACK_SYNC"); + menu.addAction("&Browse packages...", "_REAPACK_BROWSE"); + menu.addAction("&Import repositories...", "_REAPACK_IMPORT"); + menu.addAction("&Manage repositories...", "_REAPACK_MANAGE"); menu.addSeparator(); - - menu.addAction(String::format("&About ReaPack v%s", ReaPack::VERSION), - NamedCommandLookup("_REAPACK_ABOUT")); + menu.addAction(String::format("&About ReaPack v%s", ReaPack::VERSION), "_REAPACK_ABOUT"); } static bool checkLocation(REAPER_PLUGIN_HINSTANCE module) @@ -102,14 +91,13 @@ static bool checkLocation(REAPER_PLUGIN_HINSTANCE module) expected.append(REAPACK_FILE); #ifdef _WIN32 - Win32::char_type self[MAX_PATH] = {}; - GetModuleFileName(module, self, static_cast<DWORD>(size(self))); + Win32::char_type self[MAX_PATH]{}; + GetModuleFileName(module, self, static_cast<DWORD>(std::size(self))); Path current(Win32::narrow(self)); #else Dl_info info{}; - dladdr((const void *)checkLocation, &info); - const char *self = info.dli_fname; - Path current(self); + dladdr(reinterpret_cast<const void *>(&checkLocation), &info); + Path current(info.dli_fname); #endif if(current == expected) diff --git a/src/menu.cpp b/src/menu.cpp @@ -27,7 +27,7 @@ # include <swell.h> #endif -using namespace std; +#include <reaper_plugin_functions.h> Menu::Menu(HMENU handle) : m_handle(handle), m_ownership(!handle) @@ -47,7 +47,7 @@ Menu::~Menu() DestroyMenu(m_handle); } -UINT Menu::addAction(const string &label, const int commandId) +UINT Menu::addAction(const std::string &label, const int commandId) { MENUITEMINFO mii{}; mii.cbSize = sizeof(MENUITEMINFO); @@ -60,11 +60,16 @@ UINT Menu::addAction(const string &label, const int commandId) mii.fMask |= MIIM_ID; mii.wID = commandId; - const int index = m_size; + const UINT index = m_size; append(mii); return index; } +UINT Menu::addAction(const std::string &label, const char *namedCommand) +{ + return addAction(label, NamedCommandLookup(namedCommand)); +} + void Menu::addSeparator() { MENUITEMINFO mii{}; @@ -76,7 +81,7 @@ void Menu::addSeparator() append(mii); } -Menu Menu::addMenu(const string &label) +Menu Menu::addMenu(const std::string &label) { MENUITEMINFO mii{}; mii.cbSize = sizeof(MENUITEMINFO); diff --git a/src/menu.hpp b/src/menu.hpp @@ -35,6 +35,7 @@ public: bool empty() const { return m_size == 0; } UINT addAction(const std::string &label, int commandId); + UINT addAction(const std::string &label, const char *namedCommand); void addSeparator(); Menu addMenu(const std::string &label);