Some refactoring of ByteItem highlighting
This commit is contained in:
@@ -10,7 +10,7 @@ namespace Bloom::Widgets
|
||||
std::optional<std::uint32_t>& currentStackPointer,
|
||||
ByteItem** hoveredByteItem,
|
||||
AnnotationItem** hoveredAnnotationItem,
|
||||
std::set<std::uint32_t>& highlightedAddresses,
|
||||
std::set<ByteItem*>& highlightedByteItems,
|
||||
const HexViewerWidgetSettings& settings
|
||||
)
|
||||
: QGraphicsItem(nullptr)
|
||||
@@ -19,7 +19,7 @@ namespace Bloom::Widgets
|
||||
, currentStackPointer(currentStackPointer)
|
||||
, hoveredByteItem(hoveredByteItem)
|
||||
, hoveredAnnotationItem(hoveredAnnotationItem)
|
||||
, highlightedAddresses(highlightedAddresses)
|
||||
, highlightedByteItems(highlightedByteItems)
|
||||
, settings(settings)
|
||||
{
|
||||
this->setCacheMode(
|
||||
@@ -129,7 +129,7 @@ namespace Bloom::Widgets
|
||||
static const auto hoveredNeighbourBackgroundColor = QColor(0x8E, 0x8B, 0x83, 30);
|
||||
|
||||
if (this->isEnabled()) {
|
||||
if (this->highlightedAddresses.contains(this->address)) {
|
||||
if (this->highlighted) {
|
||||
return &(highlightedBackgroundColor);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace Bloom::Widgets
|
||||
}
|
||||
|
||||
} else {
|
||||
if (this->highlightedAddresses.contains(this->address)) {
|
||||
if (this->highlighted) {
|
||||
return &(disabledHighlightedBackgroundColor);
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace Bloom::Widgets
|
||||
if (
|
||||
this->excludedMemoryRegion != nullptr
|
||||
|| this->settings.displayAsciiValues
|
||||
|| (!this->highlightedAddresses.empty() && !this->highlightedAddresses.contains(this->address))
|
||||
|| (!this->highlightedByteItems.empty() && !this->highlighted)
|
||||
) {
|
||||
return &(fadedStandardTextColor);
|
||||
}
|
||||
@@ -218,10 +218,6 @@ namespace Bloom::Widgets
|
||||
return &(standardTextColor);
|
||||
}
|
||||
|
||||
if (!this->highlightedAddresses.empty() && !this->highlightedAddresses.contains(this->address)) {
|
||||
return &(fadedAsciiModeTextColor);
|
||||
}
|
||||
|
||||
return &(asciiModeTextColor);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace Bloom::Widgets
|
||||
std::size_t currentRowIndex = 0;
|
||||
std::size_t currentColumnIndex = 0;
|
||||
|
||||
bool highlighted = false;
|
||||
const FocusedMemoryRegion* focusedMemoryRegion = nullptr;
|
||||
const ExcludedMemoryRegion* excludedMemoryRegion = nullptr;
|
||||
|
||||
@@ -42,7 +43,7 @@ namespace Bloom::Widgets
|
||||
std::optional<std::uint32_t>& currentStackPointer,
|
||||
ByteItem** hoveredByteItem,
|
||||
AnnotationItem** hoveredAnnotationItem,
|
||||
std::set<std::uint32_t>& highlightedAddresses,
|
||||
std::set<ByteItem*>& highlightedByteItems,
|
||||
const HexViewerWidgetSettings& settings
|
||||
);
|
||||
|
||||
@@ -70,7 +71,7 @@ namespace Bloom::Widgets
|
||||
ByteItem** hoveredByteItem;
|
||||
AnnotationItem** hoveredAnnotationItem;
|
||||
std::optional<std::uint32_t>& currentStackPointer;
|
||||
std::set<std::uint32_t>& highlightedAddresses;
|
||||
std::set<ByteItem*>& highlightedByteItems;
|
||||
|
||||
const QColor* getBackgroundColor();
|
||||
const QColor* getTextColor();
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Bloom::Widgets
|
||||
this->currentStackPointer,
|
||||
&(this->hoveredByteWidget),
|
||||
&(this->hoveredAnnotationItem),
|
||||
this->highlightedAddresses,
|
||||
this->highlightedByteItems,
|
||||
settings
|
||||
);
|
||||
|
||||
@@ -79,8 +79,19 @@ namespace Bloom::Widgets
|
||||
}
|
||||
|
||||
void ByteItemGraphicsScene::setHighlightedAddresses(const std::set<std::uint32_t>& highlightedAddresses) {
|
||||
this->highlightedAddresses = highlightedAddresses;
|
||||
this->invalidateChildItemCaches();
|
||||
this->highlightedByteItems.clear();
|
||||
|
||||
for (auto& [address, byteItem] : this->byteItemsByAddress) {
|
||||
if (highlightedAddresses.contains(address)) {
|
||||
byteItem->highlighted = true;
|
||||
this->highlightedByteItems.insert(byteItem);
|
||||
|
||||
} else {
|
||||
byteItem->highlighted = false;
|
||||
}
|
||||
|
||||
byteItem->update();
|
||||
}
|
||||
}
|
||||
|
||||
void ByteItemGraphicsScene::refreshRegions() {
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace Bloom::Widgets
|
||||
|
||||
ByteAddressContainer* byteAddressContainer = nullptr;
|
||||
|
||||
std::set<std::uint32_t> highlightedAddresses;
|
||||
std::set<ByteItem*> highlightedByteItems;
|
||||
|
||||
int getSceneWidth() {
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user