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;
int portId = -1;

MultiLightWidget* plugLight;

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



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

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


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

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

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


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

PortWidget::~PortWidget() {
// HACK: In case onDragDrop() is called but not onLeave() afterwards...
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)
APP->scene->rack->clearCablesOnPort(this);
delete internal;
@@ -113,6 +114,10 @@ engine::PortInfo* PortWidget::getPortInfo() {
return module->outputInfos[portId];
}

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

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

Widget::step();
}


Loading…
Cancel
Save