Refactored Panel & Pane widgets
This commit is contained in:
@@ -7,7 +7,7 @@ target_sources(
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/BloomProxyStyle.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/BloomProxyStyle.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/InsightWindow.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/InsightWindow.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/AboutWindow.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/AboutWindow.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/PaneWidget.hpp
|
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/PaneWidget.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/PanelWidget.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/PanelWidget.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/Label.hpp
|
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/Label.hpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/RotatableLabel.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/RotatableLabel.cpp
|
||||||
|
|||||||
@@ -827,16 +827,9 @@ namespace Bloom
|
|||||||
this->targetRegistersSidePane->deactivate();
|
this->targetRegistersSidePane->deactivate();
|
||||||
this->targetRegistersButton->setChecked(false);
|
this->targetRegistersButton->setChecked(false);
|
||||||
|
|
||||||
/*
|
|
||||||
* Given that the target registers side pane is currently the only pane in the left panel, the panel
|
|
||||||
* will be empty so no need to leave it visible.
|
|
||||||
*/
|
|
||||||
this->leftPanel->setVisible(false);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this->targetRegistersSidePane->activate();
|
this->targetRegistersSidePane->activate();
|
||||||
this->targetRegistersButton->setChecked(true);
|
this->targetRegistersButton->setChecked(true);
|
||||||
this->leftPanel->setVisible(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->adjustMinimumSize();
|
this->adjustMinimumSize();
|
||||||
@@ -845,7 +838,6 @@ namespace Bloom
|
|||||||
void InsightWindow::toggleRamInspectionPane() {
|
void InsightWindow::toggleRamInspectionPane() {
|
||||||
if (this->ramInspectionPane->activated) {
|
if (this->ramInspectionPane->activated) {
|
||||||
this->ramInspectionPane->deactivate();
|
this->ramInspectionPane->deactivate();
|
||||||
this->bottomPanel->hide();
|
|
||||||
this->ramInspectionButton->setChecked(false);
|
this->ramInspectionButton->setChecked(false);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -854,7 +846,6 @@ namespace Bloom
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->ramInspectionPane->activate();
|
this->ramInspectionPane->activate();
|
||||||
this->bottomPanel->show();
|
|
||||||
this->ramInspectionButton->setChecked(true);
|
this->ramInspectionButton->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -864,7 +855,6 @@ namespace Bloom
|
|||||||
void InsightWindow::toggleEepromInspectionPane() {
|
void InsightWindow::toggleEepromInspectionPane() {
|
||||||
if (this->eepromInspectionPane->activated) {
|
if (this->eepromInspectionPane->activated) {
|
||||||
this->eepromInspectionPane->deactivate();
|
this->eepromInspectionPane->deactivate();
|
||||||
this->bottomPanel->hide();
|
|
||||||
this->eepromInspectionButton->setChecked(false);
|
this->eepromInspectionButton->setChecked(false);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -873,7 +863,6 @@ namespace Bloom
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->eepromInspectionPane->activate();
|
this->eepromInspectionPane->activate();
|
||||||
this->bottomPanel->show();
|
|
||||||
this->eepromInspectionButton->setChecked(true);
|
this->eepromInspectionButton->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#include "PaneWidget.hpp"
|
||||||
|
|
||||||
|
namespace Bloom::Widgets
|
||||||
|
{
|
||||||
|
PaneWidget::PaneWidget(PanelWidget* parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
, parentPanel(parent)
|
||||||
|
{
|
||||||
|
this->setMouseTracking(false);
|
||||||
|
this->setAttribute(Qt::WA_Hover, true);
|
||||||
|
|
||||||
|
QObject::connect(this, &PaneWidget::paneActivated, parent, &PanelWidget::updateVisibility);
|
||||||
|
QObject::connect(this, &PaneWidget::paneDeactivated, parent, &PanelWidget::updateVisibility);
|
||||||
|
|
||||||
|
QObject::connect(this, &PaneWidget::paneAttached, parent, &PanelWidget::updateVisibility);
|
||||||
|
QObject::connect(this, &PaneWidget::paneDetached, parent, &PanelWidget::updateVisibility);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PaneWidget::activate() {
|
||||||
|
if (this->activated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->show();
|
||||||
|
this->activated = true;
|
||||||
|
emit this->paneActivated();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PaneWidget::deactivate() {
|
||||||
|
if (!this->activated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->hide();
|
||||||
|
this->activated = false;
|
||||||
|
emit this->paneDeactivated();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PaneWidget::detach() {
|
||||||
|
this->setWindowFlag(Qt::Window);
|
||||||
|
this->show();
|
||||||
|
|
||||||
|
this->attached = false;
|
||||||
|
emit this->paneDetached();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PaneWidget::attach() {
|
||||||
|
this->setWindowFlag(Qt::Window, false);
|
||||||
|
this->hide();
|
||||||
|
this->show();
|
||||||
|
|
||||||
|
this->attached = true;
|
||||||
|
emit this->paneAttached();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,15 +12,29 @@ namespace Bloom::Widgets
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool activated = false;
|
bool activated = true;
|
||||||
|
bool attached = true;
|
||||||
PanelWidget* parentPanel = nullptr;
|
PanelWidget* parentPanel = nullptr;
|
||||||
|
|
||||||
explicit PaneWidget(PanelWidget* parent): QWidget(parent), parentPanel(parent) {};
|
explicit PaneWidget(PanelWidget* parent);
|
||||||
|
|
||||||
[[nodiscard]] PaneState getCurrentState() const {
|
[[nodiscard]] PaneState getCurrentState() const {
|
||||||
return PaneState(
|
return PaneState(
|
||||||
this->activated
|
this->activated
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void activate();
|
||||||
|
void deactivate();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void paneActivated();
|
||||||
|
void paneDeactivated();
|
||||||
|
void paneAttached();
|
||||||
|
void paneDetached();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void detach();
|
||||||
|
void attach();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
|
|
||||||
|
#include "PaneWidget.hpp"
|
||||||
|
|
||||||
namespace Bloom::Widgets
|
namespace Bloom::Widgets
|
||||||
{
|
{
|
||||||
PanelWidget::PanelWidget(QWidget* parent): QFrame(parent) {
|
PanelWidget::PanelWidget(QWidget* parent): QFrame(parent) {
|
||||||
@@ -57,6 +59,20 @@ namespace Bloom::Widgets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PanelWidget::updateVisibility() {
|
||||||
|
const auto paneWidgets = this->findChildren<PaneWidget*>();
|
||||||
|
|
||||||
|
auto visible = false;
|
||||||
|
for (const auto& paneWidget : paneWidgets) {
|
||||||
|
if (paneWidget->activated && paneWidget->attached) {
|
||||||
|
visible = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->setVisible(visible);
|
||||||
|
}
|
||||||
|
|
||||||
bool PanelWidget::event(QEvent* event) {
|
bool PanelWidget::event(QEvent* event) {
|
||||||
if (event->type() == QEvent::Type::HoverMove) {
|
if (event->type() == QEvent::Type::HoverMove) {
|
||||||
auto* hoverEvent = dynamic_cast<QHoverEvent*>(event);
|
auto* hoverEvent = dynamic_cast<QHoverEvent*>(event);
|
||||||
|
|||||||
@@ -64,6 +64,15 @@ namespace Bloom::Widgets
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will evaluate whether the panel should still be visible or not (depending on whether there are any
|
||||||
|
* visible and attached child panes).
|
||||||
|
*
|
||||||
|
* This function is called whenever a child pane is activated/deactivate/attached/detached.
|
||||||
|
* See PaneWidget::PaneWidget() for more.
|
||||||
|
*/
|
||||||
|
void updateVisibility();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int handleSize = 10;
|
int handleSize = 10;
|
||||||
int minimumResize = 10;
|
int minimumResize = 10;
|
||||||
|
|||||||
@@ -35,14 +35,12 @@ namespace Bloom::Widgets
|
|||||||
);
|
);
|
||||||
|
|
||||||
void refreshMemoryValues(std::optional<std::function<void(void)>> callback = std::nullopt);
|
void refreshMemoryValues(std::optional<std::function<void(void)>> callback = std::nullopt);
|
||||||
void activate();
|
|
||||||
void deactivate();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent* event) override;
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
|
|
||||||
virtual void postActivate();
|
void postActivate();
|
||||||
virtual void postDeactivate();
|
void postDeactivate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor;
|
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor;
|
||||||
|
|||||||
@@ -114,6 +114,20 @@ namespace Bloom::Widgets
|
|||||||
|
|
||||||
itemLayout->addStretch(1);
|
itemLayout->addStretch(1);
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
this,
|
||||||
|
&PaneWidget::paneActivated,
|
||||||
|
this,
|
||||||
|
&TargetRegistersPaneWidget::postActivate
|
||||||
|
);
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
this,
|
||||||
|
&PaneWidget::paneDeactivated,
|
||||||
|
this,
|
||||||
|
&TargetRegistersPaneWidget::postDeactivate
|
||||||
|
);
|
||||||
|
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
&insightWorker,
|
&insightWorker,
|
||||||
&InsightWorker::targetStateUpdated,
|
&InsightWorker::targetStateUpdated,
|
||||||
@@ -188,18 +202,6 @@ namespace Bloom::Widgets
|
|||||||
this->insightWorker.queueTask(readRegisterTask);
|
this->insightWorker.queueTask(readRegisterTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetRegistersPaneWidget::activate() {
|
|
||||||
this->show();
|
|
||||||
this->activated = true;
|
|
||||||
this->postActivate();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TargetRegistersPaneWidget::deactivate() {
|
|
||||||
this->hide();
|
|
||||||
this->activated = false;
|
|
||||||
this->postDeactivate();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TargetRegistersPaneWidget::onItemSelectionChange(ItemWidget* newlySelectedWidget) {
|
void TargetRegistersPaneWidget::onItemSelectionChange(ItemWidget* newlySelectedWidget) {
|
||||||
// Only one item in the target registers pane can be selected at any given time.
|
// Only one item in the target registers pane can be selected at any given time.
|
||||||
if (this->selectedItemWidget != newlySelectedWidget) {
|
if (this->selectedItemWidget != newlySelectedWidget) {
|
||||||
|
|||||||
@@ -38,16 +38,13 @@ namespace Bloom::Widgets
|
|||||||
|
|
||||||
void refreshRegisterValues(std::optional<std::function<void(void)>> callback = std::nullopt);
|
void refreshRegisterValues(std::optional<std::function<void(void)>> callback = std::nullopt);
|
||||||
|
|
||||||
void activate();
|
|
||||||
void deactivate();
|
|
||||||
|
|
||||||
void onItemSelectionChange(Bloom::Widgets::ItemWidget* newlySelectedWidget);
|
void onItemSelectionChange(Bloom::Widgets::ItemWidget* newlySelectedWidget);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent* event) override;
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
|
|
||||||
virtual void postActivate();
|
void postActivate();
|
||||||
virtual void postDeactivate();
|
void postDeactivate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Targets::TargetDescriptor& targetDescriptor;
|
const Targets::TargetDescriptor& targetDescriptor;
|
||||||
|
|||||||
Reference in New Issue
Block a user