Browse Source

Move PortWidget::plugLight to internal.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
f0446ab4c6
3 changed files with 13 additions and 9 deletions
  1. +1
    -2
      include/app/PortWidget.hpp
  2. +2
    -2
      src/app/CableWidget.cpp
  3. +10
    -5
      src/app/PortWidget.cpp

+ 1
- 2
include/app/PortWidget.hpp View File

@@ -20,12 +20,11 @@ struct PortWidget : widget::OpaqueWidget {
engine::Port::Type type = engine::Port::INPUT; engine::Port::Type type = engine::Port::INPUT;
int portId = -1; int portId = -1;


MultiLightWidget* plugLight;

PortWidget(); PortWidget();
~PortWidget(); ~PortWidget();
engine::Port* getPort(); engine::Port* getPort();
engine::PortInfo* getPortInfo(); engine::PortInfo* getPortInfo();
LightWidget* getPlugLight();
void createTooltip(); void createTooltip();
void destroyTooltip(); void destroyTooltip();




+ 2
- 2
src/app/CableWidget.cpp View File

@@ -226,7 +226,7 @@ void CableWidget::drawPlugs(const DrawArgs& args) {
// Draw plug light // Draw plug light
nvgSave(args.vg); nvgSave(args.vg);
nvgTranslate(args.vg, outputPos.x - 4, outputPos.y - 4); nvgTranslate(args.vg, outputPos.x - 4, outputPos.y - 4);
outputPort->plugLight->draw(args);
outputPort->getPlugLight()->draw(args);
nvgRestore(args.vg); nvgRestore(args.vg);
} }
} }
@@ -236,7 +236,7 @@ void CableWidget::drawPlugs(const DrawArgs& args) {
if (isComplete()) { if (isComplete()) {
nvgSave(args.vg); nvgSave(args.vg);
nvgTranslate(args.vg, inputPos.x - 4, inputPos.y - 4); nvgTranslate(args.vg, inputPos.x - 4, inputPos.y - 4);
inputPort->plugLight->draw(args);
inputPort->getPlugLight()->draw(args);
nvgRestore(args.vg); nvgRestore(args.vg);
} }
} }


+ 10
- 5
src/app/PortWidget.cpp View File

@@ -76,20 +76,21 @@ struct PlugLight : MultiLightWidget {


struct PortWidget::Internal { struct PortWidget::Internal {
ui::Tooltip* tooltip = NULL; ui::Tooltip* tooltip = NULL;
PlugLight* plugLight;
}; };




PortWidget::PortWidget() { PortWidget::PortWidget() {
internal = new Internal; internal = new Internal;
plugLight = new PlugLight;
internal->plugLight = new PlugLight;
} }


PortWidget::~PortWidget() { PortWidget::~PortWidget() {
// HACK: In case onDragDrop() is called but not onLeave() afterwards... // HACK: In case onDragDrop() is called but not onLeave() afterwards...
destroyTooltip(); destroyTooltip();
// plugLight is not a child and is thus owned by the PortWidget, so we need to delete it here
delete plugLight;
// HACK
// plugLight is not a child but owned by the PortWidget, so we need to delete it here
delete internal->plugLight;
// The port shouldn't have any cables when destroyed, but just to make sure.
if (module) if (module)
APP->scene->rack->clearCablesOnPort(this); APP->scene->rack->clearCablesOnPort(this);
delete internal; delete internal;
@@ -113,6 +114,10 @@ engine::PortInfo* PortWidget::getPortInfo() {
return module->outputInfos[portId]; return module->outputInfos[portId];
} }


LightWidget* PortWidget::getPlugLight() {
return internal->plugLight;
}

void PortWidget::createTooltip() { void PortWidget::createTooltip() {
if (!settings::tooltips) if (!settings::tooltips)
return; return;
@@ -145,7 +150,7 @@ void PortWidget::step() {
else else
values[i] = module->inputs[portId].plugLights[i].getBrightness(); values[i] = module->inputs[portId].plugLights[i].getBrightness();
} }
plugLight->setBrightnesses(values);
internal->plugLight->setBrightnesses(values);


Widget::step(); Widget::step();
} }


Loading…
Cancel
Save