mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-14 23:34:08 +00:00
UI: Recalculate scroll position after resize
This commit is contained in:
parent
d277a7541f
commit
e8541b9e27
|
@ -108,8 +108,8 @@ void OBSPropertiesView::ReloadProperties()
|
|||
|
||||
void OBSPropertiesView::RefreshProperties()
|
||||
{
|
||||
int h, v;
|
||||
GetScrollPos(h, v);
|
||||
int h, v, hend, vend;
|
||||
GetScrollPos(h, v, hend, vend);
|
||||
|
||||
children.clear();
|
||||
if (widget)
|
||||
|
@ -136,9 +136,9 @@ void OBSPropertiesView::RefreshProperties()
|
|||
|
||||
setWidgetResizable(true);
|
||||
setWidget(widget);
|
||||
SetScrollPos(h, v);
|
||||
setSizePolicy(mainPolicy);
|
||||
adjustSize();
|
||||
SetScrollPos(h, v, hend, vend);
|
||||
|
||||
lastFocused.clear();
|
||||
if (lastWidget) {
|
||||
|
@ -154,28 +154,36 @@ void OBSPropertiesView::RefreshProperties()
|
|||
emit PropertiesRefreshed();
|
||||
}
|
||||
|
||||
void OBSPropertiesView::SetScrollPos(int h, int v)
|
||||
void OBSPropertiesView::SetScrollPos(int h, int v, int old_hend, int old_vend)
|
||||
{
|
||||
QScrollBar *scroll = horizontalScrollBar();
|
||||
if (scroll)
|
||||
scroll->setValue(h);
|
||||
if (scroll) {
|
||||
int hend = scroll->maximum() + scroll->pageStep();
|
||||
scroll->setValue(h * hend / old_hend);
|
||||
}
|
||||
|
||||
scroll = verticalScrollBar();
|
||||
if (scroll)
|
||||
scroll->setValue(v);
|
||||
if (scroll) {
|
||||
int vend = scroll->maximum() + scroll->pageStep();
|
||||
scroll->setValue(v * vend / old_vend);
|
||||
}
|
||||
}
|
||||
|
||||
void OBSPropertiesView::GetScrollPos(int &h, int &v)
|
||||
void OBSPropertiesView::GetScrollPos(int &h, int &v, int &hend, int &vend)
|
||||
{
|
||||
h = v = 0;
|
||||
|
||||
QScrollBar *scroll = horizontalScrollBar();
|
||||
if (scroll)
|
||||
if (scroll) {
|
||||
h = scroll->value();
|
||||
hend = scroll->maximum() + scroll->pageStep();
|
||||
}
|
||||
|
||||
scroll = verticalScrollBar();
|
||||
if (scroll)
|
||||
if (scroll) {
|
||||
v = scroll->value();
|
||||
vend = scroll->maximum() + scroll->pageStep();
|
||||
}
|
||||
}
|
||||
|
||||
OBSPropertiesView::OBSPropertiesView(OBSData settings_, obs_object_t *obj,
|
||||
|
|
|
@ -137,8 +137,8 @@ private:
|
|||
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
void GetScrollPos(int &h, int &v);
|
||||
void SetScrollPos(int h, int v);
|
||||
void GetScrollPos(int &h, int &v, int &hend, int &vend);
|
||||
void SetScrollPos(int h, int v, int old_hend, int old_vend);
|
||||
|
||||
private slots:
|
||||
void RefreshProperties();
|
||||
|
|
Loading…
Reference in a new issue