From 371b71dd6c997adea7f77134c686652d0b45e3b2 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Wed, 4 Jun 2014 17:50:52 +0200 Subject: [PATCH] Nasal: expose vbox layout and allow setting item stretch. --- src/Scripting/NasalCanvas.cxx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Scripting/NasalCanvas.cxx b/src/Scripting/NasalCanvas.cxx index 4da6b5a23..348aed413 100644 --- a/src/Scripting/NasalCanvas.cxx +++ b/src/Scripting/NasalCanvas.cxx @@ -72,6 +72,7 @@ typedef nasal::Ghost NasalText; typedef nasal::Ghost NasalLayoutItem; typedef nasal::Ghost NasalLayout; +typedef nasal::Ghost NasalBoxLayout; typedef nasal::Ghost NasalWindow; @@ -341,6 +342,14 @@ static naRef f_customEventGetDetail( sc::CustomEvent& event, ); } +static naRef f_boxLayoutAddItem( sc::BoxLayout& box, + const nasal::CallContext& ctx ) +{ + box.addItem( ctx.requireArg(0), + ctx.getArg(1) ); + return naNil(); +} + template static naRef f_newAsBase(const nasal::CallContext& ctx) { @@ -447,8 +456,14 @@ naRef initNasalCanvas(naRef globals, naContext c) .bases() .method("addItem", &sc::Layout::addItem); + NasalBoxLayout::init("canvas.BoxLayout") + .bases() + .method("addItem", &f_boxLayoutAddItem); + canvas_module.createHash("HBoxLayout") - .set("new", &f_newAsBase); + .set("new", &f_newAsBase); + canvas_module.createHash("VBoxLayout") + .set("new", &f_newAsBase); //---------------------------------------------------------------------------- // Window