Skip to content

Commit

Permalink
add zero size support to viewer.SetTextSize
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan committed Mar 20, 2024
1 parent 9b1f9c6 commit f7a8847
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions plugins/qtcoinrave/qtcoinviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,11 @@ void QtCoinViewer::_InitConstructor(std::istream& sinput)
_messageNodes[1] = new SoText2();
pmsgsep->addChild(_messageNodes[1]);

_ivRoot->addChild(pmsgsep);
_messageSwitch = new SoSwitch();
_messageSwitch->whichChild.setValue(SO_SWITCH_ALL);
_messageSwitch->addChild(pmsgsep);

_ivRoot->addChild(_messageSwitch);
_ivRoot->addChild(_ivCamera);

SoEventCallback * ecb = new SoEventCallback;
Expand Down Expand Up @@ -675,10 +679,12 @@ void QtCoinViewer::SetTextSize(double size)

void QtCoinViewer::_SetTextSize(double size)
{
if ( size > 0 ) {
if ( size >= 0 ) {
// TODO: use a font that does not rely on hardcoded breakpoints
// move down to next text size breakpoint so that message shadow aligns nicely
_messageFont->size = _GetTextBaseSize(size);
// hide HUD text if requested size is 0
_messageSwitch->whichChild.setValue(size == 0 ? SO_SWITCH_NONE : SO_SWITCH_ALL);
// adjust the text offsets
_messageBaseTranslation->translation.setValue(_GetMessageBaseTranslation());
_messageShadowTranslation->translation.setValue(_GetMessageShadowTranslation());
Expand Down
1 change: 1 addition & 0 deletions plugins/qtcoinrave/qtcoinviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ public slots:
std::list< boost::shared_ptr<IvDragger> > _plistdraggers; /// draggers drawn
SoEventCallback* _eventKeyboardCB;

SoSwitch* _messageSwitch;
SoFont* _messageFont;
boost::array<SoText2*,2> _messageNodes;
SoTranslation* _messageBaseTranslation;
Expand Down
2 changes: 1 addition & 1 deletion plugins/qtosgrave/osgviewerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ void QOSGViewerWidget::SetViewport(int width, int height)

void QOSGViewerWidget::SetHUDTextSize(double size)
{
if ( size > 0 ) {
if ( size >= 0 ) {
_hudTextSize = size;

float scale = this->devicePixelRatio();
Expand Down

0 comments on commit f7a8847

Please sign in to comment.