Page 1 of 1

Cannot display TextArea in single Panel

PostPosted: Wed Jul 21, 2010 6:27 am
by omniter
Hi guys,

I just found what appears to be a bug in the overlay system. It seems that when I have an overlay with one container in it, any TextArea elements inside of that container will not show. I have to add another container before it in the same overlay, containing another TextArea using the same font, so that the original one will show text. It sounds very strange, but I've tested it with a bunch of different fonts, materials, using templates / not using templates, etc. I am using the latest MogreSDK (which uses OGRE 1.7.1 revision 72), so I'm not sure if it's a Mogre-specific problem. Could someone else confirm / disconfirm this? Thanks!

Re: Cannot display TextArea in single Panel

PostPosted: Wed Jul 21, 2010 4:40 pm
by jacmoe
I get the same error.
I think you can see it in the terrain sample as well.
Seems to be a refresh related issue, because it shows when the overlay is redrawn.
I think.. :)

Re: Cannot display TextArea in single Panel

PostPosted: Wed Jul 21, 2010 6:11 pm
by omniter
Seems the problem was introduced in v1.7 then. :?

Re: Cannot display TextArea in single Panel

PostPosted: Mon Aug 02, 2010 2:30 pm
by omniter
Hey guys,

I found a couple of other guys with similar problems. I didn't see the connection before, but it definitely seems like there is one now. Take a look at this thread.

Re: Cannot display TextArea in single Panel

PostPosted: Tue Aug 10, 2010 2:14 pm
by MikkelBrun
Seems like updateTextureGeometry isn't called properly at initialization.

I've been struggeling with this for quite a while, but thought it was a problem I caused myself..

Doing this, however.. does the trick:
Code: Select all
    bool first = true;

    while(mRunning)
    {
        //Pump messages in all registered RenderWindow windows
        Ogre::WindowEventUtilities::messagePump();
        mRoot->renderOneFrame(); // Ignore whatever the frame listeners return basically.

        if(first)
        {
            first = false;

            // Simple hack to make sure all text area overlay elements are shown correctly..

            Ogre::OverlayManager& om = Ogre::OverlayManager::getSingleton();

            Ogre::OverlayManager::OverlayMapIterator omi = om.getOverlayIterator();
            while(omi.hasMoreElements())
            {
                Ogre::Overlay* overlay = omi.getNext();
                Ogre::Overlay::Overlay2DElementsIterator o2dei = overlay->get2DElementsIterator();
                while(o2dei.hasMoreElements())
                {
                    Ogre::OverlayElement* oe = o2dei.getNext();
                    oe->setCaption(oe->getCaption());
                }

            }
        }
    }


It's obviously not ment to be done this way though.

Re: Cannot display TextArea in single Panel

PostPosted: Wed Aug 18, 2010 1:06 pm
by TaeHyungKim
i replied for this problem earlier another thread..
I think this is bug in OverlayElement::_update(void) function,
mPixelWidth is changed at line (1) , but mWidth is changed at line (2)
but at line (3) mGeomPositionsOutOfDate is setting to false, so when next _update fuction called, line (2) is not excuted because (4) is false
mWidth is not changed at this time, so textarea is not displayed

Code: Select all
-> OgreOverlayElement.cpp 

    void OverlayElement::_update(void)
    {
        // Check size if pixel-based
        switch (mMetricsMode)
        {
        case GMM_PIXELS :
            if (OverlayManager::getSingleton().hasViewportChanged() || mGeomPositionsOutOfDate)  // (4)
            {
                Real vpWidth, vpHeight;
                OverlayManager& oMgr = OverlayManager::getSingleton();
                vpWidth = (Real) (oMgr.getViewportWidth());
                vpHeight = (Real) (oMgr.getViewportHeight());

                mPixelScaleX = 1.0f / vpWidth;
                mPixelScaleY = 1.0f / vpHeight;

                mLeft = mPixelLeft * mPixelScaleX;
                mTop = mPixelTop * mPixelScaleY;
                mWidth = mPixelWidth * mPixelScaleX;                                                 // (2)
                mHeight = mPixelHeight * mPixelScaleY;
            }
            break;

        case GMM_RELATIVE_ASPECT_ADJUSTED :
            if (OverlayManager::getSingleton().hasViewportChanged() || mGeomPositionsOutOfDate)
            {
                Real vpWidth, vpHeight;
                OverlayManager& oMgr = OverlayManager::getSingleton();
                vpWidth = (Real) (oMgr.getViewportWidth());
                vpHeight = (Real) (oMgr.getViewportHeight());

                mPixelScaleX = 1.0f / (10000.0f * (vpWidth / vpHeight));
                mPixelScaleY = 1.0f /  10000.0f;

                mLeft = mPixelLeft * mPixelScaleX;
                mTop = mPixelTop * mPixelScaleY;
                mWidth = mPixelWidth * mPixelScaleX;
                mHeight = mPixelHeight * mPixelScaleY;
            }
            break;
        default:
            break;
        }

        _updateFromParent();
        // NB container subclasses will update children too

        // Tell self to update own position geometry
        if (mGeomPositionsOutOfDate && mInitialised)
        {
            updatePositionGeometry();                                                       // (1)
            mGeomPositionsOutOfDate = false;                                           // (3)
        }
        // Tell self to update own texture geometry
       if (mGeomUVsOutOfDate && mInitialised)
       {
   updateTextureGeometry();
   mGeomUVsOutOfDate = false;
       }
}

Re: Cannot display TextArea in single Panel

PostPosted: Wed Aug 18, 2010 11:23 pm
by omniter
So does that mean the problem doesn't occur for relative metrics mode?

Re: Cannot display TextArea in single Panel

