diff --git a/CMakeLists.txt b/CMakeLists.txt index 790593c4..48b6fecc 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,8 +128,6 @@ add_executable(Bloom src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.cpp src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.cpp - src/Insight/UserInterfaces/InsightWindow/Widgets/SlidingHandleWidget.cpp - src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingWidget.hpp src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingHeightScrollAreaWidget.hpp # Insight worker tasks diff --git a/src/Insight/Insight.hpp b/src/Insight/Insight.hpp index f3ddc16a..6317d73c 100644 --- a/src/Insight/Insight.hpp +++ b/src/Insight/Insight.hpp @@ -41,7 +41,7 @@ namespace Bloom QApplication application; InsightWorker* insightWorker = new InsightWorker(this->eventManager); - InsightWindow* mainWindow = new InsightWindow(this->application, *(this->insightWorker)); + InsightWindow* mainWindow = new InsightWindow(*(this->insightWorker)); TargetControllerConsole targetControllerConsole = TargetControllerConsole( this->eventManager, diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp index 1a280334..d2d4cdc7 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp @@ -5,7 +5,6 @@ #include #include "UiLoader.hpp" -#include "Widgets/SlidingHandleWidget.hpp" #include "Widgets/RotatableLabel.hpp" #include "Widgets/TargetWidgets/DIP/DualInlinePackageWidget.hpp" @@ -29,10 +28,11 @@ using Bloom::Targets::TargetVariant; using Bloom::Targets::TargetPackage; using Bloom::Targets::TargetPinDescriptor; -InsightWindow::InsightWindow( - QApplication& application, - InsightWorker& insightWorker -): QObject(&application), insightWorker(insightWorker) { +InsightWindow::InsightWindow(InsightWorker& insightWorker): QMainWindow(nullptr), insightWorker(insightWorker) { + this->setObjectName("main-window"); + this->setWindowTitle("Bloom Insight"); + this->setMinimumSize(1000, 500); + auto mainWindowUiFile = QFile( QString::fromStdString(Paths::compiledResourcesPath() + "/src/Insight/UserInterfaces/InsightWindow/UiFiles/InsightWindow.ui" @@ -53,8 +53,8 @@ InsightWindow::InsightWindow( } auto uiLoader = UiLoader(this); - this->mainWindowWidget = uiLoader.load(&mainWindowUiFile); - this->mainWindowWidget->setStyleSheet(mainWindowStylesheet.readAll()); + this->windowContainer = uiLoader.load(&mainWindowUiFile, this); + this->windowContainer->setStyleSheet(mainWindowStylesheet.readAll()); mainWindowUiFile.close(); mainWindowStylesheet.close(); @@ -64,11 +64,15 @@ InsightWindow::InsightWindow( + "/src/Insight/UserInterfaces/InsightWindow/Images/BloomIcon.svg" ) )); - this->ioContainerWidget = this->mainWindowWidget->findChild( + + this->layoutContainer = this->windowContainer->findChild("layout-container"); + this->mainMenuBar = this->windowContainer->findChild("menu-bar"); + this->layoutContainer->layout()->setMenuBar(this->mainMenuBar); + this->container = this->layoutContainer->findChild("container"); + this->ioContainerWidget = this->windowContainer->findChild( "io-container" ); - this->ioUnavailableWidget = this->mainWindowWidget->findChild("io-inspection-unavailable"); - this->mainMenuBar = this->mainWindowWidget->findChild("menu-bar"); + this->ioUnavailableWidget = this->windowContainer->findChild("io-inspection-unavailable"); auto fileMenu = this->mainMenuBar->findChild("file-menu"); auto helpMenu = this->mainMenuBar->findChild("help-menu"); @@ -82,7 +86,7 @@ InsightWindow::InsightWindow( connect(openGettingStartedUrlAction, &QAction::triggered, this, &InsightWindow::openGettingStartedUrl); connect(openAboutWindowAction, &QAction::triggered, this, &InsightWindow::openAboutWindow); - this->header = this->mainWindowWidget->findChild("header"); + this->header = this->windowContainer->findChild("header"); this->refreshIoInspectionButton = this->header->findChild("refresh-io-inspection-btn"); connect(this->refreshIoInspectionButton, &QToolButton::clicked, this, [this] { @@ -110,13 +114,10 @@ InsightWindow::InsightWindow( } }); - this->leftPanel = this->mainWindowWidget->findChild("left-panel"); - this->leftPanelLayoutContainer = this->leftPanel->findChild("left-panel-layout-container"); + this->leftMenuBar = this->container->findChild("left-side-menu-bar"); + this->leftPanel = this->container->findChild("left-panel"); - auto leftPanelSlider = this->mainWindowWidget->findChild("left-panel-slider"); - connect(leftPanelSlider, &SlidingHandleWidget::horizontalSlide, this, &InsightWindow::onLeftPanelHandleSlide); - - this->targetRegistersButton = this->mainWindowWidget->findChild("target-registers-btn"); + this->targetRegistersButton = this->container->findChild("target-registers-btn"); auto targetRegisterButtonLayout = this->targetRegistersButton->findChild(); auto registersBtnLabel = new RotatableLabel(270, "Registers", this->targetRegistersButton); registersBtnLabel->setObjectName("target-registers-btn-label"); @@ -125,9 +126,16 @@ InsightWindow::InsightWindow( connect(this->targetRegistersButton, &QToolButton::clicked, this, &InsightWindow::toggleTargetRegistersPane); - this->footer = this->mainWindowWidget->findChild("footer"); + this->bottomMenuBar = this->container->findChild("bottom-menu-bar"); + this->bottomPanel = this->container->findChild("bottom-panel"); + + this->footer = this->windowContainer->findChild("footer"); this->targetStatusLabel = this->footer->findChild("target-state"); this->programCounterValueLabel = this->footer->findChild("target-program-counter-value"); + + const auto windowSize = this->size(); + this->windowContainer->setFixedSize(windowSize); + this->layoutContainer->setFixedSize(windowSize); } void InsightWindow::init(TargetDescriptor targetDescriptor) { @@ -135,171 +143,13 @@ void InsightWindow::init(TargetDescriptor targetDescriptor) { this->activate(); } -void InsightWindow::activate() { - auto targetNameLabel = this->footer->findChild("target-name"); - auto targetIdLabel = this->footer->findChild("target-id"); - targetNameLabel->setText(QString::fromStdString(this->targetDescriptor.name)); - targetIdLabel->setText("0x" + QString::fromStdString(this->targetDescriptor.id).remove("0x").toUpper()); - this->variantMenu = this->footer->findChild("target-variant-menu"); +void InsightWindow::toggleUi(bool disable) { + this->uiDisabled = disable; - this->ioUnavailableWidget->hide(); - - std::optional previouslySelectedVariantName; - if (this->selectedVariant != nullptr) { - previouslySelectedVariantName = QString::fromStdString(this->selectedVariant->name).toLower(); - this->selectedVariant = nullptr; + if (this->refreshIoInspectionButton != nullptr) { + this->refreshIoInspectionButton->setDisabled(disable); + this->refreshIoInspectionButton->repaint(); } - - this->supportedVariantsByName.clear(); - - /* - * We don't want to present the user with duplicate target variants. - * - * In the context of Insight, a variant that doesn't differ in package type or pinout configuration is - * considered a duplicate. - */ - auto processedVariants = std::vector(); - auto isDuplicateVariant = [&processedVariants](const TargetVariant& variantA) { - return std::ranges::any_of( - processedVariants.begin(), - processedVariants.end(), - [&variantA, &processedVariants](const TargetVariant& variantB) { - if (variantA.package != variantB.package) { - return false; - } - - if (variantA.pinDescriptorsByNumber.size() != variantB.pinDescriptorsByNumber.size()) { - return false; - } - - if (variantA.pinDescriptorsByNumber != variantB.pinDescriptorsByNumber) { - return false; - } - - return true; - } - ); - }; - - for (const auto& targetVariant: this->targetDescriptor.variants) { - if (isDuplicateVariant(targetVariant)) { - continue; - } - - auto variantAction = new QAction(this->variantMenu); - variantAction->setText( - QString::fromStdString(targetVariant.name + " (" + targetVariant.packageName + ")") - ); - - if (InsightWindow::isVariantSupported(targetVariant)) { - auto supportedVariantPtr = &(this->supportedVariantsByName.insert( - std::pair(QString::fromStdString(targetVariant.name).toLower(), targetVariant) - ).first->second); - - connect( - variantAction, - &QAction::triggered, - this, - [this, supportedVariantPtr] { - this->selectVariant(supportedVariantPtr); - } - ); - - } else { - variantAction->setEnabled(false); - variantAction->setText(variantAction->text() + " (unsupported)"); - } - - this->variantMenu->addAction(variantAction); - processedVariants.push_back(targetVariant); - } - - this->variantMenu->setEnabled(true); - - Logger::debug("Number of target variants supported by Insight: " + std::to_string(supportedVariantsByName.size())); - - if (!this->supportedVariantsByName.empty()) { - if (previouslySelectedVariantName.has_value() - && this->supportedVariantsByName.contains(previouslySelectedVariantName.value()) - ) { - this->selectVariant(&(this->supportedVariantsByName.at(previouslySelectedVariantName.value()))); - - } else if (this->targetConfig.variantName.has_value()) { - auto selectedVariantName = QString::fromStdString(this->targetConfig.variantName.value()); - if (this->supportedVariantsByName.contains(selectedVariantName)) { - // The user has specified a valid variant name in their config file, so use that as the default - this->selectVariant(&(this->supportedVariantsByName.at(selectedVariantName))); - - } else { - Logger::error("Invalid target variant name \"" + this->targetConfig.variantName.value() - + "\" - no such variant with the given name was found."); - } - } - - if (this->selectedVariant == nullptr) { - /* - * Given that we haven't been able to select a variant at this point, we will just fallback to the first - * one that is available. - */ - this->selectVariant(&(this->supportedVariantsByName.begin()->second)); - } - - } else { - if (this->targetDescriptor.variants.empty()) { - this->variantMenu->parentWidget()->hide(); - } - - this->ioUnavailableWidget->setText( - "GPIO inspection is not available for this target. " - "Please report this to Bloom developers by clicking Help -> Report An Issue" - ); - this->ioUnavailableWidget->show(); - } - - auto leftPanelLayout = this->leftPanelLayoutContainer->findChild("left-panel-layout"); - this->targetRegistersSidePane = new TargetRegistersPaneWidget( - this->targetDescriptor, - insightWorker, - this->leftPanelLayoutContainer - ); - leftPanelLayout->addWidget(this->targetRegistersSidePane); - this->targetRegistersButton->setChecked(false); - this->targetRegistersButton->setDisabled(false); - - - this->toggleUi(this->targetState != TargetState::STOPPED); - this->activated = true; -} - -void InsightWindow::deactivate() { - if (this->targetPackageWidget != nullptr) { - this->targetPackageWidget->hide(); - this->targetPackageWidget->deleteLater(); - this->targetPackageWidget = nullptr; - } - - if (this->targetRegistersSidePane != nullptr) { - this->targetRegistersSidePane->deactivate(); - this->targetRegistersSidePane->deleteLater(); - this->leftPanel->setVisible(false); - this->targetRegistersButton->setChecked(false); - this->targetRegistersButton->setDisabled(true); - } - - this->ioUnavailableWidget->setText( - "Insight deactivated - Bloom has been disconnected from the target.\n\n" - "Bloom will attempt to reconnect upon the start of a new debug session." - ); - this->ioUnavailableWidget->show(); - - this->targetStatusLabel->setText("Unknown"); - this->programCounterValueLabel->setText("-"); - - this->variantMenu->clear(); - this->variantMenu->setEnabled(false); - - this->toggleUi(true); - this->activated = false; } bool InsightWindow::isVariantSupported(const TargetVariant& variant) { @@ -383,41 +233,219 @@ void InsightWindow::selectVariant(const TargetVariant* variant) { }); } - this->mainWindowWidget->setMinimumSize( - this->targetPackageWidget->width() + 500, - this->targetPackageWidget->height() + 150 + this->setMinimumSize( + this->targetPackageWidget->width() + 700, + this->targetPackageWidget->height() + 450 ); - this->ioContainerWidget->resize(this->ioContainerWidget->size()); - + Logger::error("ressss"); + this->adjustSize(); this->targetPackageWidget->show(); + } } -void InsightWindow::show() { - this->mainWindowWidget->activateWindow(); - this->mainWindowWidget->show(); -} +void InsightWindow::activate() { + auto targetNameLabel = this->footer->findChild("target-name"); + auto targetIdLabel = this->footer->findChild("target-id"); + targetNameLabel->setText(QString::fromStdString(this->targetDescriptor.name)); + targetIdLabel->setText("0x" + QString::fromStdString(this->targetDescriptor.id).remove("0x").toUpper()); + this->variantMenu = this->footer->findChild("target-variant-menu"); -void InsightWindow::close() { - if (this->mainWindowWidget != nullptr) { - this->mainWindowWidget->close(); + this->ioUnavailableWidget->hide(); + + std::optional previouslySelectedVariantName; + if (this->selectedVariant != nullptr) { + previouslySelectedVariantName = QString::fromStdString(this->selectedVariant->name).toLower(); + this->selectedVariant = nullptr; } -} -void InsightWindow::toggleUi(bool disable) { - this->uiDisabled = disable; + this->supportedVariantsByName.clear(); - if (this->refreshIoInspectionButton != nullptr) { - this->refreshIoInspectionButton->setDisabled(disable); - this->refreshIoInspectionButton->repaint(); + /* + * We don't want to present the user with duplicate target variants. + * + * In the context of Insight, a variant that doesn't differ in package type or pinout configuration is + * considered a duplicate. + */ + auto processedVariants = std::vector(); + auto isDuplicateVariant = [&processedVariants](const TargetVariant& variantA) { + return std::ranges::any_of( + processedVariants.begin(), + processedVariants.end(), + [&variantA, &processedVariants](const TargetVariant& variantB) { + if (variantA.package != variantB.package) { + return false; + } + + if (variantA.pinDescriptorsByNumber.size() != variantB.pinDescriptorsByNumber.size()) { + return false; + } + + if (variantA.pinDescriptorsByNumber != variantB.pinDescriptorsByNumber) { + return false; + } + + return true; + } + ); + }; + + for (const auto& targetVariant: this->targetDescriptor.variants) { + if (isDuplicateVariant(targetVariant)) { + continue; + } + + auto variantAction = new QAction(this->variantMenu); + variantAction->setText( + QString::fromStdString(targetVariant.name + " (" + targetVariant.packageName + ")") + ); + + if (InsightWindow::isVariantSupported(targetVariant)) { + auto supportedVariantPtr = &(this->supportedVariantsByName.insert( + std::pair(QString::fromStdString(targetVariant.name).toLower(), targetVariant) + ).first->second); + + connect( + variantAction, + &QAction::triggered, + this, + [this, supportedVariantPtr] { + this->selectVariant(supportedVariantPtr); + } + ); + + } else { + variantAction->setEnabled(false); + variantAction->setText(variantAction->text() + " (unsupported)"); + } + + this->variantMenu->addAction(variantAction); + processedVariants.push_back(targetVariant); } + + this->variantMenu->setEnabled(true); + + Logger::debug("Number of target variants supported by Insight: " + + std::to_string(supportedVariantsByName.size())); + + if (!this->supportedVariantsByName.empty()) { + if (previouslySelectedVariantName.has_value() + && this->supportedVariantsByName.contains(previouslySelectedVariantName.value()) + ) { + this->selectVariant(&(this->supportedVariantsByName.at(previouslySelectedVariantName.value()))); + + } else if (this->targetConfig.variantName.has_value()) { + auto selectedVariantName = QString::fromStdString(this->targetConfig.variantName.value()); + if (this->supportedVariantsByName.contains(selectedVariantName)) { + // The user has specified a valid variant name in their config file, so use that as the default + this->selectVariant(&(this->supportedVariantsByName.at(selectedVariantName))); + + } else { + Logger::error("Invalid target variant name \"" + this->targetConfig.variantName.value() + + "\" - no such variant with the given name was found."); + } + } + + if (this->selectedVariant == nullptr) { + /* + * Given that we haven't been able to select a variant at this point, we will just fallback to the first + * one that is available. + */ + this->selectVariant(&(this->supportedVariantsByName.begin()->second)); + } + + } else { + if (this->targetDescriptor.variants.empty()) { + this->variantMenu->parentWidget()->hide(); + } + + this->ioUnavailableWidget->setText( + "GPIO inspection is not available for this target. " + "Please report this to Bloom developers by clicking Help -> Report An Issue" + ); + this->ioUnavailableWidget->show(); + } + + auto leftPanelLayout = this->leftPanel->layout(); + this->targetRegistersSidePane = new TargetRegistersPaneWidget( + this->targetDescriptor, + insightWorker, + this->leftPanel + ); + leftPanelLayout->addWidget(this->targetRegistersSidePane); + this->targetRegistersButton->setChecked(false); + this->targetRegistersButton->setDisabled(false); + + this->toggleUi(this->targetState != TargetState::STOPPED); + this->activated = true; } -void InsightWindow::onLeftPanelHandleSlide(int horizontalPosition) { - auto width = std::max(this->leftPanelMinWidth, this->leftPanel->width() + horizontalPosition); - this->leftPanel->setMaximumWidth(width); - this->leftPanel->setFixedWidth(width); +void InsightWindow::deactivate() { + if (this->targetPackageWidget != nullptr) { + this->targetPackageWidget->hide(); + this->targetPackageWidget->deleteLater(); + this->targetPackageWidget = nullptr; + } + + if (this->targetRegistersSidePane != nullptr) { + this->targetRegistersSidePane->deactivate(); + this->targetRegistersSidePane->deleteLater(); + this->leftPanel->setVisible(false); + this->targetRegistersButton->setChecked(false); + this->targetRegistersButton->setDisabled(true); + } + + this->ioUnavailableWidget->setText( + "Insight deactivated - Bloom has been disconnected from the target.\n\n" + "Bloom will attempt to reconnect upon the start of a new debug session." + ); + this->ioUnavailableWidget->show(); + + this->targetStatusLabel->setText("Unknown"); + this->programCounterValueLabel->setText("-"); + + this->variantMenu->clear(); + this->variantMenu->setEnabled(false); + + this->toggleUi(true); + this->activated = false; +} + +void InsightWindow::adjustPanels() { + const auto targetPackageWidgetSize = (this->targetPackageWidget != nullptr) + ? this->targetPackageWidget->size() : QSize(); + const auto containerSize = this->container->size(); + + /* + * The purpose of the -20 is to ensure there is some padding between the panel borders and the + * target package widget. Looks nicer with the padding. + */ + this->leftPanel->setMaximumResize( + std::max( + this->leftPanel->getMinimumResize(), + containerSize.width() - targetPackageWidgetSize.width() - this->leftMenuBar->width() - 20 + ) + ); + this->bottomPanel->setMaximumResize( + std::max( + this->bottomPanel->getMinimumResize(), + containerSize.height() - targetPackageWidgetSize.height() - this->bottomMenuBar->height() - 20 + ) + ); +} + +void InsightWindow::resizeEvent(QResizeEvent* event) { + const auto windowSize = this->size(); + + this->windowContainer->setFixedSize(windowSize); + this->layoutContainer->setFixedSize(windowSize); + + this->adjustPanels(); +} + +void InsightWindow::showEvent(QShowEvent* event) { + this->adjustPanels(); } void InsightWindow::onTargetControllerSuspended() { @@ -464,7 +492,7 @@ void InsightWindow::openGettingStartedUrl() { void InsightWindow::openAboutWindow() { if (this->aboutWindowWidget == nullptr) { - this->aboutWindowWidget = new AboutWindow(this->mainWindowWidget); + this->aboutWindowWidget = new AboutWindow(this->windowContainer); } this->aboutWindowWidget->show(); diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp index d22617ca..ec49e520 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp @@ -13,6 +13,8 @@ #include "src/Targets/TargetDescriptor.hpp" #include "src/Targets/TargetVariant.hpp" +#include "Widgets/PanelWidget.hpp" + #include "Widgets/TargetWidgets/TargetPackageWidgetContainer.hpp" #include "Widgets/TargetWidgets/TargetPackageWidget.hpp" #include "Widgets/TargetRegistersPane/TargetRegistersPaneWidget.hpp" @@ -20,7 +22,7 @@ namespace Bloom { - class InsightWindow: public QObject + class InsightWindow: public QMainWindow { Q_OBJECT private: @@ -35,24 +37,28 @@ namespace Bloom Targets::TargetDescriptor targetDescriptor; Targets::TargetState targetState = Targets::TargetState::UNKNOWN; - QWidget* mainWindowWidget = nullptr; - AboutWindow* aboutWindowWidget = nullptr; + QWidget* windowContainer = nullptr; QMenuBar* mainMenuBar = nullptr; + QWidget* layoutContainer = nullptr; + QWidget* container = nullptr; QMenu* variantMenu = nullptr; + AboutWindow* aboutWindowWidget = nullptr; QWidget* header = nullptr; QToolButton* refreshIoInspectionButton = nullptr; - QWidget* leftPanel = nullptr; - int leftPanelMinWidth = 300; - QWidget* leftPanelLayoutContainer = nullptr; + QWidget* leftMenuBar = nullptr; + Widgets::PanelWidget* leftPanel = nullptr; Widgets::TargetRegistersPaneWidget* targetRegistersSidePane = nullptr; QToolButton* targetRegistersButton = nullptr; - Widgets::InsightTargetWidgets::TargetPackageWidgetContainer* ioContainerWidget = nullptr; + QLabel* ioUnavailableWidget = nullptr; Widgets::InsightTargetWidgets::TargetPackageWidget* targetPackageWidget = nullptr; + QWidget* bottomMenuBar = nullptr; + Widgets::PanelWidget* bottomPanel = nullptr; + QWidget* footer = nullptr; QLabel* targetStatusLabel = nullptr; QLabel* programCounterValueLabel = nullptr; @@ -69,8 +75,14 @@ namespace Bloom void activate(); void deactivate(); + void adjustPanels(); + + protected: + void resizeEvent(QResizeEvent* event) override; + void showEvent(QShowEvent* event) override; + public: - InsightWindow(QApplication& application, InsightWorker& insightWorker); + InsightWindow(InsightWorker& insightWorker); void setEnvironmentConfig(const EnvironmentConfig& environmentConfig) { this->environmentConfig = environmentConfig; @@ -83,15 +95,11 @@ namespace Bloom void init(Targets::TargetDescriptor targetDescriptor); - void show(); - public slots: - void onLeftPanelHandleSlide(int horizontalPosition); void onTargetControllerSuspended(); void onTargetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor); void onTargetStateUpdate(Targets::TargetState newState); void onTargetProgramCounterUpdate(quint32 programCounter); - void close(); void openReportIssuesUrl(); void openGettingStartedUrl(); void openAboutWindow(); diff --git a/src/Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss b/src/Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss index b5493e6a..f680f36d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss +++ b/src/Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss @@ -4,7 +4,7 @@ font-size: 14px; } -QMainWindow { +#main-window #window-container { background-color: #373835; } @@ -112,15 +112,11 @@ QToolTip { font-size: 13px; } - #footer { - position: relative; background-color: transparent; padding: 0 3px 0 30px; max-height: 25px; - width: auto; border-top: 1px solid #41423f; - } #footer QLabel, @@ -165,10 +161,6 @@ QToolTip { min-height: 25px; } -#footer QLayoutItem { - max-width: 100px; -} - #target-variant-menu::item { padding: 4px 10px 4px 10px; } @@ -180,8 +172,8 @@ QToolTip { QScrollBar:vertical { background-color: transparent; - width: 15px; - margin: 1px 1px 1px 5px; + width: 12px; + margin: 1px; } QScrollBar:handle:vertical { @@ -221,8 +213,13 @@ QScrollBar::sub-line:vertical { border: none; } -#left-panel-layout-container { +#left-panel { border-right: 1px solid #2F2F2D; + background-color: transparent; +} + +#left-panel-slider { + background-color: transparent; } /* Target Registers Pane */ @@ -292,3 +289,36 @@ QScrollBar::sub-line:vertical { #target-registers-side-pane #register-item[selected=true] #value[changed=true] { color: #8a8a8d; } + +/* Bottom menu bar & panels */ +#bottom-menu-bar { + background-color: transparent; + max-height: 22px; + border-top: 1px solid #2F2F2D; +} + +#bottom-menu-bar #ram-inspection-btn { + position: relative; + border: none; + min-width: 90px; + min-height: 22px; +} + +#bottom-menu-bar #ram-inspection-btn #ram-inspection-btn-icon { + margin-left: 9px; +} + +#bottom-menu-bar #ram-inspection-btn #ram-inspection-btn-label { + margin-left: 2px; +} + +#bottom-menu-bar QToolButton:hover, +#bottom-menu-bar QToolButton:checked { + background-color: #2F2F2D; + border: none; +} + +#bottom-panel { + border-top: 1px solid #2F2F2D; + background-color: transparent; +} diff --git a/src/Insight/UserInterfaces/InsightWindow/UiFiles/InsightWindow.ui b/src/Insight/UserInterfaces/InsightWindow/UiFiles/InsightWindow.ui index 6d0e5cb2..9ae9e883 100644 --- a/src/Insight/UserInterfaces/InsightWindow/UiFiles/InsightWindow.ui +++ b/src/Insight/UserInterfaces/InsightWindow/UiFiles/InsightWindow.ui @@ -1,15 +1,15 @@ - - 500 - 1000 - Bloom Insight - false - + false + 25 + 25 + + + File @@ -48,7 +48,7 @@ - + 0 @@ -67,15 +67,15 @@ 0 - - - Qt::Horizontal - + 3 + + QSizePolicy::Fixed + @@ -104,7 +104,7 @@ - + 0 @@ -112,43 +112,192 @@ 0 - - - Qt::LeftToRight + + + 0 - + + 0 + + + + + Qt::LeftToRight + + + + 0 + + + 0 + + + + + + Target Registers + + + true + + + true + + + + 0 + + + 0 + + + + + 15 + + + 22 + + + :/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/Images/target-registers.svg + + + :/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/Images/target-registers-disabled.svg + + + + + + + Qt::Vertical + + + + + + + + + + + + + false + + + 300 + + + 300 + + + 6 + + + + 0 + + + 0 + + + + + + + + + + + + + false + + Qt::AlignCenter + + + - + + + + + + + + + + + + true + + + PanelWidgetType::BOTTOM + + + 200 + + + 200 + + + 6 + + 0 0 - - - + + + + + + + + 1 + + + 0 + + + + + + 22 + + + + QSizePolicy::Fixed + + + + + - Target Registers + Inspect RAM true - true + false - + 0 0 - - + + - 15 + 22 - 22 + 15 :/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/Images/target-registers.svg @@ -158,69 +307,29 @@ - - + + + + Memory + + + + + - Qt::Vertical + Qt::Horizontal - - - - - - - false - - - 300 - - - - 0 - - - 0 - - - - - 0 - - - 0 - - - - - - - - 6 + + + Qt::Horizontal - - - - - - - - - - - false - - Qt::AlignCenter - - - - - - + @@ -230,18 +339,25 @@ - + 0 0 - + + Target State - - + + + + Qt::Horizontal + + + + - @@ -251,24 +367,21 @@ - - + Target Name - - + Target ID - - + false @@ -276,6 +389,9 @@ true + + + diff --git a/src/Insight/UserInterfaces/InsightWindow/UiLoader.cpp b/src/Insight/UserInterfaces/InsightWindow/UiLoader.cpp index fc625793..fb59c33e 100644 --- a/src/Insight/UserInterfaces/InsightWindow/UiLoader.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/UiLoader.cpp @@ -2,11 +2,10 @@ #include +#include "Widgets/PanelWidget.hpp" #include "Widgets/RotatableLabel.hpp" -#include "Widgets/SlidingHandleWidget.hpp" #include "Widgets/SvgWidget.hpp" #include "Widgets/SvgToolButton.hpp" -#include "Widgets/ExpandingWidget.hpp" #include "Widgets/ExpandingHeightScrollAreaWidget.hpp" #include "Widgets/TargetWidgets/TargetPackageWidgetContainer.hpp" @@ -17,6 +16,15 @@ using namespace Bloom::Widgets; UiLoader::UiLoader(QObject* parent): QUiLoader(parent) { this->customWidgetConstructorsByWidgetName = decltype(this->customWidgetConstructorsByWidgetName) { + { + "PanelWidget", + [this](QWidget* parent, const QString& name) { + auto widget = new PanelWidget(parent); + widget->setObjectName(name); + widget->setStyleSheet(parent->styleSheet()); + return widget; + } + }, { "RotatableLabel", [this](QWidget* parent, const QString& name) { @@ -26,24 +34,6 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) { return widget; } }, - { - "SlidingHandleWidget", - [this](QWidget* parent, const QString& name) { - auto widget = new SlidingHandleWidget(parent); - widget->setObjectName(name); - widget->setStyleSheet(parent->styleSheet()); - return widget; - } - }, - { - "ExpandingWidget", - [this](QWidget* parent, const QString& name) { - auto widget = new ExpandingWidget(parent); - widget->setObjectName(name); - widget->setStyleSheet(parent->styleSheet()); - return widget; - } - }, { "ExpandingHeightScrollAreaWidget", [this](QWidget* parent, const QString& name) { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingWidget.hpp deleted file mode 100644 index 46354f57..00000000 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingWidget.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include -#include - -namespace Bloom::Widgets -{ - class Q_WIDGETS_EXPORT ExpandingWidget: public QWidget - { - Q_OBJECT - protected: - [[nodiscard]] QSize minimumSizeHint() const override { - auto parentWidget = this->parentWidget(); - - if (parentWidget != nullptr) { - return parentWidget->size(); - } - - return QWidget::size(); - }; - - [[nodiscard]] QSize sizeHint() const override { - return this->minimumSizeHint(); - }; - - public: - explicit ExpandingWidget(QWidget* parent): QWidget(parent) {}; - - }; -} diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/SlidingHandleWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/SlidingHandleWidget.cpp deleted file mode 100644 index 88ad2ed8..00000000 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/SlidingHandleWidget.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "SlidingHandleWidget.hpp" - -#include - -using namespace Bloom::Widgets; - -void SlidingHandleWidget::mouseMoveEvent(QMouseEvent* event) { - emit this->horizontalSlide(event->pos().x()); -} - -void SlidingHandleWidget::enterEvent(QEnterEvent* event) { - this->setCursor(Qt::SplitHCursor); -} - -void SlidingHandleWidget::leaveEvent(QEvent* event) { - this->setCursor(Qt::ArrowCursor); -} diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/SlidingHandleWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/SlidingHandleWidget.hpp deleted file mode 100644 index 98368e16..00000000 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/SlidingHandleWidget.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -namespace Bloom::Widgets -{ - class Q_WIDGETS_EXPORT SlidingHandleWidget: public QFrame - { - Q_OBJECT - Q_PROPERTY(int handleWidth READ getHandleWidth WRITE setHandleWidth DESIGNABLE true) - - protected: - int handleWidth = 10; - - void mouseMoveEvent(QMouseEvent* event) override; - void enterEvent(QEnterEvent* event) override; - void leaveEvent(QEvent* event) override; - - public: - explicit SlidingHandleWidget(QWidget* parent): QFrame(parent) {}; - - QSize minimumSizeHint() const override { - return QSize(this->handleWidth, this->parentWidget()->height()); - }; - - QSize sizeHint() const override { - return QSize(this->handleWidth, this->parentWidget()->height()); - }; - - void setHandleWidth(int handleWidth) { - this->handleWidth = handleWidth; - this->setFixedWidth(handleWidth); - } - - int getHandleWidth() { - return this->handleWidth; - } - - signals: - void horizontalSlide(int position); - - }; -} diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/UiFiles/TargetRegisterInspectorWindow.ui b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/UiFiles/TargetRegisterInspectorWindow.ui index 43b5033e..960ad759 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/UiFiles/TargetRegisterInspectorWindow.ui +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/UiFiles/TargetRegisterInspectorWindow.ui @@ -32,6 +32,9 @@ 20 + + QSizePolicy::Fixed + diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.cpp index 3972bf93..4661746b 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.cpp @@ -1,11 +1,9 @@ #include "TargetRegistersPaneWidget.hpp" #include -#include #include #include "../../UiLoader.hpp" -#include "../ExpandingWidget.hpp" #include "RegisterGroupWidget.hpp" #include "RegisterWidget.hpp" @@ -25,7 +23,7 @@ using Bloom::Targets::TargetRegisterType; TargetRegistersPaneWidget::TargetRegistersPaneWidget( const TargetDescriptor& targetDescriptor, InsightWorker& insightWorker, - QWidget* parent + PanelWidget* parent ): QWidget(parent), parent(parent), targetDescriptor(targetDescriptor), insightWorker(insightWorker) { this->setObjectName("target-registers-side-pane"); @@ -65,6 +63,8 @@ TargetRegistersPaneWidget::TargetRegistersPaneWidget( this->filterRegisters(this->searchInput->text()); }); + this->itemScrollArea = this->container->findChild("item-scroll-area"); + this->itemContainer = this->container->findChild("item-container"); auto itemLayout = this->itemContainer->findChild(); @@ -124,12 +124,19 @@ TargetRegistersPaneWidget::TargetRegistersPaneWidget( } void TargetRegistersPaneWidget::resizeEvent(QResizeEvent* event) { - auto parentSize = this->parent->size(); - this->container->setFixedSize( - parentSize.width() - 1, - parentSize.height() + const auto parentSize = this->parent->size(); + const auto width = parentSize.width() - 1; + this->container->setFixedSize(width, parentSize.height()); + this->searchInput->setFixedWidth(width - 20); + + /* + * In order to avoid the panel resize handle overlapping the scroll bar handle, we reduce the size of + * the scroll area. + */ + this->itemScrollArea->setFixedSize( + width - this->parent->getHandleSize(), + parentSize.height() - this->toolBar->height() - this->searchInput->height() - 5 ); - this->searchInput->setFixedWidth(parentSize.width() - 20); } void TargetRegistersPaneWidget::postActivate() { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.hpp index 63f531f9..820cb388 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -9,7 +10,8 @@ #include #include "ItemWidget.hpp" -#include "../SvgToolButton.hpp" +#include "src/Insight/UserInterfaces/InsightWindow/Widgets/PanelWidget.hpp" +#include "src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp" #include "src/Insight/InsightWorker/InsightWorker.hpp" #include "src/Targets/TargetState.hpp" #include "src/Targets/TargetDescriptor.hpp" @@ -25,7 +27,7 @@ namespace Bloom::Widgets const Targets::TargetDescriptor& targetDescriptor; InsightWorker& insightWorker; - QWidget* parent = nullptr; + PanelWidget* parent = nullptr; QWidget* container = nullptr; QWidget* toolBar = nullptr; @@ -33,6 +35,7 @@ namespace Bloom::Widgets SvgToolButton* expandAllButton = nullptr; QLineEdit* searchInput = nullptr; + QScrollArea* itemScrollArea = nullptr; QWidget* itemContainer = nullptr; ItemWidget* selectedItemWidget = nullptr; @@ -58,7 +61,7 @@ namespace Bloom::Widgets TargetRegistersPaneWidget( const Targets::TargetDescriptor& targetDescriptor, InsightWorker& insightWorker, - QWidget *parent + PanelWidget *parent ); [[nodiscard]] QSize minimumSizeHint() const override { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/UiFiles/TargetRegistersSidePane.ui b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/UiFiles/TargetRegistersSidePane.ui index 4a62c59d..a90781bb 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/UiFiles/TargetRegistersSidePane.ui +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/UiFiles/TargetRegistersSidePane.ui @@ -13,6 +13,12 @@ 28 + + 28 + + + + 3 @@ -61,6 +67,12 @@ 27 + + 27 + + + + 0 @@ -105,15 +117,13 @@ - + true Qt::ScrollBarAsNeeded QAbstractScrollArea::AdjustToContents Qt::ScrollBarAlwaysOff - QSizePolicy::SetMinAndMaxSize - 0 @@ -129,6 +139,13 @@ + + + + Qt::Vertical + + + diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.cpp index 7c98e103..9d56c343 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.cpp @@ -1,5 +1,7 @@ #include "TargetPackageWidgetContainer.hpp" +#include + using namespace Bloom; using namespace Bloom::Widgets::InsightTargetWidgets; @@ -23,4 +25,8 @@ void TargetPackageWidgetContainer::resizeEvent(QResizeEvent* event) { void TargetPackageWidgetContainer::setPackageWidget(TargetPackageWidget* packageWidget) { this->packageWidget = packageWidget; + + if (packageWidget != nullptr) { + this->layout()->addWidget(packageWidget); + } }