Nifty and scrollPanel

Hello all,

I’ve got a problem with the scrollPanel with Nifty.

I show you my code :
First, i create the popup which will contain the scrollPanel :
[java]
public void createTempScreen(Nifty nifty) {
final CommonBuilders builders = new CommonBuilders();
new PopupBuilder(“scrollPanelPopup”) {{
childLayoutCenter();
}}.registerPopup(nifty);
}
[/java]
Very simple, i juste create the poup and register it. I call this method in my simpleInitApp() of course.
After, in my screen controller, i have an other method to create the scrollpanel and the panel which will contain text.

[java]
public void showScrollPanel() {
ScrollPanelBuilder scrollBuilder = new ScrollPanelBuilder(“scrollpaneBuilderX2”);
scrollBuilder.width(“500px”);
scrollBuilder.height(“500px”);
Element scrollPanelElement = scrollBuilder.build(nifty, screen, tempScrollPanelPopUp);
Element childRoot2 = scrollPanelElement.findElementByName("#nifty-scrollpanel-child-root");
createPanel( nifty, screen, childRoot2);
childRoot2.layoutElements();
scrollPanelElement.getNiftyControl(ScrollPanel.class).setUp( 0, 20, 0, 20*10, AutoScroll.OFF );
nifty.showPopup(screen, tempScrollPanelPopUp.getId(), tempScrollPanelPopUp);
}
[/java]

And the createPanel method :
[java]
private Element createPanel( Nifty nifty, Screen screen, Element parent){
PanelBuilder panelBuilder = new PanelBuilder();
panelBuilder.x( “0px” );
panelBuilder.y( “0px” );
panelBuilder.width( 1500 + “px” );
panelBuilder.height( 1500 + “px” );
panelBuilder.alignLeft();
panelBuilder.valignTop();
panelBuilder.set( “childLayout”, “vertical” );

	EffectBuilder effectBuilder = new EffectBuilder("gradient");
	effectBuilder.effectValue("offset", "0%", "color", "#747474");
	effectBuilder.effectValue("offset", "75%", "color", "#3B3B3B");
	effectBuilder.effectValue("offset", "100%", "color", "#3C3C3C");
	panelBuilder.onActiveEffect(effectBuilder);
	
	Element panel = panelBuilder.build( nifty, screen, parent );
	
	for (int i=0; i < 10; i++) {
	TextBuilder textBuilder = new TextBuilder();
	textBuilder.text("TEST TEXT BUILDER " + i);
	textBuilder.width( 500 + "px" );
	textBuilder.height( 50 + "px" );
	textBuilder.font("Interface/Fonts/Default.fnt" );
	textBuilder.textHAlignLeft();
	textBuilder.build(nifty, screen, panel);
	
	DropDownBuilder ddbuilder = new DropDownBuilder("");
	ddbuilder.width("300px");
	ddbuilder.height("50px");
	ddbuilder.alignLeft();
	ddbuilder.build(nifty, screen, panel);
	}
	return panel;
}

[/java]

Here is the result and my problem :

The text font is different from the default (isnt’t it?) and dropdown does not appear …

if someone can help me or have any suggestions please ?

Thank you in advance.

Hi again,

I’ve tried to add my scrollpanel in a panel but the result is same …

I don’t understand what’s happend … If i don’t make a scrollPanel but a simple panel, there is no problem with the text font and dropdown …

Nobody can help me or has any suggestions?

Have you made any changes to the nifty styles? I think there are two separate issues here. It looks like the transparency of the fonts is off which is why you are getting that black outline. Your gradient also appears to be overlayed on top of your text but I don’t think that’s causing the issue. I was able to reproduce the black drop down control problem. My guess is that adding a drop down control to a scroll panel just doesn’t work right now. It probably has something to do with how the scroll panel clips its children but you will probably need to dig into exactly what nifty is doing in order to figure out what is going on for sure.

First, thank you glh3586 for your answer.

i’ve not changed the nifty style, no. However, i noticed something interesting : when i just put the nifty-label style for labels, they don’t appear …

Here is my code now :
[java]
PanelBuilder panelBuilder = new PanelBuilder(“mainPanelForScrolling”){{ width(“500px”); height(“500px”); childLayoutCenter();}};
Element mainPanel = panelBuilder.build(nifty, screen, panelPopup);

	ScrollPanelBuilder scrollBuilder = new ScrollPanelBuilder("scrollpaneBuilderX2") {{ width("100%"); height("100%");}};
	scrollBuilder.set("horizontal", "false");
	scrollBuilder.set("vertical", "true");

	Element scrollPanelElement = scrollBuilder.build(nifty, screen, mainPanel);
	Element scrollPanelContainer = scrollPanelElement.findElementByName("#nifty-scrollpanel-child-root");
	
	createPanel(nifty, screen, scrollPanelContainer);

	scrollPanelContainer.layoutElements();
	scrollPanelElement.getNiftyControl(ScrollPanel.class).setUp( 0, 20, 0, 20*10, AutoScroll.OFF);

	nifty.showPopup(screen, panelPopup.getId(), panelPopup);

[/java]

and the createPanel method :

[java]
public Element createPanel( Nifty nifty, Screen screen, Element parent){

	PanelBuilder panelBuilder = new PanelBuilder();
	panelBuilder.width( 500 + "px" );
	panelBuilder.height( 1500 + "px" );
	panelBuilder.alignLeft();
	panelBuilder.valignTop();
	panelBuilder.childLayoutVertical();

	EffectBuilder effectBuilder = new EffectBuilder("gradient");
	effectBuilder.effectValue("offset", "0%", "color", "#747474");
	effectBuilder.effectValue("offset", "75%", "color", "#3B3B3B");
	effectBuilder.effectValue("offset", "100%", "color", "#3C3C3C");
	panelBuilder.onActiveEffect(effectBuilder);

	Element panel = panelBuilder.build( nifty, screen, parent );

	for (int i=0; i < 10; i++) {
		LabelBuilder lb = new LabelBuilder("Label"+i);
		lb.text("Label"+i);
		lb.style("nifty-label");
		lb.width("300px");
		lb.build(nifty, screen, panel);
	}
	return panel;
}

[/java]

There is nothing in my scrollPanel … so i think you are in the good way when you’re talking about nifty style. But i don’t know how to solve it for now .

If you reproduce my code, you have the same problem ?