Made row and column highlighting on hover optional via tool button

This commit is contained in:
Nav
2021-11-13 16:59:16 +00:00
parent 3f6b114c2f
commit b28e876db1
11 changed files with 373 additions and 22 deletions

View File

@@ -398,7 +398,8 @@ QScrollBar::sub-line:vertical {
}
#hex-viewer-container #tool-bar #highlight-stack-memory-btn,
#hex-viewer-container #tool-bar #highlight-focused-memory-btn {
#hex-viewer-container #tool-bar #highlight-focused-memory-btn,
#hex-viewer-container #tool-bar #highlight-hovered-rows-columns-btn {
qproperty-buttonWidth: 25;
qproperty-buttonHeight: 21;
}

View File

@@ -54,8 +54,11 @@ void ByteItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
const auto hoveredByteItem = this->hoveredByteItem.value_or(nullptr);
if (hoveredByteItem != nullptr && (
hoveredByteItem->currentColumnIndex == this->currentColumnIndex
|| hoveredByteItem->currentRowIndex == this->currentRowIndex
hoveredByteItem == this || (this->settings.highlightHoveredRowAndCol && (
hoveredByteItem->currentColumnIndex == this->currentColumnIndex
|| hoveredByteItem->currentRowIndex == this->currentRowIndex
)
)
)
) {
painter->setBrush(QColor(0x8E, 0x8B, 0x83, hoveredByteItem == this ? 70 : 30));

View File

@@ -22,6 +22,7 @@ ByteItemGraphicsScene::ByteItemGraphicsScene(
): QGraphicsScene(parent),
targetMemoryDescriptor(targetMemoryDescriptor),
insightWorker(insightWorker),
settings(settings),
hoveredAddressLabel(hoveredAddressLabel),
parent(parent) {
this->setObjectName("byte-widget-container");
@@ -158,7 +159,7 @@ void ByteItemGraphicsScene::onByteWidgetEnter(ByteItem* widget) {
"Relative Address (Absolute Address): " + widget->relativeAddressHex + " (" + widget->addressHex + ")"
);
if (!this->byteItemsByRowIndex.empty()) {
if (this->settings.highlightHoveredRowAndCol && !this->byteItemsByRowIndex.empty()) {
for (auto& byteWidget : this->byteItemsByColumnIndex.at(widget->currentColumnIndex)) {
byteWidget->update();
}
@@ -166,6 +167,9 @@ void ByteItemGraphicsScene::onByteWidgetEnter(ByteItem* widget) {
for (auto& byteWidget : this->byteItemsByRowIndex.at(widget->currentRowIndex)) {
byteWidget->update();
}
} else {
widget->update();
}
}
@@ -175,7 +179,7 @@ void ByteItemGraphicsScene::onByteWidgetLeave() {
this->hoveredAddressLabel->setText("Relative Address (Absolute Address):");
if (!this->byteItemsByRowIndex.empty()) {
if (this->settings.highlightHoveredRowAndCol && !this->byteItemsByRowIndex.empty()) {
for (auto& byteWidget : this->byteItemsByColumnIndex.at(byteItem->currentColumnIndex)) {
byteWidget->update();
}
@@ -183,6 +187,9 @@ void ByteItemGraphicsScene::onByteWidgetLeave() {
for (auto& byteWidget : this->byteItemsByRowIndex.at(byteItem->currentRowIndex)) {
byteWidget->update();
}
} else {
byteItem->update();
}
}

View File

@@ -60,6 +60,8 @@ namespace Bloom::Widgets
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
InsightWorker& insightWorker;
const HexViewerWidgetSettings& settings;
QWidget* parent = nullptr;
QLabel* hoveredAddressLabel = nullptr;

View File

@@ -44,9 +44,14 @@ HexViewerWidget::HexViewerWidget(
this->toolBar = this->container->findChild<QWidget*>("tool-bar");
this->bottomBar = this->container->findChild<QWidget*>("bottom-bar");
this->refreshButton = this->container->findChild<QToolButton*>("refresh-memory-btn");
this->highlightStackMemoryButton = this->container->findChild<SvgToolButton*>("highlight-stack-memory-btn");
this->highlightFocusedMemoryButton = this->container->findChild<SvgToolButton*>("highlight-focused-memory-btn");
this->refreshButton = this->toolBar->findChild<QToolButton*>("refresh-memory-btn");
this->highlightStackMemoryButton = this->toolBar->findChild<SvgToolButton*>("highlight-stack-memory-btn");
this->highlightHoveredRowAndColumnButton = this->toolBar->findChild<SvgToolButton*>(
"highlight-hovered-rows-columns-btn"
);
this->highlightFocusedMemoryButton = this->container->findChild<SvgToolButton*>(
"highlight-focused-memory-btn"
);
this->toolBar->setContentsMargins(0, 0, 0, 0);
this->toolBar->layout()->setContentsMargins(5, 0, 5, 1);
@@ -70,18 +75,35 @@ HexViewerWidget::HexViewerWidget(
this->byteItemGraphicsScene = this->byteItemGraphicsView->getScene();
byteItemGraphicsViewLayout->insertWidget(0, this->byteItemGraphicsView);
this->setStackMemoryHighlightingEnabled(true);
this->setHoveredRowAndColumnHighlightingEnabled(true);
this->setFocusedMemoryHighlightingEnabled(true);
QObject::connect(
this->highlightStackMemoryButton,
&QToolButton::clicked,
this,
&HexViewerWidget::toggleStackMemoryHighlighting
[this] {
this->setStackMemoryHighlightingEnabled(!this->settings.highlightStackMemory);
}
);
QObject::connect(
this->highlightHoveredRowAndColumnButton,
&QToolButton::clicked,
this,
[this] {
this->setHoveredRowAndColumnHighlightingEnabled(!this->settings.highlightHoveredRowAndCol);
}
);
QObject::connect(
this->highlightFocusedMemoryButton,
&QToolButton::clicked,
this,
&HexViewerWidget::toggleFocusedMemoryHighlighting
[this] {
this->setFocusedMemoryHighlightingEnabled(!this->settings.highlightFocusedMemory);
}
);
QObject::connect(
@@ -150,20 +172,23 @@ void HexViewerWidget::onByteWidgetsAdjusted() {
// }
}
void HexViewerWidget::toggleStackMemoryHighlighting() {
auto enable = !this->settings.highlightStackMemory;
this->highlightStackMemoryButton->setChecked(enable);
this->settings.highlightStackMemory = enable;
void HexViewerWidget::setStackMemoryHighlightingEnabled(bool enabled) {
this->highlightStackMemoryButton->setChecked(enabled);
this->settings.highlightStackMemory = enabled;
this->byteItemGraphicsScene->update();
}
void HexViewerWidget::toggleFocusedMemoryHighlighting() {
auto enable = !this->settings.highlightFocusedMemory;
this->highlightFocusedMemoryButton->setChecked(enable);
this->settings.highlightFocusedMemory = enable;
void HexViewerWidget::setHoveredRowAndColumnHighlightingEnabled(bool enabled) {
this->highlightHoveredRowAndColumnButton->setChecked(enabled);
this->settings.highlightHoveredRowAndCol = enabled;
this->byteItemGraphicsScene->update();
}
void HexViewerWidget::setFocusedMemoryHighlightingEnabled(bool enabled) {
this->highlightFocusedMemoryButton->setChecked(enabled);
this->settings.highlightFocusedMemory = enabled;
this->byteItemGraphicsScene->update();
}

View File

@@ -59,13 +59,15 @@ namespace Bloom::Widgets
SvgToolButton* highlightStackMemoryButton = nullptr;
SvgToolButton* highlightFocusedMemoryButton = nullptr;
SvgToolButton* highlightHoveredRowAndColumnButton = nullptr;
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
private slots:
void onTargetStateChanged(Targets::TargetState newState);
void onByteWidgetsAdjusted();
void toggleStackMemoryHighlighting();
void toggleFocusedMemoryHighlighting();
void setStackMemoryHighlightingEnabled(bool enabled);
void setHoveredRowAndColumnHighlightingEnabled(bool enabled);
void setFocusedMemoryHighlightingEnabled(bool enabled);
};
}

View File

@@ -10,6 +10,7 @@ namespace Bloom::Widgets
bool highlightStackMemory = false;
std::optional<std::uint32_t> stackPointerAddress;
bool highlightHoveredRowAndCol = false;
bool highlightFocusedMemory = false;
bool displayAsciiValues = false;
};

View File

@@ -89,6 +89,22 @@
</property>
</widget>
</item>
<item>
<widget class="SvgToolButton" name="highlight-hovered-rows-columns-btn">
<property name="checkable">
<bool>true</bool>
</property>
<property name="svgFilePath">
<string>:/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/highlight-hovered-rows-columns.svg</string>
</property>
<property name="disabledSvgFilePath">
<string>:/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/highlight-hovered-rows-columns-disabled.svg</string>
</property>
<property name="toolTip">
<string>Highlight Row And Column On Hover</string>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="separator"/>
</item>

View File

@@ -0,0 +1,146 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="25"
height="15"
viewBox="0 0 6.6145835 3.96875"
version="1.1"
id="svg974"
sodipodi:docname="highlight-hovered-rows-columns-disabled.svg"
inkscape:version="1.0.1 (1.0.1+r75)">
<defs
id="defs968" />
<sodipodi:namedview
id="base"
pagecolor="#343532"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:zoom="22.4"
inkscape:cx="13.726828"
inkscape:cy="5.8667711"
inkscape:document-units="px"
inkscape:current-layer="layer2"
inkscape:document-rotation="0"
showgrid="false"
units="px"
inkscape:snap-page="true"
inkscape:window-width="3440"
inkscape:window-height="1353"
inkscape:window-x="2560"
inkscape:window-y="34"
inkscape:window-maximized="1"
inkscape:snap-smooth-nodes="true"
inkscape:snap-bbox="true"
inkscape:snap-bbox-midpoints="true"
inkscape:snap-bbox-edge-midpoints="true" />
<metadata
id="metadata971">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="Main"
style="display:inline">
<rect
style="fill:#838382;fill-opacity:0.60000002;stroke-width:0.0552426;opacity:0.5"
id="rect1537-3-6"
width="0.79374999"
height="0.79374993"
x="1.3229166"
y="0.52916658" />
<rect
style="display:inline;fill:#838382;fill-opacity:1;stroke-width:0.0552426;opacity:0.5"
id="rect1537-3-6-7"
width="0.79374999"
height="0.79374999"
x="2.3812504"
y="0.52916658" />
<rect
style="display:inline;fill:#838382;fill-opacity:0.60000002;stroke-width:0.0552426;opacity:0.5"
id="rect1537-3-6-4"
width="0.79374999"
height="0.79374999"
x="3.4395833"
y="0.52916658" />
<rect
style="display:inline;fill:#838382;fill-opacity:0.60000002;stroke-width:0.0552426;opacity:0.5"
id="rect1537-3-6-3"
width="0.79374999"
height="0.79374999"
x="4.4979167"
y="0.52916658" />
<rect
style="display:inline;fill:#838382;fill-opacity:1;stroke-width:0.0552426;opacity:0.5"
id="rect1537-3-6-0"
width="0.79374999"
height="0.79374993"
x="1.3229166"
y="1.5875002" />
<rect
style="display:inline;fill:#838382;fill-opacity:1;stroke-width:0.0552426;opacity:0.5"
id="rect1537-3-6-7-7"
width="0.79374999"
height="0.79374999"
x="2.3812504"
y="1.5875002" />
<rect
style="display:inline;fill:#838382;fill-opacity:1;stroke-width:0.0552426;opacity:0.5"
id="rect1537-3-6-4-8"
width="0.79374999"
height="0.79374999"
x="3.4395835"
y="1.5875002" />
<rect
style="display:inline;fill:#838382;fill-opacity:1;stroke-width:0.0552426;opacity:0.5"
id="rect1537-3-6-3-6"
width="0.79374999"
height="0.79374999"
x="4.4979167"
y="1.5875002" />
<rect
style="display:inline;fill:#838382;fill-opacity:0.60000002;stroke-width:0.0552426;opacity:0.5"
id="rect1537-3-6-8"
width="0.79374999"
height="0.79374993"
x="1.3229166"
y="2.6458335" />
<rect
style="display:inline;fill:#838382;fill-opacity:1;stroke-width:0.0552426;opacity:0.5"
id="rect1537-3-6-7-8"
width="0.79374999"
height="0.79374999"
x="2.3812504"
y="2.6458335" />
<rect
style="display:inline;fill:#838382;fill-opacity:0.60000002;stroke-width:0.0552426;opacity:0.5"
id="rect1537-3-6-4-4"
width="0.79374999"
height="0.79374999"
x="3.4395833"
y="2.6458335" />
<rect
style="display:inline;fill:#838382;fill-opacity:0.60000002;stroke-width:0.0552426;opacity:0.5"
id="rect1537-3-6-3-3"
width="0.79374999"
height="0.79374999"
x="4.4979167"
y="2.6458335" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@@ -0,0 +1,146 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="25"
height="15"
viewBox="0 0 6.6145835 3.96875"
version="1.1"
id="svg974"
sodipodi:docname="highlight-hovered-rows-columns.svg"
inkscape:version="1.0.1 (1.0.1+r75)">
<defs
id="defs968" />
<sodipodi:namedview
id="base"
pagecolor="#343532"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:zoom="22.4"
inkscape:cx="13.726828"
inkscape:cy="5.8667711"
inkscape:document-units="px"
inkscape:current-layer="layer2"
inkscape:document-rotation="0"
showgrid="false"
units="px"
inkscape:snap-page="true"
inkscape:window-width="3440"
inkscape:window-height="1353"
inkscape:window-x="2560"
inkscape:window-y="34"
inkscape:window-maximized="1"
inkscape:snap-smooth-nodes="true"
inkscape:snap-bbox="true"
inkscape:snap-bbox-midpoints="true"
inkscape:snap-bbox-edge-midpoints="true" />
<metadata
id="metadata971">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="Main"
style="display:inline">
<rect
style="fill:#838382;fill-opacity:0.60000002;stroke-width:0.0552426"
id="rect1537-3-6"
width="0.79374999"
height="0.79374993"
x="1.3229166"
y="0.52916658" />
<rect
style="display:inline;fill:#838382;fill-opacity:1;stroke-width:0.0552426"
id="rect1537-3-6-7"
width="0.79374999"
height="0.79374999"
x="2.3812504"
y="0.52916658" />
<rect
style="display:inline;fill:#838382;fill-opacity:0.60000002;stroke-width:0.0552426"
id="rect1537-3-6-4"
width="0.79374999"
height="0.79374999"
x="3.4395833"
y="0.52916658" />
<rect
style="display:inline;fill:#838382;fill-opacity:0.60000002;stroke-width:0.0552426"
id="rect1537-3-6-3"
width="0.79374999"
height="0.79374999"
x="4.4979167"
y="0.52916658" />
<rect
style="display:inline;fill:#838382;fill-opacity:1;stroke-width:0.0552426"
id="rect1537-3-6-0"
width="0.79374999"
height="0.79374993"
x="1.3229166"
y="1.5875002" />
<rect
style="display:inline;fill:#838382;fill-opacity:1;stroke-width:0.0552426"
id="rect1537-3-6-7-7"
width="0.79374999"
height="0.79374999"
x="2.3812504"
y="1.5875002" />
<rect
style="display:inline;fill:#838382;fill-opacity:1;stroke-width:0.0552426"
id="rect1537-3-6-4-8"
width="0.79374999"
height="0.79374999"
x="3.4395835"
y="1.5875002" />
<rect
style="display:inline;fill:#838382;fill-opacity:1;stroke-width:0.0552426"
id="rect1537-3-6-3-6"
width="0.79374999"
height="0.79374999"
x="4.4979167"
y="1.5875002" />
<rect
style="display:inline;fill:#838382;fill-opacity:0.60000002;stroke-width:0.0552426"
id="rect1537-3-6-8"
width="0.79374999"
height="0.79374993"
x="1.3229166"
y="2.6458335" />
<rect
style="display:inline;fill:#838382;fill-opacity:1;stroke-width:0.0552426"
id="rect1537-3-6-7-8"
width="0.79374999"
height="0.79374999"
x="2.3812504"
y="2.6458335" />
<rect
style="display:inline;fill:#838382;fill-opacity:0.60000002;stroke-width:0.0552426"
id="rect1537-3-6-4-4"
width="0.79374999"
height="0.79374999"
x="3.4395833"
y="2.6458335" />
<rect
style="display:inline;fill:#838382;fill-opacity:0.60000002;stroke-width:0.0552426"
id="rect1537-3-6-3-3"
width="0.79374999"
height="0.79374999"
x="4.4979167"
y="2.6458335" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -55,5 +55,7 @@
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/highlight-stack-memory-disabled.svg">./Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/highlight-stack-memory-disabled.svg</file>
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/highlight-focused-memory.svg">./Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/highlight-focused-memory.svg</file>
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/highlight-focused-memory-disabled.svg">./Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/highlight-focused-memory-disabled.svg</file>
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/highlight-hovered-rows-columns.svg">./Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/highlight-hovered-rows-columns.svg</file>
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/highlight-hovered-rows-columns-disabled.svg">./Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/highlight-hovered-rows-columns-disabled.svg</file>
</qresource>
</RCC>