Skip to content

Commit

Permalink
Fix qtcoinrave textSize implementation to target message nodes, add b…
Browse files Browse the repository at this point in the history
…reakpoints for textSize and message translations
  • Loading branch information
Jonathan committed Mar 14, 2024
1 parent 7d0efe1 commit 589a704
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions plugins/qtcoinrave/qtcoinviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void QtCoinViewer::_InitConstructor(std::istream& sinput)
SoSeparator* pmsgsep = new SoSeparator();

_messagefont = new SoFont();
_messagefont->size = 18;
_messagefont->size = 10;
pmsgsep->addChild(_messagefont);

_messageBaseTranslation = new SoTranslation();
Expand Down Expand Up @@ -704,24 +704,27 @@ SbVec3f QtCoinViewer::_GetMessageBaseTranslation()
SbViewportRegion v = _pviewer->getViewportRegion();
float fwratio = 964.0f/v.getWindowSize()[0], fhratio = 688.0f/v.getWindowSize()[1];
float size = _messagefont->size.getValue();
// magic window-size-independent constants that ensure that all preset text sizes
// are roughly vertically aligned by the top of the first line
if (size < 14.0f) {
return SbVec3f(-1.0f+(0.022f*fwratio),1.0f-(0.07f*fhratio),0);
}
if (size < 18.0f) {
return SbVec3f(-1.0f+(0.022f*fwratio),1.0f-(0.098f*fhratio),0);
return SbVec3f(-1.0f+(0.022f*fwratio),1.0f-(0.082f*fhratio),0);
}
if (size < 26.0f) {
return SbVec3f(-1.0f+(0.022f*fwratio),1.0f-(0.126f*fhratio),0);
return SbVec3f(-1.0f+(0.022f*fwratio),1.0f-(0.106f*fhratio),0);
}
return SbVec3f(-1.0f+(0.022f*fwratio),1.0f-(0.182f*fhratio),0);
return SbVec3f(-1.0f+(0.022f*fwratio),1.0f-(0.126f*fhratio),0);
}

SbVec3f QtCoinViewer::_GetMessageShadowTranslation()
{
SbViewportRegion v = _pviewer->getViewportRegion();
float fwratio = 964.0f/v.getWindowSize()[0], fhratio = 688.0f/v.getWindowSize()[1];
float size = _messagefont->size.getValue();

// magic window-size-independent constants that ensure that the message shadow
// sits roughly one pixel above the base message text
if (size < 14.0f) {
return SbVec3f(-0.002f*fwratio,(0.032f*fhratio)*(size/10.0f),0);
}
Expand Down Expand Up @@ -2894,7 +2897,8 @@ void QtCoinViewer::AdvanceFrame(bool bForward)
ss << _userText << endl;
}

// adjust the shadow text
// adjust the text offsets
_messageBaseTranslation->translation.setValue(_GetMessageBaseTranslation());
_messageShadowTranslation->translation.setValue(_GetMessageShadowTranslation());

// search for all new lines
Expand Down

0 comments on commit 589a704

Please sign in to comment.