1
0
Fork 0

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)
This commit is contained in:
James Turner 2018-05-14 12:03:40 +01:00
parent 5fe24f741c
commit 6f5fa7a3c0
2 changed files with 14 additions and 6 deletions

View file

@ -161,12 +161,13 @@ void SplashScreen::createNodes()
_items.back().maxLineCount = 1; _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"), fgGetString("/sim/author"),
osgText::Text::LEFT_BOTTOM, osgText::Text::LEFT_TOP,
nullptr, nullptr,
0.6); 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, 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 void SplashScreen::TextItem::recomputeSize(int height) const
{ {
if (maxLineCount == 0) { if ((maxLineCount == 0) && (maxHeightFraction < 0.0)) {
return; return;
} }
double heightFraction = maxHeightFraction;
if (heightFraction < 0.0) {
heightFraction = 9999.0;
}
double baseSize = fractionalCharSize; double baseSize = fractionalCharSize;
textNode->update(); textNode->update();
while (textNode->getLineCount() > maxLineCount) { while ((textNode->getLineCount() > maxLineCount) ||
(baseSize * textNode->getLineCount() > heightFraction)) {
baseSize *= 0.8; // 20% shrink each time baseSize *= 0.8; // 20% shrink each time
textNode->setCharacterSize(baseSize * height); textNode->setCharacterSize(baseSize * height);
textNode->update(); textNode->update();

View file

@ -93,6 +93,7 @@ private:
double fractionalCharSize; double fractionalCharSize;
double maxWidthFraction = -1.0; double maxWidthFraction = -1.0;
unsigned int maxLineCount = 0; unsigned int maxLineCount = 0;
double maxHeightFraction = -1.0;
void recomputeSize(int height) const; void recomputeSize(int height) const;
void reposition(int width, int height) const; void reposition(int width, int height) const;