Almost working, no green to sink

This commit is contained in:
Joey Yakimowich-Payne 2026-02-12 17:07:33 -07:00
commit 2208483123
4 changed files with 26 additions and 21 deletions

View file

@ -43,8 +43,9 @@ void BezierConnectionPainter::paint(
auto *model = dynamic_cast<WarpGraphModel *>(&scene->graphModel()); auto *model = dynamic_cast<WarpGraphModel *>(&scene->graphModel());
if (model) { if (model) {
auto cId = cgo.connectionId(); auto cId = cgo.connectionId();
peakLevel = std::max(model->nodePeakLevel(cId.outNodeId), if (model->connectionExists(cId)) {
model->nodePeakLevel(cId.inNodeId)); peakLevel = model->nodePeakLevel(cId.outNodeId);
}
} }
} }

View file

@ -66,16 +66,17 @@ QPainterPath SquareConnectionPainter::orthogonalPath(
constexpr double kNodePad = 15.0; constexpr double kNodePad = 15.0;
auto const cId = cgo.connectionId(); auto const cId = cgo.connectionId();
auto *sceneForChannel = cgo.nodeScene();
auto *mdl = sceneForChannel
? dynamic_cast<WarpGraphModel *>(&sceneForChannel->graphModel())
: nullptr;
bool connectionAlive = mdl ? mdl->connectionExists(cId) : true;
double spread = static_cast<double>(cId.outPortIndex) * kSpacing; double spread = static_cast<double>(cId.outPortIndex) * kSpacing;
auto *sceneForChannel = cgo.nodeScene(); if (mdl && connectionAlive) {
if (sceneForChannel) { auto ch = mdl->connectionChannel(cId);
auto *mdl = dynamic_cast<WarpGraphModel *>(&sceneForChannel->graphModel()); spread = (static_cast<double>(ch.index) - (ch.count - 1) / 2.0)
if (mdl) { * kSpacing;
auto ch = mdl->connectionChannel(cId);
spread = (static_cast<double>(ch.index) - (ch.count - 1) / 2.0)
* kSpacing;
}
} }
double const dy = in.y() - out.y(); double const dy = in.y() - out.y();
@ -125,12 +126,9 @@ QPainterPath SquareConnectionPainter::orthogonalPath(
// //
double railOffset = 0.0; double railOffset = 0.0;
if (sceneForChannel) { if (mdl && connectionAlive) {
auto *mdl2 = dynamic_cast<WarpGraphModel *>(&sceneForChannel->graphModel()); auto ch = mdl->connectionChannel(cId);
if (mdl2) { railOffset = static_cast<double>(ch.index) * kSpacing;
auto ch = mdl2->connectionChannel(cId);
railOffset = static_cast<double>(ch.index) * kSpacing;
}
} }
double rightX = out.x() + kMinStub + railOffset; double rightX = out.x() + kMinStub + railOffset;
@ -205,8 +203,9 @@ void SquareConnectionPainter::paint(
auto *model = dynamic_cast<WarpGraphModel *>(&scene->graphModel()); auto *model = dynamic_cast<WarpGraphModel *>(&scene->graphModel());
if (model) { if (model) {
auto cId = cgo.connectionId(); auto cId = cgo.connectionId();
peakLevel = std::max(model->nodePeakLevel(cId.outNodeId), if (model->connectionExists(cId)) {
model->nodePeakLevel(cId.inNodeId)); peakLevel = model->nodePeakLevel(cId.outNodeId);
}
} }
} }

View file

@ -343,6 +343,8 @@ bool WarpGraphModel::deleteConnection(
} }
m_connections.erase(it); m_connections.erase(it);
m_connectionChannels.erase(connectionId);
recomputeConnectionChannels();
Q_EMIT connectionDeleted(connectionId); Q_EMIT connectionDeleted(connectionId);
return true; return true;
} }
@ -374,6 +376,7 @@ bool WarpGraphModel::deleteNode(QtNodes::NodeId const nodeId) {
m_positions.erase(nodeId); m_positions.erase(nodeId);
m_sizes.erase(nodeId); m_sizes.erase(nodeId);
m_volumeStates.erase(nodeId); m_volumeStates.erase(nodeId);
m_peakLevels.erase(nodeId);
m_styleCache.erase(nodeId); m_styleCache.erase(nodeId);
m_volumeWidgets.erase(nodeId); m_volumeWidgets.erase(nodeId);
Q_EMIT nodeDeleted(nodeId); Q_EMIT nodeDeleted(nodeId);

View file

@ -329,10 +329,12 @@ void NodeMeterProcess(void* data) {
had_data = true; had_data = true;
pw_stream_queue_buffer(meter->stream, buf); pw_stream_queue_buffer(meter->stream, buf);
} }
if (had_data) { if (!had_data) {
meter->peak_left.store(left, std::memory_order_relaxed); left = 0.0f;
meter->peak_right.store(right, std::memory_order_relaxed); right = 0.0f;
} }
meter->peak_left.store(left, std::memory_order_relaxed);
meter->peak_right.store(right, std::memory_order_relaxed);
} }
static const pw_stream_events kNodeMeterEvents = { static const pw_stream_events kNodeMeterEvents = {