Enabled QGraphicsItem caching for faster rendering of byte items and byte addresses, in the hex viewer widget
This commit is contained in:
@@ -6,6 +6,10 @@
|
||||
using namespace Bloom::Widgets;
|
||||
|
||||
void ByteAddressItem::setAddressHex(const QString& addressHex) {
|
||||
this->setCacheMode(
|
||||
QGraphicsItem::CacheMode::ItemCoordinateCache,
|
||||
QSize(ByteAddressItem::WIDTH, ByteAddressItem::HEIGHT)
|
||||
);
|
||||
this->addressHex = addressHex;
|
||||
}
|
||||
|
||||
@@ -13,13 +17,10 @@ void ByteAddressItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* o
|
||||
painter->setRenderHints(QPainter::RenderHint::Antialiasing | QPainter::RenderHint::SmoothPixmapTransform, true);
|
||||
|
||||
static const auto widgetRect = this->boundingRect();
|
||||
auto fontColor = QColor(0x8F, 0x91, 0x92);
|
||||
static auto font = painter->font();
|
||||
static auto fontColor = QColor(0x8F, 0x91, 0x92);
|
||||
static auto font = QFont("'Ubuntu', sans-serif");
|
||||
font.setPixelSize(12);
|
||||
|
||||
if (!this->isEnabled()) {
|
||||
fontColor.setAlpha(100);
|
||||
}
|
||||
fontColor.setAlpha(!this->isEnabled() ? 100 : 255);
|
||||
|
||||
painter->setFont(font);
|
||||
painter->setPen(fontColor);
|
||||
|
||||
@@ -19,6 +19,10 @@ address(address),
|
||||
hoveredByteItem(hoveredByteItem),
|
||||
settings(settings)
|
||||
{
|
||||
this->setCacheMode(
|
||||
QGraphicsItem::CacheMode::ItemCoordinateCache,
|
||||
QSize(ByteItem::WIDTH, ByteItem::HEIGHT)
|
||||
);
|
||||
this->setAcceptHoverEvents(true);
|
||||
|
||||
this->addressHex = "0x" + QString::number(this->address, 16).rightJustified(8, '0').toUpper();
|
||||
@@ -45,11 +49,15 @@ void ByteItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
|
||||
static const auto widgetRect = this->boundingRect();
|
||||
static const auto standardTextColor = QColor(0xAF, 0xB1, 0xB3);
|
||||
static const auto valueChangedTextColor = QColor(0x54, 0x7F, 0xBA);
|
||||
static auto font = QFont("'Ubuntu', sans-serif");
|
||||
|
||||
static const auto stackMemoryBackgroundColor = QColor(0x5E, 0x50, 0x27, 255);
|
||||
static const auto hoveredBackgroundColor = QColor(0x8E, 0x8B, 0x83, 70);
|
||||
static const auto hoveredNeighbourBackgroundColor = QColor(0x8E, 0x8B, 0x83, 30);
|
||||
|
||||
font.setPixelSize(11);
|
||||
painter->setFont(font);
|
||||
|
||||
if (this->settings.highlightStackMemory && this->settings.stackPointerAddress.has_value()
|
||||
&& this->address > this->settings.stackPointerAddress
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user