From 6f5fa7a3c0374923512420312002f24e69f95f60 Mon Sep 17 00:00:00 2001 From: James Turner Date: Mon, 14 May 2018 12:03:40 +0100 Subject: [PATCH] Tweak to splash authors display appearance Handle long author tags better for 2018.2 (real solution coming in the next version with improved author meta-data) --- src/Viewer/splash.cxx | 17 ++++++++++++----- src/Viewer/splash.hxx | 3 ++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Viewer/splash.cxx b/src/Viewer/splash.cxx index e0438c406..79152af1d 100644 --- a/src/Viewer/splash.cxx +++ b/src/Viewer/splash.cxx @@ -161,12 +161,13 @@ void SplashScreen::createNodes() _items.back().maxLineCount = 1; } - addText(geode, osg::Vec2(0.025, 0.975), 0.03, + addText(geode, osg::Vec2(0.025, 0.940), 0.03, fgGetString("/sim/author"), - osgText::Text::LEFT_BOTTOM, + osgText::Text::LEFT_TOP, nullptr, 0.6); - _items.back().maxLineCount = 1; + _items.back().maxLineCount = 3; + _items.back().maxHeightFraction = 0.055; } addText(geode, osg::Vec2(0.975, 0.935), 0.03, @@ -371,13 +372,19 @@ void SplashScreen::TextItem::reposition(int width, int height) const void SplashScreen::TextItem::recomputeSize(int height) const { - if (maxLineCount == 0) { + if ((maxLineCount == 0) && (maxHeightFraction < 0.0)) { return; } + double heightFraction = maxHeightFraction; + if (heightFraction < 0.0) { + heightFraction = 9999.0; + } + double baseSize = fractionalCharSize; textNode->update(); - while (textNode->getLineCount() > maxLineCount) { + while ((textNode->getLineCount() > maxLineCount) || + (baseSize * textNode->getLineCount() > heightFraction)) { baseSize *= 0.8; // 20% shrink each time textNode->setCharacterSize(baseSize * height); textNode->update(); diff --git a/src/Viewer/splash.hxx b/src/Viewer/splash.hxx index 7108c85e5..293c7bf67 100644 --- a/src/Viewer/splash.hxx +++ b/src/Viewer/splash.hxx @@ -93,7 +93,8 @@ private: double fractionalCharSize; double maxWidthFraction = -1.0; unsigned int maxLineCount = 0; - + double maxHeightFraction = -1.0; + void recomputeSize(int height) const; void reposition(int width, int height) const; };