Use a single widget for resize, always show handle
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
ec15f95f32
commit
5282da24e9
6 changed files with 77 additions and 58 deletions
|
@ -70,6 +70,15 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow*, const char* const text)
|
||||||
context->ui->setClipboard(nullptr, text, std::strlen(text)+1);
|
context->ui->setClipboard(nullptr, text, std::strlen(text)+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWAPI void glfwSetCursor(GLFWwindow*, GLFWcursor* const cursor)
|
||||||
|
{
|
||||||
|
CardinalPluginContext* const context = static_cast<CardinalPluginContext*>(APP);
|
||||||
|
DISTRHO_SAFE_ASSERT_RETURN(context != nullptr,);
|
||||||
|
DISTRHO_SAFE_ASSERT_RETURN(context->ui != nullptr,);
|
||||||
|
|
||||||
|
context->ui->setCursor(cursor != nullptr ? kMouseCursorDiagonal : kMouseCursorArrow);
|
||||||
|
}
|
||||||
|
|
||||||
GLFWAPI double glfwGetTime(void)
|
GLFWAPI double glfwGetTime(void)
|
||||||
{
|
{
|
||||||
CardinalPluginContext* const context = static_cast<CardinalPluginContext*>(APP);
|
CardinalPluginContext* const context = static_cast<CardinalPluginContext*>(APP);
|
||||||
|
@ -181,7 +190,6 @@ GLFWAPI const char* glfwGetKeyName(const int key, int)
|
||||||
namespace rack {
|
namespace rack {
|
||||||
namespace app {
|
namespace app {
|
||||||
widget::Widget* createMenuBar(bool isStandalone);
|
widget::Widget* createMenuBar(bool isStandalone);
|
||||||
void hideResizeHandle(Scene* scene);
|
|
||||||
}
|
}
|
||||||
namespace window {
|
namespace window {
|
||||||
void WindowSetPluginUI(Window* window, DISTRHO_NAMESPACE::UI* ui);
|
void WindowSetPluginUI(Window* window, DISTRHO_NAMESPACE::UI* ui);
|
||||||
|
@ -231,7 +239,6 @@ class CardinalUI : public CardinalBaseUI,
|
||||||
public WindowParametersCallback
|
public WindowParametersCallback
|
||||||
{
|
{
|
||||||
rack::math::Vec fLastMousePos;
|
rack::math::Vec fLastMousePos;
|
||||||
ResizeHandle fResizeHandle;
|
|
||||||
WindowParameters fWindowParameters;
|
WindowParameters fWindowParameters;
|
||||||
int fRateLimitStep = 0;
|
int fRateLimitStep = 0;
|
||||||
|
|
||||||
|
@ -263,20 +270,13 @@ class CardinalUI : public CardinalBaseUI,
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CardinalUI()
|
CardinalUI()
|
||||||
: CardinalBaseUI(1228, 666),
|
: CardinalBaseUI(1228, 666)
|
||||||
fResizeHandle(this)
|
|
||||||
{
|
{
|
||||||
Window& window(getWindow());
|
Window& window(getWindow());
|
||||||
|
|
||||||
window.setIgnoringKeyRepeat(true);
|
window.setIgnoringKeyRepeat(true);
|
||||||
context->nativeWindowId = window.getNativeWindowHandle();
|
context->nativeWindowId = window.getNativeWindowHandle();
|
||||||
|
|
||||||
if (isResizable())
|
|
||||||
{
|
|
||||||
fResizeHandle.hide();
|
|
||||||
hideResizeHandle(context->scene);
|
|
||||||
}
|
|
||||||
|
|
||||||
const double scaleFactor = getScaleFactor();
|
const double scaleFactor = getScaleFactor();
|
||||||
|
|
||||||
setGeometryConstraints(648 * scaleFactor, 538 * scaleFactor);
|
setGeometryConstraints(648 * scaleFactor, 538 * scaleFactor);
|
||||||
|
|
|
@ -49,12 +49,14 @@ void nvgluDeleteFramebuffer(NVGLUframebuffer* fb) {}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
typedef struct GLFWcursor GLFWcursor;
|
||||||
typedef struct GLFWwindow GLFWwindow;
|
typedef struct GLFWwindow GLFWwindow;
|
||||||
|
|
||||||
GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window) { return nullptr; }
|
GLFWAPI const char* glfwGetClipboardString(GLFWwindow*) { return nullptr; }
|
||||||
GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char*) {}
|
GLFWAPI void glfwSetClipboardString(GLFWwindow*, const char*) {}
|
||||||
GLFWAPI const char* glfwGetKeyName(int key, int scancode) { return nullptr; }
|
GLFWAPI void glfwSetCursor(GLFWwindow*, GLFWcursor*) {}
|
||||||
GLFWAPI int glfwGetKeyScancode(int key) { return 0; }
|
GLFWAPI const char* glfwGetKeyName(int, int) { return nullptr; }
|
||||||
|
GLFWAPI int glfwGetKeyScancode(int) { return 0; }
|
||||||
GLFWAPI double glfwGetTime(void) { return 0.0; }
|
GLFWAPI double glfwGetTime(void) { return 0.0; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,8 @@ namespace app {
|
||||||
|
|
||||||
|
|
||||||
struct ResizeHandle : widget::OpaqueWidget {
|
struct ResizeHandle : widget::OpaqueWidget {
|
||||||
|
math::Vec size;
|
||||||
|
|
||||||
void draw(const DrawArgs& args) override {
|
void draw(const DrawArgs& args) override {
|
||||||
nvgStrokeColor(args.vg, nvgRGBf(1, 1, 1));
|
nvgStrokeColor(args.vg, nvgRGBf(1, 1, 1));
|
||||||
nvgStrokeWidth(args.vg, 1);
|
nvgStrokeWidth(args.vg, 1);
|
||||||
|
@ -95,6 +97,27 @@ struct ResizeHandle : widget::OpaqueWidget {
|
||||||
nvgLineTo(args.vg, 0, box.size.y + 11);
|
nvgLineTo(args.vg, 0, box.size.y + 11);
|
||||||
nvgStroke(args.vg);
|
nvgStroke(args.vg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onHover(const HoverEvent& e) override {
|
||||||
|
e.consume(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onEnter(const EnterEvent& e) override {
|
||||||
|
glfwSetCursor(nullptr, (GLFWcursor*)0x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onLeave(const LeaveEvent& e) override {
|
||||||
|
glfwSetCursor(nullptr, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onDragStart(const DragStartEvent&) override {
|
||||||
|
size = APP->window->getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void onDragMove(const DragMoveEvent& e) override {
|
||||||
|
size = size.plus(e.mouseDelta);
|
||||||
|
APP->window->setSize(size.round());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -151,11 +174,6 @@ Scene::Scene() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void hideResizeHandle(Scene* scene) {
|
|
||||||
scene->internal->resizeHandle->hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Scene::~Scene() {
|
Scene::~Scene() {
|
||||||
delete internal;
|
delete internal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- ../Rack/src/app/Scene.cpp 2021-12-14 21:35:44.414568198 +0000
|
--- ../Rack/src/app/Scene.cpp 2021-12-14 21:35:44.414568198 +0000
|
||||||
+++ Scene.cpp 2022-01-24 11:12:33.268767988 +0000
|
+++ Scene.cpp 2022-01-26 18:47:48.006168325 +0000
|
||||||
@@ -1,3 +1,30 @@
|
@@ -1,3 +1,30 @@
|
||||||
+/*
|
+/*
|
||||||
+ * DISTRHO Cardinal Plugin
|
+ * DISTRHO Cardinal Plugin
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
#include <system.hpp>
|
#include <system.hpp>
|
||||||
#include <network.hpp>
|
#include <network.hpp>
|
||||||
#include <history.hpp>
|
#include <history.hpp>
|
||||||
@@ -14,31 +42,58 @@
|
@@ -14,6 +42,17 @@
|
||||||
#include <patch.hpp>
|
#include <patch.hpp>
|
||||||
#include <asset.hpp>
|
#include <asset.hpp>
|
||||||
|
|
||||||
|
@ -57,11 +57,9 @@
|
||||||
|
|
||||||
namespace rack {
|
namespace rack {
|
||||||
namespace app {
|
namespace app {
|
||||||
|
@@ -23,16 +62,55 @@
|
||||||
|
math::Vec size;
|
||||||
|
|
||||||
|
|
||||||
struct ResizeHandle : widget::OpaqueWidget {
|
|
||||||
- math::Vec size;
|
|
||||||
-
|
|
||||||
void draw(const DrawArgs& args) override {
|
void draw(const DrawArgs& args) override {
|
||||||
+ nvgStrokeColor(args.vg, nvgRGBf(1, 1, 1));
|
+ nvgStrokeColor(args.vg, nvgRGBf(1, 1, 1));
|
||||||
+ nvgStrokeWidth(args.vg, 1);
|
+ nvgStrokeWidth(args.vg, 1);
|
||||||
|
@ -74,12 +72,8 @@
|
||||||
- nvgClosePath(args.vg);
|
- nvgClosePath(args.vg);
|
||||||
- nvgFillColor(args.vg, nvgRGBAf(1, 1, 1, 0.15));
|
- nvgFillColor(args.vg, nvgRGBAf(1, 1, 1, 0.15));
|
||||||
- nvgFill(args.vg);
|
- nvgFill(args.vg);
|
||||||
- }
|
|
||||||
+ nvgStroke(args.vg);
|
+ nvgStroke(args.vg);
|
||||||
|
+
|
||||||
- void onDragStart(const DragStartEvent& e) override {
|
|
||||||
- size = APP->window->getSize();
|
|
||||||
- }
|
|
||||||
+ nvgBeginPath(args.vg);
|
+ nvgBeginPath(args.vg);
|
||||||
+ nvgMoveTo(args.vg, box.size.x + 5, 0);
|
+ nvgMoveTo(args.vg, box.size.x + 5, 0);
|
||||||
+ nvgLineTo(args.vg, 0, box.size.y + 5);
|
+ nvgLineTo(args.vg, 0, box.size.y + 5);
|
||||||
|
@ -91,10 +85,7 @@
|
||||||
+ nvgStroke(args.vg);
|
+ nvgStroke(args.vg);
|
||||||
+
|
+
|
||||||
+ nvgStrokeColor(args.vg, nvgRGBf(0, 0, 0));
|
+ nvgStrokeColor(args.vg, nvgRGBf(0, 0, 0));
|
||||||
|
+
|
||||||
- void onDragMove(const DragMoveEvent& e) override {
|
|
||||||
- size = size.plus(e.mouseDelta);
|
|
||||||
- APP->window->setSize(size.round());
|
|
||||||
+ nvgBeginPath(args.vg);
|
+ nvgBeginPath(args.vg);
|
||||||
+ nvgMoveTo(args.vg, box.size.x+1, 0);
|
+ nvgMoveTo(args.vg, box.size.x+1, 0);
|
||||||
+ nvgLineTo(args.vg, 0, box.size.y+1);
|
+ nvgLineTo(args.vg, 0, box.size.y+1);
|
||||||
|
@ -109,10 +100,26 @@
|
||||||
+ nvgMoveTo(args.vg, box.size.x + 11, 0);
|
+ nvgMoveTo(args.vg, box.size.x + 11, 0);
|
||||||
+ nvgLineTo(args.vg, 0, box.size.y + 11);
|
+ nvgLineTo(args.vg, 0, box.size.y + 11);
|
||||||
+ nvgStroke(args.vg);
|
+ nvgStroke(args.vg);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ void onHover(const HoverEvent& e) override {
|
||||||
|
+ e.consume(this);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ void onEnter(const EnterEvent& e) override {
|
||||||
|
+ glfwSetCursor(nullptr, (GLFWcursor*)0x1);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ void onLeave(const LeaveEvent& e) override {
|
||||||
|
+ glfwSetCursor(nullptr, nullptr);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
@@ -46,9 +101,32 @@
|
- void onDragStart(const DragStartEvent& e) override {
|
||||||
|
+ void onDragStart(const DragStartEvent&) override {
|
||||||
|
size = APP->window->getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -46,9 +124,32 @@
|
||||||
struct Scene::Internal {
|
struct Scene::Internal {
|
||||||
ResizeHandle* resizeHandle;
|
ResizeHandle* resizeHandle;
|
||||||
|
|
||||||
|
@ -147,7 +154,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -67,17 +145,17 @@
|
@@ -67,13 +168,8 @@
|
||||||
browser->hide();
|
browser->hide();
|
||||||
addChild(browser);
|
addChild(browser);
|
||||||
|
|
||||||
|
@ -162,16 +169,7 @@
|
||||||
addChild(internal->resizeHandle);
|
addChild(internal->resizeHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -89,32 +185,13 @@
|
||||||
+void hideResizeHandle(Scene* scene) {
|
|
||||||
+ scene->internal->resizeHandle->hide();
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+
|
|
||||||
Scene::~Scene() {
|
|
||||||
delete internal;
|
|
||||||
}
|
|
||||||
@@ -89,32 +167,13 @@
|
|
||||||
|
|
||||||
|
|
||||||
void Scene::step() {
|
void Scene::step() {
|
||||||
|
@ -205,7 +203,7 @@
|
||||||
// Scroll RackScrollWidget with arrow keys
|
// Scroll RackScrollWidget with arrow keys
|
||||||
math::Vec arrowDelta;
|
math::Vec arrowDelta;
|
||||||
if (internal->heldArrowKeys[0]) {
|
if (internal->heldArrowKeys[0]) {
|
||||||
@@ -143,6 +202,22 @@
|
@@ -143,6 +220,22 @@
|
||||||
rackScroll->offset += arrowDelta * arrowSpeed;
|
rackScroll->offset += arrowDelta * arrowSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +226,7 @@
|
||||||
Widget::step();
|
Widget::step();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +247,7 @@
|
@@ -172,7 +265,7 @@
|
||||||
if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) {
|
if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) {
|
||||||
// DEBUG("key '%d '%c' scancode %d '%c' keyName '%s'", e.key, e.key, e.scancode, e.scancode, e.keyName.c_str());
|
// DEBUG("key '%d '%c' scancode %d '%c' keyName '%s'", e.key, e.key, e.scancode, e.scancode, e.keyName.c_str());
|
||||||
if (e.keyName == "n" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
|
if (e.keyName == "n" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
|
||||||
|
@ -237,7 +235,7 @@
|
||||||
e.consume(this);
|
e.consume(this);
|
||||||
}
|
}
|
||||||
if (e.keyName == "q" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
|
if (e.keyName == "q" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
|
||||||
@@ -180,19 +255,20 @@
|
@@ -180,19 +273,20 @@
|
||||||
e.consume(this);
|
e.consume(this);
|
||||||
}
|
}
|
||||||
if (e.keyName == "o" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
|
if (e.keyName == "o" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
|
||||||
|
@ -262,7 +260,7 @@
|
||||||
e.consume(this);
|
e.consume(this);
|
||||||
}
|
}
|
||||||
if (e.keyName == "z" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
|
if (e.keyName == "z" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
|
||||||
@@ -232,10 +308,8 @@
|
@@ -232,10 +326,8 @@
|
||||||
settings::cpuMeter ^= true;
|
settings::cpuMeter ^= true;
|
||||||
e.consume(this);
|
e.consume(this);
|
||||||
}
|
}
|
||||||
|
@ -275,7 +273,7 @@
|
||||||
e.consume(this);
|
e.consume(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,13 +400,6 @@
|
@@ -326,13 +418,6 @@
|
||||||
|
|
||||||
// Key commands that can be overridden by children
|
// Key commands that can be overridden by children
|
||||||
if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) {
|
if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) {
|
||||||
|
@ -289,7 +287,7 @@
|
||||||
if (e.keyName == "v" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
|
if (e.keyName == "v" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
|
||||||
rack->pasteClipboardAction();
|
rack->pasteClipboardAction();
|
||||||
e.consume(this);
|
e.consume(this);
|
||||||
@@ -351,7 +418,7 @@
|
@@ -351,7 +436,7 @@
|
||||||
std::string extension = system::getExtension(path);
|
std::string extension = system::getExtension(path);
|
||||||
|
|
||||||
if (extension == ".vcv") {
|
if (extension == ".vcv") {
|
||||||
|
@ -298,7 +296,7 @@
|
||||||
e.consume(this);
|
e.consume(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -368,3 +435,73 @@
|
@@ -368,3 +453,73 @@
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace rack
|
} // namespace rack
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- ../Rack/src/window/Window.cpp 2022-01-05 19:24:25.995101080 +0000
|
--- ../Rack/src/window/Window.cpp 2022-01-05 19:24:25.995101080 +0000
|
||||||
+++ Window.cpp 2022-01-23 17:13:27.375765288 +0000
|
+++ Window.cpp 2022-01-26 18:35:47.181645555 +0000
|
||||||
@@ -1,33 +1,73 @@
|
@@ -1,33 +1,73 @@
|
||||||
+/*
|
+/*
|
||||||
+ * DISTRHO Cardinal Plugin
|
+ * DISTRHO Cardinal Plugin
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- ../Rack/src/plugin.cpp 2022-01-15 14:44:46.395281005 +0000
|
--- ../Rack/src/plugin.cpp 2022-01-15 14:44:46.395281005 +0000
|
||||||
+++ plugin.cpp 2022-01-23 22:59:41.770256440 +0000
|
+++ plugin.cpp 2022-01-24 20:38:11.436099651 +0000
|
||||||
@@ -1,308 +1,40 @@
|
@@ -1,308 +1,40 @@
|
||||||
-#include <thread>
|
-#include <thread>
|
||||||
-#include <map>
|
-#include <map>
|
||||||
|
@ -337,7 +337,7 @@
|
||||||
/** Given slug => fallback slug.
|
/** Given slug => fallback slug.
|
||||||
Correctly handles bidirectional fallbacks.
|
Correctly handles bidirectional fallbacks.
|
||||||
To request fallback slugs to be added to this list, open a GitHub issue.
|
To request fallback slugs to be added to this list, open a GitHub issue.
|
||||||
@@ -352,6 +84,11 @@
|
@@ -352,6 +84,12 @@
|
||||||
*/
|
*/
|
||||||
using PluginModuleSlug = std::tuple<std::string, std::string>;
|
using PluginModuleSlug = std::tuple<std::string, std::string>;
|
||||||
static const std::map<PluginModuleSlug, PluginModuleSlug> moduleSlugFallbacks = {
|
static const std::map<PluginModuleSlug, PluginModuleSlug> moduleSlugFallbacks = {
|
||||||
|
@ -346,10 +346,11 @@
|
||||||
+ {{"Core", "AudioInterface16"}, {"Cardinal", "HostAudio8"}},
|
+ {{"Core", "AudioInterface16"}, {"Cardinal", "HostAudio8"}},
|
||||||
+ {{"Core", "MIDIToCVInterface"}, {"Cardinal", "HostMIDI"}},
|
+ {{"Core", "MIDIToCVInterface"}, {"Cardinal", "HostMIDI"}},
|
||||||
+ {{"Core", "CV-MIDI"}, {"Cardinal", "HostMIDI"}},
|
+ {{"Core", "CV-MIDI"}, {"Cardinal", "HostMIDI"}},
|
||||||
|
+ {{"Core", "Notes"}, {"Cardinal", "TextEditor"}},
|
||||||
{{"MindMeld-ShapeMasterPro", "ShapeMasterPro"}, {"MindMeldModular", "ShapeMaster"}},
|
{{"MindMeld-ShapeMasterPro", "ShapeMasterPro"}, {"MindMeldModular", "ShapeMaster"}},
|
||||||
{{"MindMeldModular", "ShapeMaster"}, {"MindMeld-ShapeMasterPro", "ShapeMasterPro"}},
|
{{"MindMeldModular", "ShapeMaster"}, {"MindMeld-ShapeMasterPro", "ShapeMasterPro"}},
|
||||||
// {{"", ""}, {"", ""}},
|
// {{"", ""}, {"", ""}},
|
||||||
@@ -441,7 +178,6 @@
|
@@ -441,7 +179,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue