[Feature Request]SubSkin supported button

jsding

15-03-2012 02:24:54

Hi,

Now, i can not create a subskined button. I think this feature will let button widget much more useful.

Thanks.

Altren

15-03-2012 08:22:06

Could you explain what do you call "subskined button"? That's not clear at all. And where this might be used.

jsding

16-03-2012 00:03:03

Could you explain what do you call "subskined button"? That's not clear at all. And where this might be used.

I mean i can define skin for each state for the button
NormalSkin: when state in normal state
HighlightedSkin: when state in highlighted state
PushedSkin: when state in pushed state
etc.

Now, I add following in MyGUI_Button::updateButtonState, and get it worked:

if (mSubSkined) {

if (mStateSelected) {
if (!getEnabled()) {
if (!mDisabledCheckedSkin.empty() &&mCurrentSkin.compare(mDisabledCheckedSkin) !=0) {
mCurrentSkin = mDisabledCheckedSkin;
changeWidgetSkin(mDisabledCheckedSkin);
}
} else if (mIsMousePressed) {
if (!mPushedCheckedSkin.empty() &&mCurrentSkin.compare(mPushedCheckedSkin) != 0) {
mCurrentSkin = mPushedCheckedSkin;
changeWidgetSkin(mPushedCheckedSkin);
}
} else if (mIsMouseFocus) {
if (!mHighlightedCheckedSkin.empty() &&mCurrentSkin.compare(mHighlightedCheckedSkin) != 0) {
mCurrentSkin = mHighlightedCheckedSkin;
changeWidgetSkin(mHighlightedCheckedSkin);
}
} else if (!mNormalCheckedSkin.empty()) {
if (mCurrentSkin.compare(mNormalCheckedSkin) != 0) {
mCurrentSkin = mNormalCheckedSkin;
changeWidgetSkin(mNormalCheckedSkin);
}
}
} else {
if (!getEnabled()) {
if (!mDisabledSkin.empty() &&mCurrentSkin.compare(mDisabledSkin) != 0) {
mCurrentSkin = mDisabledSkin;
changeWidgetSkin(mDisabledSkin);
}
} else if (mIsMousePressed) {
if (!mPushedSkin.empty() &&mCurrentSkin.compare(mPushedSkin) != 0) {
mCurrentSkin = mPushedSkin;
changeWidgetSkin(mPushedSkin);
}
} else if (mIsMouseFocus) {
if (!mHighlightedSkin.empty() &&mCurrentSkin.compare(mHighlightedSkin) != 0) {
mCurrentSkin = mHighlightedSkin;
changeWidgetSkin(mHighlightedSkin);
}
} else if (!mNormalSkin.empty()) {
if (mCurrentSkin.compare(mNormalSkin) != 0) {
mCurrentSkin = mNormalSkin;
changeWidgetSkin(mNormalSkin);
}

}
}
}

My resourcelayout is:

<Resource type="ResourceLayout" name="CommonButton" version="3.2.0">
<Widget type="Button" name="Root" skin="button_normal" position="0 0 50 66" align="Left Top">
<Property key="HighlightedSkin" value="button_normal" />
<Property key="DisabledSkin" value="button_disabled" />
<Property key="PushedSkin" value="button_pushed" />
<Property key="NormalSkin" value="button_normal" />
</Widget>
</Resource>


button_normal , button_disabled like:

<Resource type="ResourceSkin" name="button_normal" size="50 66" texturesize="512 512" texture="tongyongcaidan.png">
<BasisSkin type="SubSkin" offset="0 0 20 66" align="Left VStretch">
<State name="normal" offset="406 0 20 66" />
</BasisSkin>
<BasisSkin type="SubSkin" offset="20 0 10 66" align="Stretch">
<State name="normal" offset="426 0 10 66" />
</BasisSkin>
<BasisSkin type="SubSkin" offset="30 0 20 66" align="Right VStretch">
<State name="normal" offset="436 0 20 66" />
</BasisSkin>
</Resource>