diff --git a/include/app/ParamWidget.hpp b/include/app/ParamWidget.hpp index 700e0897..eaa2ce9d 100644 --- a/include/app/ParamWidget.hpp +++ b/include/app/ParamWidget.hpp @@ -24,6 +24,9 @@ struct ParamWidget : widget::OpaqueWidget { */ virtual void initParamQuantity() {} engine::ParamQuantity* getParamQuantity(); + void createTooltip(); + void destroyTooltip(); + void step() override; void draw(const DrawArgs& args) override; diff --git a/include/plugin/Model.hpp b/include/plugin/Model.hpp index 113de61e..fac12de5 100644 --- a/include/plugin/Model.hpp +++ b/include/plugin/Model.hpp @@ -54,6 +54,7 @@ struct Model { } void fromJson(json_t* rootJ); + std::string getFullName(); }; diff --git a/include/plugin/Plugin.hpp b/include/plugin/Plugin.hpp index c7fd2b7b..111077be 100644 --- a/include/plugin/Plugin.hpp +++ b/include/plugin/Plugin.hpp @@ -66,6 +66,7 @@ struct Plugin { void addModel(Model* model); Model* getModel(std::string slug); void fromJson(json_t* rootJ); + std::string getBrand(); }; diff --git a/src/app/ParamWidget.cpp b/src/app/ParamWidget.cpp index c26495c2..c8e640ef 100644 --- a/src/app/ParamWidget.cpp +++ b/src/app/ParamWidget.cpp @@ -123,6 +123,23 @@ engine::ParamQuantity* ParamWidget::getParamQuantity() { return module->paramQuantities[paramId]; } +void ParamWidget::createTooltip() { + if (settings::paramTooltip && !this->tooltip && module) { + ParamTooltip* tooltip = new ParamTooltip; + tooltip->paramWidget = this; + APP->scene->addChild(tooltip); + this->tooltip = tooltip; + } +} + +void ParamWidget::destroyTooltip() { + if (tooltip) { + APP->scene->removeChild(tooltip); + delete tooltip; + tooltip = NULL; + } +} + void ParamWidget::step() { engine::ParamQuantity* pq = getParamQuantity(); if (pq) { @@ -170,6 +187,7 @@ void ParamWidget::onButton(const event::Button& e) { // Right click to open context menu if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT && (e.mods & RACK_MOD_MASK) == 0) { + destroyTooltip(); createContextMenu(); e.consume(this); } @@ -180,20 +198,11 @@ void ParamWidget::onDoubleClick(const event::DoubleClick& e) { } void ParamWidget::onEnter(const event::Enter& e) { - if (settings::paramTooltip && !this->tooltip && module) { - ParamTooltip* tooltip = new ParamTooltip; - tooltip->paramWidget = this; - APP->scene->addChild(tooltip); - this->tooltip = tooltip; - } + createTooltip(); } void ParamWidget::onLeave(const event::Leave& e) { - if (tooltip) { - APP->scene->removeChild(tooltip); - delete tooltip; - tooltip = NULL; - } + destroyTooltip(); } void ParamWidget::createContextMenu() { diff --git a/src/app/PortWidget.cpp b/src/app/PortWidget.cpp index d6bc1b17..10415b2a 100644 --- a/src/app/PortWidget.cpp +++ b/src/app/PortWidget.cpp @@ -38,6 +38,18 @@ struct PortTooltip : ui::Tooltip { text += "\n"; text += description; } + // Connected to + std::list cables = APP->scene->rack->getCablesOnPort(portWidget); + for (CableWidget* cable : cables) { + PortWidget* otherPw = (portWidget->type == engine::Port::INPUT) ? cable->outputPort : cable->inputPort; + if (!otherPw) + continue; + text += "\n"; + text += "Connected to "; + text += otherPw->module->model->getFullName(); + text += ": "; + text += otherPw->getPortInfo()->label; + } } Tooltip::step(); // Position at bottom-right of parameter diff --git a/src/plugin/Model.cpp b/src/plugin/Model.cpp index b03295ff..560774c5 100644 --- a/src/plugin/Model.cpp +++ b/src/plugin/Model.cpp @@ -51,5 +51,11 @@ void Model::fromJson(json_t* rootJ) { } +std::string Model::getFullName() { + assert(plugin); + return plugin->getBrand() + " " + name; +} + + } // namespace plugin } // namespace rack diff --git a/src/plugin/Plugin.cpp b/src/plugin/Plugin.cpp index 3db4bf29..7e41f8ba 100644 --- a/src/plugin/Plugin.cpp +++ b/src/plugin/Plugin.cpp @@ -145,5 +145,12 @@ void Plugin::fromJson(json_t* rootJ) { } +std::string Plugin::getBrand() { + if (brand == "") + return name; + return brand; +} + + } // namespace plugin } // namespace rack