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