Fixed excluded memory regions in hex viewer
This commit is contained in:
@@ -4,14 +4,20 @@ namespace Bloom
|
||||
{
|
||||
ConstructHexViewerTopLevelGroupItem::ConstructHexViewerTopLevelGroupItem(
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
const Widgets::HexViewerSharedState& hexViewerState
|
||||
)
|
||||
: focusedMemoryRegions(focusedMemoryRegions)
|
||||
, excludedMemoryRegions(excludedMemoryRegions)
|
||||
, hexViewerState(hexViewerState)
|
||||
{}
|
||||
|
||||
void ConstructHexViewerTopLevelGroupItem::run(Services::TargetControllerService&) {
|
||||
auto* item = new Widgets::TopLevelGroupItem(this->focusedMemoryRegions, this->hexViewerState);
|
||||
auto* item = new Widgets::TopLevelGroupItem(
|
||||
this->focusedMemoryRegions,
|
||||
this->excludedMemoryRegions,
|
||||
this->hexViewerState
|
||||
);
|
||||
item->rebuildItemHierarchy();
|
||||
|
||||
emit this->topLevelGroupItem(item);
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace Bloom
|
||||
public:
|
||||
ConstructHexViewerTopLevelGroupItem(
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
const Widgets::HexViewerSharedState& hexViewerState
|
||||
);
|
||||
|
||||
@@ -37,5 +38,6 @@ namespace Bloom
|
||||
private:
|
||||
const Widgets::HexViewerSharedState& hexViewerState;
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions;
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,11 +20,16 @@ namespace Bloom::Widgets
|
||||
) const {
|
||||
const auto boundingRect = QRect(0, 0, ByteItem::WIDTH, ByteItem::HEIGHT);
|
||||
|
||||
if (!graphicsItem->isEnabled()) {
|
||||
if (!graphicsItem->isEnabled() || (this->excluded && !this->selected)) {
|
||||
painter->setOpacity(0.6);
|
||||
}
|
||||
|
||||
if (this->excluded || !hexViewerState->data.has_value()) {
|
||||
if (this->selected) {
|
||||
painter->drawPixmap(boundingRect, ByteItem::selectedMissingDataPixmap.value());
|
||||
return;
|
||||
}
|
||||
|
||||
painter->drawPixmap(boundingRect, ByteItem::missingDataPixmap.value());
|
||||
return;
|
||||
}
|
||||
@@ -284,6 +289,14 @@ namespace Bloom::Widgets
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, "??");
|
||||
}
|
||||
|
||||
{
|
||||
ByteItem::selectedMissingDataPixmap = selectedTemplatePixmap;
|
||||
auto painter = QPainter(&ByteItem::selectedMissingDataPixmap.value());
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, "??");
|
||||
}
|
||||
|
||||
ByteItem::pixmapCachesGenerated = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace Bloom::Widgets
|
||||
static inline std::vector<QPixmap> hoveredPrimaryPixmapsByValue = {};
|
||||
static inline std::vector<QPixmap> hoveredPrimaryAsciiPixmapsByValue = {};
|
||||
static inline std::optional<QPixmap> missingDataPixmap = {};
|
||||
static inline std::optional<QPixmap> selectedMissingDataPixmap = {};
|
||||
|
||||
static void generatePixmapCaches();
|
||||
};
|
||||
|
||||
@@ -136,7 +136,11 @@ namespace Bloom::Widgets
|
||||
|
||||
void ItemGraphicsScene::init() {
|
||||
const auto constructHexViewerTopLevelGroupItem = QSharedPointer<ConstructHexViewerTopLevelGroupItem>(
|
||||
new ConstructHexViewerTopLevelGroupItem(this->focusedMemoryRegions, this->state),
|
||||
new ConstructHexViewerTopLevelGroupItem(
|
||||
this->focusedMemoryRegions,
|
||||
this->excludedMemoryRegions,
|
||||
this->state
|
||||
),
|
||||
&QObject::deleteLater
|
||||
);
|
||||
|
||||
@@ -731,8 +735,10 @@ namespace Bloom::Widgets
|
||||
auto data = QString();
|
||||
|
||||
for (const auto& [address, byteItem] : this->selectedByteItemsByAddress) {
|
||||
const auto byteIndex = byteItem->startAddress - this->state.memoryDescriptor.addressRange.startAddress;
|
||||
data.append("0x" + QString::number((*this->state.data)[byteIndex], 16).rightJustified(2, '0').toUpper() + "\n");
|
||||
const unsigned char byteValue = byteItem->excluded
|
||||
? 0x00
|
||||
: (*this->state.data)[byteItem->startAddress - this->state.memoryDescriptor.addressRange.startAddress];
|
||||
data.append("0x" + QString::number(byteValue, 16).rightJustified(2, '0').toUpper() + "\n");
|
||||
}
|
||||
|
||||
QApplication::clipboard()->setText(std::move(data));
|
||||
@@ -746,8 +752,10 @@ namespace Bloom::Widgets
|
||||
auto data = QString();
|
||||
|
||||
for (const auto& [address, byteItem] : this->selectedByteItemsByAddress) {
|
||||
const auto byteIndex = byteItem->startAddress - this->state.memoryDescriptor.addressRange.startAddress;
|
||||
data.append(QString::number((*this->state.data)[byteIndex], 10) + "\n");
|
||||
const unsigned char byteValue = byteItem->excluded
|
||||
? 0x00
|
||||
: (*this->state.data)[byteItem->startAddress - this->state.memoryDescriptor.addressRange.startAddress];
|
||||
data.append(QString::number(byteValue, 10) + "\n");
|
||||
}
|
||||
|
||||
QApplication::clipboard()->setText(std::move(data));
|
||||
|
||||
@@ -4,10 +4,12 @@ namespace Bloom::Widgets
|
||||
{
|
||||
TopLevelGroupItem::TopLevelGroupItem(
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
const HexViewerSharedState& hexViewerState
|
||||
)
|
||||
: GroupItem(0, nullptr)
|
||||
, focusedMemoryRegions(focusedMemoryRegions)
|
||||
, excludedMemoryRegions(excludedMemoryRegions)
|
||||
, hexViewerState(hexViewerState)
|
||||
{
|
||||
const auto memorySize = this->hexViewerState.memoryDescriptor.size();
|
||||
@@ -64,6 +66,8 @@ namespace Bloom::Widgets
|
||||
}
|
||||
|
||||
for (auto& [address, byteItem] : this->byteItemsByAddress) {
|
||||
byteItem.excluded = false;
|
||||
|
||||
if (byteItem.parent != nullptr && byteItem.parent != this) {
|
||||
// This ByteItem is managed by another group
|
||||
continue;
|
||||
@@ -73,6 +77,19 @@ namespace Bloom::Widgets
|
||||
this->items.push_back(&byteItem);
|
||||
}
|
||||
|
||||
for (const auto& excludedRegion : this->excludedMemoryRegions) {
|
||||
const auto& startAddress = excludedRegion.addressRange.startAddress;
|
||||
const auto& endAddress = excludedRegion.addressRange.endAddress;
|
||||
|
||||
// Sanity check
|
||||
assert(byteItemsByAddress.contains(startAddress) && byteItemsByAddress.contains(endAddress));
|
||||
|
||||
for (auto address = startAddress; address <= endAddress; ++address) {
|
||||
auto& byteItem = byteItemsByAddress.at(address);
|
||||
byteItem.excluded = true;
|
||||
}
|
||||
}
|
||||
|
||||
this->sortItems();
|
||||
this->refreshValues();
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp"
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp"
|
||||
|
||||
namespace Bloom::Widgets
|
||||
{
|
||||
@@ -23,6 +24,7 @@ namespace Bloom::Widgets
|
||||
|
||||
TopLevelGroupItem(
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
const HexViewerSharedState& hexViewerState
|
||||
);
|
||||
|
||||
@@ -40,6 +42,7 @@ namespace Bloom::Widgets
|
||||
|
||||
private:
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions;
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions;
|
||||
const HexViewerSharedState& hexViewerState;
|
||||
|
||||
std::list<FocusedRegionGroupItem> focusedRegionGroupItems;
|
||||
|
||||
Reference in New Issue
Block a user