Creating new skin - problem

thucanh

10-07-2008 06:26:02

Hello,

Iin my Viewer, I need some "ImageButton" control. After reading the "MyGUI skin creating" in Wiki and looking at LayoutEditor's editor.skin, I created myown skin by:
- create a icons.png image contains all my icons to be used as image on buttons
- create my.skin by copy ButtonMinimize from editor.skin.
- add my.skin to editor.xml so that it'll be loaded in.
- create my.layout using LayoutEditor

But I had some problems as folow:
1. Only the first icon located on the left edge of png image is displayed, other icons was not.

2. When I run in debug mode, I get error related to XML loading at line widgets = LayoutManager::getInstance().load("my.layout");
Error message from output:
HEAP[MyViewer.exe]: Invalid Address specified to RtlValidateHeap( 018B0000, 058FA578 )
Windows has triggered a breakpoint in MyViewer.exe.

This may be due to a corruption of the heap, and indicates a bug in MyViewer.exe or any of the DLLs it has loaded.


I think the skins I was the cause of problem no. 2, but can not figure out what it is.

Here is my.skin:


<?xml version="1.0" encoding="UTF-8"?>

<MyGUI type="Skin">
<Skin name = "Viewer_SpinIcon" size = "34 34" texture = "ToolIcons.png">
<BasisSkin type="MainSkin" offset = "0 0 34 34" align = "ALIGN_STRETCH">
<State name="disable" offset = 0 0 34 34"/>
<State name="active" offset = "0 37 34 34"/>
<State name="select" offset = "0 37 34 34"/>
<State name="normal" offset = "0 0 34 34"/>
<State name="pressed" offset = "0 0 34 34"/>
</BasisSkin>
</Skin>
<Skin name = "Viewer_RotateIcon" size = "34 34" texture = "ToolIcons.png">
<BasisSkin type="MainSkin" offset = "37 0 34 34" align = "ALIGN_STRETCH">
<State name="disable" offset = 37 0 34 34"/>
<State name="active" offset = "37 37 34 34"/>
<State name="select" offset = "37 37 34 34"/>
<State name="normal" offset = "37 0 34 34"/>
<State name="pressed" offset = "37 0 34 34"/>
</BasisSkin>
</Skin>
<Skin name = "Viewer_MoveIcon" size = "34 34" texture = "ToolIcons.png">
<BasisSkin type="MainSkin" offset = "75 0 34 34" align = "ALIGN_STRETCH">
<State name="disable" offset = 75 0 34 34"/>
<State name="active" offset = "75 37 34 34"/>
<State name="select" offset = "75 37 34 34"/>
<State name="normal" offset = "75 0 34 34"/>
<State name="pressed" offset = "75 0 34 34"/>
</BasisSkin>
</Skin>
</MyGUI>


BTW, I have an warning in MyGUI.log about the icon.png size is not power of two, may it be the cause for no. 1? I will try to resize the png file right now to see if it work ...


Another question: How can I highlight a button after user clicked it? I tried to use btn->setButtonPressed(true) and btn->setState("selected") but no effect ...

thucanh

my.name

10-07-2008 10:05:22

>>> btn->setState("selected")
>>> <State name="select" offset = "37 37 34 34"/>

thucanh

10-07-2008 12:04:10

Thank you for your reply.
>>> btn->setState("selected")
>>> <State name="select" offset = "37 37 34 34"/>

Actually it's just my typing mistake. Here is what I copied from my source code:

MyGUI::WidgetManager::getInstance().findWidgetT("viewerIconRotate")->setState("select");

But when mouse move out the widget, it still returns to "normal" state. Any other suggestions?

Update: I switched to "btn->setButtonPressed(true/false); and it worked!

How about the "only first icon shows up" problem? :(

Altren

10-07-2008 12:15:28

There's two solutions:
First is to use btn->setButtonPressed(true) and make image of pressed button same as "select".
Second is to handle eventMouseMove and set correct state when this event occurs.

Altren

10-07-2008 12:20:56

How about the "only first icon shows up" problem? :(<BasisSkin type="MainSkin" offset = "37 0 34 34" align = "ALIGN_STRETCH"> This lines is wrong - offset here is offset in widget, so it should be<BasisSkin type="MainSkin" offset = "0 0 34 34" align = "ALIGN_STRETCH"> for all skins.

thucanh

10-07-2008 13:19:23

Thank you so much!

It works now.

I will inspect debug problem tomorrow. It's time to go home now!! :)

thucanh