Signed-off-by: falkTX <falktx@falktx.com>tags/22.02
| @@ -1,6 +1,6 @@ | |||
| /* | |||
| * 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 | |||
| * 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. | |||
| * | |||
| * This program is free software: you can redistribute it and/or | |||
| @@ -1,6 +1,6 @@ | |||
| /* | |||
| * 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 | |||
| * 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. | |||
| * | |||
| * This program is free software: you can redistribute it and/or | |||
| @@ -160,7 +160,6 @@ struct FileButton : MenuButton { | |||
| // Load selection | |||
| menu->addChild(createMenuItem("Import selection", "", [=]() { | |||
| // APP->scene->rack->loadSelectionDialog(); | |||
| patchUtils::loadSelectionDialog(); | |||
| }, false, true)); | |||
| @@ -622,7 +621,6 @@ struct MenuBar : widget::OpaqueWidget { | |||
| MenuBar(const bool isStandalone) | |||
| : widget::OpaqueWidget() | |||
| // : context(ctx) | |||
| { | |||
| const float margin = 5; | |||
| box.size.y = BND_WIDGET_HEIGHT + 2 * margin; | |||
| @@ -1,6 +1,6 @@ | |||
| /* | |||
| * 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 | |||
| * 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. | |||
| * | |||
| * This program is free software: you can redistribute it and/or | |||
| @@ -44,7 +44,7 @@ namespace plugin { | |||
| void Model::fromJson(json_t* rootJ) { | |||
| assert(plugin); | |||
| DISTRHO_SAFE_ASSERT_RETURN(plugin != nullptr,); | |||
| json_t* nameJ = json_object_get(rootJ, "name"); | |||
| if (nameJ) | |||
| @@ -95,7 +95,7 @@ void Model::fromJson(json_t* rootJ) { | |||
| std::string Model::getFullName() { | |||
| assert(plugin); | |||
| DISTRHO_SAFE_ASSERT_RETURN(plugin, {}); | |||
| return plugin->getBrand() + " " + name; | |||
| } | |||
| @@ -1,6 +1,6 @@ | |||
| /* | |||
| * 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 | |||
| * 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. | |||
| * | |||
| * This program is free software: you can redistribute it and/or | |||
| @@ -27,6 +27,8 @@ | |||
| #include <thread> | |||
| #include <osdialog.h> | |||
| #include <app/Scene.hpp> | |||
| #include <app/Browser.hpp> | |||
| #include <app/TipWindow.hpp> | |||
| @@ -1,6 +1,6 @@ | |||
| /* | |||
| * 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 | |||
| * 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. | |||
| * | |||
| * This program is free software: you can redistribute it and/or | |||
| @@ -56,7 +56,23 @@ namespace rack { | |||
| 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) { | |||
| @@ -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) { | |||
| 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 { | |||
| std::string lastWindowTitle; | |||
| DISTRHO_NAMESPACE::UI* ui = nullptr; | |||
| DISTRHO_NAMESPACE::WindowParameters params; | |||
| DISTRHO_NAMESPACE::WindowParametersCallback* callback = nullptr; | |||
| @@ -130,16 +132,16 @@ struct Window::Internal { | |||
| NVGcontext* o_vg = nullptr; | |||
| NVGcontext* o_fbVg = nullptr; | |||
| math::Vec size = minWindowSize; | |||
| std::string lastWindowTitle; | |||
| math::Vec size = WINDOW_SIZE_MIN; | |||
| int mods = 0; | |||
| int currentRateLimit = 0; | |||
| int frame = 0; | |||
| int frameSwapInterval = 1; | |||
| double monitorRefreshRate = 60.0; // FIXME | |||
| double monitorRefreshRate = 60.0; | |||
| double frameTime = 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<ImageWithOriginalContext>> imageCache; | |||
| @@ -327,7 +329,8 @@ math::Vec Window::getSize() { | |||
| 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) | |||
| ui->setSize(internal->size.x, internal->size.y); | |||
| @@ -391,24 +394,30 @@ void Window::step() { | |||
| APP->scene->step(); | |||
| // 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; | |||
| } | |||
| void Window::activateContext() { | |||
| } | |||
| void Window::screenshot(const std::string&) { | |||
| } | |||
| @@ -524,6 +533,14 @@ int& Window::fbCount() { | |||
| } | |||
| void init() { | |||
| } | |||
| void destroy() { | |||
| } | |||
| } // namespace window | |||
| } // namespace rack | |||
| @@ -1,6 +1,6 @@ | |||
| /* | |||
| * 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 | |||
| * modify it under the terms of the GNU General Public License as | |||
| @@ -34,17 +34,16 @@ | |||
| #include "DistrhoPluginUtils.hpp" | |||
| // fopen_u8 | |||
| #ifdef ARCH_WIN | |||
| #if defined ARCH_WIN | |||
| #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 | |||
| // Define the global names to indicate this is Cardinal and not VCVRack | |||
| namespace rack { | |||
| 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_VERSION_MAJOR = "2"; | |||
| 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 | |||
| const std::string APP_OS = "lin"; | |||
| #error ARCH_LIN undefined | |||
| #endif | |||
| 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 | |||
| * 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 | |||
| * 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 | |||
| INFO("Deleting window"); | |||
| delete window; | |||
| window = NULL; | |||
| INFO("Deleting patch manager"); | |||
| delete patch; | |||
| patch = NULL; | |||
| INFO("Deleting scene"); | |||
| delete scene; | |||
| scene = NULL; | |||
| INFO("Deleting event state"); | |||
| delete event; | |||
| event = NULL; | |||
| INFO("Deleting history state"); | |||
| delete history; | |||
| history = NULL; | |||
| INFO("Deleting engine"); | |||
| delete engine; | |||
| engine = NULL; | |||
| } | |||
| static thread_local Context* threadContext = nullptr; | |||
| static thread_local Context* threadContext = NULL; | |||
| Context* contextGet() { | |||
| DISTRHO_SAFE_ASSERT(threadContext != nullptr); | |||
| @@ -76,9 +83,9 @@ Context* contextGet() { | |||
| #ifdef ARCH_MAC | |||
| __attribute__((optnone)) | |||
| #endif | |||
| void contextSet(Context* const context) { | |||
| // DISTRHO_SAFE_ASSERT(threadContext == nullptr); | |||
| void contextSet(Context* context) { | |||
| threadContext = context; | |||
| } | |||
| } // namespace rack | |||