diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.cpp index 613ce186..dc92ea5e 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.cpp @@ -8,6 +8,7 @@ using namespace Bloom::Widgets; ByteItem::ByteItem( std::size_t byteIndex, std::uint32_t address, + std::optional& currentStackPointer, std::optional& hoveredByteItem, std::optional& hoveredAnnotationItem, const HexViewerWidgetSettings& settings @@ -15,6 +16,7 @@ ByteItem::ByteItem( QGraphicsItem(nullptr), byteIndex(byteIndex), address(address), +currentStackPointer(currentStackPointer), hoveredByteItem(hoveredByteItem), hoveredAnnotationItem(hoveredAnnotationItem), settings(settings) @@ -69,8 +71,8 @@ void ByteItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, // This byte is within a focused region backgroundColor = focusedRegionBackgroundColor; - } else if (this->settings.highlightStackMemory && this->settings.stackPointerAddress.has_value() - && this->address > this->settings.stackPointerAddress + } else if (this->settings.highlightStackMemory && this->currentStackPointer.has_value() + && this->address > this->currentStackPointer ) { // This byte is within the stack memory backgroundColor = stackMemoryBackgroundColor; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.hpp index 6fdf57b9..e9160abc 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.hpp @@ -37,6 +37,7 @@ namespace Bloom::Widgets ByteItem( std::size_t byteIndex, std::uint32_t address, + std::optional& currentStackPointer, std::optional& hoveredByteItem, std::optional& hoveredAnnotationItem, const HexViewerWidgetSettings& settings @@ -66,5 +67,6 @@ namespace Bloom::Widgets std::optional& hoveredByteItem; std::optional& hoveredAnnotationItem; + std::optional& currentStackPointer; }; } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp index 1a1d5409..64e25aab 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp @@ -3,7 +3,6 @@ #include using namespace Bloom::Widgets; -using namespace Bloom::Exceptions; using Bloom::Targets::TargetMemoryDescriptor; @@ -36,7 +35,15 @@ ByteItemGraphicsScene::ByteItemGraphicsScene( for (std::uint32_t i = 0; i < memorySize; i++) { const auto address = startAddress + i; - auto* byteWidget = new ByteItem(i, address, this->hoveredByteWidget, this->hoveredAnnotationItem, settings); + auto* byteWidget = new ByteItem( + i, + address, + this->currentStackPointer, + this->hoveredByteWidget, + this->hoveredAnnotationItem, + settings + ); + this->byteItemsByAddress.insert(std::pair( address, byteWidget @@ -65,6 +72,11 @@ void ByteItemGraphicsScene::updateValues(const Targets::TargetMemoryBuffer& buff this->lastValueBuffer = buffer; } +void ByteItemGraphicsScene::updateStackPointer(std::uint32_t stackPointer) { + this->currentStackPointer = stackPointer; + this->invalidateChildItemCaches(); +} + void ByteItemGraphicsScene::refreshRegions() { for (auto& [byteAddress, byteWidget] : this->byteItemsByAddress) { byteWidget->focusedMemoryRegion = nullptr; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp index 4a4385c7..3c19c393 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp @@ -52,6 +52,7 @@ namespace Bloom::Widgets ); void updateValues(const Targets::TargetMemoryBuffer& buffer); + void updateStackPointer(std::uint32_t stackPointer); void refreshRegions(); void adjustSize(bool forced = false); void setEnabled(bool enabled); @@ -69,6 +70,8 @@ namespace Bloom::Widgets std::vector& focusedMemoryRegions; std::vector& excludedMemoryRegions; + std::optional currentStackPointer; + Targets::TargetMemoryBuffer lastValueBuffer; std::map byteItemsByAddress; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp index 17ee4a4b..ea07498b 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp @@ -124,8 +124,7 @@ void HexViewerWidget::refreshRegions() { } void HexViewerWidget::setStackPointer(std::uint32_t stackPointer) { - this->settings.stackPointerAddress = stackPointer; - this->byteItemGraphicsScene->invalidateChildItemCaches(); + this->byteItemGraphicsScene->updateStackPointer(stackPointer); } void HexViewerWidget::resizeEvent(QResizeEvent* event) { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidgetSettings.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidgetSettings.hpp index f7d919e0..593d9e06 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidgetSettings.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidgetSettings.hpp @@ -1,17 +1,12 @@ #pragma once -#include -#include - namespace Bloom::Widgets { struct HexViewerWidgetSettings { bool highlightStackMemory = false; - std::optional stackPointerAddress; - - bool highlightHoveredRowAndCol = false; bool highlightFocusedMemory = false; + bool highlightHoveredRowAndCol = false; bool displayAsciiValues = false; }; }