Skip to content

Commit 0289e1b

Browse files
committed
UI: Add bookmark reordering via shortcuts
Signed-off-by: Lisha Wang <[email protected]>
1 parent f333d08 commit 0289e1b

File tree

5 files changed

+68
-3
lines changed

5 files changed

+68
-3
lines changed

qrenderdoc/Code/CaptureContext.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,6 +1801,33 @@ void CaptureContext::RemoveBookmark(uint32_t EID)
18011801
RefreshUIStatus({}, true, true);
18021802
}
18031803

1804+
void CaptureContext::ShiftBookmark(uint32_t EID, int direction)
1805+
{
1806+
int index = -1;
1807+
1808+
for(int i = 0; i < m_Bookmarks.count(); i++)
1809+
{
1810+
if(m_Bookmarks[i].eventId == EID)
1811+
{
1812+
index = i;
1813+
break;
1814+
}
1815+
}
1816+
1817+
if(index == -1)
1818+
return;
1819+
1820+
int newIndex = index + direction;
1821+
1822+
if(newIndex < 0 || newIndex >= m_Bookmarks.count())
1823+
return;
1824+
1825+
std::swap(m_Bookmarks[index], m_Bookmarks[newIndex]);
1826+
1827+
SetModification(CaptureModifications::Bookmarks);
1828+
RefreshUIStatus({}, true, true);
1829+
}
1830+
18041831
void CaptureContext::DelayedCallback(uint32_t milliseconds, std::function<void()> callback)
18051832
{
18061833
QTimer::singleShot(milliseconds, callback);

qrenderdoc/Code/CaptureContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ class CaptureContext : public ICaptureContext, IExtensionManager
204204
rdcarray<EventBookmark> GetBookmarks() override { return m_Bookmarks; }
205205
void SetBookmark(const EventBookmark &mark) override;
206206
void RemoveBookmark(uint32_t EID) override;
207+
void ShiftBookmark(uint32_t EID, int direction) override;
207208
void EmbedDependentFiles() override;
208209
void RemoveDependentFiles() override;
209210

qrenderdoc/Code/Interface/QRDInterface.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,6 +2420,15 @@ If no bookmark exists, this function will do nothing.
24202420
)");
24212421
virtual void RemoveBookmark(uint32_t eventId) = 0;
24222422

2423+
DOCUMENT(R"(Reorders a bookmark by shifting its position in the bookmark list.This allows manual reordering of bookmarks.
2424+
2425+
The bookmark associated with the givenevent ID is swapped with the adjacent bookmark in the specified direction.
2426+
2427+
:param int EID: The event ID of the bookmark to move.
2428+
:param int direction: The direction to move.
2429+
)");
2430+
virtual void ShiftBookmark(uint32_t EID, int direction) = 0;
2431+
24232432
DOCUMENT(R"(Stores the dependent file data into the capture i.e. shader debug files.
24242433
24252434
This reads the contents of the dependent files and stores their file contents into the capture.

qrenderdoc/Windows/EventBrowser.cpp

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5344,9 +5344,7 @@ void EventBrowser::repopulateBookmarks()
53445344

53455345
highlightBookmarks();
53465346

5347-
m_BookmarkStripLayout->removeItem(m_BookmarkSpacer);
5348-
m_BookmarkStripLayout->addWidget(but);
5349-
m_BookmarkStripLayout->addItem(m_BookmarkSpacer);
5347+
m_BookmarkButtons[EID] = but;
53505348
}
53515349
}
53525350

@@ -5359,6 +5357,17 @@ void EventBrowser::repopulateBookmarks()
53595357
m_BookmarkButtons.remove(EID);
53605358
}
53615359
}
5360+
m_BookmarkStripLayout->removeItem(m_BookmarkSpacer);
5361+
for(const EventBookmark &mark : bookmarks)
5362+
{
5363+
if(m_BookmarkButtons.contains(mark.eventId))
5364+
{
5365+
QRClickToolButton *but = m_BookmarkButtons[mark.eventId];
5366+
m_BookmarkStripLayout->removeWidget(but);
5367+
m_BookmarkStripLayout->addWidget(but);
5368+
}
5369+
}
5370+
m_BookmarkStripLayout->addItem(m_BookmarkSpacer);
53625371

53635372
ui->bookmarkStrip->setVisible(!bookmarks.isEmpty());
53645373

@@ -5393,12 +5402,17 @@ void EventBrowser::bookmarkContextMenu(QRClickToolButton *button, uint32_t EID)
53935402

53945403
QAction renameBookmark(tr("&Rename"), this);
53955404
QAction deleteBookmark(tr("&Delete"), this);
5405+
QAction moveLeft(tr("Move &Left"), this);
5406+
QAction moveRight(tr("Move &Right"), this);
53965407

53975408
renameBookmark.setIcon(Icons::page_white_edit());
53985409
deleteBookmark.setIcon(Icons::del());
53995410

54005411
contextMenu.addAction(&renameBookmark);
54015412
contextMenu.addAction(&deleteBookmark);
5413+
contextMenu.addSeparator();
5414+
contextMenu.addAction(&moveLeft);
5415+
contextMenu.addAction(&moveRight);
54025416

54035417
QObject::connect(&deleteBookmark, &QAction::triggered, [this, EID]() {
54045418
m_Ctx.RemoveBookmark(EID);
@@ -5430,6 +5444,16 @@ void EventBrowser::bookmarkContextMenu(QRClickToolButton *button, uint32_t EID)
54305444
}
54315445
});
54325446

5447+
QObject::connect(&moveLeft, &QAction::triggered, [this, EID]() {
5448+
m_Ctx.ShiftBookmark(EID, -1);
5449+
repopulateBookmarks();
5450+
});
5451+
5452+
QObject::connect(&moveRight, &QAction::triggered, [this, EID]() {
5453+
m_Ctx.ShiftBookmark(EID, 1);
5454+
repopulateBookmarks();
5455+
});
5456+
54335457
RDDialog::show(&contextMenu, QCursor::pos());
54345458
}
54355459

qrenderdoc/Windows/PythonShell.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,10 @@ struct CaptureContextInvoker : ObjectForwarder<ICaptureContext>
647647
{
648648
InvokeVoidFunction(&ICaptureContext::RemoveBookmark, EID);
649649
}
650+
virtual void ShiftBookmark(uint32_t EID, int dir) override
651+
{
652+
InvokeVoidFunction(&ICaptureContext::ShiftBookmark, EID, dir);
653+
}
650654
virtual void EmbedDependentFiles() override
651655
{
652656
InvokeVoidFunction(&ICaptureContext::EmbedDependentFiles);

0 commit comments

Comments
 (0)