iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
ReaperExtBase.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the iPlug 2 library. Copyright (C) the iPlug 2 developers.
5
6 See LICENSE.txt for more info.
7
8 ==============================================================================
9*/
10
11#pragma once
12
19#include "IPlugTimer.h"
21#include "wdlstring.h"
22
23struct reaper_plugin_info_t;
24
25BEGIN_IPLUG_NAMESPACE
26
27#pragma pack(push, 4)
30{
31 RECT r; // Window rect when floating
32 int state; // Bit 0 = visible, Bit 1 = docked
33 int whichdock; // Docker index when docked
34};
35#pragma pack(pop)
36
38class ReaperExtBase : public EDITOR_DELEGATE_CLASS
39{
40public:
41 ReaperExtBase(reaper_plugin_info_t* pRec);
42
43 virtual ~ReaperExtBase();
44
45 //IEditorDelegate
46 void BeginInformHostOfParamChangeFromUI(int paramIdx) override {}; // NO-OP
47
48 void EndInformHostOfParamChangeFromUI(int paramIdx) override {}; // NO-OP
49
50 bool EditorResizeFromUI(int viewWidth, int viewHeight, bool needsPlatformResize) override;
51
53 virtual void OnIdle() {}; // NO-OP
54
60 void RegisterAction(const char* actionName, std::function<void()> func, bool addMenuItem = false, int* pToggle = nullptr/*, IKeyPress keyCmd*/);
61
63 void ShowHideMainWindow();
64
66 void ToggleDocking();
67
69 bool IsDocked() const { return (mDockState.state & 2) == 2; }
70
73 void SetDockId(const char* id) { mDockId.Set(id); }
74
75public:
76 // Reaper calls back to this when it wants to execute an action registered by the extension plugin
77 static bool HookCommandProc(int command, int flag);
78
79 // Reaper calls back to this when it wants to know an actions toggle state
80 static int ToggleActionCallback(int command);
81
82private:
83 static WDL_DLGRET MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
84
85 void OnTimer(Timer& t);
86 void CreateMainWindow();
87 void DestroyMainWindow();
88 void SaveDockState();
89 void LoadDockState();
90
91 reaper_plugin_info_t* mRec = nullptr;
92 std::unique_ptr<Timer> mTimer;
93 ReaperExtDockState mDockState = {};
94 WDL_FastString mDockId;
95 bool mSaveStateOnDestroy = true;
96 bool mStateLoaded = false;
97};
98
99END_IPLUG_NAMESPACE
Used for choosing an editor delegate.
This file includes classes for implementing timers - in order to get a regular callback on the main t...
State structure for dock window persistence - matches SWS pattern.
Definition: ReaperExtBase.h:30
Reaper extension base class interface.
Definition: ReaperExtBase.h:39
void ShowHideMainWindow()
Toggles the visibility of the main extension window.
bool IsDocked() const
Returns true if the window is currently docked.
Definition: ReaperExtBase.h:69
void ToggleDocking()
Toggles between docked and floating state.
void SetDockId(const char *id)
Sets the unique identifier used for dock state persistence.
Definition: ReaperExtBase.h:73
void RegisterAction(const char *actionName, std::function< void()> func, bool addMenuItem=false, int *pToggle=nullptr)
Registers an action with the REAPER extension system.
virtual void OnIdle()
Called during idle processing - override to perform periodic tasks.
Definition: ReaperExtBase.h:53
Base class for timer.
Definition: IPlugTimer.h:40