Moved current stack pointer out of HexViewerWidgetSettings - didn't belong there
This commit is contained in:
@@ -8,6 +8,7 @@ using namespace Bloom::Widgets;
|
||||
ByteItem::ByteItem(
|
||||
std::size_t byteIndex,
|
||||
std::uint32_t address,
|
||||
std::optional<std::uint32_t>& currentStackPointer,
|
||||
std::optional<ByteItem*>& hoveredByteItem,
|
||||
std::optional<AnnotationItem*>& 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;
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace Bloom::Widgets
|
||||
ByteItem(
|
||||
std::size_t byteIndex,
|
||||
std::uint32_t address,
|
||||
std::optional<std::uint32_t>& currentStackPointer,
|
||||
std::optional<ByteItem*>& hoveredByteItem,
|
||||
std::optional<AnnotationItem*>& hoveredAnnotationItem,
|
||||
const HexViewerWidgetSettings& settings
|
||||
@@ -66,5 +67,6 @@ namespace Bloom::Widgets
|
||||
|
||||
std::optional<ByteItem*>& hoveredByteItem;
|
||||
std::optional<AnnotationItem*>& hoveredAnnotationItem;
|
||||
std::optional<std::uint32_t>& currentStackPointer;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <cmath>
|
||||
|
||||
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;
|
||||
|
||||
@@ -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<FocusedMemoryRegion>& focusedMemoryRegions;
|
||||
std::vector<ExcludedMemoryRegion>& excludedMemoryRegions;
|
||||
|
||||
std::optional<std::uint32_t> currentStackPointer;
|
||||
|
||||
Targets::TargetMemoryBuffer lastValueBuffer;
|
||||
|
||||
std::map<std::uint32_t, ByteItem*> byteItemsByAddress;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
|
||||
namespace Bloom::Widgets
|
||||
{
|
||||
struct HexViewerWidgetSettings
|
||||
{
|
||||
bool highlightStackMemory = false;
|
||||
std::optional<std::uint32_t> stackPointerAddress;
|
||||
|
||||
bool highlightHoveredRowAndCol = false;
|
||||
bool highlightFocusedMemory = false;
|
||||
bool highlightHoveredRowAndCol = false;
|
||||
bool displayAsciiValues = false;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user