Skin State Problem

Highway

26-06-2008 14:05:44

I have noticed a problem when using a static image with sub-tiles. When the static image or its parent widget gets disabled and then re-enabled, the settings are messed up. Then it just shows the complete image.
I have already tried to setting up all the states in the skin, but i had no luck to fix it like that.

A similar behaivor apears when making a skin that uses several Subskins with states ("normal","disable","active"). When just on of the subskins has one state , instead of the same like the other subskins.

for example:

<!-- BACKGROUND WIDGET -->
<BasisSkin type="SubSkin" offset = "1 9 -3 -13" align = "ALIGN_STRETCH" >
<State name="normal" offset = "315 7 1 1"/>
</BasisSkin>

<!-- TOP LEFT CORNER -->
<BasisSkin type="SubSkin" offset = "0 9 11 11" align = "ALIGN_LEFT ALIGN_TOP">
<State name="active" offset = "325 2 11 11"/>
<State name="normal" offset = "325 2 11 11"/>
<State name="select" offset = "325 25 11 11"/>
<State name="pressed" offset = "325 25 11 11"/>
<State name="disable" offset = "325 2 11 11"/>
</BasisSkin>


I think it would be really helpfull to make it possible to use the "normal" state as a default when states are set or the BaseSkin. That would reduce useless copy&paste overhead ;)

Highway

26-06-2008 18:20:31

Ok I just resolved both issues described above, here are the Changes: ;)

Widget.cpp
(Added a check for empty FloatSize)

void Widget::setState(const Ogre::String & _state)
{
MapWidgetStateInfo::const_iterator iter = mStateInfo.find(_state);
if (iter == mStateInfo.end()) return;

size_t index=0;
// ñíà÷àëà ñäâèãàåì òåêñòóðû
for (VectorCroppedRectanglePtr::iterator skin = mSubSkinChild.begin(); skin != mSubSkinChild.end(); ++skin) {
CroppedRectanglePtr & info = (*skin);

const FloatRect uvOffset = iter->second.offsets[ index++ ];

if (false == info->_isText() && ! uvOffset.empty() ){
info->_setUVSet( uvOffset );
}
//else info->_correctView();//???
}
// òåïåðü åñëè íóæíî öâåò òåêñòà
if ((iter->second.colour != Ogre::ColourValue::ZERO) && (mText != null)) {
mText->setColour(iter->second.colour);
}
}


WidgetSkinInfo.h
(Changed initial base value to FloatSize(0,0,0,0) )

inline void checkBasis()
{
// è óâåëè÷èâàåì ðàçìåð ñìåùåíèé ïî êîëëè÷åñòâó ñàáâèäæåòîâ
for (MapWidgetStateInfo::iterator iter = mStates.begin(); iter!=mStates.end(); ++iter) {
while (iter->second.offsets.size() < mBasis.size()) {
iter->second.offsets.push_back(FloatRect(0, 0, 0, 0));
};
}
}



my.name

27-06-2008 10:30:14

Here this correct decision:


<!-- BACKGROUND WIDGET -->
<BasisSkin type="SubSkin" offset = "1 9 -3 -13" align = "ALIGN_STRETCH" >
<State name="active" offset = "315 7 1 1"/>
<State name="normal" offset = "315 7 1 1"/>
<State name="select" offset = "315 7 1 1"/>
<State name="pressed" offset = "315 7 1 1"/>
<State name="disable" offset = "315 7 1 1"/>
</BasisSkin>

<!-- TOP LEFT CORNER -->
<BasisSkin type="SubSkin" offset = "0 9 11 11" align = "ALIGN_LEFT ALIGN_TOP">
<State name="active" offset = "325 2 11 11"/>
<State name="normal" offset = "325 2 11 11"/>
<State name="select" offset = "325 25 11 11"/>
<State name="pressed" offset = "325 25 11 11"/>
<State name="disable" offset = "325 2 11 11"/>
</BasisSkin>



1. We should specify the intentions obviously.
2. FloatRect(0, 0, 0, 0) - It can be used for empty values.
3. If we do not specify states all of them are equally created

my.name

27-06-2008 10:34:43

And still, if you use a StaticImage, enough two states:


<!-- BACKGROUND WIDGET -->
<BasisSkin type="SubSkin" offset = "1 9 -3 -13" align = "ALIGN_STRETCH" >
<State name="disable" offset = "315 7 1 1"/>
<State name="normal" offset = "315 7 1 1"/>
</BasisSkin>

<!-- TOP LEFT CORNER -->
<BasisSkin type="SubSkin" offset = "0 9 11 11" align = "ALIGN_LEFT ALIGN_TOP">
<State name="disable" offset = "325 2 11 11"/>
<State name="normal" offset = "325 2 11 11"/>
</BasisSkin>