diff --git a/src/Insight/InsightWorker/Tasks/ConstructHexViewerByteItemScene.cpp b/src/Insight/InsightWorker/Tasks/ConstructHexViewerByteItemScene.cpp index 773ebdc5..d22d7be0 100644 --- a/src/Insight/InsightWorker/Tasks/ConstructHexViewerByteItemScene.cpp +++ b/src/Insight/InsightWorker/Tasks/ConstructHexViewerByteItemScene.cpp @@ -6,7 +6,7 @@ namespace Bloom const Targets::TargetMemoryDescriptor& memoryDescriptor, std::vector& focusedMemoryRegions, std::vector& excludedMemoryRegions, - const Widgets::HexViewerWidgetSettings& settings, + Widgets::HexViewerWidgetSettings& settings, Widgets::Label* hoveredAddressLabel ) : memoryDescriptor(memoryDescriptor) diff --git a/src/Insight/InsightWorker/Tasks/ConstructHexViewerByteItemScene.hpp b/src/Insight/InsightWorker/Tasks/ConstructHexViewerByteItemScene.hpp index f018514a..5f6e91cf 100644 --- a/src/Insight/InsightWorker/Tasks/ConstructHexViewerByteItemScene.hpp +++ b/src/Insight/InsightWorker/Tasks/ConstructHexViewerByteItemScene.hpp @@ -20,7 +20,7 @@ namespace Bloom const Targets::TargetMemoryDescriptor& memoryDescriptor, std::vector& focusedMemoryRegions, std::vector& excludedMemoryRegions, - const Widgets::HexViewerWidgetSettings& settings, + Widgets::HexViewerWidgetSettings& settings, Widgets::Label* hoveredAddressLabel ); @@ -38,7 +38,7 @@ namespace Bloom const Targets::TargetMemoryDescriptor& memoryDescriptor; std::vector& focusedMemoryRegions; std::vector& excludedMemoryRegions; - const Widgets::HexViewerWidgetSettings& settings; + Widgets::HexViewerWidgetSettings& settings; Widgets::Label* hoveredAddressLabel; }; } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressContainer.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressContainer.cpp index 8d559b7e..7dd0d778 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressContainer.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressContainer.cpp @@ -2,6 +2,10 @@ namespace Bloom::Widgets { + ByteAddressContainer::ByteAddressContainer(const HexViewerWidgetSettings& settings) + : settings(settings) + {} + void ByteAddressContainer::adjustAddressLabels( const std::map>& byteItemsByRowIndex ) { @@ -15,7 +19,7 @@ namespace Bloom::Widgets ByteAddressItem* addressLabel = nullptr; if (static_cast(rowIndex) > layoutItemMaxIndex) { - addressLabel = new ByteAddressItem(rowIndex, byteItemsByRowIndex, this); + addressLabel = new ByteAddressItem(rowIndex, byteItemsByRowIndex, this->settings.addressLabelType, this); this->addressItemsByRowIndex.emplace(rowIndex, addressLabel); } else { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressContainer.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressContainer.hpp index ed92d362..55481395 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressContainer.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressContainer.hpp @@ -9,6 +9,7 @@ #include "ByteItem.hpp" #include "ByteAddressItem.hpp" +#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidgetSettings.hpp" namespace Bloom::Widgets { @@ -17,7 +18,7 @@ namespace Bloom::Widgets public: static constexpr int WIDTH = 88; - ByteAddressContainer() = default; + ByteAddressContainer(const HexViewerWidgetSettings& settings); [[nodiscard]] QRectF boundingRect() const override { return QRectF( @@ -28,10 +29,11 @@ namespace Bloom::Widgets ); } - void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override; void adjustAddressLabels(const std::map>& byteItemsByRowIndex); + void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override; private: + const HexViewerWidgetSettings& settings; std::map addressItemsByRowIndex; }; } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressItem.cpp index 1c7eed8e..3df48cb4 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressItem.cpp @@ -7,10 +7,12 @@ namespace Bloom::Widgets ByteAddressItem::ByteAddressItem( std::size_t rowIndex, const std::map>& byteItemsByRowIndex, + const AddressType& addressType, QGraphicsItem* parent ) : rowIndex(rowIndex) , byteItemsByRowIndex(byteItemsByRowIndex) + , addressType(addressType) , QGraphicsItem(parent) { this->setCacheMode( @@ -36,7 +38,9 @@ namespace Bloom::Widgets painter->drawText( widgetRect, Qt::AlignLeft, - this->byteItemsByRowIndex.at(this->rowIndex)[0]->relativeAddressHex + this->addressType == AddressType::RELATIVE + ? this->byteItemsByRowIndex.at(this->rowIndex)[0]->relativeAddressHex + : this->byteItemsByRowIndex.at(this->rowIndex)[0]->addressHex ); } } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressItem.hpp index 35202c7c..721eebfc 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressItem.hpp @@ -6,6 +6,8 @@ #include "ByteItem.hpp" +#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/AddressType.hpp" + namespace Bloom::Widgets { class ByteAddressItem: public QGraphicsItem @@ -19,6 +21,7 @@ namespace Bloom::Widgets explicit ByteAddressItem( std::size_t rowIndex, const std::map>& byteItemsByRowIndex, + const AddressType& addressType, QGraphicsItem* parent ); @@ -35,5 +38,6 @@ namespace Bloom::Widgets private: const std::map>& byteItemsByRowIndex; + const AddressType& addressType; }; } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.cpp index c872fbd1..88ea5245 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.cpp @@ -25,7 +25,7 @@ namespace Bloom::Widgets const TargetMemoryDescriptor& targetMemoryDescriptor, std::vector& focusedMemoryRegions, std::vector& excludedMemoryRegions, - const HexViewerWidgetSettings& settings, + HexViewerWidgetSettings& settings, Label* hoveredAddressLabel ) { auto* constructSceneTask = new ConstructHexViewerByteItemScene( diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.hpp index 027c5918..27cc5f3d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.hpp @@ -24,7 +24,7 @@ namespace Bloom::Widgets const Targets::TargetMemoryDescriptor& targetMemoryDescriptor, std::vector& focusedMemoryRegions, std::vector& excludedMemoryRegions, - const HexViewerWidgetSettings& settings, + HexViewerWidgetSettings& settings, Label* hoveredAddressLabel ); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp index d9756a96..3a0bdac1 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp @@ -12,7 +12,7 @@ namespace Bloom::Widgets const TargetMemoryDescriptor& targetMemoryDescriptor, std::vector& focusedMemoryRegions, std::vector& excludedMemoryRegions, - const HexViewerWidgetSettings& settings, + HexViewerWidgetSettings& settings, Label* hoveredAddressLabel, QGraphicsView* parent ) @@ -25,7 +25,7 @@ namespace Bloom::Widgets { this->setObjectName("byte-widget-container"); - this->byteAddressContainer = new ByteAddressContainer(); + this->byteAddressContainer = new ByteAddressContainer(this->settings); this->addItem(this->byteAddressContainer); // Construct ByteWidget objects diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp index 86c12b4b..083a0a46 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp @@ -44,7 +44,7 @@ namespace Bloom::Widgets const Targets::TargetMemoryDescriptor& targetMemoryDescriptor, std::vector& focusedMemoryRegions, std::vector& excludedMemoryRegions, - const HexViewerWidgetSettings& settings, + HexViewerWidgetSettings& settings, Label* hoveredAddressLabel, QGraphicsView* parent ); @@ -91,7 +91,7 @@ namespace Bloom::Widgets Targets::TargetState targetState = Targets::TargetState::UNKNOWN; const QMargins margins = QMargins(10, 10, 10, 10); - const HexViewerWidgetSettings& settings; + HexViewerWidgetSettings& settings; Label* hoveredAddressLabel = nullptr; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidgetSettings.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidgetSettings.hpp index 70ece87f..20d8aa2a 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidgetSettings.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidgetSettings.hpp @@ -1,5 +1,7 @@ #pragma once +#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/AddressType.hpp" + namespace Bloom::Widgets { struct HexViewerWidgetSettings @@ -9,5 +11,7 @@ namespace Bloom::Widgets bool highlightHoveredRowAndCol = true; bool displayAsciiValues = false; bool displayAnnotations = true; + + AddressType addressLabelType = AddressType::ABSOLUTE; }; } diff --git a/src/ProjectSettings.cpp b/src/ProjectSettings.cpp index adee8319..31d9045a 100644 --- a/src/ProjectSettings.cpp +++ b/src/ProjectSettings.cpp @@ -184,6 +184,12 @@ namespace Bloom hexViewerSettings.displayAnnotations = hexViewerSettingsObj.value("displayAnnotations").toBool(); } + + if (hexViewerSettingsObj.contains("addressLabelType")) { + hexViewerSettings.addressLabelType = InsightProjectSettings::addressTypesByName.valueAt( + hexViewerSettingsObj.value("addressLabelType").toString() + ).value_or(hexViewerSettings.addressLabelType); + } } if (jsonObject.contains("focusedRegions")) { @@ -218,7 +224,7 @@ namespace Bloom region.createdDate.setSecsSinceEpoch(regionObj.find("createdTimestamp")->toInteger()); - const auto addressInputType = InsightProjectSettings::addressRangeInputTypesByName.valueAt( + const auto addressInputType = InsightProjectSettings::addressTypesByName.valueAt( regionObj.find("addressInputType")->toString() ); @@ -277,7 +283,7 @@ namespace Bloom region.createdDate.setSecsSinceEpoch(regionObj.find("createdTimestamp")->toInteger()); - const auto addressInputType = InsightProjectSettings::addressRangeInputTypesByName.valueAt( + const auto addressInputType = InsightProjectSettings::addressTypesByName.valueAt( regionObj.find("addressInputType")->toString() ); @@ -334,6 +340,10 @@ namespace Bloom QJsonObject InsightProjectSettings::memoryInspectionPaneSettingsToJson( const Widgets::TargetMemoryInspectionPaneSettings& inspectionPaneSettings ) const { + const auto& regionDataTypesByName = InsightProjectSettings::regionDataTypesByName; + const auto& regionEndiannessByName = InsightProjectSettings::regionEndiannessByName; + const auto& addressTypesByName = InsightProjectSettings::addressTypesByName; + auto settingsObj = QJsonObject({ {"refreshOnTargetStop", inspectionPaneSettings.refreshOnTargetStop}, {"refreshOnActivation", inspectionPaneSettings.refreshOnActivation}, @@ -346,17 +356,14 @@ namespace Bloom {"highlightHoveredRowAndCol", hexViewerSettings.highlightHoveredRowAndCol}, {"displayAsciiValues", hexViewerSettings.displayAsciiValues}, {"displayAnnotations", hexViewerSettings.displayAnnotations}, + {"addressLabelType", addressTypesByName.valueAt(hexViewerSettings.addressLabelType).value()}, })); - const auto& regionDataTypesByName = InsightProjectSettings::regionDataTypesByName; - const auto& regionEndiannessByName = InsightProjectSettings::regionEndiannessByName; - const auto& addressRangeInputTypesByName = InsightProjectSettings::addressRangeInputTypesByName; - auto focusedRegions = QJsonArray(); for (const auto& focusedRegion : inspectionPaneSettings.focusedMemoryRegions) { if (!regionDataTypesByName.contains(focusedRegion.dataType) || !regionEndiannessByName.contains(focusedRegion.endianness) - || !addressRangeInputTypesByName.contains(focusedRegion.addressRangeInputType) + || !addressTypesByName.contains(focusedRegion.addressRangeInputType) ) { continue; } @@ -370,7 +377,7 @@ namespace Bloom {"name", focusedRegion.name}, {"addressRange", addressRangeObj}, {"createdTimestamp", focusedRegion.createdDate.toSecsSinceEpoch()}, - {"addressInputType", addressRangeInputTypesByName.at(focusedRegion.addressRangeInputType)}, + {"addressInputType", addressTypesByName.at(focusedRegion.addressRangeInputType)}, {"dataType", regionDataTypesByName.at(focusedRegion.dataType)}, {"endianness", regionEndiannessByName.at(focusedRegion.endianness)}, }); @@ -380,7 +387,7 @@ namespace Bloom auto excludedRegions = QJsonArray(); for (const auto& excludedRegion : inspectionPaneSettings.excludedMemoryRegions) { - if (!addressRangeInputTypesByName.contains(excludedRegion.addressRangeInputType)) { + if (!addressTypesByName.contains(excludedRegion.addressRangeInputType)) { continue; } @@ -393,7 +400,7 @@ namespace Bloom {"name", excludedRegion.name}, {"addressRange", addressRangeObj}, {"createdTimestamp", excludedRegion.createdDate.toSecsSinceEpoch()}, - {"addressInputType", addressRangeInputTypesByName.at(excludedRegion.addressRangeInputType)}, + {"addressInputType", addressTypesByName.at(excludedRegion.addressRangeInputType)}, }); excludedRegions.push_back(regionObj); diff --git a/src/ProjectSettings.hpp b/src/ProjectSettings.hpp index 88157069..40bc1cc9 100644 --- a/src/ProjectSettings.hpp +++ b/src/ProjectSettings.hpp @@ -54,7 +54,7 @@ namespace Bloom {Targets::TargetMemoryEndianness::BIG, "big"}, }; - static const inline BiMap addressRangeInputTypesByName = { + static const inline BiMap addressTypesByName = { {AddressType::ABSOLUTE, "absolute"}, {AddressType::RELATIVE, "relative"}, };