Browse Source

Fix win32 bridge build

tags/1.9.8
falkTX 7 years ago
parent
commit
c4ceae92d3
2 changed files with 7 additions and 273 deletions
  1. +5
    -24
      source/backend/plugin/CarlaPluginVST2.cpp
  2. +2
    -249
      source/utils/CarlaPluginUI.cpp

+ 5
- 24
source/backend/plugin/CarlaPluginVST2.cpp View File

@@ -18,12 +18,6 @@
#include "CarlaPluginInternal.hpp"
#include "CarlaEngine.hpp"

#if defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN)
# define USE_JUCE_FOR_VST
#endif

#ifndef USE_JUCE_FOR_VST

#include "CarlaVstUtils.hpp"

#include "CarlaMathUtils.hpp"
@@ -422,19 +416,12 @@ public:
const char* msg = nullptr;
const uintptr_t frontendWinId(pData->engine->getOptions().frontendWinId);

#if defined(CARLA_OS_LINUX)
# ifdef HAVE_X11
fUI.window = CarlaPluginUI::newX11(this, frontendWinId, false);
# else
msg = "UI is only for systems with X11";
(void)frontendWinId; // unused
# endif
#elif defined(CARLA_OS_MAC)
# ifdef __LP64__
fUI.window = CarlaPluginUI::newCocoa(this, frontendWinId);
# endif
#if defined(CARLA_OS_MAC) && defined(__LP64__)
fUI.window = CarlaPluginUI::newCocoa(this, frontendWinId, false);
#elif defined(CARLA_OS_WIN)
fUI.window = CarlaPluginUI::newWindows(this, frontendWinId);
fUI.window = CarlaPluginUI::newWindows(this, frontendWinId, false);
#elif defined(HAVE_X11)
fUI.window = CarlaPluginUI::newX11(this, frontendWinId, false);
#else
msg = "Unknown UI type";
#endif
@@ -2388,8 +2375,6 @@ CarlaPluginVST2* CarlaPluginVST2::sLastCarlaPluginVST2 = nullptr;

CARLA_BACKEND_END_NAMESPACE

#endif // ! USE_JUCE_FOR_VST

// -------------------------------------------------------------------------------------------------------------------

CARLA_BACKEND_START_NAMESPACE
@@ -2398,9 +2383,6 @@ CarlaPlugin* CarlaPlugin::newVST2(const Initializer& init)
{
carla_debug("CarlaPlugin::newVST2({%p, \"%s\", \"%s\", " P_INT64 "})", init.engine, init.filename, init.name, init.uniqueId);

#ifdef USE_JUCE_FOR_VST
return newJuce(init, "VST");
#else
CarlaPluginVST2* const plugin(new CarlaPluginVST2(init.engine, init.id));

if (! plugin->init(init.filename, init.name, init.uniqueId, init.options))
@@ -2410,7 +2392,6 @@ CarlaPlugin* CarlaPlugin::newVST2(const Initializer& init)
}

return plugin;
#endif
}

// -------------------------------------------------------------------------------------------------------------------


+ 2
- 249
source/utils/CarlaPluginUI.cpp View File

@@ -18,17 +18,6 @@
#include "CarlaJuceUtils.hpp"
#include "CarlaPluginUI.hpp"

#include "AppConfig.h"

#if defined(CARLA_OS_WIN) || defined(CARLA_OS_MAC)
# include "juce_gui_basics/juce_gui_basics.h"
using juce::Colour;
using juce::Colours;
using juce::ComponentPeer;
using juce::DocumentWindow;
using juce::Graphics;
#endif

#ifdef HAVE_X11
# include <sys/types.h>
# include <X11/Xatom.h>
@@ -36,242 +25,6 @@ using juce::Graphics;
# include <X11/Xutil.h>
#endif

// -----------------------------------------------------
// AutoResizingNSViewComponentWithParent, see juce_audio_processors.cpp

#ifdef CARLA_OS_MAC
# include "juce_gui_extra/juce_gui_extra.h"

# ifdef CARLA_PLUGIN_UI_WITHOUT_JUCE_PROCESSORS
# include "juce_core/native/juce_BasicNativeHeaders.h"
# else
struct NSView;
# endif

namespace juce {

//==============================================================================
struct AutoResizingNSViewComponent : public NSViewComponent,
private AsyncUpdater {
AutoResizingNSViewComponent();
void childBoundsChanged(Component*) override;
void handleAsyncUpdate() override;
bool recursive;
};

struct AutoResizingNSViewComponentWithParent : public AutoResizingNSViewComponent,
private Timer {
AutoResizingNSViewComponentWithParent();
NSView* getChildView() const;
void timerCallback() override;
};

//==============================================================================
# ifdef CARLA_PLUGIN_UI_WITHOUT_JUCE_PROCESSORS
AutoResizingNSViewComponent::AutoResizingNSViewComponent()
: recursive (false) {}

void AutoResizingNSViewComponent::childBoundsChanged(Component*) /* override */
{
if (recursive)
{
triggerAsyncUpdate();
}
else
{
recursive = true;
resizeToFitView();
recursive = true;
}
}

void AutoResizingNSViewComponent::handleAsyncUpdate() /* override */
{
resizeToFitView();
}

AutoResizingNSViewComponentWithParent::AutoResizingNSViewComponentWithParent()
{
NSView* v = [[NSView alloc] init];
setView (v);
[v release];

startTimer(500);
}

NSView* AutoResizingNSViewComponentWithParent::getChildView() const
{
if (NSView* parent = (NSView*)getView())
if ([[parent subviews] count] > 0)
return [[parent subviews] objectAtIndex: 0];

return nil;
}

void AutoResizingNSViewComponentWithParent::timerCallback() /* override */
{
if (NSView* child = getChildView())
{
stopTimer();
setView(child);
}
}
# endif

} // namespace juce
using juce::AutoResizingNSViewComponentWithParent;

