summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Belt <andrewpbelt@gmail.com>2024-05-09 08:19:33 -0400
committerAndrew Belt <andrewpbelt@gmail.com>2024-05-09 08:19:33 -0400
commit58f2482df860fe878581423aedc8cadb1d94eb50 (patch)
tree69cb413e0f5f7231943ffff1fe4493b59548b3c4
parent29fa3523317e744444fab2179938c3fc03c86bd0 (diff)
Add "Create cable on top" item to port menu. Tweak menu labels.HEADv2.5.2v2
-rw-r--r--include/ui/MenuItem.hpp2
-rw-r--r--src/app/PortWidget.cpp34
2 files changed, 31 insertions, 5 deletions
diff --git a/include/ui/MenuItem.hpp b/include/ui/MenuItem.hpp
index 1d75488a..edabf430 100644
--- a/include/ui/MenuItem.hpp
+++ b/include/ui/MenuItem.hpp
@@ -32,7 +32,7 @@ struct MenuItem : MenuEntry {
struct ColorDotMenuItem : MenuItem {
- NVGcolor color;
+ NVGcolor color = color::BLACK_TRANSPARENT;
void draw(const DrawArgs& args) override;
void step() override;
diff --git a/src/app/PortWidget.cpp b/src/app/PortWidget.cpp
index 0b68aae5..e5506e57 100644
--- a/src/app/PortWidget.cpp
+++ b/src/app/PortWidget.cpp
@@ -150,7 +150,27 @@ struct PortCableItem : ui::ColorDotMenuItem {
};
-struct PortCreateCableItem : ui::ColorDotMenuItem {
+struct PortCreateCableItem : ui::MenuItem {
+ PortWidget* pw;
+
+ void onButton(const ButtonEvent& e) override {
+ OpaqueWidget::onButton(e);
+ if (disabled)
+ return;
+ if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT && (e.mods & RACK_MOD_MASK) == 0) {
+ // Set PortWidget::onDragStart overrides
+ pw->internal->overrideCreateCable = true;
+
+ // Pretend the PortWidget was clicked
+ e.consume(pw);
+ // Deletes `this`
+ doAction();
+ }
+ }
+};
+
+
+struct PortCreateCableColorItem : ui::ColorDotMenuItem {
PortWidget* pw;
size_t colorId;
@@ -251,13 +271,19 @@ void PortWidget::createContextMenu() {
));
{
- PortCloneCableItem* item = createMenuItem<PortCloneCableItem>("Duplicate top cable", RACK_MOD_CTRL_NAME "+drag");
+ PortCloneCableItem* item = createMenuItem<PortCloneCableItem>("Duplicate top cable", RACK_MOD_CTRL_NAME "+Shift+drag");
item->disabled = !topCw;
item->pw = this;
item->cw = topCw;
menu->addChild(item);
}
+ {
+ PortCreateCableItem* item = createMenuItem<PortCreateCableItem>("Create cable on top", RACK_MOD_CTRL_NAME "+drag");
+ item->pw = this;
+ menu->addChild(item);
+ }
+
menu->addChild(new ui::MenuSeparator);
// New cable items
@@ -265,8 +291,8 @@ void PortWidget::createContextMenu() {
NVGcolor color = settings::cableColors[colorId];
std::string label = get(settings::cableLabels, colorId);
if (label == "")
- label = string::f("Color #%lld", (long long) (colorId + 1));
- PortCreateCableItem* item = createMenuItem<PortCreateCableItem>(label, "Click+drag");
+ label = string::f("#%lld", (long long) (colorId + 1));
+ PortCreateCableColorItem* item = createMenuItem<PortCreateCableColorItem>("Create cable: " + label);
item->pw = this;
item->color = color;
item->colorId = colorId;