Hi,
If using niftygui batch rendering in android some controls (like buttons and dropdowns) are not rendered correctly. Their background images are not show at all as shown in the following screenshot:
BtnTest is supposed to be a button, the “Pre-scroll” is a label and then there should be a dropdown control. If creating the nifty display as previous default:
niftyDisplay = new NiftyJmeDisplay(
assetManager,
inputManager,
audioRenderer,
guiViewPort);
The controls are properly rendered:
I noticed that some images in nifty default style were not RGBA like most of them:
$ find . | grep png | xargs file | grep -v RGBA
./button/button.png: PNG image data, 100 x 69, 8-bit/color RGB, non-interlaced
./imageselect/background-focus.png: PNG image data, 23 x 80, 8-bit/color RGB, non-interlaced
./imageselect/background-hover.png: PNG image data, 23 x 80, 8-bit/color RGB, non-interlaced
./imageselect/background.png: PNG image data, 23 x 80, 8-bit/color RGB, non-interlaced
./tabs/tab-background-border.png: PNG image data, 3 x 3, 8-bit gray+alpha, non-interlaced
./tabs/tabs.png: PNG image data, 93 x 23, 8-bit colormap, non-interlaced
In fact, all those were failing rendering in my tests, so I converted them all to RGBA inside my project and created a new style file to overwrite them as follows:
<?xml version="1.0" encoding="UTF-8"?>
<nifty-styles xmlns="http://nifty-gui.lessvoid.com/nifty-gui">
<!-- +++++++++++++++++++++++++++++++++++++ -->
<!-- style for the button background panel -->
<!-- +++++++++++++++++++++++++++++++++++++ -->
<style id="nifty-button#panel">
<attributes backgroundImage="nifty-override/button.png" imageMode="sprite-resize:100,23,0,2,96,2,2,2,96,2,19,2,96,2,2"
paddingLeft="7px" paddingRight="7px" width="120px" height="28px" childLayout="center"
visibleToMouse="true"/>
<effect>
<onHover name="border" color="#822f" post="true"/>
<onFocus name="imageOverlay" filename="nifty-override/button.png"
imageMode="sprite-resize:100,23,1,2,96,2,2,2,96,2,19,2,96,2,2" post="true"/>
<onEnabled name="renderQuad" startColor="#2228" endColor="#2220" post="true" length="150"/>
<onDisabled name="renderQuad" startColor="#2220" endColor="#2228" post="true" length="150"/>
</effect>
</style>
<!-- +++++++++++++++++++++++++++++++++++++ -->
<!-- style for the button text -->
<!-- +++++++++++++++++++++++++++++++++++++ -->
<style id="nifty-button#text" base="button-font">
<attributes align="center" valign="center" textHAlign="center" textVAlign="center" visibleToMouse="false"/>
<effect>
<onEnabled name="textColorAnimated" startColor="#8886" endColor="#eeef" post="false" length="150"/>
<onDisabled name="textColorAnimated" startColor="#eeef" endColor="#8886" post="false" length="150"/>
</effect>
</style>
<style id="nifty-image-select#back-button">
<attributes backgroundImage="nifty-override/background.png" imageMode="resize:2,19,2,2,2,19,2,76,2,19,2,2"
width="23px" height="100%" childLayout="center"/>
<interact onClick="backClick()"/>
<effect>
<onClick name="focus" targetElement="#parent"/>
<onFocus name="imageOverlay" filename="nifty-override/background-focus.png"
imageMode="resize:2,19,2,2,2,19,2,76,2,19,2,2" post="true"/>
</effect>
</style>
<style id="nifty-image-select#forward-button">
<attributes backgroundImage="nifty-override/background.png" imageMode="resize:2,19,2,2,2,19,2,76,2,19,2,2"
width="23px" height="100%" childLayout="center"/>
<interact onClick="forwardClick()"/>
<effect>
<onClick name="focus" targetElement="#parent"/>
<onFocus name="imageOverlay" filename="nifty-override/background-focus.png"
imageMode="resize:2,19,2,2,2,19,2,76,2,19,2,2" post="true"/>
</effect>
</style>
<!-- This style is applied to the panel that holds the button -->
<style id="nifty-tabs#tab-button-panel">
<attributes width="100%" backgroundImage="nifty-override/tab-background-border.png"
imageMode="resize:0,3,0,0,0,3,0,2,0,3,0,1"/>
</style>
<style id="nifty-tab-button">
<attributes backgroundImage="nifty-override/tabs.png"
imageMode="sprite-resize:31,23,2,15,1,15,11,15,1,15,1,15,1,15,11" paddingLeft="11px"
paddingRight="11px" width="100px" height="23px" childLayout="center" visibleToMouse="true"/>
<effect>
<onHover name="imageOverlay" filename="nifty-override/tabs.png"
imageMode="sprite-resize:31,23,1,15,1,15,11,15,1,15,1,15,1,15,11" post="true"/>
</effect>
</style>
<!-- The style of a tab button that is the activated one. -->
<style id="nifty-tab-button-active">
<attributes backgroundImage="nifty-override/tabs.png"
imageMode="sprite-resize:31,23,0,15,1,15,11,15,1,15,1,15,1,15,11" paddingLeft="11px"
paddingRight="11px" width="100px" height="23px" childLayout="center" visibleToMouse="true"/>
<effect>
<!-- weiss noch net :)
<onHover name="imageOverlay" filename="nifty-override/tabs.png"
imageMode="sprite-resize:31,23,0,15,1,15,11,15,1,15,1,15,1,15,11" post="true"/>
-->
</effect>
</style>
</nifty-styles>
And in my nifty xml file I included it just after the default styles:
<useStyles filename="nifty-default-styles.xml" />
<useStyles filename="nifty-style-override.xml" />
<useControls filename="nifty-default-controls.xml" />
So all controls are fixed except the dropdown that keeps failing and I don’t understand why
Side note… desktop renders properly always even using batched mode
Any ideas?
Thanks