UI: Add vertical scroll area subclass

The regular scroll area can expand horizontally, but the problem with
this is that sometimes there are controls within it that expand way too
big.

For example, the properties window for window capture can have a list of
windows where the titles of the windows are really really long, and it
causes the properties to extend way too far to the right, making the
window look really unusual.

Another example are the volume controls in the main window that can
expand way to the right if the name of a source is really long, causing
the volume control to stretch way too far to the right, making the
volume controls difficult to use when that happens.

So this just makes it so it sets the maximum width of a scroll area's
internal widget to the actual width of the scroll area, preventing it
from going off the side of the scroll area.
This commit is contained in:
jp9000
2015-01-03 02:42:57 -08:00
parent 824c7b02c9
commit 2c796e4b7b
3 changed files with 28 additions and 0 deletions
+2
View File
@@ -105,6 +105,7 @@ set(obs_SOURCES
properties-view.cpp
volume-control.cpp
adv-audio-control.cpp
vertical-scroll-area.cpp
crash-report.cpp
qt-wrappers.cpp)
@@ -129,6 +130,7 @@ set(obs_HEADERS
display-helpers.hpp
volume-control.hpp
adv-audio-control.hpp
vertical-scroll-area.hpp
qt-display.hpp
crash-report.hpp
qt-wrappers.hpp)
+8
View File
@@ -0,0 +1,8 @@
#include <QResizeEvent>
#include "vertical-scroll-area.hpp"
void VScrollArea::resizeEvent(QResizeEvent *event)
{
if (!!widget())
widget()->setMaximumWidth(event->size().width());
}
+18
View File
@@ -0,0 +1,18 @@
#pragma once
#include <QScrollArea>
class QResizeEvent;
class VScrollArea : public QScrollArea {
Q_OBJECT
public:
inline VScrollArea(QWidget *parent = nullptr)
: QScrollArea(parent)
{
}
protected:
virtual void resizeEvent(QResizeEvent *event) override;
};