mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-21 14:16:08 +00:00
Highlight program counter in Navbar widget (#1095)
Highlight program counter in navbar and add navbar cursor colors to native theme configuration.
This commit is contained in:
parent
f189fb423c
commit
3666c97178
@ -15,6 +15,8 @@ static const QStringList cutterSpecificOptions = {
|
|||||||
"highlightPC",
|
"highlightPC",
|
||||||
"highlightWord",
|
"highlightWord",
|
||||||
"gui.navbar.err",
|
"gui.navbar.err",
|
||||||
|
"gui.navbar.seek",
|
||||||
|
"gui.navbar.pc",
|
||||||
"gui.navbar.sym",
|
"gui.navbar.sym",
|
||||||
"gui.dataoffset",
|
"gui.dataoffset",
|
||||||
"gui.navbar.code",
|
"gui.navbar.code",
|
||||||
|
@ -152,6 +152,8 @@ void Configuration::loadBaseThemeNative()
|
|||||||
setColor("gui.imports", QColor(50, 140, 255));
|
setColor("gui.imports", QColor(50, 140, 255));
|
||||||
setColor("gui.main", QColor(0, 128, 0));
|
setColor("gui.main", QColor(0, 128, 0));
|
||||||
setColor("gui.navbar.err", QColor(255, 0, 0));
|
setColor("gui.navbar.err", QColor(255, 0, 0));
|
||||||
|
setColor("gui.navbar.seek", QColor(233, 86, 86));
|
||||||
|
setColor("gui.navbar.pc", QColor(66, 238, 244));
|
||||||
setColor("gui.navbar.code", QColor(104, 229, 69));
|
setColor("gui.navbar.code", QColor(104, 229, 69));
|
||||||
setColor("gui.navbar.str", QColor(69, 104, 229));
|
setColor("gui.navbar.str", QColor(69, 104, 229));
|
||||||
setColor("gui.navbar.sym", QColor(229, 150, 69));
|
setColor("gui.navbar.sym", QColor(229, 150, 69));
|
||||||
@ -221,6 +223,8 @@ void Configuration::loadBaseThemeDark()
|
|||||||
|
|
||||||
// GUI: navbar
|
// GUI: navbar
|
||||||
setColor("gui.navbar.err", QColor(233, 86, 86));
|
setColor("gui.navbar.err", QColor(233, 86, 86));
|
||||||
|
setColor("gui.navbar.seek", QColor(233, 86, 86));
|
||||||
|
setColor("gui.navbar.pc", QColor(66, 238, 244));
|
||||||
setColor("gui.navbar.code", QColor(130, 200, 111));
|
setColor("gui.navbar.code", QColor(130, 200, 111));
|
||||||
setColor("angui.navbar.str", QColor(111, 134, 216));
|
setColor("angui.navbar.str", QColor(111, 134, 216));
|
||||||
setColor("gui.navbar.sym", QColor(221, 163, 104));
|
setColor("gui.navbar.sym", QColor(221, 163, 104));
|
||||||
|
@ -261,6 +261,8 @@ static const QMap<QString, OptionIfo> optionInfoMap = {
|
|||||||
{ "gui.imports", { "", "gui.imports", true } },
|
{ "gui.imports", { "", "gui.imports", true } },
|
||||||
{ "highlightPC", { "", "highlightPC", true } },
|
{ "highlightPC", { "", "highlightPC", true } },
|
||||||
{ "gui.navbar.err", { "", "gui.navbar.err", true } },
|
{ "gui.navbar.err", { "", "gui.navbar.err", true } },
|
||||||
|
{ "gui.navbar.seek", { "", "gui.navbar.seek", true } },
|
||||||
|
{ "gui.navbar.pc", { "", "gui.navbar.pc", true } },
|
||||||
{ "gui.navbar.sym", { "", "gui.navbar.sym", true } },
|
{ "gui.navbar.sym", { "", "gui.navbar.sym", true } },
|
||||||
{
|
{
|
||||||
"gui.navbar.code", {
|
"gui.navbar.code", {
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
VisualNavbar::VisualNavbar(MainWindow *main, QWidget *parent) :
|
VisualNavbar::VisualNavbar(MainWindow *main, QWidget *parent) :
|
||||||
QToolBar(main),
|
QToolBar(main),
|
||||||
graphicsView(new QGraphicsView),
|
graphicsView(new QGraphicsView),
|
||||||
cursorGraphicsItem(nullptr),
|
seekGraphicsItem(nullptr),
|
||||||
|
PCGraphicsItem(nullptr),
|
||||||
main(main)
|
main(main)
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
@ -40,6 +41,7 @@ VisualNavbar::VisualNavbar(MainWindow *main, QWidget *parent) :
|
|||||||
//addWidget(addsCombo);
|
//addWidget(addsCombo);
|
||||||
|
|
||||||
connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(on_seekChanged(RVA)));
|
connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(on_seekChanged(RVA)));
|
||||||
|
connect(Core(), SIGNAL(registersChanged()), this, SLOT(drawPCCursor()));
|
||||||
connect(Core(), SIGNAL(refreshAll()), this, SLOT(fetchAndPaintData()));
|
connect(Core(), SIGNAL(refreshAll()), this, SLOT(fetchAndPaintData()));
|
||||||
connect(Core(), SIGNAL(functionsChanged()), this, SLOT(fetchAndPaintData()));
|
connect(Core(), SIGNAL(functionsChanged()), this, SLOT(fetchAndPaintData()));
|
||||||
connect(Core(), SIGNAL(flagsChanged()), this, SLOT(fetchAndPaintData()));
|
connect(Core(), SIGNAL(flagsChanged()), this, SLOT(fetchAndPaintData()));
|
||||||
@ -116,8 +118,8 @@ void VisualNavbar::updateGraphicsScene()
|
|||||||
{
|
{
|
||||||
graphicsScene->clear();
|
graphicsScene->clear();
|
||||||
xToAddress.clear();
|
xToAddress.clear();
|
||||||
cursorGraphicsItem = nullptr;
|
seekGraphicsItem = nullptr;
|
||||||
|
PCGraphicsItem = nullptr;
|
||||||
graphicsScene->setBackgroundBrush(QBrush(Config()->getColor("gui.navbar.empty")));
|
graphicsScene->setBackgroundBrush(QBrush(Config()->getColor("gui.navbar.empty")));
|
||||||
|
|
||||||
if (stats.to <= stats.from) {
|
if (stats.to <= stats.from) {
|
||||||
@ -191,33 +193,42 @@ void VisualNavbar::updateGraphicsScene()
|
|||||||
// Update scene width
|
// Update scene width
|
||||||
graphicsScene->setSceneRect(0, 0, w, h);
|
graphicsScene->setSceneRect(0, 0, w, h);
|
||||||
|
|
||||||
drawCursor();
|
drawSeekCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualNavbar::drawCursor()
|
void VisualNavbar::drawCursor(RVA addr, QColor color, QGraphicsRectItem *&graphicsItem)
|
||||||
{
|
{
|
||||||
RVA offset = Core()->getOffset();
|
double cursor_x = addressToLocalX(addr);
|
||||||
double cursor_x = addressToLocalX(offset);
|
if (graphicsItem != nullptr) {
|
||||||
if (cursorGraphicsItem != nullptr) {
|
graphicsScene->removeItem(graphicsItem);
|
||||||
graphicsScene->removeItem(cursorGraphicsItem);
|
delete graphicsItem;
|
||||||
delete cursorGraphicsItem;
|
graphicsItem = nullptr;
|
||||||
cursorGraphicsItem = nullptr;
|
|
||||||
}
|
}
|
||||||
if (std::isnan(cursor_x)) {
|
if (std::isnan(cursor_x)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int h = this->graphicsView->height();
|
int h = this->graphicsView->height();
|
||||||
cursorGraphicsItem = new QGraphicsRectItem(cursor_x, 0, 2, h);
|
graphicsItem = new QGraphicsRectItem(cursor_x, 0, 2, h);
|
||||||
cursorGraphicsItem->setPen(Qt::NoPen);
|
graphicsItem->setPen(Qt::NoPen);
|
||||||
cursorGraphicsItem->setBrush(QBrush(Config()->getColor("gui.navbar.err")));
|
graphicsItem->setBrush(QBrush(color));
|
||||||
graphicsScene->addItem(cursorGraphicsItem);
|
graphicsScene->addItem(graphicsItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VisualNavbar::drawPCCursor()
|
||||||
|
{
|
||||||
|
drawCursor(Core()->getProgramCounterValue(), Config()->getColor("gui.navbar.pc"), PCGraphicsItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VisualNavbar::drawSeekCursor()
|
||||||
|
{
|
||||||
|
drawCursor(Core()->getOffset(), Config()->getColor("gui.navbar.err"), seekGraphicsItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualNavbar::on_seekChanged(RVA addr)
|
void VisualNavbar::on_seekChanged(RVA addr)
|
||||||
{
|
{
|
||||||
Q_UNUSED(addr);
|
Q_UNUSED(addr);
|
||||||
// Update cursor
|
// Update cursor
|
||||||
this->drawCursor();
|
this->drawSeekCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualNavbar::mousePressEvent(QMouseEvent *event)
|
void VisualNavbar::mousePressEvent(QMouseEvent *event)
|
||||||
|
@ -30,13 +30,16 @@ public slots:
|
|||||||
private slots:
|
private slots:
|
||||||
void fetchAndPaintData();
|
void fetchAndPaintData();
|
||||||
void fetchStats();
|
void fetchStats();
|
||||||
void drawCursor();
|
void drawSeekCursor();
|
||||||
|
void drawPCCursor();
|
||||||
|
void drawCursor(RVA addr, QColor color, QGraphicsRectItem *&graphicsItem);
|
||||||
void on_seekChanged(RVA addr);
|
void on_seekChanged(RVA addr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QGraphicsView *graphicsView;
|
QGraphicsView *graphicsView;
|
||||||
QGraphicsScene *graphicsScene;
|
QGraphicsScene *graphicsScene;
|
||||||
QGraphicsRectItem *cursorGraphicsItem;
|
QGraphicsRectItem *seekGraphicsItem;
|
||||||
|
QGraphicsRectItem *PCGraphicsItem;
|
||||||
MainWindow *main;
|
MainWindow *main;
|
||||||
|
|
||||||
BlockStatistics stats;
|
BlockStatistics stats;
|
||||||
|
Loading…
Reference in New Issue
Block a user