PostPosted: Thu Aug 19, 2010 7:31 pm
by TaeHyungKim
i don't know what is relative metircs mode..
i just initialize buttons like this

m_pTrayMgr = new OgreBites::MySDKTrayManager("TrayMgr", m_pRenderWnd, m_pMouse, this);
m_pTrayMgr->showCursor();
m_pTrayMgr->createButton(OgreBites::TL_BOTTOMRIGHT,"_Continue","Continue",140.0f);

caption is not displaying always.

in my update fuction, i called below code at each frame
button->setCaption("Continue");
after this , caption is display well , mWidth value is corrected.

Re: Cannot display TextArea in single Panel

PostPosted: Thu Aug 19, 2010 11:36 pm
by omniter
The SdkTrays system uses pixel metrics mode.
If you are correct, then the fix could be just to put the switch statement between lines (1) and (3).

Re: Cannot display TextArea in single Panel

PostPosted: Thu Dec 02, 2010 8:03 pm
by icaro56
I get the same error!

In my topic: viewtopic.php?f=5&t=61763


This is strange!

Re: Cannot display TextArea in single Panel

PostPosted: Wed Jul 20, 2011 10:51 am
by GemX
Try using this:
Code: Select all
  // load fonts explicitly after resources are loaded (esp. SdkTray.zip) since they will not be loaded on start up from the resource manager
  ResourceManager::ResourceMapIterator iter = Ogre::FontManager::getSingleton().getResourceIterator();
  while (iter.hasMoreElements()) { iter.getNext()->load(); }


Fonts are not loaded correctly in the first run... So add these lines at startup after you loaded your resources (esp. SdkTray.zip)!
I had this problem with sliders, labels, buttons and so forth.

Re: Cannot display TextArea in single Panel

PostPosted: Thu Aug 04, 2011 3:23 pm
by omniter
A couple of fixes have been posted a long time ago:
viewtopic.php?f=2&t=59372&p=403275#p403274

Re: Cannot display TextArea in single Panel

PostPosted: Thu Aug 04, 2011 4:08 pm
by jacmoe
That's not really impressive, as it didn't went into the code base, but it's better than nothing. :)

Re: Cannot display TextArea in single Panel

PostPosted: Tue Oct 25, 2011 5:20 am
by TaeHyungKim
omniter wrote:The SdkTrays system uses pixel metrics mode.
If you are correct, then the fix could be just to put the switch statement between lines (1) and (3).


you're right. i modify that you said "put the switch statement between lines (1) and (3)".

caption is viewed well.
thanks. i hope this fix is reflected in ogre next version.

Re: Cannot display TextArea in single Panel

PostPosted: Mon Dec 19, 2011 8:21 am
by guillaumequest
Hello,
I believe I'm still having this bug, but I'm not using SdkTrays, just overlays directly, and all the fixes use SdkTrays. Do you know if there are some other fixes available ?

Thanks for your help,
Guillaume

Re: Cannot display TextArea in single Panel

PostPosted: Mon Dec 19, 2011 9:52 am
by omniter
guillaumequest wrote:Hello,
I believe I'm still having this bug, but I'm not using SdkTrays, just overlays directly, and all the fixes use SdkTrays. Do you know if there are some other fixes available ?

Thanks for your help,
Guillaume


If you're compiling Ogre, you can look up a few posts for a solution that involves changing OgreOverlayElement.cpp.
Also, from the other threads: "Any operation that will cause the OverlayElement's geom positions to be refreshed will fix this problem."
This includes stuff like changing positions and sizes, and setting the metrics mode.

Re: Cannot display TextArea in single Panel

PostPosted: Mon Dec 19, 2011 10:34 am
by guillaumequest
Thanks,
I copied the code from ObjectTextDisplay and adapted it so that it would display the text at a fixed position and this worked for some reason, I don't really have any idea why that worked better, though...

Re: Cannot display TextArea in single Panel

PostPosted: Mon Feb 11, 2013 12:58 am
by spacegaier
FYI for everyone coming across this issue and this thread: I just fixed the problem in both the 1.8 and 1.9 branch. So if you run into the described situation please update your Ogre version/revision.

Re: Cannot display TextArea in single Panel

PostPosted: Fri Mar 22, 2013 2:19 am
by arcanemartz
Hi,

It seems the patch has broken the ability to update the position of an overlay element with setPosition(...) when element is in relative mode. It seems the switch case in _update() should be similar to the one in _notifyViewport(), i.e. add to the default case:

Code: Select all
        case GMM_RELATIVE :
            mPixelScaleX = 1.0;
            mPixelScaleY = 1.0;
            mPixelLeft = mLeft;
            mPixelTop = mTop;
            mPixelWidth = mWidth;
            mPixelHeight = mHeight;


Here is the complete switch in _update():

Code: Select all
        // Check size if pixel-based or relative-aspect-adjusted
        switch (mMetricsMode)
        {
        case GMM_PIXELS :
            if (OverlayManager::getSingleton().hasViewportChanged() || mGeomPositionsOutOfDate)
            {               
                mPixelScaleX = 1.0f / vpWidth;
                mPixelScaleY = 1.0f / vpHeight;
            }
            break;

        case GMM_RELATIVE_ASPECT_ADJUSTED :
            if (OverlayManager::getSingleton().hasViewportChanged() || mGeomPositionsOutOfDate)
            {
                mPixelScaleX = 1.0f / (10000.0f * (vpWidth / vpHeight));
                mPixelScaleY = 1.0f /  10000.0f;
            }
            break;

        default:
        case GMM_RELATIVE :
            mPixelScaleX = 1.0;
            mPixelScaleY = 1.0;
            mPixelLeft = mLeft;
            mPixelTop = mTop;
            mPixelWidth = mWidth;
            mPixelHeight = mHeight;
            break;
        }


Thanks,
Martin