Browse Source

Add "Connected to" to PortTooltip.

tags/v2.0.0
Andrew Belt 5 years ago
parent
commit
4a462fadc5
7 changed files with 50 additions and 11 deletions
  1. +3
    -0
      include/app/ParamWidget.hpp
  2. +1
    -0
      include/plugin/Model.hpp
  3. +1
    -0
      include/plugin/Plugin.hpp
  4. +20
    -11
      src/app/ParamWidget.cpp
  5. +12
    -0
      src/app/PortWidget.cpp
  6. +6
    -0
      src/plugin/Model.cpp
  7. +7
    -0
      src/plugin/Plugin.cpp

+ 3
- 0
include/app/ParamWidget.hpp View File

@@ -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;



+ 1
- 0
include/plugin/Model.hpp View File

@@ -54,6 +54,7 @@ struct Model {
}

void fromJson(json_t* rootJ);
std::string getFullName();
};




+ 1
- 0
include/plugin/Plugin.hpp View File

@@ -66,6 +66,7 @@ struct Plugin {
void addModel(Model* model);
Model* getModel(std::string slug);
void fromJson(json_t* rootJ);
std::string getBrand();
};




+ 20
- 11
src/app/ParamWidget.cpp View File

@@ -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() {


+ 12
- 0
src/app/PortWidget.cpp View File

@@ -38,6 +38,18 @@ struct PortTooltip : ui::Tooltip {
text += "\n";
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();
// Position at bottom-right of parameter


+ 6
- 0
src/plugin/Model.cpp View File

@@ -51,5 +51,11 @@ void Model::fromJson(json_t* rootJ) {
}


std::string Model::getFullName() {
assert(plugin);
return plugin->getBrand() + " " + name;
}


} // namespace plugin
} // namespace rack

+ 7
- 0
src/plugin/Plugin.cpp View File

@@ -145,5 +145,12 @@ void Plugin::fromJson(json_t* rootJ) {
}


std::string Plugin::getBrand() {
if (brand == "")
return name;
return brand;
}


} // namespace plugin
} // namespace rack

Loading…
Cancel
Save