Added base class for pin body widgets & increased temperature of pin body colors (so that they're easier on the eyes)

This commit is contained in:
Nav
2021-07-19 20:24:07 +01:00
parent dccf77fdb0
commit c0b99516d3
10 changed files with 185 additions and 215 deletions

View File

@@ -15,28 +15,6 @@ void PinBodyWidget::paintEvent(QPaintEvent* event) {
this->drawWidget(painter);
}
bool PinBodyWidget::event(QEvent* event) {
if (this->isEnabled() && this->pinState.has_value() && this->pinState->ioDirection == TargetPinState::IoDirection::OUTPUT) {
switch (event->type()) {
case QEvent::Enter: {
this->hoverActive = true;
this->repaint();
break;
}
case QEvent::Leave: {
this->hoverActive = false;
this->repaint();
break;
}
default: {
break;
}
}
}
return QWidget::event(event);
}
void PinBodyWidget::drawWidget(QPainter& painter) {
auto parentWidget = this->parentWidget();
@@ -51,31 +29,6 @@ void PinBodyWidget::drawWidget(QPainter& painter) {
auto pinColor = this->getBodyColor();
if (this->pinDescriptor.type == TargetPinType::VCC) {
pinColor = QColor("#ff3d43");
} else if (this->pinDescriptor.type == TargetPinType::GND) {
pinColor = QColor("#575757");
}
if (this->pinState.has_value()) {
if (this->pinState->ioState.has_value()
&& this->pinState->ioDirection.has_value()
&& this->pinState->ioState.value() == TargetPinState::IoState::HIGH
) {
pinColor = this->pinState->ioDirection.value() == TargetPinState::IoDirection::OUTPUT ?
QColor("#3D7F96") : QColor("#A47E3E");
}
}
if (!this->hoverActive) {
pinColor.setAlpha(225);
}
if (!this->isEnabled()) {
pinColor.setAlpha(this->getDisableAlphaLevel());
}
painter.setPen(Qt::PenStyle::NoPen);
painter.setBrush(pinColor);