@@ -24,6 +24,9 @@ struct ParamWidget : widget::OpaqueWidget { | |||||
*/ | */ | ||||
virtual void initParamQuantity() {} | virtual void initParamQuantity() {} | ||||
engine::ParamQuantity* getParamQuantity(); | engine::ParamQuantity* getParamQuantity(); | ||||
void createTooltip(); | |||||
void destroyTooltip(); | |||||
void step() override; | void step() override; | ||||
void draw(const DrawArgs& args) override; | void draw(const DrawArgs& args) override; | ||||
@@ -54,6 +54,7 @@ struct Model { | |||||
} | } | ||||
void fromJson(json_t* rootJ); | void fromJson(json_t* rootJ); | ||||
std::string getFullName(); | |||||
}; | }; | ||||
@@ -66,6 +66,7 @@ struct Plugin { | |||||
void addModel(Model* model); | void addModel(Model* model); | ||||
Model* getModel(std::string slug); | Model* getModel(std::string slug); | ||||
void fromJson(json_t* rootJ); | void fromJson(json_t* rootJ); | ||||
std::string getBrand(); | |||||
}; | }; | ||||
@@ -123,6 +123,23 @@ engine::ParamQuantity* ParamWidget::getParamQuantity() { | |||||
return module->paramQuantities[paramId]; | 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() { | void ParamWidget::step() { | ||||
engine::ParamQuantity* pq = getParamQuantity(); | engine::ParamQuantity* pq = getParamQuantity(); | ||||
if (pq) { | if (pq) { | ||||
@@ -170,6 +187,7 @@ void ParamWidget::onButton(const event::Button& e) { | |||||
// Right click to open context menu | // Right click to open context menu | ||||
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT && (e.mods & RACK_MOD_MASK) == 0) { | if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT && (e.mods & RACK_MOD_MASK) == 0) { | ||||
destroyTooltip(); | |||||
createContextMenu(); | createContextMenu(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
@@ -180,20 +198,11 @@ void ParamWidget::onDoubleClick(const event::DoubleClick& e) { | |||||
} | } | ||||
void ParamWidget::onEnter(const event::Enter& 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) { | void ParamWidget::onLeave(const event::Leave& e) { | ||||
if (tooltip) { | |||||
APP->scene->removeChild(tooltip); | |||||
delete tooltip; | |||||
tooltip = NULL; | |||||
} | |||||
destroyTooltip(); | |||||
} | } | ||||
void ParamWidget::createContextMenu() { | void ParamWidget::createContextMenu() { | ||||
@@ -38,6 +38,18 @@ struct PortTooltip : ui::Tooltip { | |||||
text += "\n"; | text += "\n"; | ||||
text += description; | text += description; | ||||
} | } | ||||
// Connected to | |||||
std::list<CableWidget*> 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(); | Tooltip::step(); | ||||
// Position at bottom-right of parameter | // Position at bottom-right of parameter | ||||
@@ -51,5 +51,11 @@ void Model::fromJson(json_t* rootJ) { | |||||
} | } | ||||
std::string Model::getFullName() { | |||||
assert(plugin); | |||||
return plugin->getBrand() + " " + name; | |||||
} | |||||
} // namespace plugin | } // namespace plugin | ||||
} // namespace rack | } // namespace rack |
@@ -145,5 +145,12 @@ void Plugin::fromJson(json_t* rootJ) { | |||||
} | } | ||||
std::string Plugin::getBrand() { | |||||
if (brand == "") | |||||
return name; | |||||
return brand; | |||||
} | |||||
} // namespace plugin | } // namespace plugin | ||||
} // namespace rack | } // namespace rack |