1
0
Fork 0

Nasal: expose vbox layout and allow setting item stretch.

This commit is contained in:
Thomas Geymayer 2014-06-04 17:50:52 +02:00
parent 1af3ad2525
commit 371b71dd6c

View file

@ -72,6 +72,7 @@ typedef nasal::Ghost<sc::TextPtr> NasalText;
typedef nasal::Ghost<sc::LayoutItemRef> NasalLayoutItem; typedef nasal::Ghost<sc::LayoutItemRef> NasalLayoutItem;
typedef nasal::Ghost<sc::LayoutRef> NasalLayout; typedef nasal::Ghost<sc::LayoutRef> NasalLayout;
typedef nasal::Ghost<sc::BoxLayoutRef> NasalBoxLayout;
typedef nasal::Ghost<sc::WindowPtr> NasalWindow; typedef nasal::Ghost<sc::WindowPtr> 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<sc::LayoutItemRef>(0),
ctx.getArg<int>(1) );
return naNil();
}
template<class Type, class Base> template<class Type, class Base>
static naRef f_newAsBase(const nasal::CallContext& ctx) static naRef f_newAsBase(const nasal::CallContext& ctx)
{ {
@ -447,8 +456,14 @@ naRef initNasalCanvas(naRef globals, naContext c)
.bases<NasalLayoutItem>() .bases<NasalLayoutItem>()
.method("addItem", &sc::Layout::addItem); .method("addItem", &sc::Layout::addItem);
NasalBoxLayout::init("canvas.BoxLayout")
.bases<NasalLayout>()
.method("addItem", &f_boxLayoutAddItem);
canvas_module.createHash("HBoxLayout") canvas_module.createHash("HBoxLayout")
.set("new", &f_newAsBase<sc::HBoxLayout, sc::Layout>); .set("new", &f_newAsBase<sc::HBoxLayout, sc::BoxLayout>);
canvas_module.createHash("VBoxLayout")
.set("new", &f_newAsBase<sc::VBoxLayout, sc::BoxLayout>);
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Window // Window