16-10-2007 12:50:35

The Sheet::setDefaultFont method seems to be not working anymore. From what I see in the soruce, the following is happening:

The parent-widget create method is called and executes the following code:

Label* newLabel = new Label(name,Size(35,15),"qgui.label.png",mGUIManager);

he Label constructor creates a Text object:

mText = new Text(mInstanceName+".Text",mQuadContainer,this);

And the Text object constructor does this:

if(owner->getParentSheet() == NULL)
Ogre::FontManager* fm = Ogre::FontManager::getSingletonPtr();
mColor = Ogre::ColourValue::White;
mColor = owner->getParentSheet()->getDefaultTextColor();

But the Label is becoming a child of the sheet only, after the Label constructor has finished. Therefore in the Text constructor this

owner->getParentSheet() == NULL

is allways true and the default font is never used.


16-10-2007 17:19:17

You're right. With recent changes it will always use the default font. I will update this code to maintain font correctly.

The parent-widget create method should set the Widget's font. I would add this to the "addChild" function, but this will interfere in scenarios where you set a widget's font, remove from one parent, and add to another. So functions that create child widgets are the most appropriate to set the font. Will add this tonight, thanks for bringing this up. (That's a few less computations on widget creation :) )


17-10-2007 09:03:32

Looks like you have removed Sheet::setDefaultFont. How I am supposed to select the default font now?


17-10-2007 17:13:19

setFont. When widgets are created they will use their parents font.


17-10-2007 17:32:38

I do feel bad that I changed the name on you, I hope this is the last changes to existing functions.. (wishful thinking?)

The reason I changed it is because the behavior of "Default Font" applies to all Widgets. A Sheet can create widget X, and widget X will have its font set to the sheet's font on creation. But also, a List can create widget Y, and widget Y will also have it's font set on creation. So for consistency, I removed setDefaultFont in favor of the existing setFont. It should be somewhat intuitive that child widgets (on creation) use the same font as their parent. Otherwise every widget that can create other widgets would need the "setDefaultFont" function.

Is this acceptible?


18-10-2007 09:39:26

Sounds reasonable.