mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 01:20:42 +00:00
Remove contents margins from sizehint when preserving aspect ratio
* This prevents a feedback loop where the label resizes wider to make room for the margins, then the margins get bigger to keep the image centred/scaled properly, etc.
This commit is contained in:
@@ -33,6 +33,26 @@ RDLabel::~RDLabel()
|
||||
{
|
||||
}
|
||||
|
||||
QSize RDLabel::sizeHint() const
|
||||
{
|
||||
QSize sz = QLabel::sizeHint();
|
||||
|
||||
if(m_preserveRatio)
|
||||
sz.setWidth(sz.width() - contentsMargins().left() - contentsMargins().right());
|
||||
|
||||
return sz;
|
||||
}
|
||||
|
||||
QSize RDLabel::minimumSizeHint() const
|
||||
{
|
||||
QSize sz = QLabel::minimumSizeHint();
|
||||
|
||||
if(m_preserveRatio)
|
||||
sz.setWidth(sz.width() - contentsMargins().left() - contentsMargins().right());
|
||||
|
||||
return sz;
|
||||
}
|
||||
|
||||
void RDLabel::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
emit(clicked(event));
|
||||
|
||||
@@ -33,6 +33,9 @@ public:
|
||||
explicit RDLabel(QWidget *parent = 0);
|
||||
~RDLabel();
|
||||
|
||||
QSize sizeHint() const override;
|
||||
QSize minimumSizeHint() const override;
|
||||
|
||||
void setPreserveAspectRatio(bool preserve) { m_preserveRatio = preserve; }
|
||||
bool preserveAspectRatio() { return m_preserveRatio; }
|
||||
signals:
|
||||
|
||||
Reference in New Issue
Block a user