First round of caf::FontTools

This commit is contained in:
Gaute Lindkvist
2020-05-09 11:23:58 +02:00
parent 0e70cf809c
commit 2fe4372dc2
86 changed files with 1021 additions and 966 deletions

View File

@@ -55,8 +55,12 @@ RimPlotWindow::RimPlotWindow()
CAF_PDM_InitField( &m_showPlotLegends, "ShowTrackLegends", true, "Show Legends", "", "", "" );
CAF_PDM_InitField( &m_plotLegendsHorizontal, "TrackLegendsHorizontal", true, "Legend Orientation", "", "", "" );
m_plotLegendsHorizontal.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() );
int defaultFontSize = RiaApplication::instance()->preferences()->defaultPlotFontSize();
CAF_PDM_InitField( &m_legendFontSize, "LegendFontSize", std::max( 8, defaultFontSize - 2 ), "Legend Font Size", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_titleFontSize, "TitleFontSize", "Title Font Size", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_legendFontSize, "LegendDeltaFontSize", "Legend Font Size", "", "", "" );
m_titleFontSize = caf::FontTools::RelativeSize::XLarge;
m_legendFontSize = caf::FontTools::RelativeSize::Small;
}
//--------------------------------------------------------------------------------------------------
@@ -81,6 +85,7 @@ RimPlotWindow& RimPlotWindow::operator=( RimPlotWindow&& rhs )
{
m_showPlotLegends = rhs.m_showPlotLegends();
m_plotLegendsHorizontal = rhs.m_plotLegendsHorizontal();
m_titleFontSize = rhs.m_titleFontSize();
m_legendFontSize = rhs.m_legendFontSize();
return *this;
}
@@ -120,17 +125,33 @@ void RimPlotWindow::setLegendsHorizontal( bool horizontal )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimPlotWindow::legendFontSize() const
void RimPlotWindow::updateFonts()
{
return m_legendFontSize;
updateLayout();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotWindow::setLegendFontSize( int fontSize )
int RimPlotWindow::fontSize() const
{
m_legendFontSize = fontSize;
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimPlotWindow::titleFontSize() const
{
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), m_titleFontSize() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimPlotWindow::legendFontSize() const
{
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), m_legendFontSize() );
}
//--------------------------------------------------------------------------------------------------
@@ -207,7 +228,7 @@ void RimPlotWindow::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
{
updateLayout();
}
else if ( changedField == &m_legendFontSize )
else if ( changedField == &m_legendFontSize || changedField == &m_titleFontSize )
{
updateLayout();
}
@@ -222,30 +243,16 @@ QList<caf::PdmOptionItemInfo> RimPlotWindow::calculateValueOptions( const caf::P
bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_legendFontSize )
{
std::vector<int> fontSizes;
fontSizes.push_back( 8 );
fontSizes.push_back( 9 );
fontSizes.push_back( 10 );
fontSizes.push_back( 11 );
fontSizes.push_back( 12 );
fontSizes.push_back( 14 );
fontSizes.push_back( 16 );
fontSizes.push_back( 18 );
fontSizes.push_back( 24 );
for ( int value : fontSizes )
{
QString text = QString( "%1" ).arg( value );
options.push_back( caf::PdmOptionItemInfo( text, value ) );
}
}
else if ( fieldNeedingOptions == &m_plotLegendsHorizontal )
if ( fieldNeedingOptions == &m_plotLegendsHorizontal )
{
options.push_back( caf::PdmOptionItemInfo( "Vertical", QVariant::fromValue( false ) ) );
options.push_back( caf::PdmOptionItemInfo( "Horizontal", QVariant::fromValue( true ) ) );
}
else if ( fieldNeedingOptions == &m_titleFontSize || fieldNeedingOptions == &m_legendFontSize )
{
options = caf::FontTools::relativeSizeValueOptions( RiaPreferences::current()->defaultPlotFontSize() );
}
return options;
}
@@ -256,6 +263,7 @@ void RimPlotWindow::uiOrderingForPlotLayout( QString uiConfigName, caf::PdmUiOrd
{
uiOrdering.add( &m_showPlotLegends );
uiOrdering.add( &m_plotLegendsHorizontal );
uiOrdering.add( &m_titleFontSize );
uiOrdering.add( &m_legendFontSize );
}