diff --git a/docs/verify-docstrings.py b/docs/verify-docstrings.py index 0fc4e1924..89f8f6e48 100644 --- a/docs/verify-docstrings.py +++ b/docs/verify-docstrings.py @@ -100,6 +100,8 @@ def make_c_type(ret: str, pattern: bool, typelist: List[str]): ret = 'rdcstrpairs' elif ret == 'Tuple[str,str]': # special case ret = 'rdcstrpair' + elif ret == 'Callable[[], None]': # callbacks with parameters or return type should have a *Callback typedef + ret = 'std::function' if pattern else 'std::function' elif ret[0:5] == 'List[': inner = make_c_type(ret[5:-1], pattern, typelist) ret = '(const )?rdcarray<{}> ?[&*]?'.format(inner) if pattern else 'rdcarray<{}>'.format(inner) diff --git a/qrenderdoc/Code/CaptureContext.cpp b/qrenderdoc/Code/CaptureContext.cpp index f16dbd6b0..edcadb0c6 100644 --- a/qrenderdoc/Code/CaptureContext.cpp +++ b/qrenderdoc/Code/CaptureContext.cpp @@ -1799,6 +1799,11 @@ void CaptureContext::RemoveBookmark(uint32_t EID) RefreshUIStatus({}, true, true); } +void CaptureContext::DelayedCallback(uint32_t milliseconds, std::function callback) +{ + QTimer::singleShot(milliseconds, callback); +} + void CaptureContext::SetModification(CaptureModifications mod) { m_CaptureMods |= mod; diff --git a/qrenderdoc/Code/CaptureContext.h b/qrenderdoc/Code/CaptureContext.h index a1e2445bb..16cd673af 100644 --- a/qrenderdoc/Code/CaptureContext.h +++ b/qrenderdoc/Code/CaptureContext.h @@ -205,6 +205,8 @@ public: void SetBookmark(const EventBookmark &mark) override; void RemoveBookmark(uint32_t EID) override; + void DelayedCallback(uint32_t milliseconds, std::function callback) override; + IMainWindow *GetMainWindow() override; IEventBrowser *GetEventBrowser() override; IAPIInspector *GetAPIInspector() override; diff --git a/qrenderdoc/Code/Interface/QRDInterface.h b/qrenderdoc/Code/Interface/QRDInterface.h index df7b73809..6650218a4 100644 --- a/qrenderdoc/Code/Interface/QRDInterface.h +++ b/qrenderdoc/Code/Interface/QRDInterface.h @@ -2390,6 +2390,14 @@ If no bookmark exists, this function will do nothing. )"); virtual void RemoveBookmark(uint32_t eventId) = 0; + DOCUMENT(R"(Registers a delayed callback to be called after a certain number of milliseconds +on the UI thread. + +:param int milliseconds: The number of milliseconds (approximately) to wait before the callback. +:param Callable[[], None] callback: The function to call +)"); + virtual void DelayedCallback(uint32_t milliseconds, std::function callback) = 0; + DOCUMENT(R"(Retrieve the current singleton :class:`MainWindow`. :return: The current window. diff --git a/qrenderdoc/Windows/PythonShell.cpp b/qrenderdoc/Windows/PythonShell.cpp index b4a3714c7..23b5b6e01 100644 --- a/qrenderdoc/Windows/PythonShell.cpp +++ b/qrenderdoc/Windows/PythonShell.cpp @@ -629,6 +629,7 @@ struct CaptureContextInvoker : ObjectForwarder { InvokeVoidFunction(&ICaptureContext::AddMessages, msgs); } + virtual void ClearMessages() override { InvokeVoidFunction(&ICaptureContext::ClearMessages); } virtual void SetResourceCustomName(ResourceId id, const rdcstr &name) override { InvokeVoidFunction(&ICaptureContext::SetResourceCustomName, id, name); @@ -646,6 +647,10 @@ struct CaptureContextInvoker : ObjectForwarder { InvokeVoidFunction(&ICaptureContext::RemoveBookmark, EID); } + virtual void DelayedCallback(uint32_t milliseconds, std::function callback) override + { + InvokeVoidFunction(&ICaptureContext::DelayedCallback, milliseconds, callback); + } virtual IMainWindow *GetMainWindow() override { return InvokeRetFunction(&ICaptureContext::GetMainWindow);