Compare commits

..

No commits in common. "916965488c9d3d2fd2b6da2584e1795fbc908e85" and "65cd227f46af53dd0a0862317c544bd378246608" have entirely different histories.

4 changed files with 4 additions and 57 deletions

View file

@ -1668,23 +1668,16 @@ void GraphEditorWidget::updateMeters() {
m_masterMeterR->setLevel(master.value.peak_right);
}
bool anyActive = false;
for (auto &[nodeId, row] : m_nodeMeters) {
const WarpNodeData *data = m_model->warpNodeData(nodeId);
if (!data || !row.meter)
continue;
auto peak = m_client->NodeMeterPeak(data->info.id);
if (peak.ok()) {
float level = std::max(peak.value.peak_left, peak.value.peak_right);
row.meter->setLevel(level);
m_model->setNodePeakLevel(nodeId, level);
if (level > 0.001f)
anyActive = true;
row.meter->setLevel(
std::max(peak.value.peak_left, peak.value.peak_right));
}
}
if (anyActive && m_scene)
m_scene->update();
}
void GraphEditorWidget::rebuildNodeMeters() {

View file

@ -1,5 +1,4 @@
#include "SquareConnectionPainter.h"
#include "WarpGraphModel.h"
#include <QtNodes/internal/BasicGraphicsScene.hpp>
#include <QtNodes/internal/ConnectionGraphicsObject.hpp>
@ -188,30 +187,6 @@ void SquareConnectionPainter::paint(
auto path = orthogonalPath(cgo);
float peakLevel = 0.0f;
auto *scene = cgo.nodeScene();
if (scene) {
auto *model = dynamic_cast<WarpGraphModel *>(&scene->graphModel());
if (model) {
auto cId = cgo.connectionId();
peakLevel = std::max(model->nodePeakLevel(cId.outNodeId),
model->nodePeakLevel(cId.inNodeId));
}
}
auto activeColor = [&](QColor base) -> QColor {
if (peakLevel < 0.005f)
return base;
float t = std::min(peakLevel * 2.0f, 1.0f);
int r = static_cast<int>(base.red() + t * (60 - base.red()));
int g = static_cast<int>(base.green() + t * (210 - base.green()));
int b = static_cast<int>(base.blue() + t * (80 - base.blue()));
return QColor(std::clamp(r, 0, 255),
std::clamp(g, 0, 255),
std::clamp(b, 0, 255),
base.alpha());
};
if (hovered || selected) {
QPen pen;
pen.setWidth(static_cast<int>(2 * style.lineWidth()));
@ -230,15 +205,9 @@ void SquareConnectionPainter::paint(
painter->setBrush(Qt::NoBrush);
painter->drawPath(path);
} else {
QColor base = selected ? style.selectedColor() : style.normalColor();
QColor color = selected ? base : activeColor(base);
float width = style.lineWidth();
if (!selected && peakLevel > 0.005f)
width += peakLevel * 1.5f;
QPen pen;
pen.setWidthF(width);
pen.setColor(color);
pen.setWidth(style.lineWidth());
pen.setColor(selected ? style.selectedColor() : style.normalColor());
painter->setPen(pen);
painter->setBrush(Qt::NoBrush);
painter->drawPath(path);

View file

@ -965,17 +965,6 @@ WarpGraphModel::nodeVolumeState(QtNodes::NodeId nodeId) const {
return {};
}
void WarpGraphModel::setNodePeakLevel(QtNodes::NodeId nodeId, float level) {
constexpr float kDecay = 0.82f;
float &stored = m_peakLevels[nodeId];
stored = std::max(level, stored * kDecay);
}
float WarpGraphModel::nodePeakLevel(QtNodes::NodeId nodeId) const {
auto it = m_peakLevels.find(nodeId);
return it != m_peakLevels.end() ? it->second : 0.0f;
}
void WarpGraphModel::saveLayout(const QString &path) const {
ViewState vs{};
saveLayout(path, vs);

View file

@ -95,9 +95,6 @@ public:
void setNodeVolumeState(QtNodes::NodeId nodeId, const NodeVolumeState &state);
NodeVolumeState nodeVolumeState(QtNodes::NodeId nodeId) const;
void setNodePeakLevel(QtNodes::NodeId nodeId, float level);
float nodePeakLevel(QtNodes::NodeId nodeId) const;
Q_SIGNALS:
void beginBatchUpdate();
void endBatchUpdate();
@ -172,5 +169,4 @@ private:
std::unordered_map<QtNodes::NodeId, NodeVolumeState> m_volumeStates;
std::unordered_map<QtNodes::NodeId, QPointer<QWidget>> m_volumeWidgets;
mutable std::unordered_map<QtNodes::NodeId, QVariant> m_styleCache;
std::unordered_map<QtNodes::NodeId, float> m_peakLevels;
};