5#include "IGraphics_include_in_plug_src.h"
8#define REAPERAPI_IMPLEMENT
9void (*AttachWindowTopmostButton)(HWND hwnd);
10#include "reaper_plugin_functions.h"
16REAPER_PLUGIN_HINSTANCE gHINSTANCE;
19std::unique_ptr<PLUG_CLASS_NAME> gPlug;
26 int* pToggle =
nullptr;
27 gaccel_register_t accel = {{0,0,0},
""};
28 std::function<void()> func;
29 bool addMenuItem =
false;
32std::vector<ReaperAction> gActions;
35#include "ReaperExtBase.cpp"
38#define IMPAPI(x) if (!((*((void **)&(x)) = (void*) pRec->GetFunc(#x)))) gErrorCount++;
40#pragma mark - ENTRY POINT
43 REAPER_PLUGIN_DLL_EXPORT
int REAPER_PLUGIN_ENTRYPOINT(REAPER_PLUGIN_HINSTANCE hInstance, reaper_plugin_info_t* pRec)
45 gHINSTANCE = hInstance;
49 if (pRec->caller_version != REAPER_PLUGIN_VERSION || !pRec->GetFunc)
52 gPlug = std::make_unique<PLUG_CLASS_NAME>(pRec);
55 IMPAPI(Main_OnCommand);
56 IMPAPI(GetResourcePath);
57 IMPAPI(AddExtensionsMainMenu);
58 IMPAPI(AttachWindowTopmostButton);
59 IMPAPI(ShowConsoleMsg);
60 IMPAPI(DockWindowAdd);
61 IMPAPI(DockWindowActivate);
66 pRec->Register(
"hookcommand", (
void*) ReaperExtBase::HookCommandProc);
67 pRec->Register(
"toggleaction", (
void*) ReaperExtBase::ToggleActionCallback);
69 AddExtensionsMainMenu();
71 gParent = pRec->hwnd_main;
73 HMENU hMenu = GetSubMenu(GetMenu(gParent),
83 for(
auto& action : gActions)
85 if(action.addMenuItem)
87 MENUITEMINFO mi={
sizeof(MENUITEMINFO),};
88 mi.fMask = MIIM_TYPE | MIIM_ID;
89 mi.fType = MFT_STRING;
90 mi.dwTypeData = LPSTR(action.accel.desc);
91 mi.wID = action.accel.accel.cmd;
92 InsertMenuItem(hMenu, menuIdx++, TRUE, &mi);
107#define SWELL_DLG_FLAGS_AUTOGEN SWELL_DLG_WS_FLIPPED
108#include "swell-dlggen.h"
109#include "main.rc_mac_dlg"
112#include "swell-menugen.h"
113#include "main.rc_mac_menu"
114float iplug::GetScaleForHWND(HWND hWnd)
120UINT(WINAPI* __GetDpiForWindow)(HWND);
122float GetScaleForHWND(HWND hWnd)
124 if (!__GetDpiForWindow)
126 HINSTANCE h = LoadLibraryA(
"user32.dll");
127 if (h) *(
void**)&__GetDpiForWindow = GetProcAddress(h,
"GetDpiForWindow");
129 if (!__GetDpiForWindow)
133 int dpi = __GetDpiForWindow(hWnd);
135 if (dpi != USER_DEFAULT_SCREEN_DPI)
136 return static_cast<float>(dpi) / USER_DEFAULT_SCREEN_DPI;
Helper struct for registering Reaper Actions.