Browse Source

Easier time switching between internal vs external window

Signed-off-by: falkTX <falktx@falktx.com>
tags/22.02
falkTX 3 years ago
parent
commit
9b4ef3440d
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 23 additions and 5 deletions
  1. +4
    -0
      plugins/Cardinal/CardinalPlugin.cpp
  2. +13
    -5
      plugins/Cardinal/CardinalUI.cpp
  3. +2
    -0
      plugins/Cardinal/DistrhoPluginInfo.h
  4. +4
    -0
      plugins/Cardinal/Makefile

+ 4
- 0
plugins/Cardinal/CardinalPlugin.cpp View File

@@ -18,6 +18,7 @@
#include <asset.hpp> #include <asset.hpp>
#include <audio.hpp> #include <audio.hpp>
#include <context.hpp> #include <context.hpp>
#include <gamepad.hpp>
#include <library.hpp> #include <library.hpp>
#include <keyboard.hpp> #include <keyboard.hpp>
#include <midi.hpp> #include <midi.hpp>
@@ -100,6 +101,9 @@ struct Initializer {
midi::init(); midi::init();
// rtmidiInit(); // rtmidiInit();
keyboard::init(); keyboard::init();
#ifndef DPF_AS_GLFW
gamepad::init();
#endif
plugin::init(); plugin::init();
library::init(); library::init();
// discord::init(); // discord::init();


+ 13
- 5
plugins/Cardinal/CardinalUI.cpp View File

@@ -27,11 +27,6 @@
#include "DistrhoUI.hpp" #include "DistrhoUI.hpp"
#include "ResizeHandle.hpp" #include "ResizeHandle.hpp"


GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window) { return nullptr; }
GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char*) {}
GLFWAPI const char* glfwGetKeyName(int key, int scancode) { return nullptr; }
GLFWAPI int glfwGetKeyScancode(int key) { return 0; }

namespace rack { namespace rack {
namespace network { namespace network {
std::string encodeUrl(const std::string&) { return {}; } std::string encodeUrl(const std::string&) { return {}; }
@@ -40,6 +35,12 @@ namespace network {
} }
} }


#ifdef DPF_AS_GLFW
GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window) { return nullptr; }
GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char*) {}
GLFWAPI const char* glfwGetKeyName(int key, int scancode) { return nullptr; }
GLFWAPI int glfwGetKeyScancode(int key) { return 0; }

namespace rack { namespace rack {
namespace window { namespace window {
DISTRHO_NAMESPACE::UI* lastUI = nullptr; DISTRHO_NAMESPACE::UI* lastUI = nullptr;
@@ -49,6 +50,7 @@ namespace window {
void scrollCallback(Window* win, double x, double y); void scrollCallback(Window* win, double x, double y);
} }
} }
#endif


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


@@ -95,7 +97,9 @@ public:
*/ */
// Initialize context // Initialize context
INFO("Initializing context"); INFO("Initializing context");
#ifdef DPF_AS_GLFW
window::lastUI = this; window::lastUI = this;
#endif
contextSet(new Context); contextSet(new Context);
APP->engine = new engine::Engine; APP->engine = new engine::Engine;
APP->history = new history::State; APP->history = new history::State;
@@ -106,7 +110,9 @@ public:
/*if (!settings::headless)*/ { /*if (!settings::headless)*/ {
APP->window = new window::Window; APP->window = new window::Window;
} }
#ifdef DPF_AS_GLFW
window::lastUI = nullptr; window::lastUI = nullptr;
#endif


APP->engine->startFallbackThread(); APP->engine->startFallbackThread();
} }
@@ -143,6 +149,7 @@ protected:


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


#ifdef DPF_AS_GLFW
bool onMouse(const MouseEvent& ev) override bool onMouse(const MouseEvent& ev) override
{ {
int button; int button;
@@ -205,6 +212,7 @@ protected:
scrollCallback(APP->window, ev.delta.getX(), ev.delta.getY()); scrollCallback(APP->window, ev.delta.getX(), ev.delta.getY());
return true; return true;
} }
#endif


#if 0 #if 0
void onResize(const ResizeEvent& ev) override void onResize(const ResizeEvent& ev) override


+ 2
- 0
plugins/Cardinal/DistrhoPluginInfo.h View File

@@ -33,6 +33,8 @@
// #define DISTRHO_UI_USE_NANOVG 1 // #define DISTRHO_UI_USE_NANOVG 1
#define DISTRHO_UI_USER_RESIZABLE 0 #define DISTRHO_UI_USER_RESIZABLE 0


#define DPF_AS_GLFW 1

enum Parameters { enum Parameters {
kParameterCount kParameterCount
}; };


+ 4
- 0
plugins/Cardinal/Makefile View File

@@ -63,6 +63,10 @@ endif


EXTRA_LIBS += Rack/dep/lib/libzstd.a EXTRA_LIBS += Rack/dep/lib/libzstd.a


# for raw GLFW window
# EXTRA_LIBS += Rack/dep/lib/libglfw3.a
# FILES_DSP += Rack/src/gamepad.cpp Rack/src/window/Window.cpp

# -------------------------------------------------------------- # --------------------------------------------------------------
# Do some magic # Do some magic




Loading…
Cancel
Save