diff --git a/src/Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss b/src/Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss index 93eb59ee..2101df88 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss +++ b/src/Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss @@ -421,6 +421,26 @@ QScrollBar::sub-line:vertical { qproperty-buttonHeight: 21; } +#hex-viewer-container #tool-bar #go-to-address-input { + min-width: 100px; + max-width: 100px; + min-height: 15px; + max-height: 15px; + border: none; + background-color: transparent; + font-size: 13px; + color: #848486; +} + +#hex-viewer-container #tool-bar #go-to-address-input:focus { + /*background-color: #2f312e;*/ + color: #afb1b3; +} + +#hex-viewer-container #tool-bar #go-to-address-input:disabled { + color: #686767; +} + #hex-viewer-container QScrollArea, #hex-viewer-container #graphics-view-container, #hex-viewer-container #graphics-view-container #graphics-view { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.cpp index d3f5f5b7..e3a902c4 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.cpp @@ -34,6 +34,10 @@ ByteItemContainerGraphicsView::ByteItemContainerGraphicsView( } +void ByteItemContainerGraphicsView::scrollToByteItemAtAddress(std::uint32_t address) { + this->centerOn(this->scene->getByteItemPositionByAddress(address)); +} + bool ByteItemContainerGraphicsView::event(QEvent* event) { const auto eventType = event->type(); if (eventType == QEvent::Type::EnabledChange) { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.hpp index e785729f..c249c550 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.hpp @@ -34,6 +34,8 @@ namespace Bloom::Widgets return this->scene; } + void scrollToByteItemAtAddress(std::uint32_t address); + protected: bool event(QEvent* event) override; void resizeEvent(QResizeEvent* event) override; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp index 88f5f4b6..314201a9 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp @@ -221,6 +221,14 @@ void ByteItemGraphicsScene::invalidateChildItemCaches() { } } +QPointF ByteItemGraphicsScene::getByteItemPositionByAddress(std::uint32_t address) { + if (this->byteItemsByAddress.contains(address)) { + return this->byteItemsByAddress.at(address)->pos(); + } + + return QPointF(); +} + bool ByteItemGraphicsScene::event(QEvent* event) { if (event->type() == QEvent::Type::GraphicsSceneLeave && this->hoveredByteWidget.has_value()) { this->onByteWidgetLeave(); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp index 6760caf2..c4a17cbd 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp @@ -55,6 +55,7 @@ namespace Bloom::Widgets void adjustSize(bool forced = false); void setEnabled(bool enabled); void invalidateChildItemCaches(); + QPointF getByteItemPositionByAddress(std::uint32_t address); signals: void byteWidgetsAdjusted(); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp index d35a7aa0..c9b0e73b 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp @@ -58,6 +58,8 @@ HexViewerWidget::HexViewerWidget( this->displayAnnotationsButton = this->container->findChild("display-annotations-btn"); this->displayAsciiButton = this->container->findChild("display-ascii-btn"); + this->goToAddressInput = this->container->findChild("go-to-address-input"); + this->toolBar->setContentsMargins(0, 0, 0, 0); this->toolBar->layout()->setContentsMargins(5, 0, 5, 1); @@ -137,6 +139,20 @@ HexViewerWidget::HexViewerWidget( } ); + QObject::connect( + this->goToAddressInput, + &QLineEdit::textEdited, + this, + &HexViewerWidget::onGoToAddressInputChanged + ); + + QObject::connect( + this->goToAddressInput, + &TextInput::focusChanged, + this, + &HexViewerWidget::onGoToAddressInputChanged + ); + QObject::connect( &insightWorker, &InsightWorker::targetStateUpdated, @@ -211,3 +227,18 @@ void HexViewerWidget::setDisplayAsciiEnabled(bool enabled) { this->byteItemGraphicsScene->invalidateChildItemCaches(); } + +void HexViewerWidget::onGoToAddressInputChanged() { + auto addressConversionOk = false; + const auto address = this->goToAddressInput->text().toUInt(&addressConversionOk, 16); + + const auto& memoryAddressRange = this->targetMemoryDescriptor.addressRange; + + if (addressConversionOk && memoryAddressRange.contains(address) && this->goToAddressInput->hasFocus()) { + this->byteItemGraphicsScene->setHighlightedAddresses({address}); + this->byteItemGraphicsView->scrollToByteItemAtAddress(address); + return; + } + + this->byteItemGraphicsScene->setHighlightedAddresses({}); +} diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp index 557d09c6..9c4bbc16 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp @@ -12,6 +12,7 @@ #include "src/Insight/InsightWorker/InsightWorker.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp" +#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TextInput.hpp" #include "HexViewerWidgetSettings.hpp" #include "ByteItemContainerGraphicsView.hpp" @@ -70,6 +71,8 @@ namespace Bloom::Widgets SvgToolButton* displayAnnotationsButton = nullptr; SvgToolButton* displayAsciiButton = nullptr; + TextInput* goToAddressInput = nullptr; + Targets::TargetState targetState = Targets::TargetState::UNKNOWN; void onTargetStateChanged(Targets::TargetState newState); @@ -78,5 +81,6 @@ namespace Bloom::Widgets void setFocusedMemoryHighlightingEnabled(bool enabled); void setAnnotationsEnabled(bool enabled); void setDisplayAsciiEnabled(bool enabled); + void onGoToAddressInputChanged(); }; } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/UiFiles/HexViewerWidget.ui b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/UiFiles/HexViewerWidget.ui index 200402d5..c608ee00 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/UiFiles/HexViewerWidget.ui +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/UiFiles/HexViewerWidget.ui @@ -162,6 +162,28 @@ + + + + + 1 + + + + QSizePolicy::Fixed + + + + + + + Go to address... + + + + + +