History: MyGUI use ButtonImage
Source of version: 5 (current)
Copy to clipboard
From the MyGUI Ogre forums, posted by my.name 2010 May 24.%%%Preserved here because dpaste is going to delete the sample code tomorrow (2010 June 22).
{BOX(width="24%",float="right")}{REMARKSBOX(type="comment",title="Note")}''Button_ModeImage'' is optional. If set, the image will change when the button's state changes (mouse hover, pressed, disabled, etc). If not set, the image state does not track button state.{REMARKSBOX}{BOX}
{CODE(caption="Layout Fragment",wrap="1",colors="xml")}<Widget type="Button" skin="ButtonImage" position="10 280 98 18" layer="Back">
<Property key="Button_ImageResource" value="pic_ButtonImage1"/>
<Property key="Button_ModeImage" value="true"/>
</Widget>
{CODE}
These properties are supported by the MyGUI Layout Editor. The value of ''Button_ImageResource'' should match the ''name='' attribute of the ''Resource'' element below. This layout fragment is incomplete. The snippet should be used somewhere within a complete layout.
{CODE(caption="ButtonImage.resource",wrap="1", colors="xml")}<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Resource">
<Resource type="ResourceImageSet" name="pic_ButtonImage1">
<Group name="States" texture="core.png" size="50 50">
<Index name="disabled">
<Frame point="0 203"/>
</Index>
<Index name="normal">
<Frame point="50 203"/>
</Index>
<Index name="highlighted">
<Frame point="100 203"/>
</Index>
<Index name="pushed">
<Frame point="150 203"/>
</Index>
</Group>
</Resource>
</MyGUI>
{CODE}
The resource file is complete and may be used as-is (though pointing at core.png isn't necessarily useful).
The Resource must be explicitly loaded:
{CODE(caption="Resource Load",wrap="1",colors="c++")}MyGUI::ResourceManager::getInstance().load("ButtonImage.resource");{CODE}
This HowTo also applies to ''ButtonImageText'', with the addition that the property ''Widget_Caption'' is supported within the button layout.