4 #include "IGraphics_include_in_plug_src.h" 7 #define REAPERAPI_IMPLEMENT 8 void (*AttachWindowTopmostButton)(HWND hwnd);
9 #include "reaper_plugin_functions.h" 15 REAPER_PLUGIN_HINSTANCE gHINSTANCE;
18 std::unique_ptr<PLUG_CLASS_NAME> gPlug;
25 int* pToggle =
nullptr;
26 gaccel_register_t accel = {{0,0,0},
""};
27 std::function<void()> func;
28 bool addMenuItem =
false;
31 std::vector<ReaperAction> gActions;
34 #include "ReaperExtBase.cpp" 37 #define IMPAPI(x) if (!((*((void **)&(x)) = (void *)pRec->GetFunc(#x)))) gErrorCount++; 39 #pragma mark - ENTRY POINT 42 REAPER_PLUGIN_DLL_EXPORT
int REAPER_PLUGIN_ENTRYPOINT(REAPER_PLUGIN_HINSTANCE hInstance, reaper_plugin_info_t* pRec)
44 gHINSTANCE = hInstance;
48 if (pRec->caller_version != REAPER_PLUGIN_VERSION || !pRec->GetFunc)
51 gPlug = std::make_unique<PLUG_CLASS_NAME>(pRec);
54 IMPAPI(Main_OnCommand);
55 IMPAPI(GetResourcePath);
56 IMPAPI(AddExtensionsMainMenu);
57 IMPAPI(AttachWindowTopmostButton);
58 IMPAPI(ShowConsoleMsg);
59 IMPAPI(DockWindowAdd);
60 IMPAPI(DockWindowActivate);
65 pRec->Register(
"hookcommand", (
void*) ReaperExtBase::HookCommandProc);
66 pRec->Register(
"toggleaction", (
void*) ReaperExtBase::ToggleActionCallback);
68 AddExtensionsMainMenu();
70 gParent = pRec->hwnd_main;
72 HMENU hMenu = GetSubMenu(GetMenu(gParent),
82 for(
auto& action : gActions)
84 if(action.addMenuItem)
86 MENUITEMINFO mi={
sizeof(MENUITEMINFO),};
87 mi.fMask = MIIM_TYPE | MIIM_ID;
88 mi.fType = MFT_STRING;
89 mi.dwTypeData = LPSTR(action.accel.desc);
90 mi.wID = action.accel.accel.cmd;
91 InsertMenuItem(hMenu, menuIdx++, TRUE, &mi);
106 #define SWELL_DLG_FLAGS_AUTOGEN SWELL_DLG_WS_FLIPPED//|SWELL_DLG_WS_RESIZABLE 107 #include "swell-dlggen.h" 108 #include "main.rc_mac_dlg" 111 #include "swell-menugen.h" 112 #include "main.rc_mac_menu" 115 UINT(WINAPI* __GetDpiForWindow)(HWND);
117 float GetScaleForHWND(HWND hWnd)
119 if (!__GetDpiForWindow)
121 HINSTANCE h = LoadLibraryA(
"user32.dll");
122 if (h) *(
void**)&__GetDpiForWindow = GetProcAddress(h,
"GetDpiForWindow");
124 if (!__GetDpiForWindow)
128 int dpi = __GetDpiForWindow(hWnd);
130 if (dpi != USER_DEFAULT_SCREEN_DPI)
131 return static_cast<float>(dpi) / USER_DEFAULT_SCREEN_DPI;
Helper struct for registering Reaper Actions.