diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilterCollection.cpp index 17f4f0832e6..b855a9839d3 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilterCollection.cpp @@ -25,11 +25,8 @@ #include "RiuTextContentFrame.h" #include -#include #include -#include - CAF_PDM_SOURCE_INIT( RimEnsembleCurveFilterCollection, "RimEnsembleCurveFilterCollection" ); //-------------------------------------------------------------------------------------------------- @@ -43,7 +40,6 @@ RimEnsembleCurveFilterCollection::RimEnsembleCurveFilterCollection() CAF_PDM_InitFieldNoDefault( &m_filters, "CurveFilters", "" ); m_filters.uiCapability()->setUiTreeChildrenHidden( true ); - // m_filters.uiCapability()->setUiEditorTypeName(caf::PdmUiTableViewEditor::uiEditorTypeName()); m_filters.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); CAF_PDM_InitFieldNoDefault( &m_newFilterButton, "NewEnsembleFilter", "New Filter" ); @@ -247,7 +243,17 @@ RiuTextContentFrame* RimEnsembleCurveFilterCollection::makeFilterDescriptionFram { QString descriptions = filterDescriptions(); descriptions.replace( "+", "\n+" ); - return new RiuTextContentFrame( nullptr, QString( "Active curve filters:" ), descriptions ); + + // A size of -1 use default plot font + int fontSize = -1; + + auto plotWindow = firstAncestorOrThisOfType(); + if ( plotWindow ) + { + fontSize = plotWindow->legendFontSize(); + } + + return new RiuTextContentFrame( nullptr, QString( "Active curve filters:" ), descriptions, fontSize ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 5cf84dff465..76d5b59f02b 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -1756,7 +1756,7 @@ void RimEnsembleCurveSet::updateObjectiveFunctionLegend() } if ( !title.isEmpty() && !description.isEmpty() ) { - m_objectiveFunctionOverlayFrame->setContentFrame( new RiuTextContentFrame( nullptr, title, description ) ); + m_objectiveFunctionOverlayFrame->setContentFrame( new RiuTextContentFrame( nullptr, title, description, -1 ) ); m_objectiveFunctionOverlayFrame->setMaximumWidth( 10000 ); plot->plotWidget()->addOverlayFrame( m_objectiveFunctionOverlayFrame ); } diff --git a/ApplicationLibCode/UserInterface/RiuTextContentFrame.cpp b/ApplicationLibCode/UserInterface/RiuTextContentFrame.cpp index 3da8e5ab5b6..c32591faf6e 100644 --- a/ApplicationLibCode/UserInterface/RiuTextContentFrame.cpp +++ b/ApplicationLibCode/UserInterface/RiuTextContentFrame.cpp @@ -34,12 +34,15 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuTextContentFrame::RiuTextContentFrame( QWidget* parent, const QString& title, const QString& text ) +RiuTextContentFrame::RiuTextContentFrame( QWidget* parent, const QString& title, const QString& text, int fontPixelSize ) : RiuAbstractOverlayContentFrame( parent ) , m_title( title ) , m_text( text ) + , m_fontPixelSize( fontPixelSize ) { setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ); + + updateFromFontSize(); } //-------------------------------------------------------------------------------------------------- @@ -71,6 +74,7 @@ QSize RiuTextContentFrame::minimumSizeHint() const { LayoutInfo layout( QSize( 200, 100 ) ); // Use default size layoutInfo( &layout ); + QFont titleFont = font(); titleFont.setBold( true ); QFontMetrics fontMetrics( titleFont ); @@ -92,7 +96,7 @@ QSize RiuTextContentFrame::minimumSizeHint() const //-------------------------------------------------------------------------------------------------- void RiuTextContentFrame::renderTo( QPainter* painter, const QRect& targetRect ) { - updateFontSize(); + updateFromFontSize(); QColor textColor = RiuGuiTheme::getColorByVariableName( "textColor" ); @@ -160,3 +164,20 @@ void RiuTextContentFrame::layoutInfo( LayoutInfo* layout ) const layout->margins = QMargins( 8, 8, 8, 8 ); layout->tickTextLeadSpace = 5; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuTextContentFrame::updateFromFontSize() +{ + if ( m_fontPixelSize != -1 ) + { + QFont font = this->font(); + font.setPixelSize( m_fontPixelSize ); + setFont( font ); + } + else + { + updateFontSize(); + } +} diff --git a/ApplicationLibCode/UserInterface/RiuTextContentFrame.h b/ApplicationLibCode/UserInterface/RiuTextContentFrame.h index d5f4d211ac8..6f86ac2414f 100644 --- a/ApplicationLibCode/UserInterface/RiuTextContentFrame.h +++ b/ApplicationLibCode/UserInterface/RiuTextContentFrame.h @@ -22,19 +22,21 @@ #include #include +class QFont; + class RiuTextContentFrame : public RiuAbstractOverlayContentFrame { Q_OBJECT public: - RiuTextContentFrame( QWidget* parent, const QString& title, const QString& text ); + RiuTextContentFrame( QWidget* parent, const QString& title, const QString& text, int fontPixeSize ); QSize sizeHint() const override; QSize minimumSizeHint() const override; void renderTo( QPainter* painter, const QRect& targetRect ) override; -protected: +private: struct LayoutInfo { LayoutInfo( const QSize& size ) @@ -60,7 +62,10 @@ class RiuTextContentFrame : public RiuAbstractOverlayContentFrame private: virtual void layoutInfo( LayoutInfo* layout ) const; -protected: + void updateFromFontSize(); + +private: QString m_title; QString m_text; + int m_fontPixelSize; };