mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-29 02:40:05 +00:00
VST3 Client: Change VST3 native menu so that its position is specified in logical pixels
This commit is contained in:
parent
0f3e3d365a
commit
ea250b3655
2 changed files with 24 additions and 10 deletions
|
|
@ -1472,8 +1472,9 @@ private:
|
|||
class EditorContextMenu : public HostProvidedContextMenu
|
||||
{
|
||||
public:
|
||||
EditorContextMenu (VSTComSmartPtr<Steinberg::Vst::IContextMenu> contextMenuIn)
|
||||
: contextMenu (contextMenuIn) {}
|
||||
EditorContextMenu (AudioProcessorEditor& editorIn,
|
||||
VSTComSmartPtr<Steinberg::Vst::IContextMenu> contextMenuIn)
|
||||
: editor (editorIn), contextMenu (contextMenuIn) {}
|
||||
|
||||
PopupMenu getEquivalentPopupMenu() const override
|
||||
{
|
||||
|
|
@ -1542,10 +1543,12 @@ private:
|
|||
|
||||
void showNativeMenu (Point<int> pos) const override
|
||||
{
|
||||
contextMenu->popup (pos.x, pos.y);
|
||||
const auto scaled = pos * Component::getApproximateScaleFactorForComponent (&editor);
|
||||
contextMenu->popup (scaled.x, scaled.y);
|
||||
}
|
||||
|
||||
private:
|
||||
AudioProcessorEditor& editor;
|
||||
VSTComSmartPtr<Steinberg::Vst::IContextMenu> contextMenu;
|
||||
};
|
||||
|
||||
|
|
@ -1553,9 +1556,10 @@ private:
|
|||
{
|
||||
public:
|
||||
EditorHostContext (JuceAudioProcessor& processorIn,
|
||||
AudioProcessorEditor& editorIn,
|
||||
Steinberg::Vst::IComponentHandler* handler,
|
||||
Steinberg::IPlugView* viewIn)
|
||||
: processor (processorIn), componentHandler (handler), view (viewIn) {}
|
||||
: processor (processorIn), editor (editorIn), componentHandler (handler), view (viewIn) {}
|
||||
|
||||
std::unique_ptr<HostProvidedContextMenu> getContextMenuForParameterIndex (const AudioProcessorParameter* parameter) const override
|
||||
{
|
||||
|
|
@ -1569,11 +1573,12 @@ private:
|
|||
|
||||
const auto idToUse = parameter != nullptr ? processor.getVSTParamIDForIndex (parameter->getParameterIndex()) : 0;
|
||||
const auto menu = VSTComSmartPtr<Steinberg::Vst::IContextMenu> (handler->createContextMenu (view, &idToUse));
|
||||
return std::make_unique<EditorContextMenu> (menu);
|
||||
return std::make_unique<EditorContextMenu> (editor, menu);
|
||||
}
|
||||
|
||||
private:
|
||||
JuceAudioProcessor& processor;
|
||||
AudioProcessorEditor& editor;
|
||||
Steinberg::Vst::IComponentHandler* componentHandler = nullptr;
|
||||
Steinberg::IPlugView* view = nullptr;
|
||||
};
|
||||
|
|
@ -1586,7 +1591,6 @@ private:
|
|||
public:
|
||||
JuceVST3Editor (JuceVST3EditController& ec, JuceAudioProcessor& p)
|
||||
: EditorView (&ec, nullptr),
|
||||
editorHostContext (p, ec.getComponentHandler(), this),
|
||||
owner (&ec),
|
||||
pluginInstance (*p.get())
|
||||
{
|
||||
|
|
@ -1925,7 +1929,12 @@ private:
|
|||
|
||||
if (pluginEditor != nullptr)
|
||||
{
|
||||
pluginEditor->setHostContext (&owner.editorHostContext);
|
||||
editorHostContext = std::make_unique<EditorHostContext> (*owner.owner->audioProcessor,
|
||||
*pluginEditor,
|
||||
owner.owner->getComponentHandler(),
|
||||
&owner);
|
||||
|
||||
pluginEditor->setHostContext (editorHostContext.get());
|
||||
|
||||
addAndMakeVisible (pluginEditor.get());
|
||||
pluginEditor->setTopLeftPosition (0, 0);
|
||||
|
|
@ -2071,6 +2080,7 @@ private:
|
|||
|
||||
private:
|
||||
JuceVST3Editor& owner;
|
||||
std::unique_ptr<EditorHostContext> editorHostContext;
|
||||
FakeMouseMoveGenerator fakeMouseGenerator;
|
||||
Rectangle<int> lastBounds;
|
||||
bool resizingChild = false, resizingParent = false;
|
||||
|
|
@ -2094,8 +2104,6 @@ private:
|
|||
//==============================================================================
|
||||
ScopedJuceInitialiser_GUI libraryInitialiser;
|
||||
|
||||
EditorHostContext editorHostContext;
|
||||
|
||||
#if JUCE_LINUX || JUCE_BSD
|
||||
SharedResourcePointer<MessageThread> messageThread;
|
||||
SharedResourcePointer<EventHandler> eventHandler;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,13 @@ struct HostProvidedContextMenu
|
|||
*/
|
||||
virtual PopupMenu getEquivalentPopupMenu() const = 0;
|
||||
|
||||
/** Asks the host to display its native menu at a particular location. */
|
||||
/** Asks the host to display its native menu at a location relative
|
||||
to the top left corner of the editor.
|
||||
|
||||
The position you provide should be in logical pixels. To display
|
||||
the menu next to the mouse cursor, call Component::getMouseXYRelative()
|
||||
on your editor and pass the result to this function.
|
||||
*/
|
||||
virtual void showNativeMenu (Point<int> pos) const = 0;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue