diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.cpp index 1e9a1f8a..6f2e45ed 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.cpp @@ -1,11 +1,12 @@ #include "BodyWidget.hpp" -#include - -#include "src/Exceptions/Exception.hpp" - using namespace Bloom::Widgets::InsightTargetWidgets::Dip; -using namespace Bloom::Exceptions; + +BodyWidget::BodyWidget(QWidget* parent): QWidget(parent) { + this->setObjectName("target-body"); + + this->setFixedHeight(BodyWidget::HEIGHT); +} void BodyWidget::paintEvent(QPaintEvent* event) { auto painter = QPainter(this); @@ -13,17 +14,11 @@ void BodyWidget::paintEvent(QPaintEvent* event) { } void BodyWidget::drawWidget(QPainter& painter) { - auto parentWidget = this->parentWidget(); - - if (parentWidget == nullptr) { - throw Exception("BodyWidget requires a parent widget"); - } - painter.setRenderHints(QPainter::RenderHint::Antialiasing | QPainter::RenderHint::SmoothPixmapTransform, true); // Draw target body auto targetBodyColor = this->getBodyColor(); - auto backgroundColor = QColor("#373835"); + auto backgroundColor = QColor(0x37, 0x38, 0x35); if (!this->isEnabled()) { targetBodyColor.setAlpha(this->getDisableAlphaLevel()); @@ -31,7 +26,6 @@ void BodyWidget::drawWidget(QPainter& painter) { painter.setPen(Qt::PenStyle::NoPen); painter.setBrush(targetBodyColor); - const auto targetBodyHeight = this->height(); auto targetBodyPoint = QPoint( 0, @@ -42,22 +36,22 @@ void BodyWidget::drawWidget(QPainter& painter) { targetBodyPoint.x(), targetBodyPoint.y(), this->width(), - targetBodyHeight + BodyWidget::HEIGHT ); painter.setPen(Qt::PenStyle::NoPen); painter.setBrush(backgroundColor); painter.drawEllipse(QRectF( targetBodyPoint.x() + 10, - targetBodyPoint.y() + (targetBodyHeight - 30), + targetBodyPoint.y() + (BodyWidget::HEIGHT - 30), 18, 18 )); painter.drawEllipse(QRectF( targetBodyPoint.x() - 15, - targetBodyPoint.y() + (targetBodyHeight / 2) - 15, - 28, - 28 + targetBodyPoint.y() + (BodyWidget::HEIGHT / 2) - 15, + 24, + 24 )); } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.hpp index d85173e9..0c97f000 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include namespace Bloom::Widgets::InsightTargetWidgets::Dip { @@ -11,9 +12,9 @@ namespace Bloom::Widgets::InsightTargetWidgets::Dip Q_PROPERTY(int disableAlphaLevel READ getDisableAlphaLevel WRITE setDisableAlphaLevel DESIGNABLE true) public: - explicit BodyWidget(QWidget* parent): QWidget(parent) { - this->setObjectName("target-body"); - } + static constexpr int HEIGHT = 130; + + explicit BodyWidget(QWidget* parent); [[nodiscard]] QColor getBodyColor() const { return this->bodyColor; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.cpp index 4ccd818a..dcabf6e5 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.cpp @@ -30,18 +30,20 @@ DualInlinePackageWidget::DualInlinePackageWidget( this->layout = new QVBoxLayout(); this->layout->setSpacing(PinWidget::WIDTH_SPACING); this->layout->setContentsMargins(0, 0, 0, 0); + this->layout->setAlignment(Qt::AlignmentFlag::AlignVCenter); this->topPinLayout = new QHBoxLayout(); - this->topPinLayout->setSpacing(0); + this->topPinLayout->setSpacing(PinWidget::WIDTH_SPACING); this->topPinLayout->setDirection(QBoxLayout::Direction::RightToLeft); this->topPinLayout->setAlignment(Qt::AlignmentFlag::AlignHCenter); this->bottomPinLayout = new QHBoxLayout(); - this->bottomPinLayout->setSpacing(0); + this->bottomPinLayout->setSpacing(PinWidget::WIDTH_SPACING); this->bottomPinLayout->setAlignment(Qt::AlignmentFlag::AlignHCenter); for (const auto& [targetPinNumber, targetPinDescriptor]: targetVariant.pinDescriptorsByNumber) { auto* pinWidget = new PinWidget(targetPinDescriptor, targetVariant, insightWorker, this); this->pinWidgets.push_back(pinWidget); + TargetPackageWidget::pinWidgets.push_back(pinWidget); if (targetPinNumber <= (targetVariant.pinDescriptorsByNumber.size() / 2)) { this->bottomPinLayout->addWidget(pinWidget, 0, Qt::AlignmentFlag::AlignHCenter); @@ -52,23 +54,33 @@ DualInlinePackageWidget::DualInlinePackageWidget( this->layout->addLayout(this->topPinLayout); this->bodyWidget = new BodyWidget(this); - this->layout->addWidget(this->bodyWidget); + this->layout->addWidget(this->bodyWidget, 0, Qt::AlignmentFlag::AlignVCenter); this->layout->addLayout(this->bottomPinLayout); this->setLayout(this->layout); const auto bodyWidgetWidth = ((PinWidget::MINIMUM_WIDTH + PinWidget::WIDTH_SPACING) - * static_cast(this->pinWidgets.size() / 2)) + 46; - const auto bodyWidgetHeight = 150; + * static_cast(this->pinWidgets.size() / 2)) - PinWidget::WIDTH_SPACING + 46; const auto width = bodyWidgetWidth; - const auto height = (PinWidget::MAXIMUM_HEIGHT * 2) + bodyWidgetHeight + (PinWidget::WIDTH_SPACING * 2); + const auto height = ( + ( + PinWidget::MAXIMUM_HEIGHT + PinWidget::WIDTH_SPACING + PinWidget::PIN_LABEL_LONG_LINE_LENGTH + + PinWidget::PIN_LABEL_SHORT_LINE_LENGTH + ( + (PinWidget::LABEL_HEIGHT + PinWidget::PIN_LABEL_SPACING) * 2 + ) + ) * 2) + BodyWidget::HEIGHT; - this->bodyWidget->setGeometry(0, PinWidget::MAXIMUM_HEIGHT + PinWidget::WIDTH_SPACING, width, bodyWidgetHeight); + this->bodyWidget->setGeometry( + 0, + PinWidget::MAXIMUM_HEIGHT + PinWidget::WIDTH_SPACING, + width, + BodyWidget::HEIGHT + ); this->topPinLayout->setGeometry(QRect(0, 0, width, PinWidget::MAXIMUM_HEIGHT)); this->bottomPinLayout->setGeometry( QRect( 0, - (PinWidget::MAXIMUM_HEIGHT + bodyWidgetHeight + (PinWidget::WIDTH_SPACING * 2)), + (PinWidget::MAXIMUM_HEIGHT + BodyWidget::HEIGHT + (PinWidget::WIDTH_SPACING * 2)), width, PinWidget::MAXIMUM_HEIGHT ) @@ -85,3 +97,151 @@ DualInlinePackageWidget::DualInlinePackageWidget( height ); } + +void DualInlinePackageWidget::paintEvent(QPaintEvent* event) { + auto painter = QPainter(this); + this->drawWidget(painter); +} + +void DualInlinePackageWidget::drawWidget(QPainter& painter) { + using Targets::TargetPinState; + + static auto pinNameFont = QFont("'Ubuntu', sans-serif"); + static auto pinDirectionFont = pinNameFont; + pinNameFont.setPixelSize(11); + pinDirectionFont.setPixelSize(10); + + static const auto lineColor = QColor(0x4F, 0x4F, 0x4F); + static const auto pinNameFontColor = QColor(0xA6, 0xA7, 0xAA); + static const auto pinDirectionFontColor = QColor(0x8A, 0x8A, 0x8D); + static const auto pinChangedFontColor = QColor(0x4D, 0x7B, 0xBA); + + static const auto inDirectionText = QString("IN"); + static const auto outDirectionText = QString("OUT"); + + for (const auto* pinWidget : this->pinWidgets) { + const auto pinGeoPosition = pinWidget->pos(); + const auto& pinState = pinWidget->getPinState(); + const auto pinStateChanged = pinWidget->hasPinStateChanged(); + + painter.setFont(pinNameFont); + + if (pinWidget->position == Position::TOP) { + painter.setPen(lineColor); + const auto pinNameLabelLineLength = (pinWidget->getPinNumber() % 2 == 0 ? + PinWidget::PIN_LABEL_LONG_LINE_LENGTH + : PinWidget::PIN_LABEL_SHORT_LINE_LENGTH + ); + const auto pinDirectionLabelLineLength = (pinWidget->getPinNumber() % 2 == 0 ? + PinWidget::PIN_LABEL_SHORT_LINE_LENGTH + : PinWidget::PIN_LABEL_LONG_LINE_LENGTH + ); + + painter.drawLine(QLine( + pinGeoPosition.x() + (PinWidget::MINIMUM_WIDTH / 2), + pinGeoPosition.y() - pinNameLabelLineLength, + pinGeoPosition.x() + (PinWidget::MINIMUM_WIDTH / 2), + pinGeoPosition.y() + )); + + painter.setPen(pinStateChanged ? pinChangedFontColor : pinNameFontColor); + painter.drawText( + QRect( + pinGeoPosition.x() + (PinWidget::MINIMUM_WIDTH / 2) + - (PinWidget::MAXIMUM_LABEL_WIDTH / 2), + pinGeoPosition.y() - pinNameLabelLineLength - PinWidget::MAXIMUM_LABEL_HEIGHT, + PinWidget::MAXIMUM_LABEL_WIDTH, + PinWidget::MAXIMUM_LABEL_HEIGHT + ), + Qt::AlignCenter, + pinWidget->pinNameLabelText + ); + + if (pinState.has_value() && pinState->ioDirection.has_value()) { + painter.setFont(pinDirectionFont); + + painter.setPen(lineColor); + painter.drawLine(QLine( + pinGeoPosition.x() + (PinWidget::MINIMUM_WIDTH / 2), + pinGeoPosition.y() - pinNameLabelLineLength - PinWidget::MAXIMUM_LABEL_HEIGHT + - pinDirectionLabelLineLength, + pinGeoPosition.x() + (PinWidget::MINIMUM_WIDTH / 2), + pinGeoPosition.y() - pinNameLabelLineLength - PinWidget::MAXIMUM_LABEL_HEIGHT + )); + + painter.setPen(pinDirectionFontColor); + painter.drawText( + QRect( + pinGeoPosition.x() + (PinWidget::MINIMUM_WIDTH / 2) + - (PinWidget::MAXIMUM_LABEL_WIDTH / 2), + pinGeoPosition.y() - pinNameLabelLineLength - pinDirectionLabelLineLength + - (PinWidget::MAXIMUM_LABEL_HEIGHT * 2), + PinWidget::MAXIMUM_LABEL_WIDTH, + PinWidget::MAXIMUM_LABEL_HEIGHT + ), + Qt::AlignCenter, + pinState->ioDirection == TargetPinState::IoDirection::INPUT ? inDirectionText : outDirectionText + ); + } + + } else if (pinWidget->position == Position::BOTTOM) { + painter.setPen(lineColor); + const auto pinNameLabelLineLength = (pinWidget->getPinNumber() % 2 == 0 ? + PinWidget::PIN_LABEL_LONG_LINE_LENGTH + : PinWidget::PIN_LABEL_SHORT_LINE_LENGTH + ); + const auto pinDirectionLabelLineLength = (pinWidget->getPinNumber() % 2 == 0 ? + PinWidget::PIN_LABEL_SHORT_LINE_LENGTH + : PinWidget::PIN_LABEL_LONG_LINE_LENGTH + ); + + painter.drawLine(QLine( + pinGeoPosition.x() + (PinWidget::MINIMUM_WIDTH / 2), + pinGeoPosition.y() + PinWidget::MAXIMUM_HEIGHT, + pinGeoPosition.x() + (PinWidget::MINIMUM_WIDTH / 2), + pinGeoPosition.y() + PinWidget::MAXIMUM_HEIGHT + pinNameLabelLineLength + )); + + painter.setPen(pinStateChanged ? pinChangedFontColor : pinNameFontColor); + painter.drawText( + QRect( + pinGeoPosition.x() + (PinWidget::MINIMUM_WIDTH / 2) + - (PinWidget::MAXIMUM_LABEL_WIDTH / 2), + pinGeoPosition.y() + + PinWidget::MAXIMUM_HEIGHT + pinNameLabelLineLength, + PinWidget::MAXIMUM_LABEL_WIDTH, + PinWidget::MAXIMUM_LABEL_HEIGHT + ), + Qt::AlignCenter, + pinWidget->pinNameLabelText + ); + + if (pinState.has_value() && pinState->ioDirection.has_value()) { + painter.setFont(pinDirectionFont); + + painter.setPen(lineColor); + painter.drawLine(QLine( + pinGeoPosition.x() + (PinWidget::MINIMUM_WIDTH / 2), + pinGeoPosition.y() + PinWidget::MAXIMUM_HEIGHT + pinNameLabelLineLength + + PinWidget::MAXIMUM_LABEL_HEIGHT, + pinGeoPosition.x() + (PinWidget::MINIMUM_WIDTH / 2), + pinGeoPosition.y() + PinWidget::MAXIMUM_HEIGHT + pinNameLabelLineLength + + PinWidget::MAXIMUM_LABEL_HEIGHT + pinDirectionLabelLineLength + )); + + painter.setPen(pinDirectionFontColor); + painter.drawText( + QRect( + pinGeoPosition.x() + (PinWidget::MINIMUM_WIDTH / 2) + - (PinWidget::MAXIMUM_LABEL_WIDTH / 2), + pinGeoPosition.y() + PinWidget::MAXIMUM_HEIGHT + pinNameLabelLineLength + + PinWidget::MAXIMUM_LABEL_HEIGHT + pinDirectionLabelLineLength, + PinWidget::MAXIMUM_LABEL_WIDTH, + PinWidget::MAXIMUM_LABEL_HEIGHT + ), + Qt::AlignCenter, + pinState->ioDirection == TargetPinState::IoDirection::INPUT ? inDirectionText : outDirectionText + ); + } + } + } +} diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.hpp index f3efc189..6596ef0e 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.hpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include "../TargetPackageWidget.hpp" @@ -27,10 +29,16 @@ namespace Bloom::Widgets::InsightTargetWidgets::Dip QWidget* parent ); + protected: + void paintEvent(QPaintEvent* event) override; + void drawWidget(QPainter& painter); + private: QVBoxLayout* layout = nullptr; QHBoxLayout* topPinLayout = nullptr; QHBoxLayout* bottomPinLayout = nullptr; BodyWidget* bodyWidget = nullptr; + + std::vector pinWidgets; }; } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.cpp index 77171fbe..0607bf2a 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.cpp @@ -9,8 +9,7 @@ PinWidget::PinWidget( InsightWorker& insightWorker, QWidget* parent ): TargetPinWidget(pinDescriptor, targetVariant, insightWorker, parent) { - static constexpr auto width = PinWidget::MINIMUM_WIDTH + PinWidget::WIDTH_SPACING; - this->setFixedSize(width, PinWidget::MAXIMUM_HEIGHT); + this->setFixedSize(PinWidget::MINIMUM_WIDTH, PinWidget::MAXIMUM_HEIGHT); this->layout = new QVBoxLayout(); this->layout->setContentsMargins(0, 0, 0, 0); @@ -25,21 +24,8 @@ PinWidget::PinWidget( this->layout->setAlignment(isTopWidget ? (Qt::AlignmentFlag::AlignHCenter | Qt::AlignmentFlag::AlignBottom) : (Qt::AlignmentFlag::AlignHCenter | Qt::AlignmentFlag::AlignTop)); - this->pinDirectionLabel = new QLabel(this); - this->pinDirectionLabel->setObjectName("target-pin-direction"); - this->pinDirectionLabel->setAlignment(Qt::AlignmentFlag::AlignCenter); - - auto pinName = QString::fromStdString(pinDescriptor.name).toUpper(); - this->pinNameLabel = new QLabel(this); - this->pinNameLabel->setObjectName("target-pin-name"); - this->pinNameLabel->setToolTip(pinName); - if (pinName.size() > 4) { - pinName.truncate(4); - } - this->pinNameLabel->setText(pinName); - this->pinNameLabel->setAlignment(Qt::AlignmentFlag::AlignCenter); - this->pinNameLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - this->pinNameLabel->setFixedWidth(width); + this->pinNameLabelText = QString::fromStdString(pinDescriptor.name).toUpper(); + this->pinNameLabelText.truncate(5); this->pinNumberLabel = new QLabel(this); this->pinNumberLabel->setObjectName("target-pin-number"); @@ -51,55 +37,11 @@ PinWidget::PinWidget( } this->layout->addWidget(this->bodyWidget, 0, Qt::AlignmentFlag::AlignHCenter); - this->layout->insertSpacing(1, 3); + this->layout->insertSpacing(1, PinWidget::PIN_LABEL_SPACING); this->layout->addWidget(this->pinNumberLabel, 0, Qt::AlignmentFlag::AlignHCenter); - this->layout->insertSpacing(3, (this->pinDescriptor.number % 2 == 0) ? 20 : 2); - this->layout->addWidget(this->pinNameLabel, 0, Qt::AlignmentFlag::AlignHCenter); - this->layout->insertSpacing(5, (this->pinDescriptor.number % 2 != 0) ? 20 : 2); - this->layout->addWidget(this->pinDirectionLabel, 0, Qt::AlignmentFlag::AlignHCenter); - this->pinNameLabel->setFixedHeight(PinWidget::LABEL_HEIGHT - 2); - this->pinNumberLabel->setFixedHeight(PinWidget::LABEL_HEIGHT - 2); + this->pinNumberLabel->setFixedHeight(PinWidget::LABEL_HEIGHT); this->setLayout(this->layout); connect(this->bodyWidget, &PinBodyWidget::clicked, this, &TargetPinWidget::onWidgetBodyClicked); } - -void PinWidget::paintEvent(QPaintEvent* event) { - auto painter = QPainter(this); - this->drawWidget(painter); -} - -void PinWidget::drawWidget(QPainter& painter) { - painter.setPen(QPen(QColor("#4F4F4F"), 1)); - - if (this->pinDescriptor.number % 2 == 0) { - /* - * Minus 17 for the length of the line - * Plus/minus 3 to account for spacing between the pin body and number label - */ - const auto yOffset = this->position == Position::TOP - ? PinWidget::MAXIMUM_HEIGHT - PinBodyWidget::HEIGHT - PinWidget::LABEL_HEIGHT - 17 - 3 - : PinBodyWidget::HEIGHT + PinWidget::LABEL_HEIGHT + 3; - - painter.drawLine(QLine( - (PinWidget::MINIMUM_WIDTH + PinWidget::WIDTH_SPACING) / 2, - yOffset, - (PinWidget::MINIMUM_WIDTH + PinWidget::WIDTH_SPACING) / 2, - yOffset + 17 - )); - - } else if (this->pinState.has_value()) { - // Plus/minus 2 because it looks nicer - const auto yOffset = this->position == Position::TOP - ? PinWidget::MAXIMUM_HEIGHT - PinBodyWidget::HEIGHT - (PinWidget::LABEL_HEIGHT * 2) - 17 - 3 + 2 - : PinBodyWidget::HEIGHT + (PinWidget::LABEL_HEIGHT * 2) + 3 - 2; - - painter.drawLine(QLine( - (PinWidget::MINIMUM_WIDTH + PinWidget::WIDTH_SPACING) / 2, - yOffset, - (PinWidget::MINIMUM_WIDTH + PinWidget::WIDTH_SPACING) / 2, - yOffset + 17 - )); - } -} diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.hpp index 06301791..fa099d1b 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.hpp @@ -24,12 +24,22 @@ namespace Bloom::Widgets::InsightTargetWidgets::Dip Q_OBJECT public: - static const int MINIMUM_WIDTH = PinBodyWidget::WIDTH; - static const int WIDTH_SPACING = 6; - static const int MAXIMUM_LABEL_COUNT = 3; - static const int LABEL_HEIGHT = 20; - static const int MAXIMUM_HEIGHT = PinBodyWidget::HEIGHT - + (PinWidget::LABEL_HEIGHT * PinWidget::MAXIMUM_LABEL_COUNT) + 40; + static constexpr int MINIMUM_WIDTH = PinBodyWidget::WIDTH; + static constexpr int WIDTH_SPACING = 4; + static constexpr int PIN_LABEL_SPACING = 2; + static constexpr int PIN_LABEL_LONG_LINE_LENGTH = 25; + static constexpr int PIN_LABEL_SHORT_LINE_LENGTH = 5; + static constexpr int MAXIMUM_LABEL_COUNT = 3; + static constexpr int LABEL_HEIGHT = 20; + static constexpr int MAXIMUM_PIN_NUMBER_LABEL_WIDTH = 26; + static constexpr int MAXIMUM_PIN_DIRECTION_LABEL_WIDTH = 24; + static constexpr int MAXIMUM_LABEL_WIDTH = 32; + static constexpr int MAXIMUM_LABEL_HEIGHT = 20; + static constexpr int MAXIMUM_HEIGHT = PinBodyWidget::HEIGHT + PinWidget::PIN_LABEL_SPACING + + PinWidget::LABEL_HEIGHT; + + Position position = Position::TOP; + QString pinNameLabelText; PinWidget( const Targets::TargetPinDescriptor& pinDescriptor, @@ -41,39 +51,14 @@ namespace Bloom::Widgets::InsightTargetWidgets::Dip void updatePinState(const Targets::TargetPinState& pinState) override { TargetPinWidget::updatePinState(pinState); - if (pinState.ioDirection.has_value()) { - this->pinDirectionLabel->setText( - pinState.ioDirection.value() == Targets::TargetPinState::IoDirection::INPUT ? "IN" : "OUT" - ); - - } else { - this->pinDirectionLabel->setText(""); - } - if (this->bodyWidget != nullptr) { this->bodyWidget->setPinState(pinState); } - - this->setLabelColor(this->pinStateChanged ? "#4d7bba" : "#a6a7aa"); } - protected: - void paintEvent(QPaintEvent* event) override; - void drawWidget(QPainter& painter); - private: - Position position = Position::TOP; QVBoxLayout* layout = nullptr; QLabel* pinNumberLabel = nullptr; - QLabel* pinNameLabel = nullptr; - QLabel* pinDirectionLabel = nullptr; PinBodyWidget* bodyWidget = nullptr; - - void setLabelColor(const QString& hexColor) { - auto style = QString("QLabel { color: " + hexColor + "; }"); - if (this->pinNameLabel != nullptr) { - this->pinNameLabel->setStyleSheet(style); - } - } }; } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/Stylesheets/DualInlinePackage.qss b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/Stylesheets/DualInlinePackage.qss index 6f14a1f4..7ac55ddf 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/Stylesheets/DualInlinePackage.qss +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/Stylesheets/DualInlinePackage.qss @@ -1,5 +1,5 @@ #target-pin-number { - font-size: 14px; + font-size: 13px; } #target-pin-name {