Signed-off-by: falkTX <falktx@falktx.com>tags/22.02
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* DISTRHO Cardinal Plugin | * DISTRHO Cardinal Plugin | ||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
* modify it under the terms of the GNU General Public License as | * modify it under the terms of the GNU General Public License as | ||||
@@ -16,7 +16,7 @@ | |||||
*/ | */ | ||||
/** | /** | ||||
* This file is an edited version of VCVRack's Engine.cpp | |||||
* This file is an edited version of VCVRack's engine/Engine.cpp | |||||
* Copyright (C) 2016-2021 VCV. | * Copyright (C) 2016-2021 VCV. | ||||
* | * | ||||
* This program is free software: you can redistribute it and/or | * This program is free software: you can redistribute it and/or | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* DISTRHO Cardinal Plugin | * DISTRHO Cardinal Plugin | ||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
* modify it under the terms of the GNU General Public License as | * modify it under the terms of the GNU General Public License as | ||||
@@ -16,7 +16,7 @@ | |||||
*/ | */ | ||||
/** | /** | ||||
* This file is an edited version of VCVRack's MenuBar.cpp | |||||
* This file is an edited version of VCVRack's app/MenuBar.cpp | |||||
* Copyright (C) 2016-2021 VCV. | * Copyright (C) 2016-2021 VCV. | ||||
* | * | ||||
* This program is free software: you can redistribute it and/or | * This program is free software: you can redistribute it and/or | ||||
@@ -160,7 +160,6 @@ struct FileButton : MenuButton { | |||||
// Load selection | // Load selection | ||||
menu->addChild(createMenuItem("Import selection", "", [=]() { | menu->addChild(createMenuItem("Import selection", "", [=]() { | ||||
// APP->scene->rack->loadSelectionDialog(); | |||||
patchUtils::loadSelectionDialog(); | patchUtils::loadSelectionDialog(); | ||||
}, false, true)); | }, false, true)); | ||||
@@ -622,7 +621,6 @@ struct MenuBar : widget::OpaqueWidget { | |||||
MenuBar(const bool isStandalone) | MenuBar(const bool isStandalone) | ||||
: widget::OpaqueWidget() | : widget::OpaqueWidget() | ||||
// : context(ctx) | |||||
{ | { | ||||
const float margin = 5; | const float margin = 5; | ||||
box.size.y = BND_WIDGET_HEIGHT + 2 * margin; | box.size.y = BND_WIDGET_HEIGHT + 2 * margin; | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* DISTRHO Cardinal Plugin | * DISTRHO Cardinal Plugin | ||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
* modify it under the terms of the GNU General Public License as | * modify it under the terms of the GNU General Public License as | ||||
@@ -16,7 +16,7 @@ | |||||
*/ | */ | ||||
/** | /** | ||||
* This file is an edited version of VCVRack's Model.cpp | |||||
* This file is an edited version of VCVRack's plugin/Model.cpp | |||||
* Copyright (C) 2016-2021 VCV. | * Copyright (C) 2016-2021 VCV. | ||||
* | * | ||||
* This program is free software: you can redistribute it and/or | * This program is free software: you can redistribute it and/or | ||||
@@ -44,7 +44,7 @@ namespace plugin { | |||||
void Model::fromJson(json_t* rootJ) { | void Model::fromJson(json_t* rootJ) { | ||||
assert(plugin); | |||||
DISTRHO_SAFE_ASSERT_RETURN(plugin != nullptr,); | |||||
json_t* nameJ = json_object_get(rootJ, "name"); | json_t* nameJ = json_object_get(rootJ, "name"); | ||||
if (nameJ) | if (nameJ) | ||||
@@ -95,7 +95,7 @@ void Model::fromJson(json_t* rootJ) { | |||||
std::string Model::getFullName() { | std::string Model::getFullName() { | ||||
assert(plugin); | |||||
DISTRHO_SAFE_ASSERT_RETURN(plugin, {}); | |||||
return plugin->getBrand() + " " + name; | return plugin->getBrand() + " " + name; | ||||
} | } | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* DISTRHO Cardinal Plugin | * DISTRHO Cardinal Plugin | ||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
* modify it under the terms of the GNU General Public License as | * modify it under the terms of the GNU General Public License as | ||||
@@ -16,7 +16,7 @@ | |||||
*/ | */ | ||||
/** | /** | ||||
* This file is an edited version of VCVRack's Scene.cpp | |||||
* This file is an edited version of VCVRack's app/Scene.cpp | |||||
* Copyright (C) 2016-2021 VCV. | * Copyright (C) 2016-2021 VCV. | ||||
* | * | ||||
* This program is free software: you can redistribute it and/or | * This program is free software: you can redistribute it and/or | ||||
@@ -27,6 +27,8 @@ | |||||
#include <thread> | #include <thread> | ||||
#include <osdialog.h> | |||||
#include <app/Scene.hpp> | #include <app/Scene.hpp> | ||||
#include <app/Browser.hpp> | #include <app/Browser.hpp> | ||||
#include <app/TipWindow.hpp> | #include <app/TipWindow.hpp> | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* DISTRHO Cardinal Plugin | * DISTRHO Cardinal Plugin | ||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
* modify it under the terms of the GNU General Public License as | * modify it under the terms of the GNU General Public License as | ||||
@@ -16,7 +16,7 @@ | |||||
*/ | */ | ||||
/** | /** | ||||
* This file is an edited version of VCVRack's Window.cpp | |||||
* This file is an edited version of VCVRack's window/Window.cpp | |||||
* Copyright (C) 2016-2021 VCV. | * Copyright (C) 2016-2021 VCV. | ||||
* | * | ||||
* This program is free software: you can redistribute it and/or | * This program is free software: you can redistribute it and/or | ||||
@@ -56,7 +56,23 @@ namespace rack { | |||||
namespace window { | namespace window { | ||||
static const math::Vec minWindowSize = math::Vec(648, 538); | |||||
static const math::Vec WINDOW_SIZE_MIN = math::Vec(648, 538); | |||||
struct FontWithOriginalContext : Font { | |||||
int ohandle = -1; | |||||
std::string ofilename; | |||||
}; | |||||
struct ImageWithOriginalContext : Image { | |||||
int ohandle = -1; | |||||
std::string ofilename; | |||||
}; | |||||
Font::~Font() { | |||||
// There is no NanoVG deleteFont() function yet, so do nothing | |||||
} | |||||
void Font::loadFile(const std::string& filename, NVGcontext* vg) { | void Font::loadFile(const std::string& filename, NVGcontext* vg) { | ||||
@@ -75,13 +91,15 @@ void Font::loadFile(const std::string& filename, NVGcontext* vg) { | |||||
} | } | ||||
Font::~Font() { | |||||
// There is no NanoVG deleteFont() function yet, so do nothing | |||||
std::shared_ptr<Font> Font::load(const std::string& filename) { | |||||
return APP->window->loadFont(filename); | |||||
} | } | ||||
std::shared_ptr<Font> Font::load(const std::string& filename) { | |||||
return APP->window->loadFont(filename); | |||||
Image::~Image() { | |||||
// TODO What if handle is invalid? | |||||
if (handle >= 0) | |||||
nvgDeleteImage(vg, handle); | |||||
} | } | ||||
@@ -96,30 +114,14 @@ void Image::loadFile(const std::string& filename, NVGcontext* vg) { | |||||
} | } | ||||
Image::~Image() { | |||||
// TODO What if handle is invalid? | |||||
if (handle >= 0) | |||||
nvgDeleteImage(vg, handle); | |||||
} | |||||
std::shared_ptr<Image> Image::load(const std::string& filename) { | std::shared_ptr<Image> Image::load(const std::string& filename) { | ||||
return APP->window->loadImage(filename); | return APP->window->loadImage(filename); | ||||
} | } | ||||
struct FontWithOriginalContext : Font { | |||||
int ohandle = -1; | |||||
std::string ofilename; | |||||
}; | |||||
struct ImageWithOriginalContext : Image { | |||||
int ohandle = -1; | |||||
std::string ofilename; | |||||
}; | |||||
struct Window::Internal { | struct Window::Internal { | ||||
std::string lastWindowTitle; | |||||
DISTRHO_NAMESPACE::UI* ui = nullptr; | DISTRHO_NAMESPACE::UI* ui = nullptr; | ||||
DISTRHO_NAMESPACE::WindowParameters params; | DISTRHO_NAMESPACE::WindowParameters params; | ||||
DISTRHO_NAMESPACE::WindowParametersCallback* callback = nullptr; | DISTRHO_NAMESPACE::WindowParametersCallback* callback = nullptr; | ||||
@@ -130,16 +132,16 @@ struct Window::Internal { | |||||
NVGcontext* o_vg = nullptr; | NVGcontext* o_vg = nullptr; | ||||
NVGcontext* o_fbVg = nullptr; | NVGcontext* o_fbVg = nullptr; | ||||
math::Vec size = minWindowSize; | |||||
std::string lastWindowTitle; | |||||
math::Vec size = WINDOW_SIZE_MIN; | |||||
int mods = 0; | int mods = 0; | ||||
int currentRateLimit = 0; | |||||
int frame = 0; | int frame = 0; | ||||
int frameSwapInterval = 1; | int frameSwapInterval = 1; | ||||
double monitorRefreshRate = 60.0; // FIXME | |||||
double monitorRefreshRate = 60.0; | |||||
double frameTime = 0.0; | double frameTime = 0.0; | ||||
double lastFrameDuration = 0.0; | double lastFrameDuration = 0.0; | ||||
int currentRateLimit = 0; | |||||
std::map<std::string, std::shared_ptr<FontWithOriginalContext>> fontCache; | std::map<std::string, std::shared_ptr<FontWithOriginalContext>> fontCache; | ||||
std::map<std::string, std::shared_ptr<ImageWithOriginalContext>> imageCache; | std::map<std::string, std::shared_ptr<ImageWithOriginalContext>> imageCache; | ||||
@@ -327,7 +329,8 @@ math::Vec Window::getSize() { | |||||
void Window::setSize(math::Vec size) { | void Window::setSize(math::Vec size) { | ||||
internal->size = size.max(minWindowSize); | |||||
size = size.max(WINDOW_SIZE_MIN); | |||||
internal->size = size; | |||||
if (DISTRHO_NAMESPACE::UI* const ui = internal->ui) | if (DISTRHO_NAMESPACE::UI* const ui = internal->ui) | ||||
ui->setSize(internal->size.x, internal->size.y); | ui->setSize(internal->size.x, internal->size.y); | ||||
@@ -391,24 +394,30 @@ void Window::step() { | |||||
APP->scene->step(); | APP->scene->step(); | ||||
// Render scene | // Render scene | ||||
// Update and render | |||||
nvgScale(vg, pixelRatio, pixelRatio); | |||||
// Draw scene | |||||
widget::Widget::DrawArgs args; | |||||
args.vg = vg; | |||||
args.clipBox = APP->scene->box.zeroPos(); | |||||
APP->scene->draw(args); | |||||
glViewport(0, 0, fbWidth, fbHeight); | |||||
glClearColor(0.0, 0.0, 0.0, 1.0); | |||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | |||||
{ | |||||
// Update and render | |||||
nvgScale(vg, pixelRatio, pixelRatio); | |||||
// Draw scene | |||||
widget::Widget::DrawArgs args; | |||||
args.vg = vg; | |||||
args.clipBox = APP->scene->box.zeroPos(); | |||||
APP->scene->draw(args); | |||||
glViewport(0, 0, fbWidth, fbHeight); | |||||
glClearColor(0.0, 0.0, 0.0, 1.0); | |||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | |||||
} | |||||
} | } | ||||
++internal->frame; | ++internal->frame; | ||||
} | } | ||||
void Window::activateContext() { | |||||
} | |||||
void Window::screenshot(const std::string&) { | void Window::screenshot(const std::string&) { | ||||
} | } | ||||
@@ -524,6 +533,14 @@ int& Window::fbCount() { | |||||
} | } | ||||
void init() { | |||||
} | |||||
void destroy() { | |||||
} | |||||
} // namespace window | } // namespace window | ||||
} // namespace rack | } // namespace rack | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* DISTRHO Cardinal Plugin | * DISTRHO Cardinal Plugin | ||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
* modify it under the terms of the GNU General Public License as | * modify it under the terms of the GNU General Public License as | ||||
@@ -34,17 +34,16 @@ | |||||
#include "DistrhoPluginUtils.hpp" | #include "DistrhoPluginUtils.hpp" | ||||
// fopen_u8 | |||||
#ifdef ARCH_WIN | |||||
#if defined ARCH_WIN | |||||
#include <windows.h> | #include <windows.h> | ||||
FILE* fopen_u8(const char* filename, const char* mode) | |||||
{ | |||||
return _wfopen(rack::string::UTF8toUTF16(filename).c_str(), rack::string::UTF8toUTF16(mode).c_str()); | |||||
FILE* fopen_u8(const char* filename, const char* mode) { | |||||
return _wfopen(rack::string::UTF8toUTF16(filename).c_str(), rack::string::UTF8toUTF16(mode).c_str()); | |||||
} | } | ||||
#endif | #endif | ||||
// Define the global names to indicate this is Cardinal and not VCVRack | |||||
namespace rack { | namespace rack { | ||||
const std::string APP_NAME = "Cardinal"; | const std::string APP_NAME = "Cardinal"; | ||||
@@ -52,22 +51,24 @@ const std::string APP_EDITION = getPluginFormatName(); | |||||
const std::string APP_EDITION_NAME = "Audio Plugin"; | const std::string APP_EDITION_NAME = "Audio Plugin"; | ||||
const std::string APP_VERSION_MAJOR = "2"; | const std::string APP_VERSION_MAJOR = "2"; | ||||
const std::string APP_VERSION = "2.0"; | const std::string APP_VERSION = "2.0"; | ||||
#if defined(ARCH_WIN) | |||||
const std::string APP_OS = "win"; | |||||
#elif defined(ARCH_MAC) | |||||
const std::string APP_OS = "mac"; | |||||
#if defined ARCH_WIN | |||||
const std::string APP_OS = "win"; | |||||
#elif ARCH_MAC | |||||
const std::string APP_OS = "mac"; | |||||
#elif defined ARCH_LIN | |||||
const std::string APP_OS = "lin"; | |||||
#else | #else | ||||
const std::string APP_OS = "lin"; | |||||
#error ARCH_LIN undefined | |||||
#endif | #endif | ||||
const std::string API_URL = ""; | const std::string API_URL = ""; | ||||
Exception::Exception(const char* format, ...) | |||||
{ | |||||
va_list args; | |||||
va_start(args, format); | |||||
msg = string::fV(format, args); | |||||
va_end(args); | |||||
Exception::Exception(const char* format, ...) { | |||||
va_list args; | |||||
va_start(args, format); | |||||
msg = string::fV(format, args); | |||||
va_end(args); | |||||
} | } | ||||
} | |||||
} // namespace rack |
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* DISTRHO Cardinal Plugin | * DISTRHO Cardinal Plugin | ||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
* modify it under the terms of the GNU General Public License as | * modify it under the terms of the GNU General Public License as | ||||
@@ -46,26 +46,33 @@ Context::~Context() { | |||||
// Set pointers to NULL so other objects will segfault when attempting to access them | // Set pointers to NULL so other objects will segfault when attempting to access them | ||||
INFO("Deleting window"); | |||||
delete window; | delete window; | ||||
window = NULL; | window = NULL; | ||||
INFO("Deleting patch manager"); | |||||
delete patch; | delete patch; | ||||
patch = NULL; | patch = NULL; | ||||
INFO("Deleting scene"); | |||||
delete scene; | delete scene; | ||||
scene = NULL; | scene = NULL; | ||||
INFO("Deleting event state"); | |||||
delete event; | delete event; | ||||
event = NULL; | event = NULL; | ||||
INFO("Deleting history state"); | |||||
delete history; | delete history; | ||||
history = NULL; | history = NULL; | ||||
INFO("Deleting engine"); | |||||
delete engine; | delete engine; | ||||
engine = NULL; | engine = NULL; | ||||
} | } | ||||
static thread_local Context* threadContext = nullptr; | |||||
static thread_local Context* threadContext = NULL; | |||||
Context* contextGet() { | Context* contextGet() { | ||||
DISTRHO_SAFE_ASSERT(threadContext != nullptr); | DISTRHO_SAFE_ASSERT(threadContext != nullptr); | ||||
@@ -76,9 +83,9 @@ Context* contextGet() { | |||||
#ifdef ARCH_MAC | #ifdef ARCH_MAC | ||||
__attribute__((optnone)) | __attribute__((optnone)) | ||||
#endif | #endif | ||||
void contextSet(Context* const context) { | |||||
// DISTRHO_SAFE_ASSERT(threadContext == nullptr); | |||||
void contextSet(Context* context) { | |||||
threadContext = context; | threadContext = context; | ||||
} | } | ||||
} // namespace rack | } // namespace rack |