iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
IGraphicsEditorDelegate.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
13#include <memory>
14
15#include "IPlugEditorDelegate.h"
16
22BEGIN_IPLUG_NAMESPACE
23BEGIN_IGRAPHICS_NAMESPACE
24
25class IGraphics;
26class IControl;
27
30{
31 friend class IGraphics;
32
33public:
34 IGEditorDelegate(int nParams);
36
37 IGEditorDelegate(const IGEditorDelegate&) = delete;
38 IGEditorDelegate& operator=(const IGEditorDelegate&) = delete;
39
40 //IEditorDelegate
41 void* OpenWindow(void* pHandle) final;
42 void CloseWindow() final;
43 void SetScreenScale(float scale) final;
44
45 bool OnKeyDown(const IKeyPress& key) override;
46 bool OnKeyUp(const IKeyPress& key) override;
47
48 // Default serialization implementations (which serialize the size/scale) = override for custom behaviours
49 bool SerializeEditorState(IByteChunk& chunk) const override;
50 int UnserializeEditorState(const IByteChunk& chunk, int startPos) override;
51
52 //The rest should be final, but the WebSocketEditorDelegate needs to override them
53 void SendControlValueFromDelegate(int ctrlTag, double normalizedValue) override;
54 void SendControlMsgFromDelegate(int ctrlTag, int msgTag, int dataSize = 0, const void* pData = nullptr) override;
55 void SendMidiMsgFromDelegate(const IMidiMsg& msg) override;
56 void SendParameterValueFromDelegate(int paramIdx, double value, bool normalized) override;
57
60 {
61 if(mMakeGraphicsFunc)
62 return mMakeGraphicsFunc();
63 else
64 return nullptr;
65 }
66
68 virtual void LayoutUI(IGraphics* pGraphics)
69 {
70 if(mLayoutFunc)
71 mLayoutFunc(pGraphics);
72 }
73
75 IGraphics* GetUI() { return mGraphics.get(); };
76
78 const IGraphics* GetUI() const { return mGraphics.get(); };
79
83 bool SerializeEditorSize(IByteChunk& data) const;
84
89 int UnserializeEditorSize(const IByteChunk& chunk, int startPos);
90
91protected:
92 std::function<IGraphics*()> mMakeGraphicsFunc = nullptr;
93 std::function<void(IGraphics* pGraphics)> mLayoutFunc = nullptr;
94private:
95 std::unique_ptr<IGraphics> mGraphics;
96 int mLastWidth = 0;
97 int mLastHeight = 0;
98 float mLastScale = 0.f;
99 bool mClosing = false; // used to prevent re-entrancy on closing
100};
101
102END_IGRAPHICS_NAMESPACE
103END_IPLUG_NAMESPACE
Manages a block of memory, for plug-in settings store/recall.
Definition: IPlugStructs.h:112
The lowest level base class of an IGraphics control.
Definition: IControl.h:49
This pure virtual interface delegates communication in both directions between a UI editor and someth...
An editor delegate base class for a SOMETHING that uses IGraphics for it's UI.
bool SerializeEditorSize(IByteChunk &data) const
Serializes the size and scale of the IGraphics.
const IGraphics * GetUI() const
Get a const pointer to the IGraphics context.
void * OpenWindow(void *pHandle) final
If you are not using IGraphics, you can implement this method to attach to the native parent view e....
int UnserializeEditorSize(const IByteChunk &chunk, int startPos)
Unserializes the size and scale of the IGraphics.
void SetScreenScale(float scale) final
Can be used by a host API to inform the editor of screen scale changes.
bool OnKeyDown(const IKeyPress &key) override
KeyDown handler, in order to get keystrokes from certain hosts/plugin formats that send key press mes...
bool SerializeEditorState(IByteChunk &chunk) const override
Serializes the editor state (such as scale) into a binary chunk.
void SendControlValueFromDelegate(int ctrlTag, double normalizedValue) override
SendControlValueFromDelegate (Abbreviation: SCVFD) WARNING: should not be called on the realtime audi...
void SendMidiMsgFromDelegate(const IMidiMsg &msg) override
SendMidiMsgFromDelegate (Abbreviation: SMMFD) WARNING: should not be called on the realtime audio thr...
int UnserializeEditorState(const IByteChunk &chunk, int startPos) override
Unserializes editor state (such as scale).
virtual void LayoutUI(IGraphics *pGraphics)
Called to layout controls when the GUI is initially opened and again if the UI size changes.
void SendControlMsgFromDelegate(int ctrlTag, int msgTag, int dataSize=0, const void *pData=nullptr) override
SendControlMsgFromDelegate (Abbreviation: SCMFD) WARNING: should not be called on the realtime audio ...
bool OnKeyUp(const IKeyPress &key) override
KeyDown handler, in order to get keystrokes from certain hosts/plugin formats that send key press mes...
IGraphics * GetUI()
Get a pointer to the IGraphics context.
virtual IGraphics * CreateGraphics()
Called to create the IGraphics instance for this editor.
void CloseWindow() final
If you are not using IGraphics you can if you need to free resources etc when the window closes.
void SendParameterValueFromDelegate(int paramIdx, double value, bool normalized) override
SendParameterValueFromDelegate (Abbreviation: SPVFD) WARNING: should not be called on the realtime au...
The lowest level base class of an IGraphics context.
Definition: IGraphics.h:86
Used for key press info, such as ASCII representation, virtual key (mapped to win32 codes) and modifi...
Definition: IPlugStructs.h:616
Encapsulates a MIDI message and provides helper functions.
Definition: IPlugMidi.h:31