Moved Insight target widgets to "Widgets" sub-folder.

This commit is contained in:
Nav
2021-07-07 20:54:45 +01:00
parent d8f53e4f9f
commit 2e4810389f
25 changed files with 43 additions and 44 deletions

View File

@@ -0,0 +1,61 @@
#pragma once
#include <QWidget>
#include <QLabel>
#include "../TargetPinWidget.hpp"
#include "PinBodyWidget.hpp"
#include "src/Targets/TargetVariant.hpp"
namespace Bloom::Widgets::InsightTargetWidgets::Dip
{
class PinWidget: public TargetPinWidget
{
Q_OBJECT
private:
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);
}
}
public:
static const int MINIMUM_WIDTH = 30;
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);
PinWidget(
QWidget* parent,
const Targets::TargetPinDescriptor& pinDescriptor,
const Targets::TargetVariant& targetVariant
);
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 ? "#6FA0FF" : "#a6a7aa");
}
};
}