diff --git a/qrenderdoc/Code/Interface/Extensions.h b/qrenderdoc/Code/Interface/Extensions.h index 85452db7b..bb4890975 100644 --- a/qrenderdoc/Code/Interface/Extensions.h +++ b/qrenderdoc/Code/Interface/Extensions.h @@ -695,6 +695,20 @@ add text next to it. )"); virtual rdcstr GetWidgetText(QWidget *widget) = 0; + DOCUMENT(R"(Scroll the widget's vertical scrollbar to the top. If the widget has no scrollbar +this will do nothing + +:param QWidget widget: The widget to scroll in. +)"); + virtual void ScrollToTop(QWidget *widget) = 0; + + DOCUMENT(R"(Scroll the widget's vertical scrollbar to the bottom. If the widget has no scrollbar +this will do nothing + +:param QWidget widget: The widget to scroll in. +)"); + virtual void ScrollToBottom(QWidget *widget) = 0; + DOCUMENT(R"(Change the font properties of a widget. :param QWidget widget: The widget to change font of. diff --git a/qrenderdoc/Code/MiniQtHelper.cpp b/qrenderdoc/Code/MiniQtHelper.cpp index 017b916a8..88f605d3f 100644 --- a/qrenderdoc/Code/MiniQtHelper.cpp +++ b/qrenderdoc/Code/MiniQtHelper.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include "Code/QRDUtils.h" @@ -412,6 +413,26 @@ rdcstr MiniQtHelper::GetWidgetText(QWidget *widget) return widget->windowTitle(); } +void MiniQtHelper::ScrollToTop(QWidget *widget) +{ + if(!widget) + return; + + QAbstractScrollArea *w = qobject_cast(widget); + if(w) + w->verticalScrollBar()->setSliderPosition(w->verticalScrollBar()->minimum()); +} + +void MiniQtHelper::ScrollToBottom(QWidget *widget) +{ + if(!widget) + return; + + QAbstractScrollArea *w = qobject_cast(widget); + if(w) + w->verticalScrollBar()->setSliderPosition(w->verticalScrollBar()->maximum()); +} + void MiniQtHelper::SetWidgetFont(QWidget *widget, const rdcstr &font, int32_t fontSize, bool bold, bool italic) { diff --git a/qrenderdoc/Code/MiniQtHelper.h b/qrenderdoc/Code/MiniQtHelper.h index f76fbfa4e..41056b81c 100644 --- a/qrenderdoc/Code/MiniQtHelper.h +++ b/qrenderdoc/Code/MiniQtHelper.h @@ -74,6 +74,9 @@ public: void SetWidgetText(QWidget *widget, const rdcstr &text) override; rdcstr GetWidgetText(QWidget *widget) override; + void ScrollToTop(QWidget *widget) override; + void ScrollToBottom(QWidget *widget) override; + void SetWidgetFont(QWidget *widget, const rdcstr &font, int32_t fontSize, bool bold, bool italic) override; diff --git a/qrenderdoc/Code/pyrenderdoc/PythonInvokers.cpp b/qrenderdoc/Code/pyrenderdoc/PythonInvokers.cpp index 05cdfe9e4..34045ac9a 100644 --- a/qrenderdoc/Code/pyrenderdoc/PythonInvokers.cpp +++ b/qrenderdoc/Code/pyrenderdoc/PythonInvokers.cpp @@ -182,6 +182,12 @@ struct MiniQtInvoker : UIThreadInvoker return InvokeRetFunction(&IMiniQtHelper::GetWidgetText, widget); } + void ScrollToTop(QWidget *widget) { InvokeVoidFunction(&IMiniQtHelper::ScrollToTop, widget); } + void ScrollToBottom(QWidget *widget) + { + InvokeVoidFunction(&IMiniQtHelper::ScrollToBottom, widget); + } + void SetWidgetFont(QWidget *widget, const rdcstr &font, int32_t fontSize, bool bold, bool italic) { InvokeVoidFunction(&IMiniQtHelper::SetWidgetFont, widget, font, fontSize, bold, italic);