Skip to content

Commit

Permalink
Refactor visNode paint method to render edit widget items before draw…
Browse files Browse the repository at this point in the history
…ing hot areas; adjust rectangle dimensions for better alignment
  • Loading branch information
dongzgh committed Jan 12, 2025
1 parent f6941de commit 8730807
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/visNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,22 +340,30 @@ void visNode::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, Q
// Set no pen.
painter->setPen(Qt::NoPen);

// Draw edit box hot areas.
// Draw the QLineEdit items first.
int yOffset = titleHeight + spacing;
for (int i = 0; i < edits.size(); ++i) {
// Assuming edits[i] is a QLineEdit or similar widget
edits[i]->render(painter, QPoint(spacing, yOffset));
yOffset += editHeight + spacing;
}

// Draw edit box hot areas.
yOffset = titleHeight + spacing;
for (int i = 0; i < edits.size(); ++i) {
if (i == 0) {
// Draw for the in hidden edit box.
QRectF inputHotRect(spacing / 2, 0, spacing / 2, titleHeight);
hotRects.append(inputHotRect);
QRectF drawRect(spacing / 2, 0, editHeight, editHeight);
QRectF drawRect(spacing / 2, 0, titleHeight, titleHeight);
painter->setBrush(inputColor);
painter->drawRect(drawRect);
}
else if (i == 1) {
// Draw for the out hidden edit box.
QRectF outputHotRect(boundingRect().width() - spacing, 0, spacing / 2, titleHeight);
hotRects.append(outputHotRect);
QRectF drawRect(boundingRect().width() - spacing / 2 - editHeight, 0, editHeight, editHeight);
QRectF drawRect(boundingRect().width() - spacing / 2 - titleHeight, 0, titleHeight, titleHeight);
painter->setBrush(outputColor);
painter->drawRect(drawRect);
}
Expand Down

0 comments on commit 8730807

Please sign in to comment.