New struct to hold settings for the HexViewierWidget
This commit is contained in:
@@ -10,8 +10,15 @@ using namespace Bloom::Widgets;
|
||||
ByteItem::ByteItem(
|
||||
std::size_t byteIndex,
|
||||
std::uint32_t address,
|
||||
std::optional<ByteItem*>& hoveredByteItem
|
||||
): QGraphicsItem(nullptr), byteIndex(byteIndex), address(address), hoveredByteItem(hoveredByteItem) {
|
||||
std::optional<ByteItem*>& hoveredByteItem,
|
||||
const HexViewerWidgetSettings& settings
|
||||
):
|
||||
QGraphicsItem(nullptr),
|
||||
byteIndex(byteIndex),
|
||||
address(address),
|
||||
hoveredByteItem(hoveredByteItem),
|
||||
settings(settings)
|
||||
{
|
||||
this->setAcceptHoverEvents(true);
|
||||
|
||||
this->addressHex = "0x" + QString::number(this->address, 16).rightJustified(8, '0').toUpper();
|
||||
@@ -37,15 +44,22 @@ void ByteItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
|
||||
|
||||
static const auto widgetRect = this->boundingRect();
|
||||
|
||||
if (this->hoveredByteItem.has_value()) {
|
||||
const auto hoveredWidget = this->hoveredByteItem.value();
|
||||
if (this->settings.highlightStackMemory && this->settings.stackPointerAddress.has_value()
|
||||
&& this->address > this->settings.stackPointerAddress
|
||||
) {
|
||||
// This byte is within the stack memory
|
||||
painter->setBrush(QColor(0x5E, 0x50, 0x27, 255));
|
||||
painter->drawRect(widgetRect);
|
||||
}
|
||||
|
||||
if (hoveredWidget->currentColumnIndex == this->currentColumnIndex
|
||||
|| hoveredWidget->currentRowIndex == this->currentRowIndex
|
||||
){
|
||||
painter->setBrush(QColor(0x8E, 0x8B, 0x83, hoveredWidget == this ? 70 : 30));
|
||||
painter->drawRect(widgetRect);
|
||||
}
|
||||
const auto hoveredByteItem = this->hoveredByteItem.value_or(nullptr);
|
||||
if (hoveredByteItem != nullptr && (
|
||||
hoveredByteItem->currentColumnIndex == this->currentColumnIndex
|
||||
|| hoveredByteItem->currentRowIndex == this->currentRowIndex
|
||||
)
|
||||
) {
|
||||
painter->setBrush(QColor(0x8E, 0x8B, 0x83, hoveredByteItem == this ? 70 : 30));
|
||||
painter->drawRect(widgetRect);
|
||||
}
|
||||
|
||||
auto textColor = QColor(this->valueChanged ? "#547fba" : "#afb1b3");
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <optional>
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.hpp"
|
||||
#include "HexViewerWidgetSettings.hpp"
|
||||
|
||||
namespace Bloom::Widgets
|
||||
{
|
||||
@@ -30,7 +31,8 @@ namespace Bloom::Widgets
|
||||
ByteItem(
|
||||
std::size_t byteIndex,
|
||||
std::uint32_t address,
|
||||
std::optional<ByteItem*>& hoveredByteItem
|
||||
std::optional<ByteItem*>& hoveredByteItem,
|
||||
const HexViewerWidgetSettings& settings
|
||||
);
|
||||
|
||||
void setValue(unsigned char value);
|
||||
@@ -50,6 +52,8 @@ namespace Bloom::Widgets
|
||||
bool valueInitialised = false;
|
||||
bool valueChanged = false;
|
||||
|
||||
const HexViewerWidgetSettings& settings;
|
||||
|
||||
QString hexValue;
|
||||
std::optional<QString> asciiValue;
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ using Bloom::Targets::TargetMemoryDescriptor;
|
||||
ByteItemContainerGraphicsView::ByteItemContainerGraphicsView(
|
||||
const TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
InsightWorker& insightWorker,
|
||||
const HexViewerWidgetSettings& settings,
|
||||
QLabel* hoveredAddressLabel,
|
||||
QWidget* parent
|
||||
): QGraphicsView(parent) {
|
||||
@@ -28,6 +29,7 @@ ByteItemContainerGraphicsView::ByteItemContainerGraphicsView(
|
||||
this->scene = new ByteItemGraphicsScene(
|
||||
targetMemoryDescriptor,
|
||||
insightWorker,
|
||||
settings,
|
||||
hoveredAddressLabel,
|
||||
this
|
||||
);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "src/Insight/InsightWorker/InsightWorker.hpp"
|
||||
|
||||
#include "ByteItemGraphicsScene.hpp"
|
||||
#include "HexViewerWidgetSettings.hpp"
|
||||
|
||||
namespace Bloom::Widgets
|
||||
{
|
||||
@@ -30,6 +31,7 @@ namespace Bloom::Widgets
|
||||
ByteItemContainerGraphicsView(
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
InsightWorker& insightWorker,
|
||||
const HexViewerWidgetSettings& settings,
|
||||
QLabel* hoveredAddressLabel,
|
||||
QWidget* parent
|
||||
);
|
||||
|
||||
@@ -16,6 +16,7 @@ using Bloom::Targets::TargetMemoryDescriptor;
|
||||
ByteItemGraphicsScene::ByteItemGraphicsScene(
|
||||
const TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
InsightWorker& insightWorker,
|
||||
const HexViewerWidgetSettings& settings,
|
||||
QLabel* hoveredAddressLabel,
|
||||
QWidget* parent
|
||||
): QGraphicsScene(parent),
|
||||
@@ -39,7 +40,7 @@ parent(parent) {
|
||||
for (std::uint32_t i = 0; i < memorySize; i++) {
|
||||
const auto address = startAddress + i;
|
||||
|
||||
auto* byteWidget = new ByteItem(i, address, this->hoveredByteWidget);
|
||||
auto* byteWidget = new ByteItem(i, address, this->hoveredByteWidget, settings);
|
||||
this->byteItemsByAddress.insert(std::pair(
|
||||
address,
|
||||
byteWidget
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "ByteItem.hpp"
|
||||
#include "ByteAddressContainer.hpp"
|
||||
#include "HexViewerWidgetSettings.hpp"
|
||||
|
||||
namespace Bloom::Widgets
|
||||
{
|
||||
@@ -36,6 +37,7 @@ namespace Bloom::Widgets
|
||||
ByteItemGraphicsScene(
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
InsightWorker& insightWorker,
|
||||
const HexViewerWidgetSettings& settings,
|
||||
QLabel* hoveredAddressLabel,
|
||||
QWidget* parent
|
||||
);
|
||||
|
||||
@@ -60,6 +60,7 @@ HexViewerWidget::HexViewerWidget(
|
||||
this->byteItemGraphicsView = new ByteItemContainerGraphicsView(
|
||||
targetMemoryDescriptor,
|
||||
insightWorker,
|
||||
this->settings,
|
||||
this->hoveredAddressLabel,
|
||||
byteItemGraphicsViewContainer
|
||||
);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "src/Insight/InsightWorker/InsightWorker.hpp"
|
||||
|
||||
#include "HexViewerWidgetSettings.hpp"
|
||||
#include "ByteItemContainerGraphicsView.hpp"
|
||||
|
||||
namespace Bloom::Widgets
|
||||
@@ -42,6 +43,8 @@ namespace Bloom::Widgets
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor;
|
||||
InsightWorker& insightWorker;
|
||||
|
||||
HexViewerWidgetSettings settings = HexViewerWidgetSettings();
|
||||
|
||||
QWidget* container = nullptr;
|
||||
QWidget* toolBar = nullptr;
|
||||
QWidget* bottomBar = nullptr;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
|
||||
namespace Bloom::Widgets
|
||||
{
|
||||
struct HexViewerWidgetSettings
|
||||
{
|
||||
bool highlightStackMemory = false;
|
||||
std::optional<std::uint32_t> stackPointerAddress;
|
||||
|
||||
bool highlightFocusedMemory = false;
|
||||
bool displayAsciiValues = false;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user