Skip to content

Commit

Permalink
Define and use a common set of content margin sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Nov 1, 2023
1 parent 9fc380d commit 43c5705
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
4 changes: 3 additions & 1 deletion ApplicationLibCode/UserInterface/RiuMessagePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#include "DockWidget.h"

#include "cafStyleSheetTools.h"

#include <QMenu>
#include <QPlainTextEdit>
#include <QThread>
Expand All @@ -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 );
Expand Down
6 changes: 5 additions & 1 deletion Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

#include "cafPdmObject.h"
#include "cafPdmUiDefaultObjectEditor.h"
#include "cafStyleSheetTools.h"

#include <QEvent>
#include <QHBoxLayout>
Expand Down Expand Up @@ -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 );
Expand Down
8 changes: 7 additions & 1 deletion Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "cafPdmUiTreeOrdering.h"
#include "cafPdmUiTreeViewEditor.h"
#include "cafQTreeViewStateSerializer.h"
#include "cafStyleSheetTools.h"

#include <QHBoxLayout>
#include <QLineEdit>
Expand All @@ -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 );

Expand Down
16 changes: 16 additions & 0 deletions Fwk/AppFwk/cafUserInterface/cafStyleSheetTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 4 additions & 0 deletions Fwk/AppFwk/cafUserInterface/cafStyleSheetTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class StyleSheetTools
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

0 comments on commit 43c5705

Please sign in to comment.