#endif

// -----------------------------------------------------
// JUCE

#if defined(CARLA_OS_WIN) || defined(CARLA_OS_MAC)
class JucePluginUI : public CarlaPluginUI,
public DocumentWindow
{
public:
JucePluginUI(CloseCallback* const cb, const uintptr_t /*parentId*/)
: CarlaPluginUI(cb, false),
DocumentWindow("JucePluginUI", Colour(50, 50, 200), DocumentWindow::closeButton, false),
fClosed(false)
#ifdef CARLA_OS_MAC
, fCocoaWrapper()
#endif
{
setVisible(false);
//setAlwaysOnTop(true);
setOpaque(true);
setResizable(false, false);
setUsingNativeTitleBar(true);

#ifdef CARLA_OS_MAC
addAndMakeVisible(fCocoaWrapper = new AutoResizingNSViewComponentWithParent());
#endif

addToDesktop();
}

~JucePluginUI() override
{
#ifdef CARLA_OS_MAC
// deleted before window
fCocoaWrapper = nullptr;
#endif
}

protected:
// CarlaPluginUI calls
void closeButtonPressed() override
{
fClosed = true;
}

void show() override
{
fClosed = false;

DocumentWindow::setVisible(true);
}

void hide() override
{
DocumentWindow::setVisible(false);
}

void focus() override
{
DocumentWindow::toFront(true);
}

void idle() override
{
if (fClosed)
{
fClosed = false;
CARLA_SAFE_ASSERT_RETURN(fCallback != nullptr,);
fCallback->handlePluginUIClosed();
}
}

void setSize(const uint width, const uint height, const bool /*forceUpdate*/) override
{
DocumentWindow::setSize(static_cast<int>(width), static_cast<int>(height));
}

void setTitle(const char* const title) override
{
DocumentWindow::setName(title);
}

void setTransientWinId(const uintptr_t /*winId*/) override
{
}

void* getPtr() const noexcept override
{
#ifdef CARLA_OS_MAC
return fCocoaWrapper->getView();
#else
if (ComponentPeer* const peer = getPeer())
return peer->getNativeHandle();

carla_stdout("getPtr() failed");
return nullptr;
#endif
}

#ifdef CARLA_OS_MAC
// JUCE MacOS calls
void childBoundsChanged(Component*) override
{
if (fCocoaWrapper != nullptr)
{
const int w = fCocoaWrapper->getWidth();
const int h = fCocoaWrapper->getHeight();

if (w != DocumentWindow::getWidth() || h != DocumentWindow::getHeight())
DocumentWindow::setSize(w, h);
}
}

void resized() override
{
if (fCocoaWrapper != nullptr)
fCocoaWrapper->setSize(DocumentWindow::getWidth(), DocumentWindow::getHeight());
}
#endif

#ifdef CARLA_OS_WINDOWS
// JUCE Windows calls
void mouseDown(const MouseEvent&) override
{
DocumentWindow::toFront(true);
}
#endif

void paint(Graphics& g) override
{
g.fillAll(Colours::black);
}

#if 0
//==============================================================================
bool keyStateChanged (bool) override { return pluginWantsKeys; }
bool keyPressed (const juce::KeyPress&) override { return pluginWantsKeys; }
#endif

private:
volatile bool fClosed;

#ifdef CARLA_OS_MAC
juce::ScopedPointer<AutoResizingNSViewComponentWithParent> fCocoaWrapper;
#endif

CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(JucePluginUI)
};
#endif

// -----------------------------------------------------
// X11

@@ -784,14 +537,14 @@ bool CarlaPluginUI::tryTransientWinIdMatch(const uintptr_t pid, const char* cons
#ifdef CARLA_OS_MAC
CarlaPluginUI* CarlaPluginUI::newCocoa(CloseCallback* cb, uintptr_t parentId, bool /*isResizable*/)
{
return new JucePluginUI(cb, parentId);
return nullptr;
}
#endif

#ifdef CARLA_OS_WIN
CarlaPluginUI* CarlaPluginUI::newWindows(CloseCallback* cb, uintptr_t parentId, bool /*isResizable*/)
{
return new JucePluginUI(cb, parentId);
return nullptr;
}
#endif



Loading…
Cancel
Save