20,741
edits
(→A simple tile map: Tilesize) |
|||
Line 405: | Line 405: | ||
|} | |} | ||
== Canvas ScrollArea == | |||
{| class="wikitable" | |||
|- | |||
! Screenshot !! Code | |||
|- | |||
|[[File:Canvas-snippets-scrollArea-demo.png|thumb|Screen shot showing a Canvas ScrollArea populated with different splash screens, loaded from $FG_ROOT/Textures]] | |||
|| | |||
<syntaxhighlight lang="nasal" enclose="div"> | |||
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> | |||
|} | |||
== Using Layouts == | == Using Layouts == |