mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4256 Update fonts in Project and views when changing preferences
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "RimAnnotationCollection.h"
|
||||
#include "RimAnnotationGroupCollection.h"
|
||||
#include "RimAnnotationTextAppearance.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimGridView.h"
|
||||
@@ -234,6 +235,46 @@ size_t RimAnnotationInViewCollection::annotationsCount() const
|
||||
return m_textAnnotations->m_annotations.size() + allGlobalPdmAnnotations().size();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimAnnotationInViewCollection::hasTextAnnotationsWithCustomFontSize(RiaFontCache::FontSize defaultFontSize) const
|
||||
{
|
||||
for (auto annotation : textAnnotations())
|
||||
{
|
||||
if (annotation->appearance()->fontSize() != defaultFontSize)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto annotationInView : globalTextAnnotations())
|
||||
{
|
||||
if (annotationInView->sourceAnnotation()->appearance()->fontSize() != defaultFontSize)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAnnotationInViewCollection::applyFontSizeToAllTextAnnotations(RiaFontCache::FontSize fontSize)
|
||||
{
|
||||
for (auto annotation : textAnnotations())
|
||||
{
|
||||
annotation->appearance()->setFontSize(fontSize);
|
||||
}
|
||||
|
||||
for (auto annotationInView : globalTextAnnotations())
|
||||
{
|
||||
annotationInView->sourceAnnotation()->appearance()->setFontSize(fontSize);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RiaFontCache.h"
|
||||
#include "RimAnnotationCollectionBase.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
@@ -59,6 +60,9 @@ public:
|
||||
void onGlobalCollectionChanged(const RimAnnotationCollection* globalCollection);
|
||||
size_t annotationsCount() const;
|
||||
|
||||
bool hasTextAnnotationsWithCustomFontSize(RiaFontCache::FontSize defaultFontSize) const;
|
||||
void applyFontSizeToAllTextAnnotations(RiaFontCache::FontSize fontSize);
|
||||
|
||||
protected:
|
||||
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
||||
@@ -38,7 +38,7 @@ RimAnnotationTextAppearance::RimAnnotationTextAppearance()
|
||||
auto defaultBackgroundColor = prefs->defaultViewerBackgroundColor();
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_fontSize, "FontSize", "Font Size", "", "", "");
|
||||
m_fontSize = prefs->fontSizeInScene();
|
||||
m_fontSize = prefs->defaultAnnotationFontSize();
|
||||
|
||||
CAF_PDM_InitField(&m_fontColor, "FontColor", cvf::Color3f(cvf::Color3f::BLACK), "Font Color", "", "", "");
|
||||
CAF_PDM_InitField(&m_backgroundColor, "BackgroundColor", defaultBackgroundColor , "Background Color", "", "", "");
|
||||
|
||||
Reference in New Issue
Block a user