From 96c3279efdb8af6065ed9277ac6984258e4954e3 Mon Sep 17 00:00:00 2001 From: Nav Date: Tue, 24 Aug 2021 20:12:07 +0100 Subject: [PATCH] Improved automatic Insight window resizing when a QFP target package widget is enabled --- .../Widgets/TargetWidgets/QFP/PinWidget.hpp | 3 ++- .../QFP/QuadFlatPackageWidget.cpp | 22 +++++++++---------- .../QFP/QuadFlatPackageWidget.hpp | 2 -- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.hpp index b2d21e91..dcb6ffeb 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.hpp @@ -34,7 +34,8 @@ namespace Bloom::Widgets::InsightTargetWidgets::Qfp } public: - static const int MAXIMUM_SPACING = 8; + static const int PIN_WIDGET_LAYOUT_PADDING = 46; + static const int PIN_WIDGET_SPACING = 8; static const int MAXIMUM_LABEL_COUNT = 3; static const int LABEL_HEIGHT = 20; static const int MAXIMUM_LABEL_WIDTH = PinBodyWidget::WIDTH; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/QuadFlatPackageWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/QuadFlatPackageWidget.cpp index c1983be7..ba2ce72d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/QuadFlatPackageWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/QuadFlatPackageWidget.cpp @@ -39,19 +39,19 @@ QuadFlatPackageWidget::QuadFlatPackageWidget( this->horizontalLayout->setDirection(QBoxLayout::Direction::LeftToRight); this->topPinLayout = new QHBoxLayout(); - this->topPinLayout->setSpacing(QuadFlatPackageWidget::PIN_WIDGET_SPACING); + this->topPinLayout->setSpacing(PinWidget::PIN_WIDGET_SPACING); this->topPinLayout->setDirection(QBoxLayout::Direction::RightToLeft); this->rightPinLayout = new QVBoxLayout(); - this->rightPinLayout->setSpacing(QuadFlatPackageWidget::PIN_WIDGET_SPACING); + this->rightPinLayout->setSpacing(PinWidget::PIN_WIDGET_SPACING); this->rightPinLayout->setDirection(QBoxLayout::Direction::BottomToTop); this->bottomPinLayout = new QHBoxLayout(); - this->bottomPinLayout->setSpacing(QuadFlatPackageWidget::PIN_WIDGET_SPACING); + this->bottomPinLayout->setSpacing(PinWidget::PIN_WIDGET_SPACING); this->bottomPinLayout->setDirection(QBoxLayout::Direction::LeftToRight); this->leftPinLayout = new QVBoxLayout(); - this->leftPinLayout->setSpacing(QuadFlatPackageWidget::PIN_WIDGET_SPACING); + this->leftPinLayout->setSpacing(PinWidget::PIN_WIDGET_SPACING); this->leftPinLayout->setDirection(QBoxLayout::Direction::TopToBottom); auto insightWindow = qobject_cast(insightWindowObj); @@ -101,8 +101,8 @@ QuadFlatPackageWidget::QuadFlatPackageWidget( insightWindowWidget->setMinimumWidth( std::max( 1000, - static_cast((PinWidget::MAXIMUM_VERTICAL_WIDTH * pinCountPerLayout) - + (PinWidget::MAXIMUM_VERTICAL_WIDTH * 2)) + 300 + static_cast(((PinWidget::MAXIMUM_VERTICAL_WIDTH + PinWidget::PIN_WIDGET_SPACING) * pinCountPerLayout) + + (PinWidget::MAXIMUM_VERTICAL_WIDTH * 2)) + 600 ) ); } @@ -130,11 +130,11 @@ void QuadFlatPackageWidget::drawWidget(QPainter& painter) { * Horizontal layouts are the right and left pin layouts - the ones that hold horizontal pin widgets. * The bottom and top layouts are vertical layouts, as they hold the vertical pin widgets. */ - auto horizontalLayoutHeight = ((horizontalPinWidgetHeight + QuadFlatPackageWidget::PIN_WIDGET_SPACING) * pinCountPerLayout - + QuadFlatPackageWidget::PIN_WIDGET_LAYOUT_PADDING - QuadFlatPackageWidget::PIN_WIDGET_SPACING); + auto horizontalLayoutHeight = ((horizontalPinWidgetHeight + PinWidget::PIN_WIDGET_SPACING) * pinCountPerLayout + + PinWidget::PIN_WIDGET_LAYOUT_PADDING - PinWidget::PIN_WIDGET_SPACING); - auto verticalLayoutWidth = ((verticalPinWidgetWidth + QuadFlatPackageWidget::PIN_WIDGET_SPACING) * pinCountPerLayout - + QuadFlatPackageWidget::PIN_WIDGET_LAYOUT_PADDING - QuadFlatPackageWidget::PIN_WIDGET_SPACING); + auto verticalLayoutWidth = ((verticalPinWidgetWidth + PinWidget::PIN_WIDGET_SPACING) * pinCountPerLayout + + PinWidget::PIN_WIDGET_LAYOUT_PADDING - PinWidget::PIN_WIDGET_SPACING); auto containerWidth = verticalLayoutWidth + (horizontalPinWidgetWidth * 2); @@ -180,7 +180,7 @@ void QuadFlatPackageWidget::drawWidget(QPainter& painter) { verticalPinWidgetHeight )); - auto pinWidgetLayoutMargin = QuadFlatPackageWidget::PIN_WIDGET_LAYOUT_PADDING / 2; + auto pinWidgetLayoutMargin = PinWidget::PIN_WIDGET_LAYOUT_PADDING / 2; this->topPinLayout->setContentsMargins( pinWidgetLayoutMargin, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/QuadFlatPackageWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/QuadFlatPackageWidget.hpp index 96ee18b0..a616a4d5 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/QuadFlatPackageWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/QuadFlatPackageWidget.hpp @@ -32,8 +32,6 @@ namespace Bloom::Widgets::InsightTargetWidgets::Qfp void drawWidget(QPainter& painter); public: - static const int PIN_WIDGET_LAYOUT_PADDING = 46; - static const int PIN_WIDGET_SPACING = 8; QuadFlatPackageWidget(const Targets::TargetVariant& targetVariant, QObject* insightWindowObj, QWidget* parent); }; }