Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions qrenderdoc/Code/CaptureContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1801,6 +1801,33 @@ void CaptureContext::RemoveBookmark(uint32_t EID)
RefreshUIStatus({}, true, true);
}

void CaptureContext::ShiftBookmark(uint32_t EID, int32_t direction)
{
int index = -1;

for(int i = 0; i < m_Bookmarks.count(); i++)
{
if(m_Bookmarks[i].eventId == EID)
{
index = i;
break;
}
}

if(index == -1)
return;

int newIndex = index + direction;

if(newIndex < 0 || newIndex >= m_Bookmarks.count())
return;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be good to early return if "newIndex == index"

std::swap(m_Bookmarks[index], m_Bookmarks[newIndex]);

SetModification(CaptureModifications::Bookmarks);
RefreshUIStatus({}, true, true);
}

void CaptureContext::DelayedCallback(uint32_t milliseconds, std::function<void()> callback)
{
QTimer::singleShot(milliseconds, callback);
Expand Down
1 change: 1 addition & 0 deletions qrenderdoc/Code/CaptureContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class CaptureContext : public ICaptureContext, IExtensionManager
rdcarray<EventBookmark> GetBookmarks() override { return m_Bookmarks; }
void SetBookmark(const EventBookmark &mark) override;
void RemoveBookmark(uint32_t EID) override;
void ShiftBookmark(uint32_t EID, int32_t direction) override;
void EmbedDependentFiles() override;
void RemoveDependentFiles() override;

Expand Down
9 changes: 9 additions & 0 deletions qrenderdoc/Code/Interface/QRDInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -2420,6 +2420,15 @@ If no bookmark exists, this function will do nothing.
)");
virtual void RemoveBookmark(uint32_t eventId) = 0;

DOCUMENT(R"(Reorders a bookmark by shifting its position in the bookmark list.This allows manual reordering of bookmarks.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like some spaces are missing:

"list.This" -> "list. This"
"givenevent" -> "given event"


The bookmark associated with the givenevent ID is swapped with the adjacent bookmark in the specified direction.

:param int EID: The event ID of the bookmark to move.
:param int direction: The direction to move.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would benefit from being an enum instead of an int
The enum could be more expressive

)");
virtual void ShiftBookmark(uint32_t EID, int32_t direction) = 0;

DOCUMENT(R"(Stores the dependent file data into the capture i.e. shader debug files.

This reads the contents of the dependent files and stores their file contents into the capture.
Expand Down
30 changes: 27 additions & 3 deletions qrenderdoc/Windows/EventBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5344,9 +5344,7 @@ void EventBrowser::repopulateBookmarks()

highlightBookmarks();

m_BookmarkStripLayout->removeItem(m_BookmarkSpacer);
m_BookmarkStripLayout->addWidget(but);
m_BookmarkStripLayout->addItem(m_BookmarkSpacer);
m_BookmarkButtons[EID] = but;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is required ? It is already set on line 5343

}
}

Expand All @@ -5359,6 +5357,17 @@ void EventBrowser::repopulateBookmarks()
m_BookmarkButtons.remove(EID);
}
}
m_BookmarkStripLayout->removeItem(m_BookmarkSpacer);
for(const EventBookmark &mark : bookmarks)
{
if(m_BookmarkButtons.contains(mark.eventId))
{
QRClickToolButton *but = m_BookmarkButtons[mark.eventId];
m_BookmarkStripLayout->removeWidget(but);
m_BookmarkStripLayout->addWidget(but);
}
}
m_BookmarkStripLayout->addItem(m_BookmarkSpacer);

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

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

QAction renameBookmark(tr("&Rename"), this);
QAction deleteBookmark(tr("&Delete"), this);
QAction moveLeft(tr("Move &Left"), this);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to add an appropriate icon for the new context actions. Perhaps
Icons::arrow_left()
Icons::arrow_right()

QAction moveRight(tr("Move &Right"), this);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R : keyboard shortcut is already used by Rename : need to choose a different character


renameBookmark.setIcon(Icons::page_white_edit());
deleteBookmark.setIcon(Icons::del());

contextMenu.addAction(&renameBookmark);
contextMenu.addAction(&deleteBookmark);
contextMenu.addSeparator();
contextMenu.addAction(&moveLeft);
contextMenu.addAction(&moveRight);

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

QObject::connect(&moveLeft, &QAction::triggered, [this, EID]() {
m_Ctx.ShiftBookmark(EID, -1);
repopulateBookmarks();
});

QObject::connect(&moveRight, &QAction::triggered, [this, EID]() {
m_Ctx.ShiftBookmark(EID, 1);
repopulateBookmarks();
});

RDDialog::show(&contextMenu, QCursor::pos());
}

Expand Down
4 changes: 4 additions & 0 deletions qrenderdoc/Windows/PythonShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,10 @@ struct CaptureContextInvoker : ObjectForwarder<ICaptureContext>
{
InvokeVoidFunction(&ICaptureContext::RemoveBookmark, EID);
}
virtual void ShiftBookmark(uint32_t EID, int dir) override
{
InvokeVoidFunction(&ICaptureContext::ShiftBookmark, EID, dir);
}
virtual void EmbedDependentFiles() override
{
InvokeVoidFunction(&ICaptureContext::EmbedDependentFiles);
Expand Down
Loading