Define and use a common set of content margin sizes

This commit is contained in:
Magne Sjaastad 2023-10-31 09:21:54 +01:00
parent 9fc380dd5f
commit 43c5705c8b
5 changed files with 35 additions and 3 deletions

View File

@ -24,6 +24,8 @@
#include "DockWidget.h"
#include "cafStyleSheetTools.h"
#include <QMenu>
#include <QPlainTextEdit>
#include <QThread>
@ -42,7 +44,7 @@ RiuMessagePanel::RiuMessagePanel( QWidget* parent )
: QWidget( parent )
{
QVBoxLayout* layout = new QVBoxLayout( this );
layout->setMargin( 0 );
layout->setMargin( caf::StyleSheetTools::smallContentMargin() );
m_textEdit = new QPlainTextEdit;
m_textEdit->setReadOnly( true );

View File

@ -38,6 +38,7 @@
#include "cafPdmObject.h"
#include "cafPdmUiDefaultObjectEditor.h"
#include "cafStyleSheetTools.h"
#include <QEvent>
#include <QHBoxLayout>
@ -96,7 +97,10 @@ PdmUiPropertyView::PdmUiPropertyView( QWidget* parent, Qt::WindowFlags f )
m_scrollArea->setWidget( m_placeholder );
m_placeHolderLayout = new QVBoxLayout();
m_placeHolderLayout->setContentsMargins( 5, 5, 5, 0 );
m_placeHolderLayout->setContentsMargins( caf::StyleSheetTools::mediumContentMargin(),
caf::StyleSheetTools::mediumContentMargin(),
caf::StyleSheetTools::mediumContentMargin(),
0 );
m_placeholder->setLayout( m_placeHolderLayout );
QVBoxLayout* dummy = new QVBoxLayout( this );

View File

@ -42,6 +42,7 @@
#include "cafPdmUiTreeOrdering.h"
#include "cafPdmUiTreeViewEditor.h"
#include "cafQTreeViewStateSerializer.h"
#include "cafStyleSheetTools.h"
#include <QHBoxLayout>
#include <QLineEdit>
@ -59,7 +60,12 @@ PdmUiTreeView::PdmUiTreeView( QWidget* parent, Qt::WindowFlags f )
: QWidget( parent, f )
{
m_layout = new QVBoxLayout();
m_layout->setContentsMargins( 0, 0, 0, 0 );
// 0 as content margin has been used for a long time, but that is too little
m_layout->setContentsMargins( caf::StyleSheetTools::mediumContentMargin(),
caf::StyleSheetTools::mediumContentMargin(),
caf::StyleSheetTools::mediumContentMargin(),
caf::StyleSheetTools::mediumContentMargin() );
setLayout( m_layout );

View File

@ -70,3 +70,19 @@ QString StyleSheetTools::colorStringWithAlpha( const QColor& color )
{
return QString( "rgba(%1, %2, %3, %4)" ).arg( color.red() ).arg( color.green() ).arg( color.blue() ).arg( color.alpha() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int StyleSheetTools::smallContentMargin()
{
return 3;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int StyleSheetTools::mediumContentMargin()
{
return 6;
}

View File

@ -50,6 +50,10 @@ public:
const QColor& backgroundColor,
const QColor& backgroundFrameColor );
static QString colorStringWithAlpha( const QColor& color );
// Default content margin on most platforms is 11 pixels
static int smallContentMargin();
static int mediumContentMargin();
};
} // namespace caf