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(DockWindowAddEx);
62 IMPAPI(DockWindowRemove);
63 IMPAPI(DockWindowActivate);
64 IMPAPI(DockIsChildOfDock);
66 IMPAPI(EnsureNotCompletelyOffscreen);
71 pRec->Register(
"hookcommand", (
void*) ReaperExtBase::HookCommandProc);
72 pRec->Register(
"toggleaction", (
void*) ReaperExtBase::ToggleActionCallback);
74 AddExtensionsMainMenu();
76 gParent = pRec->hwnd_main;
78 HMENU hMenu = GetSubMenu(GetMenu(gParent),
88 for(
auto& action : gActions)
90 if(action.addMenuItem)
92 MENUITEMINFO mi={
sizeof(MENUITEMINFO),};
93 mi.fMask = MIIM_TYPE | MIIM_ID;
94 mi.fType = MFT_STRING;
95 mi.dwTypeData = LPSTR(action.accel.desc);
96 mi.wID = action.accel.accel.cmd;
97 InsertMenuItem(hMenu, menuIdx++, TRUE, &mi);
112#define SWELL_DLG_FLAGS_AUTOGEN SWELL_DLG_WS_FLIPPED|SWELL_DLG_WS_RESIZABLE
113#include "swell-dlggen.h"
114#include "main.rc_mac_dlg"
117#include "swell-menugen.h"
118#include "main.rc_mac_menu"
119float iplug::GetScaleForHWND(HWND hWnd)
125UINT(WINAPI* __GetDpiForWindow)(HWND);
127float GetScaleForHWND(HWND hWnd)
129 if (!__GetDpiForWindow)
131 HINSTANCE h = LoadLibraryA(
"user32.dll");
132 if (h) *(
void**)&__GetDpiForWindow = GetProcAddress(h,
"GetDpiForWindow");
134 if (!__GetDpiForWindow)
138 int dpi = __GetDpiForWindow(hWnd);
140 if (dpi != USER_DEFAULT_SCREEN_DPI)
141 return static_cast<float>(dpi) / USER_DEFAULT_SCREEN_DPI;
Helper struct for registering Reaper Actions.