Howto:Creating a custom waypointlist pendant using Canvas: Difference between revisions

Jump to navigation Jump to search
m
m (→‎Canvas Code (proof-of-concept): generic boilerplate)
m (→‎Canvas Code (proof-of-concept): ScrollArea snippet)
Line 43: Line 43:
The following snippet of code is to be executed/tested using the built-in [[Nasal  Console]]:  
The following snippet of code is to be executed/tested using the built-in [[Nasal  Console]]:  


[[File:Nasal-console-3.0.png|500px|The Nasal console in FG 3.0 with copy/paste buttons ]]
[[File:Nasal-console-3.0.png|thumb|right|The Nasal console in FG 3.0 with copy/paste buttons ]]




Line 72: Line 72:
var root = myCanvas.createGroup();
var root = myCanvas.createGroup();


var vbox = canvas.VBoxLayout.new();
myCanvas.setLayout(vbox);
var scroll = canvas.gui.widgets.ScrollArea.new(root, canvas.style, {size: [96, 128]}).move(20, 100);
vbox.addItem(scroll, 1);
var scrollContent =
      scroll.getContent()
            .set("font", "LiberationFonts/LiberationSans-Bold.ttf")
            .set("character-size", 16)
            .set("alignment", "left-center");
var list = canvas.VBoxLayout.new();
scroll.setLayout(list);
for (var i=1;i<=5;i+=1) {
var label = canvas.gui.widgets.Label.new(scrollContent, canvas.style, {wordWrap: 0});
label.setImage("Textures/Splash"~i~".png");
label.setFixedSize(256,256);
list.addItem(label);
}


</syntaxhighlight>
</syntaxhighlight>

Navigation menu