I started working on a groovy DSL to specify lemur windows.
Result:
Groovy definition:
import com.simsilica.lemur.Axis
import com.simsilica.lemur.FillMode
import com.simsilica.lemur.component.SpringGridLayout
window("testWindow") {
def textLabel = label("testLabel", "text") {
}
container("testContainer") {
setLayout(new SpringGridLayout(Axis.X, Axis.Y, FillMode.Even, FillMode.Even))
label("testLabel2", "Label2") {
}
label("testLabel3", "Label3") {
}
button("testButton", "Direct action") {
onClick({ println "CLICK" })
}
button("testButton2", "Delegate") {
onClick({ callDelegate("buttonClicked") })
}
}
action("TestAction") {
println "Hello"
}
action("ChangeText") { newTxt ->
textLabel.text = newTxt
}
center()
}
Java binding:
Window w = windowManager.getWindow("testWindow"); //Get the window
w.setDelegate("buttonClicked", () -> { //Add a delegate that is called when the testButton2 is clicked -> groovy:
//onClick({ callDelegate("buttonClicked") })
System.out.println("Delegate called!");
w.executeAction("ChangeText", "New label text"); //Execute a change in the gui -> groovy:
/*action("ChangeText") { newTxt ->
textLabel.text = newTxt
}*/
});
w.show(); //Aattach the window to the guiNode
I’m not very far yet (actually I used all implemented features in this example), but I’d like to hear opinions on this. Would this be useful for other people too? Has someone ideas to implement things more concise or cleaner in the DSL?