diff --git a/src/Scripting/NasalCanvas.cxx b/src/Scripting/NasalCanvas.cxx index 5257d42d8..2440103cf 100644 --- a/src/Scripting/NasalCanvas.cxx +++ b/src/Scripting/NasalCanvas.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -77,6 +78,7 @@ typedef nasal::Ghost NasalLayoutItem; typedef nasal::Ghost NasalLayout; typedef nasal::Ghost NasalBoxLayout; typedef nasal::Ghost NasalGridLayout; +using NasalSpacerItem = nasal::Ghost; typedef nasal::Ghost NasalWindow; @@ -433,6 +435,16 @@ static naRef f_gridLayoutAddItem(sc::GridLayout& grid, return naNil(); } +static naRef f_newGridLayout(const nasal::CallContext& ctx) +{ + return ctx.to_nasal(new sc::GridLayout); +} + +static naRef f_newSpacerItem(const nasal::CallContext& ctx) +{ + return ctx.to_nasal(new sc::SpacerItem); +} + naRef initNasalCanvas(naRef globals, naContext c) { nasal::Hash globals_module(globals, c), @@ -608,17 +620,23 @@ naRef initNasalCanvas(naRef globals, naContext c) .method("setStretchFactor", &sc::BoxLayout::setStretchFactor) .method("stretch", &sc::BoxLayout::stretch); - canvas_module.createHash("HBoxLayout") - .set("new", &f_newAsBase); - canvas_module.createHash("VBoxLayout") - .set("new", &f_newAsBase); - NasalGridLayout::init("canvas.GridLayout") .bases() .method("addItem", &f_gridLayoutAddItem) .method("setRowStretch", &sc::GridLayout::setRowStretch) .method("setColumnStretch", &sc::GridLayout::setColumnStretch); + NasalSpacerItem::init("canvas.SpacerItem") + .bases(); + + canvas_module.createHash("HBoxLayout") + .set("new", &f_newAsBase); + canvas_module.createHash("VBoxLayout") + .set("new", &f_newAsBase); + canvas_module.createHash("GridLayout") + .set("new", &f_newGridLayout); + canvas_module.createHash("Spacer") + .set("new", &f_newSpacerItem); //---------------------------------------------------------------------------- // Window